Salome HOME
Merge V9_dev branch into master
[modules/smesh.git] / src / SMESH_SWIG_WITHIHM / libSMESH_Swig.i
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
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 %module libSMESH_Swig
21
22 %{
23 #include "libSMESH_Swig.h"
24 %}
25
26 /* Exception handler for all functions */
27 %exception 
28 {
29   class PyAllowThreadsGuard
30   {
31   public:
32     // Py_BEGIN_ALLOW_THREADS
33     PyAllowThreadsGuard() { _save = PyEval_SaveThread(); }
34     // Py_END_ALLOW_THREADS
35     ~PyAllowThreadsGuard() { PyEval_RestoreThread(_save); }
36   private:
37     PyThreadState* _save;
38   };
39
40   PyAllowThreadsGuard guard;
41
42   $action
43 }
44
45 %include "typemaps.i"
46 %include "std_vector.i"
47 %include "std_pair.i"
48
49 namespace std
50 {
51   %template(VectorInt) vector<int>;
52   %template() std::pair<int,int>;
53   %template(PairVector) std::vector<std::pair<int,int> >;
54 };
55
56 // See SMESH_Actor.h
57 typedef enum
58 {
59   EntityNone    = 0x00,
60   Entity0d      = 0x01,   // SMESH_Actor::e0DElements
61   EntityEdges   = 0x02,   // SMESH_Actor::eEdges
62   EntityFaces   = 0x04,   // SMESH_Actor::eFaces
63   EntityVolumes = 0x08,   // SMESH_Actor::eVolumes
64   EntityBalls   = 0x10,   // SMESH_Actor::eBallElem
65   EntityAll     = 0xff    // SMESH_Actor::eAllEntity
66 } EntityMode;
67
68 // See SVTK_Selection.h
69 enum SelectionMode
70 {
71   Undefined = -1,
72   Node = 0,       // NodeSelection
73   Cell,           // CellSelection
74   EdgeOfCell,     // EdgeOfCellSelection
75   Edge,           // EdgeSelection
76   Face,           // FaceSelection
77   Volume,         // VolumeSelection
78   Actor,          // ActorSelection
79   Elem0D,         // Elem0DSelection
80   Ball            // BallSelection
81 };
82
83 // See SMESH_Actor.h
84 enum DisplayMode
85 {
86   UndefinedMode = -1,
87   PointMode = 0,      // SMESH_Actor::ePoint
88   EdgeMode,           // SMESH_Actor::eEdge
89   SurfaceMode         // SMESH_Actor::eSurface
90 };
91
92 struct ColorData
93 {
94   double r, g, b;
95 };
96
97 struct BicolorData
98 {
99   double r, g, b;
100   int delta;
101 };
102
103 struct Properties
104 {
105   ColorData nodeColor;
106   int markerType;
107   int markerScale;
108
109   ColorData edgeColor;
110   int edgeWidth;
111
112   BicolorData surfaceColor;
113   BicolorData volumeColor;
114
115   ColorData elem0dColor;
116   int elem0dSize;
117
118   ColorData ballColor;
119   double ballScale;
120
121   ColorData outlineColor;
122   int outlineWidth;
123
124   ColorData orientationColor;
125   double orientationScale;
126   bool orientation3d;
127
128   double shrinkFactor;
129   double opacity;
130 };
131
132 typedef ColorData nodeColorStruct; // deprecated
133 typedef ColorData edgeColorStruct; // deprecated
134 typedef BicolorData surfaceColorStruct; // deprecated
135 typedef BicolorData volumeColorStruct; // deprecated
136 typedef Properties actorAspect; // deprecated
137
138 class SMESH_Swig
139 {
140 public:
141   SMESH_Swig();
142   ~SMESH_Swig();
143
144
145   // Initialization =============================================
146
147   void Init(); // deprecated
148
149   // Publishing =================================================
150   
151   const char* publish(const char*, const char* = 0);
152   void rename(const char*, const char*);
153
154   const char* AddNewMesh(const char*, const char* = 0); // deprecated
155   const char* AddNewHypothesis(const char*, const char* = 0); // deprecated
156   const char* AddNewAlgorithms(const char*, const char* = 0); // deprecated
157   const char* AddNewAlgorithm(const char*, const char* = 0); // deprecated
158
159   void SetShape(const char*, const char*); // deprecated
160
161   void SetHypothesis(const char*, const char*); // deprecated
162   void SetAlgorithms(const char*, const char*); // deprecated
163
164   void UnSetHypothesis(const char*); // deprecated
165
166   const char* AddSubMesh(const char*, const char*, int, const char* = 0); // deprecated
167   const char* AddSubMeshOnShape (const char*, const char*, const char*, int, const char* = 0); // deprecated
168
169   void SetName(const char*, const char*); // deprecated
170
171   void SetMeshIcon(const char*, const bool, const bool); // deprecated
172
173   // Visualization  =============================================
174
175   void display(const char*, int = 0, bool = true);
176   void erase(const char*, int = 0, bool = true);
177   void update(const char*);
178
179   Properties properties(const char*, int = 0);
180   void setProperties(const char*, const Properties&, int = 0);
181
182   bool nodesNumbering(const char*, int = 0);
183   void setNodesNumbering(const char*, bool, int = 0);
184   bool elementsNumbering(const char*, int = 0);
185   void setElementsNumbering(const char*, bool, int = 0);
186
187   DisplayMode displayMode(const char*, int = 0);
188   void setDisplayMode(const char*, DisplayMode, int = 0);
189
190   bool shrinkMode(const char*, int = 0);
191   void setShrinkMode(const char*, bool, int = 0);
192
193   double opacity(const char*, int = 0);
194   void setOpacity(const char*, double, int = 0);
195
196   bool isOrientationShown(const char*, int = 0);
197   void setOrientationShown(const char*, bool, int = 0);
198
199   int entitiesShown(const char*, int = 0);
200   void setEntitiesShown(const char*, int, int = 0);
201   bool isEntityShown(const char*, EntityMode, int = 0);
202   void setEntityShown(const char*, EntityMode, bool, int = 0);
203
204   void CreateAndDisplayActor(const char*); // deprecated
205   void EraseActor(const char*, const bool = false); // deprecated
206   void UpdateActor(const char*); // deprecated
207
208   actorAspect GetActorAspect(const char*, int = 0); // deprecated
209   void SetActorAspect(const actorAspect&, const char*, int = 0); // deprecated
210
211   // Selection  =================================================
212
213   SelectionMode getSelectionMode(int = 0);
214   void setSelectionMode(SelectionMode, int = 0);
215
216   std::vector<int> getSelected(const char*);
217   std::vector<std::pair<int,int> > getSelectedEdgeOfCell(const char*);
218
219   void select(const char*, std::vector<int>, bool = false);
220   void select(const char*, int, bool = false);
221   void select(const char*, std::vector<std::pair<int,int> >, bool = false);
222 };