Salome HOME
48523add3b7771552b36e02c471d33a629429a10
[modules/med.git] / src / MedClient / src / libMEDClient.i
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 %module libMEDClient
24
25 %{
26 #include "GMESHClient.hxx"
27 #include "MESHClient.hxx"
28 #include "SUPPORTClient.hxx"
29 #include "FIELDClient.hxx"
30 #include CORBA_CLIENT_HEADER(MED)
31
32   using namespace MEDMEM;
33   using namespace MED_EN;
34 %}
35
36 %typemap(in) MESH* {
37   if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 0)) == -1) {
38     MESHClient *client;
39     if ((SWIG_ConvertPtr($input, (void **) &client, $descriptor(MESHClient *), 0)) == -1) {
40       SWIG_Python_TypeError("MESH* or MESHClient*", $input);
41       return NULL;
42     }
43     $1 = (MESH *) client;
44   }
45 }
46
47 %include "libMedCorba_Swig.i"
48 %include "libMEDMEM_Swig.i"
49
50 %typecheck(SWIG_TYPECHECK_POINTER) SALOME_MED::FIELDDOUBLE_ptr, SALOME_MED::FIELDINT_ptr
51 {
52   $1 = ($input != 0);
53 }
54
55 /*
56   managing C++ exception in the Python API
57 */
58 /*%exception
59 {
60   class PyAllowThreadsGuard {
61    public:
62     PyAllowThreadsGuard() { _save = PyEval_SaveThread(); }
63     ~PyAllowThreadsGuard() { PyEval_RestoreThread(_save); }
64    private:
65     PyThreadState *_save;
66   };
67
68   PyAllowThreadsGuard guard;
69
70   $action
71 }*/
72
73 class GMESHClient : public GMESH {
74
75  public:
76   
77   GMESHClient(const SALOME_MED::GMESH_ptr m);
78
79   void blankCopy();
80   void fillCopy();
81   %extend {
82     ~GMESHClient(){
83       self->removeReference();
84     }
85   }
86 };
87
88 class MESHClient : public MESH {
89
90  public:
91   
92   MESHClient(const SALOME_MED::MESH_ptr m);
93
94   void blankCopy();
95   void fillCopy();
96   %extend {
97     ~MESHClient(){
98       self->removeReference();
99     }
100   }
101 };
102
103 MESH * getMeshPointer(MESHClient * input);
104 %{
105   MESH * getMeshPointer(MESHClient * input)
106   {
107     return (MESH *) input;
108   }
109 %}
110
111 class SUPPORTClient : public SUPPORT {
112
113  public:
114
115   SUPPORTClient(const SALOME_MED::SUPPORT_ptr S, 
116                 MESH * M = NULL);
117
118   void blankCopy();
119   void fillCopy();
120   %extend {
121     ~SUPPORTClient() {
122       self->removeReference();
123     }
124   }
125
126 };
127
128 template<class T, class INTERLACING_TAG>
129 class FIELDClient : public FIELD<T,INTERLACING_TAG>
130 {
131 public:
132   template<class U>
133   FIELDClient(U ptrCorba,MEDMEM::SUPPORT * S = NULL);
134   ~FIELDClient();
135 };
136
137 %template (FIELDDOUBLEClient)                  FIELDClient<double, FullInterlace>;
138 %template (FIELDDOUBLENOINTERLACEClient)       FIELDClient<double, NoInterlace>;
139 %template (FIELDDOUBLENOINTERLACEBYTYPEClient) FIELDClient<double, NoInterlaceByType>;
140 %template (FIELDINTClient)                     FIELDClient<int, FullInterlace>;
141 %template (FIELDINTNOINTERLACEClient)          FIELDClient<int, NoInterlace>;
142 %template (FIELDINTNOINTERLACEBYTYPEClient)    FIELDClient<int, NoInterlaceByType>;
143
144 %extend FIELDClient<double, FullInterlace>
145 {
146   %template(FIELDDOUBLEClient) FIELDClient<SALOME_MED::FIELDDOUBLE_ptr>;
147 };
148
149 %extend FIELDClient<double, NoInterlace>
150 {
151   %template(FIELDDOUBLENOINTERLACEClient) FIELDClient<SALOME_MED::FIELDDOUBLE_ptr>;
152 };
153
154 %extend FIELDClient<double, NoInterlaceByType>
155 {
156   %template(FIELDDOUBLENOINTERLACEBYTYPEClient) FIELDClient<SALOME_MED::FIELDDOUBLE_ptr>;
157 };
158
159 %extend FIELDClient<int, FullInterlace>
160 {
161   %template(FIELDINTClient) FIELDClient<SALOME_MED::FIELDINT_ptr>;
162 };
163
164 %extend FIELDClient<int, NoInterlace>
165 {
166   %template(FIELDINTNOINTERLACEClient) FIELDClient<SALOME_MED::FIELDINT_ptr>;
167 };
168
169 %extend FIELDClient<int, NoInterlaceByType>
170 {
171   %template(FIELDINTNOINTERLACEBYTYPEClient) FIELDClient<SALOME_MED::FIELDINT_ptr>;
172 };
173
174 FIELD<double> * getDoublePointer(FIELDClient<double,FullInterlace> * input);
175
176 FIELD<double,NoInterlace> *getDoubleNoInterlacePointer(FIELDClient<double,NoInterlace> * input);
177
178 FIELD<double,NoInterlaceByType> *getDoubleNoInterlaceByTypePointer(FIELDClient<double,NoInterlaceByType> * input);
179
180 FIELD<int> * getIntPointer(FIELDClient<int,FullInterlace> * input);
181
182 FIELD<int,NoInterlace> * getIntNoInterlacePointer(FIELDClient<int,NoInterlace> * input);
183
184 FIELD<int,NoInterlaceByType> * getIntNoInterlaceByTypePointer(FIELDClient<int,NoInterlaceByType> * input);
185
186 %{
187   FIELD<double> * getDoublePointer(FIELDClient<double,FullInterlace> * input)
188     {
189       return (FIELD<double> *) input;
190     }
191
192   FIELD<double,NoInterlace> *getDoubleNoInterlacePointer(FIELDClient<double,NoInterlace> * input)
193     {
194       return (FIELD<double,NoInterlace> *) input;
195     }
196
197   FIELD<double,NoInterlaceByType> *getDoubleNoInterlaceByTypePointer(FIELDClient<double,NoInterlaceByType> * input)
198     {
199       return (FIELD<double,NoInterlaceByType> *) input;
200     }
201
202   FIELD<int> * getIntPointer(FIELDClient<int,FullInterlace> * input)
203   {
204       return (FIELD<int> *) input;
205   }
206
207   FIELD<int,NoInterlace> * getIntNoInterlacePointer(FIELDClient<int,NoInterlace> * input)
208   {
209       return (FIELD<int,NoInterlace> *) input;
210   }
211
212   FIELD<int,NoInterlaceByType> * getIntNoInterlaceByTypePointer(FIELDClient<int,NoInterlaceByType> * input)
213   {
214       return (FIELD<int,NoInterlaceByType> *) input;
215   }
216 %}