Salome HOME
b76fd2dc433da48ec55917f838656249d29c963a
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI.i
1 // Copyright (C) 2014-2020  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 /* FeaturesAPI.i */
21
22 %module FeaturesAPI
23
24 %{
25   #include "FeaturesAPI_swig.h"
26 %}
27
28 %include "doxyhelp.i"
29
30 // import other modules
31 %import "ModelHighAPI.i"
32
33 // to avoid error on this
34 #define FEATURESAPI_EXPORT
35
36 // standard definitions
37 %include "typemaps.i"
38 %include "std_shared_ptr.i"
39
40 // functions with named parameters
41 %feature("kwargs") addChamfer;
42 %feature("kwargs") addCommon;
43 %feature("kwargs") addCut;
44 %feature("kwargs") addFillet;
45 %feature("kwargs") addFuse;
46 %feature("kwargs") addIntersection;
47 %feature("kwargs") addMultiRotation;
48 %feature("kwargs") addMultiTranslation;
49 %feature("kwargs") addPartition;
50 %feature("kwargs") addPlacement;
51 %feature("kwargs") addRotation;
52 %feature("kwargs") addScale;
53 %feature("kwargs") addSplit;
54 %feature("kwargs") addSmash;
55 %feature("kwargs") addSymmetry;
56 %feature("kwargs") addTranslation;
57 %feature("kwargs") addUnion;
58
59 // shared pointers
60 %shared_ptr(FeaturesAPI_BooleanCut)
61 %shared_ptr(FeaturesAPI_BooleanFuse)
62 %shared_ptr(FeaturesAPI_BooleanCommon)
63 %shared_ptr(FeaturesAPI_BooleanSmash)
64 %shared_ptr(FeaturesAPI_BooleanFill)
65 %shared_ptr(FeaturesAPI_Chamfer)
66 %shared_ptr(FeaturesAPI_Extrusion)
67 %shared_ptr(FeaturesAPI_ExtrusionBoolean)
68 %shared_ptr(FeaturesAPI_ExtrusionCut)
69 %shared_ptr(FeaturesAPI_ExtrusionFuse)
70 %shared_ptr(FeaturesAPI_Fillet)
71 %shared_ptr(FeaturesAPI_Fillet1D)
72 %shared_ptr(FeaturesAPI_Fillet2D)
73 %shared_ptr(FeaturesAPI_Intersection)
74 %shared_ptr(FeaturesAPI_MultiRotation)
75 %shared_ptr(FeaturesAPI_MultiTranslation)
76 %shared_ptr(FeaturesAPI_Partition)
77 %shared_ptr(FeaturesAPI_Pipe)
78 %shared_ptr(FeaturesAPI_Placement)
79 %shared_ptr(FeaturesAPI_Recover)
80 %shared_ptr(FeaturesAPI_RemoveSubShapes)
81 %shared_ptr(FeaturesAPI_Revolution)
82 %shared_ptr(FeaturesAPI_RevolutionBoolean)
83 %shared_ptr(FeaturesAPI_RevolutionCut)
84 %shared_ptr(FeaturesAPI_RevolutionFuse)
85 %shared_ptr(FeaturesAPI_Rotation)
86 %shared_ptr(FeaturesAPI_Scale)
87 %shared_ptr(FeaturesAPI_Symmetry)
88 %shared_ptr(FeaturesAPI_Translation)
89 %shared_ptr(FeaturesAPI_Union)
90 %shared_ptr(FeaturesAPI_FusionFaces)
91 %shared_ptr(FeaturesAPI_RemoveResults)
92 %shared_ptr(FeaturesAPI_Copy)
93 %shared_ptr(FeaturesAPI_ImportResult)
94 %shared_ptr(FeaturesAPI_Defeaturing)
95
96
97 %typecheck(SWIG_TYPECHECK_POINTER) std::pair<std::list<ModelHighAPI_Selection>, bool>, const std::pair<std::list<ModelHighAPI_Selection>, bool> & {
98   ModelHighAPI_Selection* temp_selection;
99   bool* temp_bool;
100   int newmem = 0;
101   $1 = 1;
102   std::list<PyObject*> temp_inputlist;
103   if (PySequence_Check($input)) {
104     for (Py_ssize_t i = 0; i < PySequence_Size($input) && $1; ++i) {
105       PyObject * temp = PySequence_GetItem($input, i);
106
107       if ((SWIG_ConvertPtrAndOwn(temp, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
108         if (temp_selection) {
109           $1 = 1;
110         } else {
111           $1 = 0;
112         }
113       } else {
114         $1 = 0;
115       }
116     }
117   } else if (PyBool_Check($input)) {
118     $1 = 1;
119   } else {
120     $1 = 0;
121   }
122 }
123
124 %typemap(in) const std::pair<std::list<ModelHighAPI_Selection>, bool> & (std::pair<std::list<ModelHighAPI_Selection>, bool> temp) {
125   ModelHighAPI_Selection* temp_selection;
126   std::list<ModelHighAPI_Selection> temp_selectionlist;
127   int newmem = 0;
128   std::list<PyObject*> temp_inputlist;
129   if (PySequence_Check($input)) {
130     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
131       PyObject * temp = PySequence_GetItem($input, i);
132
133       if ((SWIG_ConvertPtrAndOwn(temp, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
134         if (temp_selection) {
135           temp_selectionlist.push_back(*temp_selection);
136           if (newmem & SWIG_CAST_NEW_MEMORY) {
137             delete temp_selection;
138           }
139         }
140       } else {
141         PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Selection.");
142         return NULL;
143       }
144     }
145     temp = std::pair<std::list<ModelHighAPI_Selection>, bool>(temp_selectionlist, false);
146   } else if (PyBool_Check($input)) {
147     temp = std::pair<std::list<ModelHighAPI_Selection>, bool>(std::list<ModelHighAPI_Selection>(), $input == Py_True);
148   } else {
149     PyErr_SetString(PyExc_TypeError, "argument must be std::list<ModelHighAPI_Selection> or bool.");
150     return NULL;
151   }
152   $1 = &temp;
153 }
154
155 // fix compilation error: 'res*' was not declared in this scope
156 %typemap(freearg) const std::pair<std::list<ModelHighAPI_Selection>, bool> & {}
157
158
159 %typecheck(SWIG_TYPECHECK_POINTER) std::pair<ModelHighAPI_Selection, ModelHighAPI_Double>, const std::pair<ModelHighAPI_Selection, ModelHighAPI_Double> & {
160   ModelHighAPI_Selection* temp_selection;
161   int newmem = 0;
162   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
163     if (temp_selection) {
164       $1 = 1;
165     } else {
166       $1 = 0;
167     }
168   } else {
169     $1 = ((PyFloat_Check($input) || PyLong_Check($input) || PyUnicode_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
170   }
171 }
172
173 %typemap(in) const std::pair<ModelHighAPI_Selection, ModelHighAPI_Double> & (std::pair<ModelHighAPI_Selection, ModelHighAPI_Double> temp) {
174   ModelHighAPI_Selection* temp_selection;
175   int newmem = 0;
176   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
177     if (temp_selection) {
178       temp = std::pair<ModelHighAPI_Selection, ModelHighAPI_Double>(*temp_selection, ModelHighAPI_Double(0.0));
179       if (newmem & SWIG_CAST_NEW_MEMORY) {
180         delete temp_selection;
181       }
182     }
183   } else if (PyFloat_Check($input) || PyLong_Check($input)) {
184     temp = std::pair<ModelHighAPI_Selection, ModelHighAPI_Double>(ModelHighAPI_Selection(), ModelHighAPI_Double(PyFloat_AsDouble($input)));
185   } else if (PyUnicode_Check($input)) {
186     Py_ssize_t size;
187     temp = std::pair<ModelHighAPI_Selection, ModelHighAPI_Double>(ModelHighAPI_Selection(), ModelHighAPI_Double(PyUnicode_AsWideCharString($input, &size)));
188   } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
189     temp = std::pair<ModelHighAPI_Selection, ModelHighAPI_Double>($1->first, $1->second);
190   } else {
191     PyErr_SetString(PyExc_ValueError, "argument must be selection, ModelHighAPI_Double, float, int or string.");
192     return NULL;
193   }
194   $1 = &temp;
195 }
196
197 // fix compilation error: 'res*' was not declared in this scope
198 %typemap(freearg) const std::pair<ModelHighAPI_Selection, ModelHighAPI_Double> & {}
199
200
201 // all supported interfaces
202 %include "FeaturesAPI_BooleanCut.h"
203 %include "FeaturesAPI_BooleanFuse.h"
204 %include "FeaturesAPI_BooleanCommon.h"
205 %include "FeaturesAPI_BooleanSmash.h"
206 %include "FeaturesAPI_BooleanFill.h"
207 %include "FeaturesAPI_Chamfer.h"
208 %include "FeaturesAPI_Defeaturing.h"
209 %include "FeaturesAPI_Extrusion.h"
210 %include "FeaturesAPI_ExtrusionBoolean.h"
211 %include "FeaturesAPI_Fillet.h"
212 %include "FeaturesAPI_Intersection.h"
213 %include "FeaturesAPI_Measurement.h"
214 %include "FeaturesAPI_MultiRotation.h"
215 %include "FeaturesAPI_MultiTranslation.h"
216 %include "FeaturesAPI_Partition.h"
217 %include "FeaturesAPI_Pipe.h"
218 %include "FeaturesAPI_Placement.h"
219 %include "FeaturesAPI_Recover.h"
220 %include "FeaturesAPI_RemoveSubShapes.h"
221 %include "FeaturesAPI_Revolution.h"
222 %include "FeaturesAPI_RevolutionBoolean.h"
223 %include "FeaturesAPI_Rotation.h"
224 %include "FeaturesAPI_Scale.h"
225 %include "FeaturesAPI_Symmetry.h"
226 %include "FeaturesAPI_Translation.h"
227 %include "FeaturesAPI_Union.h"
228 %include "FeaturesAPI_FusionFaces.h"
229 %include "FeaturesAPI_RemoveResults.h"
230 %include "FeaturesAPI_Copy.h"
231 %include "FeaturesAPI_ImportResult.h"