Salome HOME
Merge branch 'master' into occ/bsplines
[modules/shaper.git] / src / GeomAPI / GeomAPI.i
1 // Copyright (C) 2014-2019  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 /* GeomAPI.i */
21 %module GeomAPI
22 %{
23   #include "GeomAPI_swig.h"
24 %}
25
26 // to avoid error on this
27 #define GEOMAPI_EXPORT
28
29 // standard definitions
30 %include "typemaps.i"
31 %include "std_list.i"
32 %include "std_map.i"
33 %include "std_set.i"
34 %include "std_shared_ptr.i"
35 %include "std_string.i"
36
37 // shared pointers
38 %shared_ptr(GeomAPI_AISObject)
39 %shared_ptr(GeomAPI_Angle)
40 %shared_ptr(GeomAPI_Angle2d)
41 %shared_ptr(GeomAPI_Ax1)
42 %shared_ptr(GeomAPI_Ax2)
43 %shared_ptr(GeomAPI_Ax3)
44 %shared_ptr(GeomAPI_Box)
45 %shared_ptr(GeomAPI_BSpline)
46 %shared_ptr(GeomAPI_BSpline2d)
47 %shared_ptr(GeomAPI_Circ)
48 %shared_ptr(GeomAPI_Circ2d)
49 %shared_ptr(GeomAPI_Cone)
50 %shared_ptr(GeomAPI_Curve)
51 %shared_ptr(GeomAPI_Cylinder)
52 %shared_ptr(GeomAPI_DataMapOfShapeMapOfShapes)
53 %shared_ptr(GeomAPI_DataMapOfShapeShape)
54 %shared_ptr(GeomAPI_Dir)
55 %shared_ptr(GeomAPI_Dir2d)
56 %shared_ptr(GeomAPI_Edge)
57 %shared_ptr(GeomAPI_Ellipse)
58 %shared_ptr(GeomAPI_Ellipse2d)
59 %shared_ptr(GeomAPI_Face)
60 %shared_ptr(GeomAPI_ICustomPrs)
61 %shared_ptr(GeomAPI_Interface)
62 %shared_ptr(GeomAPI_IPresentable)
63 %shared_ptr(GeomAPI_Lin)
64 %shared_ptr(GeomAPI_Lin2d)
65 %shared_ptr(GeomAPI_PlanarEdges)
66 %shared_ptr(GeomAPI_Pln)
67 %shared_ptr(GeomAPI_Pnt)
68 %shared_ptr(GeomAPI_Pnt2d)
69 %shared_ptr(GeomAPI_Shape)
70 %shared_ptr(GeomAPI_ShapeExplorer)
71 %shared_ptr(GeomAPI_ShapeIterator)
72 %shared_ptr(GeomAPI_Shell)
73 %shared_ptr(GeomAPI_Solid)
74 %shared_ptr(GeomAPI_Sphere)
75 %shared_ptr(GeomAPI_Torus)
76 %shared_ptr(GeomAPI_Trsf)
77 %shared_ptr(GeomAPI_Vertex)
78 %shared_ptr(GeomAPI_Wire)
79 %shared_ptr(GeomAPI_XY)
80 %shared_ptr(GeomAPI_XYZ)
81
82
83 %typemap(in) std::list<std::shared_ptr<GeomAPI_Pnt> > &thePoints (std::list<std::shared_ptr<GeomAPI_Pnt> > temp) {
84   std::shared_ptr<GeomAPI_Pnt> * temp_pnt;
85   int newmem = 0;
86   if (PySequence_Check($input)) {
87     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
88       PyObject * item = PySequence_GetItem($input, i);
89       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_pnt, $descriptor(std::shared_ptr<GeomAPI_Pnt> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
90         if (!temp_pnt) {
91           PyErr_SetString(PyExc_TypeError, "argument must be list of GeomAPI_Pnt.");
92           return NULL;
93        }
94         temp.push_back(*temp_pnt);
95         if (newmem & SWIG_CAST_NEW_MEMORY) {
96           delete temp_pnt;
97         }
98       }
99       Py_DECREF(item);
100     }
101     $1 = &temp;
102   } else {
103     PyErr_SetString(PyExc_ValueError, "argument must be list of GeomAPI_Pnt.");
104     return NULL;
105   }
106 }
107
108 %typemap(in, numinputs=0) double & (double temp) {
109   $1 = &temp;
110 }
111
112 %typemap(argout) double & {
113   $result = SWIG_Python_AppendOutput($result, PyFloat_FromDouble(*$1));
114 }
115
116 // std::dynamic_pointer_cast
117 template<class T1, class T2> std::shared_ptr<T1> shared_ptr_cast(std::shared_ptr<T2> theObject);
118 %template(shapeToEdge) shared_ptr_cast<GeomAPI_Edge, GeomAPI_Shape>;
119
120
121 // all supported interfaces
122 %include "GeomAPI_Interface.h"
123 %include "GeomAPI_Shape.h"
124 %include "GeomAPI_AISObject.h"
125 %include "GeomAPI_Angle.h"
126 %include "GeomAPI_Angle2d.h"
127 %include "GeomAPI_Ax1.h"
128 %include "GeomAPI_Ax2.h"
129 %include "GeomAPI_Ax3.h"
130 %include "GeomAPI_Box.h"
131 %include "GeomAPI_BSpline.h"
132 %include "GeomAPI_BSpline2d.h"
133 %include "GeomAPI_Circ.h"
134 %include "GeomAPI_Circ2d.h"
135 %include "GeomAPI_Cone.h"
136 %include "GeomAPI_Curve.h"
137 %include "GeomAPI_Cylinder.h"
138 %include "GeomAPI_DataMapOfShapeMapOfShapes.h"
139 %include "GeomAPI_DataMapOfShapeShape.h"
140 %include "GeomAPI_Dir.h"
141 %include "GeomAPI_Dir2d.h"
142 %include "GeomAPI_Edge.h"
143 %include "GeomAPI_Ellipse.h"
144 %include "GeomAPI_Ellipse2d.h"
145 %include "GeomAPI_Face.h"
146 %include "GeomAPI_ICustomPrs.h"
147 %include "GeomAPI_IPresentable.h"
148 %include "GeomAPI_Lin.h"
149 %include "GeomAPI_Lin2d.h"
150 %include "GeomAPI_PlanarEdges.h"
151 %include "GeomAPI_Pln.h"
152 %include "GeomAPI_Pnt.h"
153 %include "GeomAPI_Pnt2d.h"
154 %include "GeomAPI_ShapeExplorer.h"
155 %include "GeomAPI_ShapeIterator.h"
156 %include "GeomAPI_Shell.h"
157 %include "GeomAPI_Solid.h"
158 %include "GeomAPI_Sphere.h"
159 %include "GeomAPI_Torus.h"
160 %include "GeomAPI_Trsf.h"
161 %include "GeomAPI_Vertex.h"
162 %include "GeomAPI_Wire.h"
163 %include "GeomAPI_XY.h"
164 %include "GeomAPI_XYZ.h"
165
166 // std::list -> []
167 %template(PointList) std::list<std::shared_ptr<GeomAPI_Pnt> >;
168 %template(ShapeList) std::list<std::shared_ptr<GeomAPI_Shape> >;
169 // std::set -> []
170 %template(ShapeSet) std::set<std::shared_ptr<GeomAPI_Shape>, GeomAPI_Shape::Comparator>;
171 %template(OriShapeSet) std::set<std::shared_ptr<GeomAPI_Shape>, GeomAPI_Shape::ComparatorWithOri>;
172 // std::map -> {}
173 %template(ShapeToShapesMap) std::map<std::shared_ptr<GeomAPI_Shape>, std::set<std::shared_ptr<GeomAPI_Shape>, GeomAPI_Shape::ComparatorWithOri>, GeomAPI_Shape::Comparator>;