Salome HOME
Make SHAPER STUDY fields exported in SMESH into MED file
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI.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 /* 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") addCommon;
42 %feature("kwargs") addCut;
43 %feature("kwargs") addFuse;
44 %feature("kwargs") addPartition;
45 %feature("kwargs") addSplit;
46 %feature("kwargs") addSmash;
47 %feature("kwargs") addUnion;
48
49 // shared pointers
50 %shared_ptr(FeaturesAPI_BooleanCut)
51 %shared_ptr(FeaturesAPI_BooleanFuse)
52 %shared_ptr(FeaturesAPI_BooleanCommon)
53 %shared_ptr(FeaturesAPI_BooleanSmash)
54 %shared_ptr(FeaturesAPI_BooleanFill)
55 %shared_ptr(FeaturesAPI_Chamfer)
56 %shared_ptr(FeaturesAPI_Extrusion)
57 %shared_ptr(FeaturesAPI_ExtrusionBoolean)
58 %shared_ptr(FeaturesAPI_ExtrusionCut)
59 %shared_ptr(FeaturesAPI_ExtrusionFuse)
60 %shared_ptr(FeaturesAPI_Fillet)
61 %shared_ptr(FeaturesAPI_Intersection)
62 %shared_ptr(FeaturesAPI_MultiRotation)
63 %shared_ptr(FeaturesAPI_MultiTranslation)
64 %shared_ptr(FeaturesAPI_Partition)
65 %shared_ptr(FeaturesAPI_Pipe)
66 %shared_ptr(FeaturesAPI_Placement)
67 %shared_ptr(FeaturesAPI_Recover)
68 %shared_ptr(FeaturesAPI_RemoveSubShapes)
69 %shared_ptr(FeaturesAPI_Revolution)
70 %shared_ptr(FeaturesAPI_RevolutionBoolean)
71 %shared_ptr(FeaturesAPI_RevolutionCut)
72 %shared_ptr(FeaturesAPI_RevolutionFuse)
73 %shared_ptr(FeaturesAPI_Rotation)
74 %shared_ptr(FeaturesAPI_Scale)
75 %shared_ptr(FeaturesAPI_Symmetry)
76 %shared_ptr(FeaturesAPI_Translation)
77 %shared_ptr(FeaturesAPI_Union)
78 %shared_ptr(FeaturesAPI_FusionFaces)
79 %shared_ptr(FeaturesAPI_RemoveResults)
80
81
82 %typecheck(SWIG_TYPECHECK_POINTER) std::pair<std::list<ModelHighAPI_Selection>, bool>, const std::pair<std::list<ModelHighAPI_Selection>, bool> & {
83   ModelHighAPI_Selection* temp_selection;
84   bool* temp_bool;
85   int newmem = 0;
86   $1 = 1;
87   std::list<PyObject*> temp_inputlist;
88   if (PySequence_Check($input)) {
89     for (Py_ssize_t i = 0; i < PySequence_Size($input) && $1; ++i) {
90       PyObject * temp = PySequence_GetItem($input, i);
91
92       if ((SWIG_ConvertPtrAndOwn(temp, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
93         if (temp_selection) {
94           $1 = 1;
95         } else {
96           $1 = 0;
97         }
98       } else {
99         $1 = 0;
100       }
101     }
102   } else if (PyBool_Check($input)) {
103     $1 = 1;
104   } else {
105     $1 = 0;
106   }
107 }
108
109 %typemap(in) const std::pair<std::list<ModelHighAPI_Selection>, bool> & (std::pair<std::list<ModelHighAPI_Selection>, bool> temp) {
110   ModelHighAPI_Selection* temp_selection;
111   std::list<ModelHighAPI_Selection> temp_selectionlist;
112   int newmem = 0;
113   std::list<PyObject*> temp_inputlist;
114   if (PySequence_Check($input)) {
115     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
116       PyObject * temp = PySequence_GetItem($input, i);
117
118       if ((SWIG_ConvertPtrAndOwn(temp, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
119         if (temp_selection) {
120           temp_selectionlist.push_back(*temp_selection);
121           if (newmem & SWIG_CAST_NEW_MEMORY) {
122             delete temp_selection;
123           }
124         }
125       } else {
126         PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Selection.");
127         return NULL;
128       }
129     }
130     temp = std::pair<std::list<ModelHighAPI_Selection>, bool>(temp_selectionlist, false);
131   } else if (PyBool_Check($input)) {
132     temp = std::pair<std::list<ModelHighAPI_Selection>, bool>(std::list<ModelHighAPI_Selection>(), $input == Py_True);
133   } else {
134     PyErr_SetString(PyExc_TypeError, "argument must be std::list<ModelHighAPI_Selection> or bool.");
135     return NULL;
136   }
137   $1 = &temp;
138 }
139
140 // fix compilation error: 'res*' was not declared in this scope
141 %typemap(freearg) const std::pair<std::list<ModelHighAPI_Selection>, bool> & {}
142
143 // all supported interfaces
144 %include "FeaturesAPI_BooleanCut.h"
145 %include "FeaturesAPI_BooleanFuse.h"
146 %include "FeaturesAPI_BooleanCommon.h"
147 %include "FeaturesAPI_BooleanSmash.h"
148 %include "FeaturesAPI_BooleanFill.h"
149 %include "FeaturesAPI_Chamfer.h"
150 %include "FeaturesAPI_Extrusion.h"
151 %include "FeaturesAPI_ExtrusionBoolean.h"
152 %include "FeaturesAPI_Fillet.h"
153 %include "FeaturesAPI_Intersection.h"
154 %include "FeaturesAPI_Measurement.h"
155 %include "FeaturesAPI_MultiRotation.h"
156 %include "FeaturesAPI_MultiTranslation.h"
157 %include "FeaturesAPI_Partition.h"
158 %include "FeaturesAPI_Pipe.h"
159 %include "FeaturesAPI_Placement.h"
160 %include "FeaturesAPI_Recover.h"
161 %include "FeaturesAPI_RemoveSubShapes.h"
162 %include "FeaturesAPI_Revolution.h"
163 %include "FeaturesAPI_RevolutionBoolean.h"
164 %include "FeaturesAPI_Rotation.h"
165 %include "FeaturesAPI_Scale.h"
166 %include "FeaturesAPI_Symmetry.h"
167 %include "FeaturesAPI_Translation.h"
168 %include "FeaturesAPI_Union.h"
169 %include "FeaturesAPI_FusionFaces.h"
170 %include "FeaturesAPI_RemoveResults.h"