Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/med.git] / src / MedClient / src / libMEDClient.i
1 //  Copyright (C) 2007-2008  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 %module libMEDClient
23
24 %{
25 #include "MESHClient.hxx"
26 #include "SUPPORTClient.hxx"
27 #include "FIELDClient.hxx"
28 #include CORBA_CLIENT_HEADER(MED)
29
30   using namespace MEDMEM;
31   using namespace MED_EN;
32 %}
33
34 %typemap(in) MESH* {
35   if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 0)) == -1) {
36     MESHClient *client;
37     if ((SWIG_ConvertPtr($input, (void **) &client, $descriptor(MESHClient *), 0)) == -1) {
38       SWIG_Python_TypeError("MESH* or MESHClient*", $input);
39       return NULL;
40     }
41     $1 = (MESH *) client;
42   }
43 }
44
45 %include "libMedCorba_Swig.i"
46 %include "libMEDMEM_Swig.i"
47
48 %typecheck(SWIG_TYPECHECK_POINTER) SALOME_MED::FIELDDOUBLE_ptr, SALOME_MED::FIELDINT_ptr
49 {
50   $1 = ($input != 0);
51 }
52
53 /*
54   managing C++ exception in the Python API
55 */
56 /*%exception
57 {
58   class PyAllowThreadsGuard {
59    public:
60     PyAllowThreadsGuard() { _save = PyEval_SaveThread(); }
61     ~PyAllowThreadsGuard() { PyEval_RestoreThread(_save); }
62    private:
63     PyThreadState *_save;
64   };
65
66   PyAllowThreadsGuard guard;
67
68   $action
69 }*/
70
71 class MESHClient : public MESH {
72
73  public:
74   
75   MESHClient(const SALOME_MED::MESH_ptr m);
76
77   void blankCopy();
78   void fillCopy();
79   %extend {
80     ~MESHClient(){
81       self->removeReference();
82     }
83   }
84 };
85
86 MESH * getMeshPointer(MESHClient * input);
87 %{
88   MESH * getMeshPointer(MESHClient * input)
89   {
90     return (MESH *) input;
91   }
92 %}
93
94 class SUPPORTClient : public SUPPORT {
95
96  public:
97
98   SUPPORTClient(const SALOME_MED::SUPPORT_ptr S, 
99                 MESH * M = NULL);
100
101   void blankCopy();
102   void fillCopy();
103   %extend {
104     ~SUPPORTClient() {
105       self->removeReference();
106     }
107   }
108
109 };
110
111 template<class T, class INTERLACING_TAG>
112 class FIELDClient : public FIELD<T,INTERLACING_TAG>
113 {
114 public:
115   template<class U>
116   FIELDClient(U ptrCorba,MEDMEM::SUPPORT * S = NULL);
117   ~FIELDClient();
118 };
119
120 %template (FIELDDOUBLEClient)                  FIELDClient<double, FullInterlace>;
121 %template (FIELDDOUBLENOINTERLACEClient)       FIELDClient<double, NoInterlace>;
122 %template (FIELDDOUBLENOINTERLACEBYTYPEClient) FIELDClient<double, NoInterlaceByType>;
123 %template (FIELDINTClient)                     FIELDClient<int, FullInterlace>;
124 %template (FIELDINTNOINTERLACEClient)          FIELDClient<int, NoInterlace>;
125 %template (FIELDINTNOINTERLACEBYTYPEClient)    FIELDClient<int, NoInterlaceByType>;
126
127 %extend FIELDClient<double, FullInterlace>
128 {
129   %template(FIELDDOUBLEClient) FIELDClient<SALOME_MED::FIELDDOUBLE_ptr>;
130 };
131
132 %extend FIELDClient<double, NoInterlace>
133 {
134   %template(FIELDDOUBLENOINTERLACEClient) FIELDClient<SALOME_MED::FIELDDOUBLE_ptr>;
135 };
136
137 %extend FIELDClient<double, NoInterlaceByType>
138 {
139   %template(FIELDDOUBLENOINTERLACEBYTYPEClient) FIELDClient<SALOME_MED::FIELDDOUBLE_ptr>;
140 };
141
142 %extend FIELDClient<int, FullInterlace>
143 {
144   %template(FIELDINTClient) FIELDClient<SALOME_MED::FIELDINT_ptr>;
145 };
146
147 %extend FIELDClient<int, NoInterlace>
148 {
149   %template(FIELDINTNOINTERLACEClient) FIELDClient<SALOME_MED::FIELDINT_ptr>;
150 };
151
152 %extend FIELDClient<int, NoInterlaceByType>
153 {
154   %template(FIELDINTNOINTERLACEBYTYPEClient) FIELDClient<SALOME_MED::FIELDINT_ptr>;
155 };
156
157 FIELD<double> * getDoublePointer(FIELDClient<double,FullInterlace> * input);
158
159 FIELD<double,NoInterlace> *getDoubleNoInterlacePointer(FIELDClient<double,NoInterlace> * input);
160
161 FIELD<double,NoInterlaceByType> *getDoubleNoInterlaceByTypePointer(FIELDClient<double,NoInterlaceByType> * input);
162
163 FIELD<int> * getIntPointer(FIELDClient<int,FullInterlace> * input);
164
165 FIELD<int,NoInterlace> * getIntNoInterlacePointer(FIELDClient<int,NoInterlace> * input);
166
167 FIELD<int,NoInterlaceByType> * getIntNoInterlaceByTypePointer(FIELDClient<int,NoInterlaceByType> * input);
168
169 %{
170   FIELD<double> * getDoublePointer(FIELDClient<double,FullInterlace> * input)
171     {
172       return (FIELD<double> *) input;
173     }
174
175   FIELD<double,NoInterlace> *getDoubleNoInterlacePointer(FIELDClient<double,NoInterlace> * input)
176     {
177       return (FIELD<double,NoInterlace> *) input;
178     }
179
180   FIELD<double,NoInterlaceByType> *getDoubleNoInterlaceByTypePointer(FIELDClient<double,NoInterlaceByType> * input)
181     {
182       return (FIELD<double,NoInterlaceByType> *) input;
183     }
184
185   FIELD<int> * getIntPointer(FIELDClient<int,FullInterlace> * input)
186   {
187       return (FIELD<int> *) input;
188   }
189
190   FIELD<int,NoInterlace> * getIntNoInterlacePointer(FIELDClient<int,NoInterlace> * input)
191   {
192       return (FIELD<int,NoInterlace> *) input;
193   }
194
195   FIELD<int,NoInterlaceByType> * getIntNoInterlaceByTypePointer(FIELDClient<int,NoInterlaceByType> * input)
196   {
197       return (FIELD<int,NoInterlaceByType> *) input;
198   }
199 %}