Salome HOME
Implementation of the task #3109 : Feature Copy
[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 %shared_ptr(FeaturesAPI_Copy)
81
82
83 %typecheck(SWIG_TYPECHECK_POINTER) std::pair<std::list<ModelHighAPI_Selection>, bool>, const std::pair<std::list<ModelHighAPI_Selection>, bool> & {
84   ModelHighAPI_Selection* temp_selection;
85   bool* temp_bool;
86   int newmem = 0;
87   $1 = 1;
88   std::list<PyObject*> temp_inputlist;
89   if (PySequence_Check($input)) {
90     for (Py_ssize_t i = 0; i < PySequence_Size($input) && $1; ++i) {
91       PyObject * temp = PySequence_GetItem($input, i);
92
93       if ((SWIG_ConvertPtrAndOwn(temp, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
94         if (temp_selection) {
95           $1 = 1;
96         } else {
97           $1 = 0;
98         }
99       } else {
100         $1 = 0;
101       }
102     }
103   } else if (PyBool_Check($input)) {
104     $1 = 1;
105   } else {
106     $1 = 0;
107   }
108 }
109
110 %typemap(in) const std::pair<std::list<ModelHighAPI_Selection>, bool> & (std::pair<std::list<ModelHighAPI_Selection>, bool> temp) {
111   ModelHighAPI_Selection* temp_selection;
112   std::list<ModelHighAPI_Selection> temp_selectionlist;
113   int newmem = 0;
114   std::list<PyObject*> temp_inputlist;
115   if (PySequence_Check($input)) {
116     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
117       PyObject * temp = PySequence_GetItem($input, i);
118
119       if ((SWIG_ConvertPtrAndOwn(temp, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
120         if (temp_selection) {
121           temp_selectionlist.push_back(*temp_selection);
122           if (newmem & SWIG_CAST_NEW_MEMORY) {
123             delete temp_selection;
124           }
125         }
126       } else {
127         PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Selection.");
128         return NULL;
129       }
130     }
131     temp = std::pair<std::list<ModelHighAPI_Selection>, bool>(temp_selectionlist, false);
132   } else if (PyBool_Check($input)) {
133     temp = std::pair<std::list<ModelHighAPI_Selection>, bool>(std::list<ModelHighAPI_Selection>(), $input == Py_True);
134   } else {
135     PyErr_SetString(PyExc_TypeError, "argument must be std::list<ModelHighAPI_Selection> or bool.");
136     return NULL;
137   }
138   $1 = &temp;
139 }
140
141 // fix compilation error: 'res*' was not declared in this scope
142 %typemap(freearg) const std::pair<std::list<ModelHighAPI_Selection>, bool> & {}
143
144 // all supported interfaces
145 %include "FeaturesAPI_BooleanCut.h"
146 %include "FeaturesAPI_BooleanFuse.h"
147 %include "FeaturesAPI_BooleanCommon.h"
148 %include "FeaturesAPI_BooleanSmash.h"
149 %include "FeaturesAPI_BooleanFill.h"
150 %include "FeaturesAPI_Chamfer.h"
151 %include "FeaturesAPI_Extrusion.h"
152 %include "FeaturesAPI_ExtrusionBoolean.h"
153 %include "FeaturesAPI_Fillet.h"
154 %include "FeaturesAPI_Intersection.h"
155 %include "FeaturesAPI_Measurement.h"
156 %include "FeaturesAPI_MultiRotation.h"
157 %include "FeaturesAPI_MultiTranslation.h"
158 %include "FeaturesAPI_Partition.h"
159 %include "FeaturesAPI_Pipe.h"
160 %include "FeaturesAPI_Placement.h"
161 %include "FeaturesAPI_Recover.h"
162 %include "FeaturesAPI_RemoveSubShapes.h"
163 %include "FeaturesAPI_Revolution.h"
164 %include "FeaturesAPI_RevolutionBoolean.h"
165 %include "FeaturesAPI_Rotation.h"
166 %include "FeaturesAPI_Scale.h"
167 %include "FeaturesAPI_Symmetry.h"
168 %include "FeaturesAPI_Translation.h"
169 %include "FeaturesAPI_Union.h"
170 %include "FeaturesAPI_FusionFaces.h"
171 %include "FeaturesAPI_RemoveResults.h"
172 %include "FeaturesAPI_Copy.h"