-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cgeometry.swig
67 lines (39 loc) · 996 Bytes
/
Cgeometry.swig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
%module Cgeometry;
%{
#include "geometry2D.h"
%}
%include "cinder-lite/Vector.h"
%template(Vec2) cinderlite::Vec2<double>;
%include "geometry2D.h"
/*
%extend Vec2 {
std::string __repr__() const {
return "toto";
}
}
*/
%inline %{
size_t swig_ptr_as_int(const void *x) {
return (size_t)x;
}
Circle* downcast_Circle(Shape2D *shape) {
return dynamic_cast<Circle*>(shape);
}
%}
%pythoncode %{
def Vec2__repr__(self):
return "Vec2(%f, %f)" % (self.x, self.y)
Vec2.__repr__ = Vec2__repr__
def BBox__repr__(self):
return "Bbox(%s, %s)" % (self.Cmin, self.Cmax)
BBox.__repr__ = BBox__repr__
# to convert a C++ style iterator to one that can be used
# directly in python
def py_style_iterator(self):
while self.has_next():
yield self.next()
IntersectingLeavesIterator.__iter__ = py_style_iterator
ShapeVectorIterator.__iter__ = py_style_iterator
LeafIterator.__iter__ = py_style_iterator
TwoLeavesIterator.__iter__ = py_style_iterator
%}