Salome HOME
4aa51443f7c1dd8a0f389413318126ea0f5df5cb
[tools/medcoupling.git] / src / MEDCoupling_Swig / MEDCouplingTypemaps.i
1 // Copyright (C) 2007-2015  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 // Author : Anthony Geay (CEA/DEN)
20
21 #include "MEDCouplingDataArrayTypemaps.i"
22
23 static PyObject *convertMesh(MEDCoupling::MEDCouplingMesh *mesh, int owner) throw(INTERP_KERNEL::Exception)
24 {
25   PyObject *ret=0;
26   if(!mesh)
27     {
28       Py_XINCREF(Py_None);
29       return Py_None;
30     }
31   if(dynamic_cast<MEDCoupling::MEDCouplingUMesh *>(mesh))
32     ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh,owner);
33   if(dynamic_cast<MEDCoupling::MEDCoupling1SGTUMesh *>(mesh))
34     ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCoupling1SGTUMesh,owner);
35   if(dynamic_cast<MEDCoupling::MEDCoupling1DGTUMesh *>(mesh))
36     ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCoupling1DGTUMesh,owner);
37   if(dynamic_cast<MEDCoupling::MEDCouplingMappedExtrudedMesh *>(mesh))
38     ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCouplingMappedExtrudedMesh,owner);
39   if(dynamic_cast<MEDCoupling::MEDCouplingCMesh *>(mesh))
40     ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCouplingCMesh,owner);
41   if(dynamic_cast<MEDCoupling::MEDCouplingCurveLinearMesh *>(mesh))
42     ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCouplingCurveLinearMesh,owner);
43   if(dynamic_cast<MEDCoupling::MEDCouplingIMesh *>(mesh))
44     ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCouplingIMesh,owner);
45   if(!ret)
46     throw INTERP_KERNEL::Exception("Not recognized type of mesh on downcast !");
47   return ret;
48 }
49
50 static PyObject *convertFieldDiscretization(MEDCoupling::MEDCouplingFieldDiscretization *fd, int owner) throw(INTERP_KERNEL::Exception)
51 {
52   PyObject *ret=0;
53   if(!fd)
54     {
55       Py_XINCREF(Py_None);
56       return Py_None;
57     }
58   if(dynamic_cast<MEDCoupling::MEDCouplingFieldDiscretizationP0 *>(fd))
59     ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDiscretizationP0,owner);
60   if(dynamic_cast<MEDCoupling::MEDCouplingFieldDiscretizationP1 *>(fd))
61     ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDiscretizationP1,owner);
62   if(dynamic_cast<MEDCoupling::MEDCouplingFieldDiscretizationGauss *>(fd))
63     ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDiscretizationGauss,owner);
64   if(dynamic_cast<MEDCoupling::MEDCouplingFieldDiscretizationGaussNE *>(fd))
65     ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDiscretizationGaussNE,owner);
66   if(dynamic_cast<MEDCoupling::MEDCouplingFieldDiscretizationKriging *>(fd))
67     ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDiscretizationKriging,owner);
68   if(!ret)
69     throw INTERP_KERNEL::Exception("Not recognized type of field discretization on downcast !");
70   return ret;
71 }
72
73 static PyObject* convertMultiFields(MEDCoupling::MEDCouplingMultiFields *mfs, int owner) throw(INTERP_KERNEL::Exception)
74 {
75   PyObject *ret=0;
76   if(!mfs)
77     {
78       Py_XINCREF(Py_None);
79       return Py_None;
80     }
81   if(dynamic_cast<MEDCoupling::MEDCouplingFieldOverTime *>(mfs))
82     ret=SWIG_NewPointerObj((void*)mfs,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldOverTime,owner);
83   else
84     ret=SWIG_NewPointerObj((void*)mfs,SWIGTYPE_p_MEDCoupling__MEDCouplingMultiFields,owner);
85   return ret;
86 }
87
88 static PyObject *convertPartDefinition(MEDCoupling::PartDefinition *pd, int owner) throw(INTERP_KERNEL::Exception)
89 {
90   PyObject *ret=0;
91   if(!pd)
92     {
93       Py_XINCREF(Py_None);
94       return Py_None;
95     }
96   if(dynamic_cast<MEDCoupling::DataArrayPartDefinition *>(pd))
97     ret=SWIG_NewPointerObj((void*)pd,SWIGTYPE_p_MEDCoupling__DataArrayPartDefinition,owner);
98   else
99     ret=SWIG_NewPointerObj((void*)pd,SWIGTYPE_p_MEDCoupling__SlicePartDefinition,owner);
100   return ret;
101 }
102
103 static PyObject *convertCartesianAMRMesh(MEDCoupling::MEDCouplingCartesianAMRMeshGen *mesh, int owner) throw(INTERP_KERNEL::Exception)
104 {
105   if(!mesh)
106     {
107       Py_XINCREF(Py_None);
108       return Py_None;
109     }
110   if(dynamic_cast<MEDCoupling::MEDCouplingCartesianAMRMeshSub *>(mesh))
111     {
112       return SWIG_NewPointerObj(reinterpret_cast<void*>(mesh),SWIGTYPE_p_MEDCoupling__MEDCouplingCartesianAMRMeshSub,owner);
113     }
114   if(dynamic_cast<MEDCoupling::MEDCouplingCartesianAMRMesh *>(mesh))
115     {
116       return SWIG_NewPointerObj(reinterpret_cast<void*>(mesh),SWIGTYPE_p_MEDCoupling__MEDCouplingCartesianAMRMesh,owner);
117     }
118   throw INTERP_KERNEL::Exception("convertCartesianAMRMesh wrap : unrecognized type of cartesian AMR mesh !");
119 }
120
121 static PyObject *convertDataForGodFather(MEDCoupling::MEDCouplingDataForGodFather *data, int owner) throw(INTERP_KERNEL::Exception)
122 {
123   if(!data)
124     {
125       Py_XINCREF(Py_None);
126       return Py_None;
127     }
128   if(dynamic_cast<MEDCoupling::MEDCouplingAMRAttribute *>(data))
129     {
130       return SWIG_NewPointerObj(reinterpret_cast<void*>(data),SWIGTYPE_p_MEDCoupling__MEDCouplingAMRAttribute,owner);
131     }
132   throw INTERP_KERNEL::Exception("convertDataForGodFather wrap : unrecognized data type for AMR !");
133 }
134
135 static PyObject *convertCartesianAMRPatch(MEDCoupling::MEDCouplingCartesianAMRPatchGen *patch, int owner) throw(INTERP_KERNEL::Exception)
136 {
137   if(!patch)
138     {
139       Py_XINCREF(Py_None);
140       return Py_None;
141     }
142   if(dynamic_cast<MEDCoupling::MEDCouplingCartesianAMRPatchGF *>(patch))
143     {
144       return SWIG_NewPointerObj(reinterpret_cast<void*>(patch),SWIGTYPE_p_MEDCoupling__MEDCouplingCartesianAMRPatchGF,owner);
145     }
146   if(dynamic_cast<MEDCoupling::MEDCouplingCartesianAMRPatch *>(patch))
147     {
148       return SWIG_NewPointerObj(reinterpret_cast<void*>(patch),SWIGTYPE_p_MEDCoupling__MEDCouplingCartesianAMRPatch,owner);
149     }
150   throw INTERP_KERNEL::Exception("convertCartesianAMRPatch wrap : unrecognized type of cartesian AMR patch !");
151 }
152
153 static MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___add__Impl(MEDCoupling::MEDCouplingFieldDouble *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
154 {
155   const char msg[]="Unexpected situation in MEDCouplingFieldDouble.__add__ ! Expecting a not null MEDCouplingFieldDouble or DataArrayDouble or DataArrayDoubleTuple instance, or a list of double, or a double.";
156   const char msg2[]="in MEDCouplingFieldDouble.__add__ : self field has no Array of values set !";
157   void *argp;
158   //
159   if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,0|0)))
160     {
161       MEDCoupling::MEDCouplingFieldDouble *other=reinterpret_cast< MEDCoupling::MEDCouplingFieldDouble * >(argp);
162       if(other)
163         return (*self)+(*other);
164       else
165         throw INTERP_KERNEL::Exception(msg);
166     }
167   //
168   double val;
169   MEDCoupling::DataArrayDouble *a;
170   MEDCoupling::DataArrayDoubleTuple *aa;
171   std::vector<double> bb;
172   int sw;
173   convertObjToPossibleCpp5(obj,sw,val,a,aa,bb);
174   switch(sw)
175     {
176     case 1:
177       {
178         if(!self->getArray())
179           throw INTERP_KERNEL::Exception(msg2);
180         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=self->getArray()->deepCopy();
181         ret->applyLin(1.,val);
182         MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
183         ret2->setArray(ret);
184         return ret2.retn();
185       }
186     case 2:
187       {
188         if(!self->getArray())
189           throw INTERP_KERNEL::Exception(msg2);
190         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Add(self->getArray(),a);
191         MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
192         ret2->setArray(ret);
193         return ret2.retn();
194       }
195     case 3:
196       {
197         if(!self->getArray())
198           throw INTERP_KERNEL::Exception(msg2);
199         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
200         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Add(self->getArray(),aaa);
201         MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
202         ret2->setArray(ret);
203         return ret2.retn();
204       }
205     case 4:
206       {
207         if(!self->getArray())
208           throw INTERP_KERNEL::Exception(msg2);
209         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=MEDCoupling::DataArrayDouble::New(); aaa->useArray(&bb[0],false,MEDCoupling::CPP_DEALLOC,1,(int)bb.size());
210         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Add(self->getArray(),aaa);
211         MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
212         ret2->setArray(ret);
213         return ret2.retn();
214       }
215     default:
216       { throw INTERP_KERNEL::Exception(msg); }
217     }
218 }
219
220 static MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___radd__Impl(MEDCoupling::MEDCouplingFieldDouble *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
221 {
222   return MEDCoupling_MEDCouplingFieldDouble___add__Impl(self,obj);
223 }
224
225 static MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___rsub__Impl(MEDCoupling::MEDCouplingFieldDouble *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
226 {
227   const char msg[]="Unexpected situation in MEDCouplingFieldDouble.__rsub__ ! Expecting a not null MEDCouplingFieldDouble or DataArrayDouble or DataArrayDoubleTuple instance, or a list of double, or a double.";
228   const char msg2[]="in MEDCouplingFieldDouble.__rsub__ : self field has no Array of values set !";
229   void *argp;
230   //
231   if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,0|0)))
232     {
233       MEDCoupling::MEDCouplingFieldDouble *other=reinterpret_cast< MEDCoupling::MEDCouplingFieldDouble * >(argp);
234       if(other)
235         return (*other)-(*self);
236       else
237         throw INTERP_KERNEL::Exception(msg);
238     }
239   //
240   double val;
241   MEDCoupling::DataArrayDouble *a;
242   MEDCoupling::DataArrayDoubleTuple *aa;
243   std::vector<double> bb;
244   int sw;
245   convertObjToPossibleCpp5(obj,sw,val,a,aa,bb);
246   switch(sw)
247     {
248     case 1:
249       {
250         if(!self->getArray())
251           throw INTERP_KERNEL::Exception(msg2);
252         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=self->getArray()->deepCopy();
253         ret->applyLin(-1.,val);
254         MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
255         ret2->setArray(ret);
256         return ret2.retn();
257       }
258     case 2:
259       {
260         if(!self->getArray())
261           throw INTERP_KERNEL::Exception(msg2);
262         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Substract(a,self->getArray());
263         MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
264         ret2->setArray(ret);
265         return ret2.retn();
266       }
267     case 3:
268       {
269         if(!self->getArray())
270           throw INTERP_KERNEL::Exception(msg2);
271         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
272         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Substract(aaa,self->getArray());
273         MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
274         ret2->setArray(ret);
275         return ret2.retn();
276       }
277     case 4:
278       {
279         if(!self->getArray())
280           throw INTERP_KERNEL::Exception(msg2);
281         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=MEDCoupling::DataArrayDouble::New(); aaa->useArray(&bb[0],false,MEDCoupling::CPP_DEALLOC,1,(int)bb.size());
282         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Substract(aaa,self->getArray());
283         MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
284         ret2->setArray(ret);
285         return ret2.retn();
286       }
287     default:
288       { throw INTERP_KERNEL::Exception(msg); }
289     }
290 }
291
292 static MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___mul__Impl(MEDCoupling::MEDCouplingFieldDouble *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
293 {
294   const char msg[]="Unexpected situation in MEDCouplingFieldDouble.__mul__ ! Expecting a not null MEDCouplingFieldDouble or DataArrayDouble or DataArrayDoubleTuple instance, or a list of double, or a double.";
295   const char msg2[]="in MEDCouplingFieldDouble.__mul__ : self field has no Array of values set !";
296   void *argp;
297   //
298   if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,0|0)))
299     {
300       MEDCoupling::MEDCouplingFieldDouble *other=reinterpret_cast< MEDCoupling::MEDCouplingFieldDouble * >(argp);
301       if(other)
302         return (*self)*(*other);
303       else
304         throw INTERP_KERNEL::Exception(msg);
305     }
306   //
307   double val;
308   MEDCoupling::DataArrayDouble *a;
309   MEDCoupling::DataArrayDoubleTuple *aa;
310   std::vector<double> bb;
311   int sw;
312   convertObjToPossibleCpp5(obj,sw,val,a,aa,bb);
313   switch(sw)
314     {
315     case 1:
316       {
317         if(!self->getArray())
318           throw INTERP_KERNEL::Exception(msg2);
319         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=self->getArray()->deepCopy();
320         ret->applyLin(val,0.);
321         MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
322         ret2->setArray(ret);
323         return ret2.retn();
324       }
325     case 2:
326       {
327         if(!self->getArray())
328           throw INTERP_KERNEL::Exception(msg2);
329         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Multiply(self->getArray(),a);
330         MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
331         ret2->setArray(ret);
332         return ret2.retn();
333       }
334     case 3:
335       {
336         if(!self->getArray())
337           throw INTERP_KERNEL::Exception(msg2);
338         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
339         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Multiply(self->getArray(),aaa);
340         MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
341         ret2->setArray(ret);
342         return ret2.retn();
343       }
344     case 4:
345       {
346         if(!self->getArray())
347           throw INTERP_KERNEL::Exception(msg2);
348         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=MEDCoupling::DataArrayDouble::New(); aaa->useArray(&bb[0],false,MEDCoupling::CPP_DEALLOC,1,(int)bb.size());
349         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Multiply(self->getArray(),aaa);
350         MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
351         ret2->setArray(ret);
352         return ret2.retn();
353       }
354     default:
355       { throw INTERP_KERNEL::Exception(msg); }
356     }
357 }
358
359 MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___rmul__Impl(MEDCoupling::MEDCouplingFieldDouble *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
360 {
361   return MEDCoupling_MEDCouplingFieldDouble___mul__Impl(self,obj);
362 }
363
364 MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___rdiv__Impl(MEDCoupling::MEDCouplingFieldDouble *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
365 {
366   const char msg[]="Unexpected situation in MEDCouplingFieldDouble.__rdiv__ ! Expecting a not null MEDCouplingFieldDouble or DataArrayDouble or DataArrayDoubleTuple instance, or a list of double, or a double.";
367   const char msg2[]="in MEDCouplingFieldDouble.__div__ : self field has no Array of values set !";
368   void *argp;
369   //
370   if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,0|0)))
371     {
372       MEDCoupling::MEDCouplingFieldDouble *other=reinterpret_cast< MEDCoupling::MEDCouplingFieldDouble * >(argp);
373       if(other)
374         return (*other)/(*self);
375       else
376         throw INTERP_KERNEL::Exception(msg);
377     }
378   //
379   double val;
380   MEDCoupling::DataArrayDouble *a;
381   MEDCoupling::DataArrayDoubleTuple *aa;
382   std::vector<double> bb;
383   int sw;
384   convertObjToPossibleCpp5(obj,sw,val,a,aa,bb);
385   switch(sw)
386     {
387     case 1:
388       {
389         if(!self->getArray())
390           throw INTERP_KERNEL::Exception(msg2);
391         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=self->getArray()->deepCopy();
392         ret->applyInv(val);
393         MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
394         ret2->setArray(ret);
395         return ret2.retn();
396       }
397     case 2:
398       {
399         if(!self->getArray())
400           throw INTERP_KERNEL::Exception(msg2);
401         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Divide(a,self->getArray());
402         MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
403         ret2->setArray(ret);
404         return ret2.retn();
405       }
406     case 3:
407       {
408         if(!self->getArray())
409           throw INTERP_KERNEL::Exception(msg2);
410         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
411         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Divide(aaa,self->getArray());
412         MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
413         ret2->setArray(ret);
414         return ret2.retn();
415       }
416     case 4:
417       {
418         if(!self->getArray())
419           throw INTERP_KERNEL::Exception(msg2);
420         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=MEDCoupling::DataArrayDouble::New(); aaa->useArray(&bb[0],false,MEDCoupling::CPP_DEALLOC,1,(int)bb.size());
421         MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Divide(aaa,self->getArray());
422         MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
423         ret2->setArray(ret);
424         return ret2.retn();
425       }
426     default:
427       { throw INTERP_KERNEL::Exception(msg); }
428     }
429 }
430
431 static PyObject *NewMethWrapCallInitOnlyIfEmptyDictInInput(PyObject *cls, PyObject *args, const char *clsName)
432 {
433   if(!PyTuple_Check(args))
434     {
435       std::ostringstream oss; oss << clsName << ".__new__ : the args in input is expected to be a tuple !";
436       throw INTERP_KERNEL::Exception(oss.str().c_str());
437     }
438   PyObject *builtinsd(PyEval_GetBuiltins());//borrowed
439   PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed
440   PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__"));
441   //
442   PyObject *tmp0(PyTuple_New(1));
443   PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls);
444   PyObject *instance(PyObject_CallObject(selfMeth,tmp0));
445   Py_DECREF(tmp0);
446   Py_DECREF(selfMeth);
447   if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==0 )
448     {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ !
449       PyObject *initMeth(PyObject_GetAttrString(instance,"__init__"));
450       PyObject *tmp3(PyTuple_New(0));
451       PyObject *tmp2(PyObject_CallObject(initMeth,tmp3));
452       Py_XDECREF(tmp2);
453       Py_DECREF(tmp3);
454       Py_DECREF(initMeth);
455     }
456   return instance;
457 }