Salome HOME
Merge from V6_main 13/12/2012
[modules/med.git] / src / MEDLoader / Swig / MEDLoaderCommon.i
1 // Copyright (C) 2007-2012  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.
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 %module MEDLoader
22
23 #define MEDCOUPLING_EXPORT
24 #define MEDLOADER_EXPORT
25
26 %include "MEDCouplingCommon.i"
27
28 %{
29 #include "MEDLoader.hxx"
30 #include "MEDFileMesh.hxx"
31 #include "MEDFileField.hxx"
32 #include "MEDFileData.hxx"
33 #include "MEDLoaderTypemaps.i"
34 #include "SauvReader.hxx"
35 #include "SauvWriter.hxx"
36
37 using namespace ParaMEDMEM;
38 %}
39
40 #if SWIG_VERSION >= 0x010329
41 %template()  std::vector<std::string>;
42 #endif
43
44 %typemap(out) ParaMEDMEM::MEDFileMesh*
45 {
46   $result=convertMEDFileMesh($1,$owner);
47 }
48
49 %newobject MEDLoader::ReadUMeshFromFamilies;
50 %newobject MEDLoader::ReadUMeshFromGroups;
51 %newobject MEDLoader::ReadUMeshFromFile;
52 %newobject MEDLoader::ReadField;
53 %newobject MEDLoader::ReadFieldCell;
54 %newobject MEDLoader::ReadFieldNode;
55 %newobject MEDLoader::ReadFieldGauss;
56 %newobject MEDLoader::ReadFieldGaussNE;
57 %newobject ParaMEDMEM::MEDFileMesh::New;
58 %newobject ParaMEDMEM::MEDFileMesh::getGenMeshAtLevel;
59 %newobject ParaMEDMEM::MEDFileMesh::getGroupArr;
60 %newobject ParaMEDMEM::MEDFileMesh::getGroupsArr;
61 %newobject ParaMEDMEM::MEDFileMesh::getFamilyArr;
62 %newobject ParaMEDMEM::MEDFileMesh::getFamiliesArr;
63 %newobject ParaMEDMEM::MEDFileMesh::getNodeGroupArr;
64 %newobject ParaMEDMEM::MEDFileMesh::getNodeGroupsArr;
65 %newobject ParaMEDMEM::MEDFileMesh::getNodeFamilyArr;
66 %newobject ParaMEDMEM::MEDFileMesh::getNodeFamiliesArr;
67 %newobject ParaMEDMEM::MEDFileMesh::getAllFamiliesIdsReferenced;
68 %newobject ParaMEDMEM::MEDFileUMesh::New;
69 %newobject ParaMEDMEM::MEDFileUMesh::getCoords;
70 %newobject ParaMEDMEM::MEDFileUMesh::getGroup;
71 %newobject ParaMEDMEM::MEDFileUMesh::getGroups;
72 %newobject ParaMEDMEM::MEDFileUMesh::getFamily;
73 %newobject ParaMEDMEM::MEDFileUMesh::getFamilies;
74 %newobject ParaMEDMEM::MEDFileUMesh::getMeshAtLevel;
75 %newobject ParaMEDMEM::MEDFileUMesh::getLevel0Mesh;
76 %newobject ParaMEDMEM::MEDFileUMesh::getLevelM1Mesh;
77 %newobject ParaMEDMEM::MEDFileUMesh::getLevelM2Mesh;
78 %newobject ParaMEDMEM::MEDFileUMesh::getLevelM3Mesh;
79 %newobject ParaMEDMEM::MEDFileCMesh::New;
80 %newobject ParaMEDMEM::MEDFileMeshMultiTS::New;
81 %newobject ParaMEDMEM::MEDFileMeshMultiTS::getOneTimeStep;
82 %newobject ParaMEDMEM::MEDFileMeshes::New;
83 %newobject ParaMEDMEM::MEDFileMeshes::getMeshAtPos;
84 %newobject ParaMEDMEM::MEDFileMeshes::getMeshWithName;
85 %newobject ParaMEDMEM::MEDFileMeshes::__getitem__;
86 %newobject ParaMEDMEM::MEDFileMeshes::__iter__;
87
88 %newobject ParaMEDMEM::MEDFileFields::New;
89 %newobject ParaMEDMEM::MEDFileFields::getFieldWithName;
90 %newobject ParaMEDMEM::MEDFileFields::getFieldAtPos;
91 %newobject ParaMEDMEM::MEDFileFields::__getitem__;
92 %newobject ParaMEDMEM::MEDFileFields::__iter__;
93 %newobject ParaMEDMEM::MEDFileFieldMultiTS::New;
94 %newobject ParaMEDMEM::MEDFileFieldMultiTS::getTimeStepAtPos;
95 %newobject ParaMEDMEM::MEDFileFieldMultiTS::getTimeStep;
96 %newobject ParaMEDMEM::MEDFileFieldMultiTS::getTimeStepGivenTime;
97 %newobject ParaMEDMEM::MEDFileFieldMultiTS::__getitem__;
98 %newobject ParaMEDMEM::MEDFileFieldMultiTS::__iter__;
99 %newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldAtLevel;
100 %newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldAtTopLevel;
101 %newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldOnMeshAtLevel;
102 %newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldAtLevelOld;
103 %newobject ParaMEDMEM::MEDFileFieldMultiTS::getUndergroundDataArray;
104 %newobject ParaMEDMEM::MEDFileField1TS::New;
105 %newobject ParaMEDMEM::MEDFileField1TS::getFieldAtLevel;
106 %newobject ParaMEDMEM::MEDFileField1TS::getFieldAtTopLevel;
107 %newobject ParaMEDMEM::MEDFileField1TS::getFieldOnMeshAtLevel;
108 %newobject ParaMEDMEM::MEDFileField1TS::getFieldAtLevelOld;
109 %newobject ParaMEDMEM::MEDFileField1TS::getUndergroundDataArray;
110
111 %newobject ParaMEDMEM::MEDFileData::New;
112 %newobject ParaMEDMEM::MEDFileData::getMeshes;
113 %newobject ParaMEDMEM::MEDFileData::getFields;
114
115 %newobject ParaMEDMEM::SauvWriter::New;
116 %newobject ParaMEDMEM::SauvReader::New;
117 %newobject ParaMEDMEM::SauvReader::loadInMEDFileDS;
118
119 %feature("unref") MEDFileMesh "$this->decrRef();"
120 %feature("unref") MEDFileUMesh "$this->decrRef();"
121 %feature("unref") MEDFileCMesh "$this->decrRef();"
122 %feature("unref") MEDFileMeshMultiTS "$this->decrRef();"
123 %feature("unref") MEDFileMeshes "$this->decrRef();"
124 %feature("unref") MEDFileFieldLoc "$this->decrRef();"
125 %feature("unref") MEDFileField1TS "$this->decrRef();"
126 %feature("unref") MEDFileFieldMultiTS "$this->decrRef();"
127 %feature("unref") MEDFileFields "$this->decrRef();"
128 %feature("unref") MEDFileData "$this->decrRef();"
129 %feature("unref") SauvReader "$this->decrRef();"
130 %feature("unref") SauvWriter "$this->decrRef();"
131
132 class MEDLoader
133 {
134 public:
135   static void setEpsilonForNodeComp(double val) throw(INTERP_KERNEL::Exception);
136   static void setCompPolicyForCell(int val) throw(INTERP_KERNEL::Exception);
137   static void setTooLongStrPolicy(int val) throw(INTERP_KERNEL::Exception);
138   static void CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception);
139   static std::vector<std::string> GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception);
140   static std::vector<std::string> GetMeshNamesOnField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
141   static std::vector<std::string> GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
142   static std::vector<std::string> GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
143   static std::vector<std::string> GetMeshFamiliesNamesOnGroup(const char *fileName, const char *meshName, const char *grpName) throw(INTERP_KERNEL::Exception);
144   static std::vector<std::string> GetMeshGroupsNamesOnFamily(const char *fileName, const char *meshName, const char *famName) throw(INTERP_KERNEL::Exception);
145   static std::vector<std::string> GetAllFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
146   static std::vector<std::string> GetAllFieldNames(const char *fileName) throw(INTERP_KERNEL::Exception);
147   static std::vector<std::string> GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
148   static std::vector<std::string> GetCellFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
149   static std::vector<std::string> GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
150   static double GetTimeAttachedOnFieldIteration(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
151   %extend
152      {
153        static PyObject *GetFieldIterations(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
154        {
155          std::vector< std::pair<int,int> > res=MEDLoader::GetFieldIterations(type,fileName,meshName,fieldName);
156          PyObject *ret=PyList_New(res.size());
157          int rk=0;
158          for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
159            {
160              PyObject *elt=PyTuple_New(2);
161              PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
162              PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
163              PyList_SetItem(ret,rk,elt);
164            }
165          return ret;
166        }
167
168        static PyObject *GetAllFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
169        {
170          std::vector< std::pair< std::pair<int,int>, double> > res=MEDLoader::GetAllFieldIterations(fileName,meshName,fieldName);
171          PyObject *ret=PyList_New(res.size());
172          int rk=0;
173          for(std::vector< std::pair< std::pair<int,int>, double> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
174            {
175              PyObject *elt=PyTuple_New(3);
176              PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first.first));
177              PyTuple_SetItem(elt,1,SWIG_From_int((*iter).first.second));
178              PyTuple_SetItem(elt,2,SWIG_From_double((*iter).second));
179              PyList_SetItem(ret,rk,elt);
180            }
181          return ret;
182        }
183
184        static PyObject *GetCellFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
185        {
186          std::vector< std::pair<int,int> > res=MEDLoader::GetCellFieldIterations(fileName,meshName,fieldName);
187          PyObject *ret=PyList_New(res.size());
188          int rk=0;
189          for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
190            {
191              PyObject *elt=PyTuple_New(2);
192              PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
193              PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
194              PyList_SetItem(ret,rk,elt);
195            }
196          return ret;
197        }
198        static PyObject *GetNodeFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
199        {
200          std::vector< std::pair<int,int> > res=MEDLoader::GetNodeFieldIterations(fileName,meshName,fieldName);
201          PyObject *ret=PyList_New(res.size());
202          int rk=0;
203          for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
204            {
205              PyObject *elt=PyTuple_New(2);
206              PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
207              PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
208              PyList_SetItem(ret,rk,elt);
209            }
210          return ret;
211        }
212        static PyObject *GetComponentsNamesOfField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
213        {
214          std::vector< std::pair<std::string,std::string> > res=MEDLoader::GetComponentsNamesOfField(fileName,fieldName);
215          PyObject *ret=PyList_New(res.size());
216          int rk=0;
217          for(std::vector< std::pair<std::string,std::string> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
218            {
219              PyObject *elt=PyTuple_New(2);
220              PyTuple_SetItem(elt,0,PyString_FromString((*iter).first.c_str()));
221              PyTuple_SetItem(elt,1,PyString_FromString((*iter).second.c_str()));
222              PyList_SetItem(ret,rk,elt);
223            }
224          return ret;
225        }
226        static PyObject *GetUMeshGlobalInfo(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception)
227        {
228          int meshDim,spaceDim,numberOfNodes;
229          std::vector< std::vector< std::pair<INTERP_KERNEL::NormalizedCellType,int> > > res=MEDLoader::GetUMeshGlobalInfo(fileName,meshName,meshDim,spaceDim,numberOfNodes);
230          PyObject *ret=PyTuple_New(4);
231          PyObject *elt0=PyList_New(res.size());
232          int i=0;
233          for(std::vector< std::vector< std::pair<INTERP_KERNEL::NormalizedCellType,int> > >::const_iterator it=res.begin();it!=res.end();it++,i++)
234            {
235              const std::vector< std::pair<INTERP_KERNEL::NormalizedCellType,int> >&obj2=(*it);
236              int j=0;
237              PyObject *elt1=PyList_New(obj2.size());
238              for(std::vector< std::pair<INTERP_KERNEL::NormalizedCellType,int> >::const_iterator it2=obj2.begin();it2!=obj2.end();it2++,j++)
239                {
240                  PyObject *elt2=PyTuple_New(2);
241                  PyTuple_SetItem(elt2,0,SWIG_From_int((int)(*it2).first));
242                  PyTuple_SetItem(elt2,1,SWIG_From_int((*it2).second));
243                  PyList_SetItem(elt1,j,elt2);
244                }
245              PyList_SetItem(elt0,i,elt1);
246            }
247          PyTuple_SetItem(ret,0,elt0);
248          PyTuple_SetItem(ret,1,SWIG_From_int(meshDim));
249          PyTuple_SetItem(ret,2,SWIG_From_int(spaceDim));
250          PyTuple_SetItem(ret,3,SWIG_From_int(numberOfNodes));
251          return ret;
252        }
253        static PyObject *ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax,
254                                              const char *fieldName, PyObject *liIts) throw(INTERP_KERNEL::Exception)
255        {
256          std::vector<std::pair<int,int> > its=convertTimePairIdsFromPy(liIts);
257          std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> res=MEDLoader::ReadFieldsOnSameMesh(type,fileName,meshName,meshDimRelToMax,fieldName,its);
258          return convertFieldDoubleVecToPy(res);
259        }
260        static void WriteUMeshesPartition(const char *fileName, const char *meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
261        {
262          std::vector<const ParaMEDMEM::MEDCouplingUMesh *> v;
263          convertFromPyObjVectorOfObj<const ParaMEDMEM::MEDCouplingUMesh *>(li,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,"MEDCouplingUMesh",v);
264          MEDLoader::WriteUMeshesPartition(fileName,meshName,v,writeFromScratch);
265        }
266        static void WriteUMeshesPartitionDep(const char *fileName, const char *meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
267        {
268          std::vector<const ParaMEDMEM::MEDCouplingUMesh *> v;
269          convertFromPyObjVectorOfObj<const ParaMEDMEM::MEDCouplingUMesh *>(li,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,"MEDCouplingUMesh",v);
270          MEDLoader::WriteUMeshesPartitionDep(fileName,meshName,v,writeFromScratch);
271        }
272        static void WriteUMeshes(const char *fileName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
273        {
274          std::vector<const ParaMEDMEM::MEDCouplingUMesh *> v;
275          convertFromPyObjVectorOfObj<const ParaMEDMEM::MEDCouplingUMesh *>(li,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,"MEDCouplingUMesh",v);
276          MEDLoader::WriteUMeshes(fileName,v,writeFromScratch);
277        }
278        static PyObject *GetTypesOfField(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
279        {
280          std::vector< ParaMEDMEM::TypeOfField > v=MEDLoader::GetTypesOfField(fileName,meshName,fieldName);
281          int size=v.size();
282          PyObject *ret=PyList_New(size);
283          for(int i=0;i<size;i++)
284            PyList_SetItem(ret,i,PyInt_FromLong((int)v[i]));
285          return ret;
286        }
287        static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, PyObject *li) throw(INTERP_KERNEL::Exception)
288        {
289          std::vector<std::string> grps;
290          converPyListToVecString(li,grps);
291          return MEDLoader::ReadUMeshFromGroups(fileName,meshName,meshDimRelToMax,grps);
292        }
293        static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, PyObject *li) throw(INTERP_KERNEL::Exception)
294        {
295          std::vector<std::string> fams;
296          converPyListToVecString(li,fams);
297          return MEDLoader::ReadUMeshFromFamilies(fileName,meshName,meshDimRelToMax,fams);
298        }
299      }
300   static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
301   static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
302   static int ReadUMeshDimFromFile(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
303   static ParaMEDMEM::MEDCouplingFieldDouble *ReadField(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
304   static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
305   static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
306   static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
307   static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
308   static void WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
309   static void WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
310   static void WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
311   static void WriteFieldDep(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
312   static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception);
313 };
314
315 namespace ParaMEDMEM
316 {
317   class MEDFileWritable
318   {
319   public:
320     void copyOptionsFrom(const MEDFileWritable& other) const;
321     int getTooLongStrPolicy() const throw(INTERP_KERNEL::Exception);
322     void setTooLongStrPolicy(int newVal) throw(INTERP_KERNEL::Exception);
323     int getZipConnPolicy() throw(INTERP_KERNEL::Exception);
324     void setZipConnPolicy(int newVal) throw(INTERP_KERNEL::Exception);
325   };
326
327   class MEDFileMesh : public RefCountObject, public MEDFileWritable
328   {
329   public:
330     static MEDFileMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
331     static MEDFileMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1);
332     virtual void clearNonDiscrAttributes() const;
333     void setName(const char *name);
334     const char *getName();
335     void setUnivName(const char *name);
336     const char *getUnivName() const;
337     void setDescription(const char *name);
338     const char *getDescription() const;
339     void setOrder(int order);
340     int getOrder() const;
341     void setIteration(int it);
342     int getIteration();
343     void setTimeValue(double time);
344     void setTime(int dt, int it, double time);
345     double getTimeValue() const;
346     void setTimeUnit(const char *unit);
347     const char *getTimeUnit() const;
348     virtual int getNumberOfNodes() const throw(INTERP_KERNEL::Exception);
349     std::vector<int> getNonEmptyLevels() const;
350     std::vector<int> getNonEmptyLevelsExt() const;
351     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
352     int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
353     //
354     bool existsGroup(const char *groupName) const;
355     bool existsFamily(int famId) const;
356     bool existsFamily(const char *familyName) const;
357     void setFamilyId(const char *familyName, int id);
358     void setFamilyIdUnique(const char *familyName, int id) throw(INTERP_KERNEL::Exception);
359     void addFamily(const char *familyName, int id) throw(INTERP_KERNEL::Exception);
360     void addFamilyOnGrp(const char *grpName, const char *famName) throw(INTERP_KERNEL::Exception);
361     virtual void createGroupOnAll(int meshDimRelToMaxExt, const char *groupName) throw(INTERP_KERNEL::Exception);
362     virtual bool keepFamIdsOnlyOnLevs(const std::vector<int>& famIds, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception);
363     void copyFamGrpMapsFrom(const MEDFileMesh& other);
364     const std::map<std::string,int>& getFamilyInfo() const;
365     const std::map<std::string, std::vector<std::string> >& getGroupInfo() const;
366     std::vector<std::string> getFamiliesOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
367     std::vector<std::string> getFamiliesOnGroups(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
368     std::vector<int> getFamiliesIdsOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
369     void setFamiliesOnGroup(const char *name, const std::vector<std::string>& fams) throw(INTERP_KERNEL::Exception);
370     void setFamiliesIdsOnGroup(const char *name, const std::vector<int>& famIds) throw(INTERP_KERNEL::Exception);
371     std::vector<std::string> getGroupsOnFamily(const char *name) const throw(INTERP_KERNEL::Exception);
372     void setGroupsOnFamily(const char *famName, const std::vector<std::string>& grps) throw(INTERP_KERNEL::Exception);
373     std::vector<std::string> getGroupsNames() const;
374     std::vector<std::string> getFamiliesNames() const;
375     void assignFamilyNameWithGroupName() throw(INTERP_KERNEL::Exception);
376     void removeGroup(const char *name) throw(INTERP_KERNEL::Exception);
377     void removeFamily(const char *name) throw(INTERP_KERNEL::Exception);
378     void changeGroupName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
379     void changeFamilyName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
380     void changeFamilyId(int oldId, int newId) throw(INTERP_KERNEL::Exception);
381     void setFamilyInfo(const std::map<std::string,int>& info);
382     void setGroupInfo(const std::map<std::string, std::vector<std::string> >&info);
383     int getFamilyId(const char *name) const throw(INTERP_KERNEL::Exception);
384     int getMaxFamilyId() const throw(INTERP_KERNEL::Exception);
385     int getMinFamilyId() const throw(INTERP_KERNEL::Exception);
386     DataArrayInt *getAllFamiliesIdsReferenced() const throw(INTERP_KERNEL::Exception);
387     std::vector<int> getFamiliesIds(const std::vector<std::string>& famNames) const throw(INTERP_KERNEL::Exception);
388     std::string getFamilyNameGivenId(int id) const throw(INTERP_KERNEL::Exception);
389     bool ensureDifferentFamIdsPerLevel() throw(INTERP_KERNEL::Exception);
390     void normalizeFamIdsTrio() throw(INTERP_KERNEL::Exception);
391     void normalizeFamIdsMEDFile() throw(INTERP_KERNEL::Exception);
392     virtual int getMeshDimension() const throw(INTERP_KERNEL::Exception);
393     virtual std::string simpleRepr() const throw(INTERP_KERNEL::Exception);
394     virtual std::string advancedRepr() const throw(INTERP_KERNEL::Exception);
395     //
396     virtual MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const throw(INTERP_KERNEL::Exception);
397     virtual void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception);
398     virtual void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayInt *renumArr) throw(INTERP_KERNEL::Exception);
399     virtual DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
400     virtual DataArrayInt *getGroupsArr(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
401     virtual DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
402     virtual DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
403     virtual DataArrayInt *getNodeGroupArr(const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
404     virtual DataArrayInt *getNodeGroupsArr(const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
405     virtual DataArrayInt *getNodeFamilyArr(const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
406     virtual DataArrayInt *getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
407     %extend
408        {
409          MEDFileMesh(const char *fileName) throw(INTERP_KERNEL::Exception)
410          {
411            return MEDFileMesh::New(fileName);
412          }
413
414          MEDFileMesh(const char *fileName, const char *mName, int dt=-1, int it=-1)
415          {
416            return MEDFileMesh::New(fileName,mName,dt,it);
417          }
418          
419          std::string __str__() const throw(INTERP_KERNEL::Exception)
420          {
421            return self->simpleRepr();
422          }
423
424          PyObject *getTime() throw(INTERP_KERNEL::Exception)
425          {
426            int tmp1,tmp2;
427            double tmp0=self->getTime(tmp1,tmp2);
428            PyObject *res = PyList_New(3);
429            PyList_SetItem(res,0,SWIG_From_int(tmp1));
430            PyList_SetItem(res,1,SWIG_From_int(tmp2));
431            PyList_SetItem(res,2,SWIG_From_double(tmp0));
432            return res;
433          }
434
435          virtual PyObject *isEqual(const MEDFileMesh *other, double eps) const throw(INTERP_KERNEL::Exception)
436          {
437            std::string what;
438            bool ret0=self->isEqual(other,eps,what);
439            PyObject *res=PyList_New(2);
440            PyObject *ret0Py=ret0?Py_True:Py_False;
441            Py_XINCREF(ret0Py);
442            PyList_SetItem(res,0,ret0Py);
443            PyList_SetItem(res,1,PyString_FromString(what.c_str()));
444            return res;
445          }
446          
447          PyObject *areFamsEqual(const MEDFileMesh *other) const throw(INTERP_KERNEL::Exception)
448          {
449            std::string what;
450            bool ret0=self->areFamsEqual(other,what);
451            PyObject *res=PyList_New(2);
452            PyObject *ret0Py=ret0?Py_True:Py_False;
453            Py_XINCREF(ret0Py);
454            PyList_SetItem(res,0,ret0Py);
455            PyList_SetItem(res,1,PyString_FromString(what.c_str()));
456            return res;
457          }
458
459          PyObject *areGrpsEqual(const MEDFileMesh *other) const throw(INTERP_KERNEL::Exception)
460          {
461            std::string what;
462            bool ret0=self->areGrpsEqual(other,what);
463            PyObject *res=PyList_New(2);
464            PyObject *ret0Py=ret0?Py_True:Py_False;
465            Py_XINCREF(ret0Py);
466            PyList_SetItem(res,0,ret0Py);
467            PyList_SetItem(res,1,PyString_FromString(what.c_str()));
468            return res;
469          }
470
471          PyObject *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
472          {
473            const DataArrayInt *tmp=self->getFamilyFieldAtLevel(meshDimRelToMaxExt);
474            if(tmp)
475              tmp->incrRef();
476            return SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
477          }
478
479          PyObject *getNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
480          {
481            const DataArrayInt *tmp=self->getNumberFieldAtLevel(meshDimRelToMaxExt);
482            if(tmp)
483              tmp->incrRef();
484            return SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
485          }
486
487          PyObject *findOrCreateAndGiveFamilyWithId(int id, bool& created) throw(INTERP_KERNEL::Exception)
488          {
489            bool ret1;
490            std::string ret0=self->findOrCreateAndGiveFamilyWithId(id,ret1);
491            PyObject *ret=PyTuple_New(2);
492            PyTuple_SetItem(ret,0,PyString_FromString(ret0.c_str()));
493            PyTuple_SetItem(ret,1,SWIG_From_bool(ret1));
494            return ret;
495          }
496          
497          PyObject *unPolyze() throw(INTERP_KERNEL::Exception)
498          {
499            DataArrayInt *ret3=0;
500            std::vector<int> ret1,ret2;
501            bool ret0=self->unPolyze(ret1,ret2,ret3);
502            PyObject *ret=PyTuple_New(4);
503            PyTuple_SetItem(ret,0,SWIG_From_bool(ret0));
504            //
505            PyObject *retLev1_0=PyList_New((int)ret1.size()/3);
506            for(int j=0;j<(int)ret1.size()/3;j++)
507              {
508                PyObject *retLev2=PyList_New(3);
509                PyList_SetItem(retLev2,0,SWIG_From_int(ret1[3*j]));
510                PyList_SetItem(retLev2,1,SWIG_From_int(ret1[3*j+1]));
511                PyList_SetItem(retLev2,2,SWIG_From_int(ret1[3*j+2]));
512                PyList_SetItem(retLev1_0,j,retLev2);
513              }
514            PyTuple_SetItem(ret,1,retLev1_0);
515            //
516            PyObject *retLev1_1=PyList_New((int)ret2.size()/3);
517            for(int j=0;j<(int)ret2.size()/3;j++)
518              {
519                PyObject *retLev2=PyList_New(3);
520                PyList_SetItem(retLev2,0,SWIG_From_int(ret2[3*j]));
521                PyList_SetItem(retLev2,1,SWIG_From_int(ret2[3*j+1]));
522                PyList_SetItem(retLev2,2,SWIG_From_int(ret2[3*j+2]));
523                PyList_SetItem(retLev1_1,j,retLev2);
524              }
525            PyTuple_SetItem(ret,2,retLev1_1);
526            //
527            PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(ret3),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
528            return ret;
529          }
530        }
531   };
532
533   class MEDFileUMesh : public MEDFileMesh
534   {
535   public:
536     static MEDFileUMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception);
537     static MEDFileUMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
538     static MEDFileUMesh *New();
539     ~MEDFileUMesh();
540     int getSpaceDimension() const throw(INTERP_KERNEL::Exception);
541     //
542     std::vector<int> getGrpNonEmptyLevels(const char *grp) const throw(INTERP_KERNEL::Exception);
543     std::vector<int> getGrpNonEmptyLevelsExt(const char *grp) const throw(INTERP_KERNEL::Exception);
544     std::vector<int> getFamNonEmptyLevels(const char *fam) const throw(INTERP_KERNEL::Exception);
545     std::vector<int> getFamNonEmptyLevelsExt(const char *fam) const throw(INTERP_KERNEL::Exception);
546     std::vector<int> getGrpsNonEmptyLevels(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
547     std::vector<int> getGrpsNonEmptyLevelsExt(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
548     std::vector<int> getFamsNonEmptyLevels(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception);
549     std::vector<int> getFamsNonEmptyLevelsExt(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception);
550     std::vector<std::string> getGroupsOnSpecifiedLev(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
551     MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
552     DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
553     MEDCouplingUMesh *getGroups(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
554     DataArrayInt *getGroupsArr(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
555     MEDCouplingUMesh *getFamily(int meshDimRelToMaxExt, const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
556     DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
557     MEDCouplingUMesh *getFamilies(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
558     DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
559     DataArrayInt *getNodeGroupArr(const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
560     DataArrayInt *getNodeGroupsArr(const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
561     DataArrayInt *getNodeFamilyArr(const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
562     DataArrayInt *getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
563     MEDCouplingUMesh *getMeshAtLevel(int meshDimRelToMaxExt, bool renum=false) const throw(INTERP_KERNEL::Exception);
564     MEDCouplingUMesh *getLevel0Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
565     MEDCouplingUMesh *getLevelM1Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
566     MEDCouplingUMesh *getLevelM2Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
567     MEDCouplingUMesh *getLevelM3Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
568     //
569     void setFamilyNameAttachedOnId(int id, const std::string& newFamName) throw(INTERP_KERNEL::Exception);
570     void setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception);
571     void eraseGroupsAtLevel(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception);
572     void addNodeGroup(const std::string& name, const std::vector<int>& ids) throw(INTERP_KERNEL::Exception);
573     void removeMeshAtLevel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception);
574     void setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld=false) throw(INTERP_KERNEL::Exception);
575     void setMeshAtLevelGen(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld) throw(INTERP_KERNEL::Exception);
576     void setGroupsFromScratch(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms) throw(INTERP_KERNEL::Exception);
577     void setGroupsOnSetMesh(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms, bool renum) throw(INTERP_KERNEL::Exception);
578     void optimizeFamilies() throw(INTERP_KERNEL::Exception);
579     %extend
580        { 
581          MEDFileUMesh(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception)
582          {
583            return MEDFileUMesh::New(fileName,mName,dt,it);
584          }
585
586          MEDFileUMesh(const char *fileName) throw(INTERP_KERNEL::Exception)
587          {
588            return MEDFileUMesh::New(fileName);
589          }
590
591          MEDFileUMesh()
592          {
593            return MEDFileUMesh::New();
594          }
595          
596          PyObject *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
597          {
598            const DataArrayInt *tmp=self->getRevNumberFieldAtLevel(meshDimRelToMaxExt);
599            if(tmp)
600              tmp->incrRef();
601            return SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
602          }
603          
604          void setGroupsAtLevel(int meshDimRelToMaxExt, PyObject *li, bool renum=false) throw(INTERP_KERNEL::Exception)
605          {
606            std::vector<const DataArrayInt *> grps;
607            convertFromPyObjVectorOfObj<const ParaMEDMEM::DataArrayInt *>(li,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,"DataArrayInt",grps);
608            self->setGroupsAtLevel(meshDimRelToMaxExt,grps,renum);
609          }
610
611          DataArrayDouble *getCoords() const throw(INTERP_KERNEL::Exception)
612          {
613            DataArrayDouble *ret=self->getCoords();
614            if(ret)
615              ret->incrRef();
616            return ret;
617          }
618
619          PyObject *duplicateNodesOnM1Group(const char *grpNameM1) throw(INTERP_KERNEL::Exception)
620          {
621            DataArrayInt *ret0=0,*ret1=0,*ret2=0;
622            self->duplicateNodesOnM1Group(grpNameM1,ret0,ret1,ret2);
623            PyObject *ret=PyTuple_New(3);
624            PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
625            PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
626            PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(ret2),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
627            return ret;
628          }
629        }
630   };
631
632   class MEDFileCMesh : public MEDFileMesh
633   {
634   public:
635     static MEDFileCMesh *New();
636     static MEDFileCMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
637     static MEDFileCMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception);
638     void setMesh(MEDCouplingCMesh *m) throw(INTERP_KERNEL::Exception);
639     %extend
640        {
641          MEDFileCMesh()
642          {
643            return MEDFileCMesh::New();
644          }
645
646          MEDFileCMesh(const char *fileName) throw(INTERP_KERNEL::Exception)
647          {
648            return MEDFileCMesh::New(fileName);
649          }
650
651          MEDFileCMesh(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception)
652          {
653            return MEDFileCMesh::New(fileName,mName,dt,it);
654          }
655          
656          PyObject *getMesh() const throw(INTERP_KERNEL::Exception)
657          {
658            const MEDCouplingCMesh *tmp=self->getMesh();
659            if(tmp)
660              tmp->incrRef();
661            return SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__MEDCouplingCMesh, SWIG_POINTER_OWN | 0 );
662          }
663        }
664   };
665
666   class MEDFileMeshMultiTS : public RefCountObject, public MEDFileWritable
667   {
668   public:
669     static MEDFileMeshMultiTS *New();
670     static MEDFileMeshMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
671     static MEDFileMeshMultiTS *New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
672     const char *getName() const throw(INTERP_KERNEL::Exception);
673     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
674     void setOneTimeStep(MEDFileMesh *mesh1TimeStep) throw(INTERP_KERNEL::Exception);
675     %extend
676        { 
677          MEDFileMeshMultiTS()
678          {
679            return MEDFileMeshMultiTS::New();
680          }
681
682          MEDFileMeshMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
683          {
684            return MEDFileMeshMultiTS::New(fileName);
685          }
686
687          MEDFileMeshMultiTS(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception)
688          {
689            return MEDFileMeshMultiTS::New(fileName,mName);
690          }
691
692          MEDFileMesh *getOneTimeStep() const throw(INTERP_KERNEL::Exception)
693            {
694              MEDFileMesh *ret=self->getOneTimeStep();
695              if(ret)
696                ret->incrRef();
697              return ret;
698            }
699        }
700   };
701
702   class MEDFileMeshesIterator
703   {
704   public:
705     %extend
706     {
707       PyObject *next() throw(INTERP_KERNEL::Exception)
708       {
709         MEDFileMesh *ret=self->nextt();
710         if(ret)
711           {
712             ret->incrRef();
713             return convertMEDFileMesh(ret,SWIG_POINTER_OWN | 0 );
714           }
715         else
716           {
717             PyErr_SetString(PyExc_StopIteration,"No more data.");
718             return 0;
719           }
720       }
721     }
722   };
723
724   class MEDFileMeshes : public RefCountObject, public MEDFileWritable
725   {
726   public:
727     static MEDFileMeshes *New();
728     static MEDFileMeshes *New(const char *fileName) throw(INTERP_KERNEL::Exception);
729     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
730     int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception);
731     std::vector<std::string> getMeshesNames() const throw(INTERP_KERNEL::Exception);
732     //
733     void resize(int newSize) throw(INTERP_KERNEL::Exception);
734     void pushMesh(MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
735     void setMeshAtPos(int i, MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
736     void destroyMeshAtPos(int i) throw(INTERP_KERNEL::Exception);
737     %extend
738        {
739          MEDFileMeshes()
740          {
741            return MEDFileMeshes::New();
742          }
743
744          MEDFileMeshes(const char *fileName) throw(INTERP_KERNEL::Exception)
745          {
746            return MEDFileMeshes::New(fileName);
747          }
748
749          std::string __str__() const
750            {
751              return self->simpleRepr();
752            }
753
754          MEDFileMesh *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
755          {
756            if(PyInt_Check(obj))
757              {
758                MEDFileMesh *ret=self->getMeshAtPos((int)PyInt_AS_LONG(obj));
759                if(ret)
760                  ret->incrRef();
761                return ret;
762              }
763            else if(PyString_Check(obj))
764              {
765                MEDFileMesh *ret=self->getMeshWithName(PyString_AsString(obj));
766                if(ret)
767                  ret->incrRef();
768                return ret;
769              }
770            else
771              throw INTERP_KERNEL::Exception("MEDFileMeshes::__getitem__ : only integer or string with meshname supported !");
772          }
773
774          MEDFileMeshes *__setitem__(int obj, MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception)
775          {
776            self->setMeshAtPos(obj,mesh);
777            return self;
778          }
779
780          MEDFileMeshesIterator *__iter__() throw(INTERP_KERNEL::Exception)
781          {
782            return self->iterator();
783          }
784          
785          MEDFileMesh *getMeshAtPos(int i) const throw(INTERP_KERNEL::Exception)
786            {
787              MEDFileMesh *ret=self->getMeshAtPos(i);
788              if(ret)
789                ret->incrRef();
790              return ret;
791            }
792          MEDFileMesh *getMeshWithName(const char *mname) const throw(INTERP_KERNEL::Exception)
793            {
794              MEDFileMesh *ret=self->getMeshWithName(mname);
795              if(ret)
796                ret->incrRef();
797              return ret;
798            }
799        }
800   };
801
802   class MEDFileFieldLoc : public RefCountObject
803   {
804   public:
805     const std::string& getName() const;
806     int getDimension() const;
807     int getNumberOfGaussPoints() const;
808     int getNumberOfPointsInCells() const;
809     const std::vector<double>& getRefCoords() const;
810     const std::vector<double>& getGaussCoords() const;
811     const std::vector<double>& getGaussWeights() const;
812     bool isEqual(const MEDFileFieldLoc& other, double eps) const;
813   %extend
814     {
815       std::string __str__() const throw(INTERP_KERNEL::Exception)
816       {
817         return self->repr();
818       }
819     }
820   };
821
822   class MEDFileFieldGlobsReal
823   {
824   public:
825     void shallowCpyGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception);
826     std::vector<std::string> getPfls() const throw(INTERP_KERNEL::Exception);
827     std::vector<std::string> getLocs() const throw(INTERP_KERNEL::Exception);
828     bool existsPfl(const char *pflName) const throw(INTERP_KERNEL::Exception);
829     bool existsLoc(const char *locName) const throw(INTERP_KERNEL::Exception);
830     std::string createNewNameOfPfl() const throw(INTERP_KERNEL::Exception);
831     std::string createNewNameOfLoc() const throw(INTERP_KERNEL::Exception);
832     std::vector< std::vector<int> > whichAreEqualProfiles() const throw(INTERP_KERNEL::Exception);
833     std::vector< std::vector<int> > whichAreEqualLocs(double eps) const throw(INTERP_KERNEL::Exception);
834     virtual std::vector<std::string> getPflsReallyUsed() const throw(INTERP_KERNEL::Exception);
835     virtual std::vector<std::string> getLocsReallyUsed() const throw(INTERP_KERNEL::Exception);
836     virtual std::vector<std::string> getPflsReallyUsedMulti() const throw(INTERP_KERNEL::Exception);
837     virtual std::vector<std::string> getLocsReallyUsedMulti() const throw(INTERP_KERNEL::Exception);
838     void killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception);
839     void killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception);
840     void changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
841     void changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
842     int getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception);
843     int getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception);
844   %extend
845      {
846        PyObject *getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
847        {
848          const DataArrayInt *ret=self->getProfile(pflName);
849          if(ret)
850            ret->incrRef();
851          return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
852        }
853
854        PyObject *getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
855        {
856          const DataArrayInt *ret=self->getProfileFromId(pflId);
857          if(ret)
858            ret->incrRef();
859          return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
860        }
861
862        PyObject *getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
863        {
864          const MEDFileFieldLoc *loc=&self->getLocalizationFromId(locId);
865          loc->incrRef();
866          return SWIG_NewPointerObj(SWIG_as_voidptr(loc),SWIGTYPE_p_ParaMEDMEM__MEDFileFieldLoc, SWIG_POINTER_OWN | 0 );
867        }
868        
869        PyObject *getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
870        {
871          const MEDFileFieldLoc *loc=&self->getLocalization(locName);
872          loc->incrRef();
873          return SWIG_NewPointerObj(SWIG_as_voidptr(loc),SWIGTYPE_p_ParaMEDMEM__MEDFileFieldLoc, SWIG_POINTER_OWN | 0 );
874        }
875        
876        PyObject *zipPflsNames() throw(INTERP_KERNEL::Exception)
877        {
878          std::vector< std::pair<std::vector<std::string>, std::string > > ret=self->zipPflsNames();
879          return convertVecPairVecStToPy(ret);
880        }
881
882        PyObject *zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
883        {
884          std::vector< std::pair<std::vector<std::string>, std::string > > ret=self->zipLocsNames(eps);
885          return convertVecPairVecStToPy(ret);
886        }
887
888        void changePflsNames(PyObject *li) throw(INTERP_KERNEL::Exception)
889        {
890          std::vector< std::pair<std::vector<std::string>, std::string > > v=convertVecPairVecStFromPy(li);
891          self->changePflsNames(v);
892        }
893
894        void changePflsRefsNamesGen(PyObject *li) throw(INTERP_KERNEL::Exception)
895        {
896          std::vector< std::pair<std::vector<std::string>, std::string > > v=convertVecPairVecStFromPy(li);
897          self->changePflsRefsNamesGen(v);
898        }
899
900        void changePflsNamesInStruct(PyObject *li) throw(INTERP_KERNEL::Exception)
901        {
902          std::vector< std::pair<std::vector<std::string>, std::string > > v=convertVecPairVecStFromPy(li);
903          self->changePflsNamesInStruct(v);
904        }
905
906        void changeLocsNames(PyObject *li) throw(INTERP_KERNEL::Exception)
907        {
908          std::vector< std::pair<std::vector<std::string>, std::string > > v=convertVecPairVecStFromPy(li);
909          self->changeLocsNames(v);
910        }
911
912        void changeLocsRefsNamesGen(PyObject *li) throw(INTERP_KERNEL::Exception)
913        {
914          std::vector< std::pair<std::vector<std::string>, std::string > > v=convertVecPairVecStFromPy(li);
915          self->changeLocsRefsNamesGen(v);
916        }
917        
918        void changeLocsNamesInStruct(PyObject *li) throw(INTERP_KERNEL::Exception)
919        {
920          std::vector< std::pair<std::vector<std::string>, std::string > > v=convertVecPairVecStFromPy(li);
921          self->changeLocsNamesInStruct(v);
922        }
923      }
924   };
925
926   class MEDFileField1TS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable
927   {
928   public:
929     static MEDFileField1TS *New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
930     static MEDFileField1TS *New();
931     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
932     MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
933     MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception);
934     MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
935     MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
936     MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
937     //
938     void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
939     void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
940     void setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception);
941     void setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception);
942     void copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
943     //
944     int getDimension() const throw(INTERP_KERNEL::Exception);
945     int getIteration() const throw(INTERP_KERNEL::Exception);
946     int getOrder() const throw(INTERP_KERNEL::Exception);
947     std::string getName() throw(INTERP_KERNEL::Exception);
948     void setName(const char *name) throw(INTERP_KERNEL::Exception);
949     std::string getMeshName() throw(INTERP_KERNEL::Exception);
950     void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
951     int getNumberOfComponents() const throw(INTERP_KERNEL::Exception);
952     bool isDealingTS(int iteration, int order) const throw(INTERP_KERNEL::Exception);
953     const std::vector<std::string>& getInfo() const throw(INTERP_KERNEL::Exception);
954     void setTime(int iteration, int order, double val) throw(INTERP_KERNEL::Exception);
955     %extend
956        {
957          MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
958          {
959            return MEDFileField1TS::New(fileName,fieldName,iteration,order);
960          }
961
962          MEDFileField1TS()
963          {
964            return MEDFileField1TS::New();
965          }
966          
967          std::string __str__() const throw(INTERP_KERNEL::Exception)
968            {
969              return self->simpleRepr();
970            }
971
972          PyObject *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
973            {
974              DataArrayInt *ret1=0;
975              DataArrayDouble *ret0=self->getFieldWithProfile(type,meshDimRelToMax,mesh,ret1);
976              PyObject *ret=PyTuple_New(2);
977              PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
978              PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
979              return ret;
980            }
981
982          void setProfileNameOnLeaf(INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception)
983            {
984              self->setProfileNameOnLeaf(0,typ,locId,newPflName,forceRenameOnGlob);
985            }
986          
987          void setLocNameOnLeaf(INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception)
988            {
989              self->setLocNameOnLeaf(0,typ,locId,newLocName,forceRenameOnGlob);
990            }
991
992          PyObject *getTime() throw(INTERP_KERNEL::Exception)
993          {
994            int tmp1,tmp2;
995            double tmp0=self->getTime(tmp1,tmp2);
996            PyObject *res = PyList_New(3);
997            PyList_SetItem(res,0,SWIG_From_int(tmp1));
998            PyList_SetItem(res,1,SWIG_From_int(tmp2));
999            PyList_SetItem(res,2,SWIG_From_double(tmp0));
1000            return res;
1001          }
1002          
1003          PyObject *getDtIt() const throw(INTERP_KERNEL::Exception)
1004          {
1005            std::pair<int,int> res=self->getDtIt();
1006            PyObject *elt=PyTuple_New(2);
1007            PyTuple_SetItem(elt,0,SWIG_From_int(res.first));
1008            PyTuple_SetItem(elt,1,SWIG_From_int(res.second));
1009            return elt;
1010          }
1011          
1012          PyObject *getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
1013          {
1014            std::vector<TypeOfField> ret=self->getTypesOfFieldAvailable();
1015            PyObject *ret2=PyList_New(ret.size());
1016            for(int i=0;i<(int)ret.size();i++)
1017              PyList_SetItem(ret2,i,SWIG_From_int(ret[i]));
1018            return ret2;
1019          }
1020          
1021          PyObject *getNonEmptyLevels(const char *mname=0) const throw(INTERP_KERNEL::Exception)
1022          {
1023            std::vector<int> ret1;
1024            int ret0=self->getNonEmptyLevels(mname,ret1);
1025            PyObject *elt=PyTuple_New(2);
1026            PyTuple_SetItem(elt,0,SWIG_From_int(ret0));
1027            PyTuple_SetItem(elt,1,convertIntArrToPyList2(ret1));
1028            return elt;
1029          }
1030          
1031          PyObject *getFieldSplitedByType(const char *mname=0) const throw(INTERP_KERNEL::Exception)
1032          {
1033            std::vector<INTERP_KERNEL::NormalizedCellType> types;
1034            std::vector< std::vector<TypeOfField> > typesF;
1035            std::vector< std::vector<std::string> > pfls;
1036            std::vector< std::vector<std::string> > locs;
1037            std::vector< std::vector< std::pair<int,int> > > ret=self->getFieldSplitedByType(mname,types,typesF,pfls,locs);
1038            int sz=ret.size();
1039            PyObject *ret2=PyList_New(sz);
1040            for(int i=0;i<sz;i++)
1041              {
1042                const std::vector< std::pair<int,int> >& dadsI=ret[i];
1043                const std::vector<TypeOfField>& typesFI=typesF[i];
1044                const std::vector<std::string>& pflsI=pfls[i];
1045                const std::vector<std::string>& locsI=locs[i];
1046                PyObject *elt=PyTuple_New(2);
1047                PyTuple_SetItem(elt,0,SWIG_From_int(types[i]));
1048                int sz2=ret[i].size();
1049                PyObject *elt2=PyList_New(sz2);
1050                for(int j=0;j<sz2;j++)
1051                  {
1052                    PyObject *elt3=PyTuple_New(4);
1053                    PyTuple_SetItem(elt3,0,SWIG_From_int(typesFI[j]));
1054                    PyObject *elt4=PyTuple_New(2); PyTuple_SetItem(elt4,0,SWIG_From_int(dadsI[j].first)); PyTuple_SetItem(elt4,1,SWIG_From_int(dadsI[j].second));
1055                    PyTuple_SetItem(elt3,1,elt4);
1056                    PyTuple_SetItem(elt3,2,PyString_FromString(pflsI[j].c_str()));
1057                    PyTuple_SetItem(elt3,3,PyString_FromString(locsI[j].c_str()));
1058                    PyList_SetItem(elt2,j,elt3);
1059                  }
1060                PyTuple_SetItem(elt,1,elt2);
1061                PyList_SetItem(ret2,i,elt);
1062              }
1063            return ret2;
1064          }
1065
1066          PyObject *getFieldSplitedByType2(const char *mname=0) const throw(INTERP_KERNEL::Exception)
1067          {
1068            std::vector<INTERP_KERNEL::NormalizedCellType> types;
1069            std::vector< std::vector<TypeOfField> > typesF;
1070            std::vector< std::vector<std::string> > pfls;
1071            std::vector< std::vector<std::string> > locs;
1072            std::vector< std::vector<DataArrayDouble *> > ret=self->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
1073            int sz=ret.size();
1074            PyObject *ret2=PyList_New(sz);
1075            for(int i=0;i<sz;i++)
1076              {
1077                const std::vector<DataArrayDouble *>& dadsI=ret[i];
1078                const std::vector<TypeOfField>& typesFI=typesF[i];
1079                const std::vector<std::string>& pflsI=pfls[i];
1080                const std::vector<std::string>& locsI=locs[i];
1081                PyObject *elt=PyTuple_New(2);
1082                PyTuple_SetItem(elt,0,SWIG_From_int(types[i]));
1083                int sz2=ret[i].size();
1084                PyObject *elt2=PyList_New(sz2);
1085                for(int j=0;j<sz2;j++)
1086                  {
1087                    PyObject *elt3=PyTuple_New(4);
1088                    PyTuple_SetItem(elt3,0,SWIG_From_int(typesFI[j]));
1089                    PyTuple_SetItem(elt3,1,SWIG_NewPointerObj(SWIG_as_voidptr(dadsI[j]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
1090                    PyTuple_SetItem(elt3,2,PyString_FromString(pflsI[j].c_str()));
1091                    PyTuple_SetItem(elt3,3,PyString_FromString(locsI[j].c_str()));
1092                    PyList_SetItem(elt2,j,elt3);
1093                  }
1094                PyTuple_SetItem(elt,1,elt2);
1095                PyList_SetItem(ret2,i,elt);
1096              }
1097            return ret2;
1098          }
1099
1100          DataArrayDouble *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
1101          {
1102            DataArrayDouble *ret=self->getUndergroundDataArray();
1103            if(ret)
1104              ret->incrRef();
1105            return ret;
1106          }
1107
1108          PyObject *getUndergroundDataArrayExt() const throw(INTERP_KERNEL::Exception)
1109          {
1110            std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > elt1Cpp;
1111            DataArrayDouble *elt0=self->getUndergroundDataArrayExt(elt1Cpp);
1112            if(elt0)
1113              elt0->incrRef();
1114            PyObject *ret=PyTuple_New(2);
1115            PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(elt0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
1116            std::size_t sz=elt1Cpp.size();
1117            PyObject *elt=PyList_New(sz);
1118            for(std::size_t i=0;i<sz;i++)
1119              {
1120                PyObject *elt1=PyTuple_New(2);
1121                PyObject *elt2=PyTuple_New(2);
1122                PyTuple_SetItem(elt2,0,SWIG_From_int((int)elt1Cpp[i].first.first));
1123                PyTuple_SetItem(elt2,1,SWIG_From_int(elt1Cpp[i].first.second));
1124                PyObject *elt3=PyTuple_New(2);
1125                PyTuple_SetItem(elt3,0,SWIG_From_int(elt1Cpp[i].second.first));
1126                PyTuple_SetItem(elt3,1,SWIG_From_int(elt1Cpp[i].second.second));
1127                PyTuple_SetItem(elt1,0,elt2);
1128                PyTuple_SetItem(elt1,1,elt3);
1129                PyList_SetItem(elt,i,elt1);
1130              }
1131            PyTuple_SetItem(ret,1,elt);
1132            return ret;
1133          }
1134          
1135          bool changeMeshNames(PyObject *li) throw(INTERP_KERNEL::Exception)
1136          {
1137            std::vector< std::pair<std::string,std::string> > modifTab=convertVecPairStStFromPy(li);
1138            return self->changeMeshNames(modifTab);
1139          }
1140        }
1141   };
1142
1143   class MEDFileFieldMultiTSIterator
1144   {
1145   public:
1146     %extend
1147     {
1148       PyObject *next() throw(INTERP_KERNEL::Exception)
1149       {
1150         MEDFileField1TS *ret=self->nextt();
1151         if(ret)
1152           return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDFileField1TS,SWIG_POINTER_OWN | 0);
1153         else
1154           {
1155             PyErr_SetString(PyExc_StopIteration,"No more data.");
1156             return 0;
1157           }
1158       }
1159     }
1160   };
1161
1162   class MEDFileFieldMultiTS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable
1163   {
1164   public:
1165     static MEDFileFieldMultiTS *New() throw(INTERP_KERNEL::Exception);
1166     static MEDFileFieldMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
1167     static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
1168     //
1169     MEDFileField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception);
1170     MEDFileField1TS *getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
1171     MEDFileField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
1172     //
1173     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
1174     MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
1175     MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception);
1176     MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
1177     MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
1178     MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
1179     //
1180     void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
1181     void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
1182     //
1183     int getNumberOfTS() const throw(INTERP_KERNEL::Exception);
1184     void eraseEmptyTS() throw(INTERP_KERNEL::Exception);
1185     int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
1186     int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
1187     std::string getName() const throw(INTERP_KERNEL::Exception);
1188     void setName(const char *name) throw(INTERP_KERNEL::Exception);
1189     std::string getMeshName() const throw(INTERP_KERNEL::Exception);
1190     void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
1191     const std::vector<std::string>& getInfo() const throw(INTERP_KERNEL::Exception);
1192     %extend
1193        {
1194          MEDFileFieldMultiTS()
1195          {
1196            return MEDFileFieldMultiTS::New();
1197          }
1198
1199          MEDFileFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
1200          {
1201            return MEDFileFieldMultiTS::New(fileName);
1202          }
1203
1204          MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
1205          {
1206            return MEDFileFieldMultiTS::New(fileName,fieldName);
1207          }
1208          
1209          std::string __str__() const throw(INTERP_KERNEL::Exception)
1210            {
1211              return self->simpleRepr();
1212            }
1213
1214          MEDFileField1TS *__getitem__(PyObject *elt0) const throw(INTERP_KERNEL::Exception)
1215          {
1216            if(elt0 && PyInt_Check(elt0))
1217              {//fmts[3]
1218                int pos=PyInt_AS_LONG(elt0);
1219                return self->getTimeStepAtPos(pos);
1220              }
1221            else if(elt0 && PyTuple_Check(elt0))
1222              {
1223                if(PyTuple_Size(elt0)==2)
1224                  {
1225                    PyObject *o0=PyTuple_GetItem(elt0,0);
1226                    PyObject *o1=PyTuple_GetItem(elt0,1);
1227                    if(PyInt_Check(o0) && PyInt_Check(o1))
1228                      {//fmts(1,-1)
1229                        int iter=PyInt_AS_LONG(o0);
1230                        int order=PyInt_AS_LONG(o1);
1231                        return self->getTimeStep(iter,order);
1232                      }
1233                    else
1234                      throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size 2 but two integers are expected in this tuple to request a time steps !");
1235                  }
1236                else
1237                  throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size != 2 ! two integers are expected in this tuple to request a time steps !");
1238              }
1239            else if(elt0 && PyFloat_Check(elt0))
1240              {
1241                double val=PyFloat_AS_DOUBLE(elt0);
1242                return self->getTimeStepGivenTime(val);
1243              }
1244            else
1245              throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input params ! expected fmts[int], fmts[int,int] or fmts[double] to request time step !");
1246          }
1247
1248          MEDFileFieldMultiTSIterator *__iter__() throw(INTERP_KERNEL::Exception)
1249          {
1250            return self->iterator();
1251          }
1252
1253          PyObject *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
1254            {
1255              DataArrayInt *ret1=0;
1256              DataArrayDouble *ret0=self->getFieldWithProfile(type,iteration,order,meshDimRelToMax,mesh,ret1);
1257              PyObject *ret=PyTuple_New(2);
1258              PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
1259              PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
1260              return ret;
1261            }
1262
1263          PyObject *getIterations() const
1264          {
1265            std::vector< std::pair<int,int> > res=self->getIterations();
1266            PyObject *ret=PyList_New(res.size());
1267            int rk=0;
1268            for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
1269              {
1270                PyObject *elt=PyTuple_New(2);
1271                PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
1272                PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
1273                PyList_SetItem(ret,rk,elt);
1274              }
1275            return ret;
1276          }
1277
1278          PyObject *getTimeSteps() const throw(INTERP_KERNEL::Exception)
1279            {
1280              std::vector<double> ret1;
1281              std::vector< std::pair<int,int> > ret=self->getTimeSteps(ret1);
1282              std::size_t sz=ret.size();
1283              PyObject *ret2=PyList_New(sz);
1284              for(std::size_t i=0;i<sz;i++)
1285                {
1286                  PyObject *elt=PyTuple_New(3);
1287                  PyTuple_SetItem(elt,0,SWIG_From_int(ret[i].first));
1288                  PyTuple_SetItem(elt,1,SWIG_From_int(ret[i].second));
1289                  PyTuple_SetItem(elt,2,SWIG_From_double(ret1[i]));
1290                  PyList_SetItem(ret2,i,elt);
1291                }
1292              return ret2;
1293            }
1294
1295          PyObject *getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
1296          {
1297            std::vector< std::vector<TypeOfField> > ret=self->getTypesOfFieldAvailable();
1298            PyObject *ret2=PyList_New(ret.size());
1299            for(int i=0;i<(int)ret.size();i++)
1300              {
1301                const std::vector<TypeOfField>& rett=ret[i];
1302                PyObject *ret3=PyList_New(rett.size());
1303                for(int j=0;j<(int)rett.size();j++)
1304                  PyList_SetItem(ret3,j,SWIG_From_int(rett[j]));
1305                PyList_SetItem(ret2,i,ret3);
1306              }
1307            return ret2;
1308          }
1309
1310          PyObject *getNonEmptyLevels(int iteration, int order, const char *mname=0) const throw(INTERP_KERNEL::Exception)
1311          {
1312            std::vector<int> ret1;
1313            int ret0=self->getNonEmptyLevels(iteration,order,mname,ret1);
1314            PyObject *elt=PyTuple_New(2);
1315            PyTuple_SetItem(elt,0,SWIG_From_int(ret0));
1316            PyTuple_SetItem(elt,1,convertIntArrToPyList2(ret1));
1317            return elt;
1318          }
1319
1320          PyObject *getFieldSplitedByType(int iteration, int order, const char *mname=0) const throw(INTERP_KERNEL::Exception)
1321          {
1322            std::vector<INTERP_KERNEL::NormalizedCellType> types;
1323            std::vector< std::vector<TypeOfField> > typesF;
1324            std::vector< std::vector<std::string> > pfls;
1325            std::vector< std::vector<std::string> > locs;
1326            std::vector< std::vector< std::pair<int,int> > > ret=self->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
1327            int sz=ret.size();
1328            PyObject *ret2=PyList_New(sz);
1329            for(int i=0;i<sz;i++)
1330              {
1331                const std::vector< std::pair<int,int> >& dadsI=ret[i];
1332                const std::vector<TypeOfField>& typesFI=typesF[i];
1333                const std::vector<std::string>& pflsI=pfls[i];
1334                const std::vector<std::string>& locsI=locs[i];
1335                PyObject *elt=PyTuple_New(2);
1336                PyTuple_SetItem(elt,0,SWIG_From_int(types[i]));
1337                int sz2=ret[i].size();
1338                PyObject *elt2=PyList_New(sz2);
1339                for(int j=0;j<sz2;j++)
1340                  {
1341                    PyObject *elt3=PyTuple_New(4);
1342                    PyTuple_SetItem(elt3,0,SWIG_From_int(typesFI[j]));
1343                    PyObject *elt4=PyTuple_New(2); PyTuple_SetItem(elt4,0,SWIG_From_int(dadsI[j].first)); PyTuple_SetItem(elt4,1,SWIG_From_int(dadsI[j].second));
1344                    PyTuple_SetItem(elt3,1,elt4);
1345                    PyTuple_SetItem(elt3,2,PyString_FromString(pflsI[j].c_str()));
1346                    PyTuple_SetItem(elt3,3,PyString_FromString(locsI[j].c_str()));
1347                    PyList_SetItem(elt2,j,elt3);
1348                  }
1349                PyTuple_SetItem(elt,1,elt2);
1350                PyList_SetItem(ret2,i,elt);
1351              }
1352            return ret2;
1353          }
1354
1355          PyObject *getFieldSplitedByType2(int iteration, int order, const char *mname=0) const throw(INTERP_KERNEL::Exception)
1356          {
1357            std::vector<INTERP_KERNEL::NormalizedCellType> types;
1358            std::vector< std::vector<TypeOfField> > typesF;
1359            std::vector< std::vector<std::string> > pfls;
1360            std::vector< std::vector<std::string> > locs;
1361            std::vector< std::vector<DataArrayDouble *> > ret=self->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
1362            int sz=ret.size();
1363            PyObject *ret2=PyList_New(sz);
1364            for(int i=0;i<sz;i++)
1365              {
1366                const std::vector<DataArrayDouble *>& dadsI=ret[i];
1367                const std::vector<TypeOfField>& typesFI=typesF[i];
1368                const std::vector<std::string>& pflsI=pfls[i];
1369                const std::vector<std::string>& locsI=locs[i];
1370                PyObject *elt=PyTuple_New(2);
1371                PyTuple_SetItem(elt,0,SWIG_From_int(types[i]));
1372                int sz2=ret[i].size();
1373                PyObject *elt2=PyList_New(sz2);
1374                for(int j=0;j<sz2;j++)
1375                  {
1376                    PyObject *elt3=PyTuple_New(4);
1377                    PyTuple_SetItem(elt3,0,SWIG_From_int(typesFI[j]));
1378                    PyTuple_SetItem(elt3,1,SWIG_NewPointerObj(SWIG_as_voidptr(dadsI[j]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
1379                    PyTuple_SetItem(elt3,2,PyString_FromString(pflsI[j].c_str()));
1380                    PyTuple_SetItem(elt3,3,PyString_FromString(locsI[j].c_str()));
1381                    PyList_SetItem(elt2,j,elt3);
1382                  }
1383                PyTuple_SetItem(elt,1,elt2);
1384                PyList_SetItem(ret2,i,elt);
1385              }
1386            return ret2;
1387          }
1388          DataArrayDouble *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
1389          {
1390            DataArrayDouble *ret=self->getUndergroundDataArray(iteration,order);
1391            if(ret)
1392              ret->incrRef();
1393            return ret;
1394          }
1395          PyObject *getUndergroundDataArrayExt(int iteration, int order) const throw(INTERP_KERNEL::Exception)
1396          {
1397            std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > elt1Cpp;
1398            DataArrayDouble *elt0=self->getUndergroundDataArrayExt(iteration,order,elt1Cpp);
1399            if(elt0)
1400              elt0->incrRef();
1401            PyObject *ret=PyTuple_New(2);
1402            PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(elt0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
1403            std::size_t sz=elt1Cpp.size();
1404            PyObject *elt=PyList_New(sz);
1405            for(std::size_t i=0;i<sz;i++)
1406              {
1407                PyObject *elt1=PyTuple_New(2);
1408                PyObject *elt2=PyTuple_New(2);
1409                PyTuple_SetItem(elt2,0,SWIG_From_int(elt1Cpp[i].first.first));
1410                PyTuple_SetItem(elt2,1,SWIG_From_int(elt1Cpp[i].first.second));
1411                PyObject *elt3=PyTuple_New(2);
1412                PyTuple_SetItem(elt3,0,SWIG_From_int(elt1Cpp[i].second.first));
1413                PyTuple_SetItem(elt3,1,SWIG_From_int(elt1Cpp[i].second.second));
1414                PyTuple_SetItem(elt1,0,elt2);
1415                PyTuple_SetItem(elt1,1,elt3);
1416                PyList_SetItem(elt,i,elt1);
1417              }
1418            PyTuple_SetItem(ret,1,elt);
1419            return ret;
1420          }
1421
1422          int getTimeId(PyObject *elt0) const throw(INTERP_KERNEL::Exception)
1423          {
1424            if(elt0 && PyInt_Check(elt0))
1425              {//fmts[3]
1426                int pos=PyInt_AS_LONG(elt0);
1427                return pos;
1428              }
1429            else if(elt0 && PyTuple_Check(elt0))
1430              {
1431                if(PyTuple_Size(elt0)==2)
1432                  {
1433                    PyObject *o0=PyTuple_GetItem(elt0,0);
1434                    PyObject *o1=PyTuple_GetItem(elt0,1);
1435                    if(PyInt_Check(o0) && PyInt_Check(o1))
1436                      {//fmts(1,-1)
1437                        int iter=PyInt_AS_LONG(o0);
1438                        int order=PyInt_AS_LONG(o1);
1439                        return self->getPosOfTimeStep(iter,order);
1440                      }
1441                    else
1442                      throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size 2 but two integers are expected in this tuple to request a time steps !");
1443                  }
1444                else
1445                  throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size != 2 ! two integers are expected in this tuple to request a time steps !");
1446              }
1447            else if(elt0 && PyFloat_Check(elt0))
1448              {
1449                double val=PyFloat_AS_DOUBLE(elt0);
1450                return self->getPosGivenTime(val);
1451              }
1452            else
1453              throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input params ! expected fmts[int], fmts[int,int] or fmts[double] to request time step !");
1454          }
1455
1456          std::vector<int> getTimeIds(PyObject *elts) const throw(INTERP_KERNEL::Exception)
1457          {
1458            if(PyList_Check(elts))
1459              {
1460                int sz=PyList_Size(elts);
1461                std::vector<int> ret(sz);
1462                for(int i=0;i<sz;i++)
1463                  {
1464                    PyObject *elt=PyList_GetItem(elts,i);
1465                    ret[i]=ParaMEDMEM_MEDFileFieldMultiTS_getTimeId(self,elt);
1466                  }
1467                return ret;
1468              }
1469            else
1470              {
1471                std::vector<int> ret(1);
1472                ret[0]=ParaMEDMEM_MEDFileFieldMultiTS_getTimeId(self,elts);
1473                return ret;
1474              }
1475          }
1476
1477          void __delitem__(PyObject *elts) throw(INTERP_KERNEL::Exception)
1478          {
1479            std::vector<int> idsToRemove=ParaMEDMEM_MEDFileFieldMultiTS_getTimeIds(self,elts);
1480            if(!idsToRemove.empty())
1481              self->eraseTimeStepIds(&idsToRemove[0],&idsToRemove[0]+idsToRemove.size());
1482          }
1483
1484          void eraseTimeStepIds(PyObject *li) throw(INTERP_KERNEL::Exception)
1485          {
1486            int sw;
1487            int pos1;
1488            std::vector<int> pos2;
1489            DataArrayInt *pos3=0;
1490            DataArrayIntTuple *pos4=0;
1491            convertObjToPossibleCpp1(li,sw,pos1,pos2,pos3,pos4);
1492            switch(sw)
1493              {
1494              case 1:
1495                {
1496                  self->eraseTimeStepIds(&pos1,&pos1+1);
1497                  return;
1498                }
1499              case 2:
1500                {
1501                  if(pos2.empty())
1502                    return;
1503                  self->eraseTimeStepIds(&pos2[0],&pos2[0]+pos2.size());
1504                  return ;
1505                }
1506              case 3:
1507                {
1508                  self->eraseTimeStepIds(pos3->begin(),pos3->end());
1509                  return ;
1510                }
1511              default:
1512                throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::eraseTimeStepIds : unexpected input array type recognized !");
1513              }
1514          }
1515
1516          bool changeMeshNames(PyObject *li) throw(INTERP_KERNEL::Exception)
1517          {
1518            std::vector< std::pair<std::string,std::string> > modifTab=convertVecPairStStFromPy(li);
1519            return self->changeMeshNames(modifTab);
1520          }
1521        }
1522   };
1523
1524   class MEDFileFieldsIterator
1525   {
1526   public:
1527     %extend
1528     {
1529       PyObject *next() throw(INTERP_KERNEL::Exception)
1530       {
1531         MEDFileFieldMultiTS *ret=self->nextt();
1532         if(ret)
1533           return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDFileFieldMultiTS,SWIG_POINTER_OWN | 0);
1534         else
1535           {
1536             PyErr_SetString(PyExc_StopIteration,"No more data.");
1537             return 0;
1538           }
1539       }
1540     }
1541   };
1542
1543   class MEDFileFields : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable
1544   {
1545   public:
1546     static MEDFileFields *New() throw(INTERP_KERNEL::Exception);
1547     static MEDFileFields *New(const char *fileName) throw(INTERP_KERNEL::Exception);
1548     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
1549     int getNumberOfFields() const;
1550     std::vector<std::string> getFieldsNames() const throw(INTERP_KERNEL::Exception);
1551     std::vector<std::string> getMeshesNames() const throw(INTERP_KERNEL::Exception);
1552     //
1553     void resize(int newSize) throw(INTERP_KERNEL::Exception);
1554     void pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
1555     void setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
1556     MEDFileFieldMultiTS *getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception);
1557     MEDFileFieldMultiTS *getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
1558     void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception);
1559     %extend
1560        {
1561          MEDFileFields()
1562          {
1563            return MEDFileFields::New();
1564          }
1565
1566          MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception)
1567          {
1568            return MEDFileFields::New(fileName);
1569          }
1570          
1571          std::string __str__() const throw(INTERP_KERNEL::Exception)
1572          {
1573            return self->simpleRepr();
1574          }
1575          
1576          MEDFileFieldMultiTS *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
1577          {
1578            if(PyInt_Check(obj))
1579              {
1580                return self->getFieldAtPos((int)PyInt_AS_LONG(obj));
1581              }
1582            else if(PyString_Check(obj))
1583              {
1584                return self->getFieldWithName(PyString_AsString(obj));
1585              }
1586            else
1587              throw INTERP_KERNEL::Exception("MEDFileFields::__getitem__ : only integer or string with fieldname supported !");
1588          }
1589
1590          MEDFileFields *__setitem__(int obj, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
1591          {
1592            self->setFieldAtPos(obj,field);
1593            return self;
1594          }
1595
1596          MEDFileFieldsIterator *__iter__() throw(INTERP_KERNEL::Exception)
1597          {
1598            return self->iterator();
1599          }
1600          
1601          bool changeMeshNames(PyObject *li) throw(INTERP_KERNEL::Exception)
1602          {
1603            std::vector< std::pair<std::string,std::string> > modifTab=convertVecPairStStFromPy(li);
1604            return self->changeMeshNames(modifTab);
1605          }
1606        }
1607   };
1608
1609   class MEDFileData : public RefCountObject, public MEDFileWritable
1610   {
1611   public:
1612     static MEDFileData *New(const char *fileName) throw(INTERP_KERNEL::Exception);
1613     static MEDFileData *New();
1614     void setFields(MEDFileFields *fields) throw(INTERP_KERNEL::Exception);
1615     void setMeshes(MEDFileMeshes *meshes) throw(INTERP_KERNEL::Exception);
1616     int getNumberOfFields() const throw(INTERP_KERNEL::Exception);
1617     int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception);
1618     //
1619     bool changeMeshName(const char *oldMeshName, const char *newMeshName) throw(INTERP_KERNEL::Exception);
1620     bool unPolyzeMeshes() throw(INTERP_KERNEL::Exception);
1621     //
1622     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
1623     %extend
1624        {
1625          MEDFileData(const char *fileName) throw(INTERP_KERNEL::Exception)
1626          {
1627            return MEDFileData::New(fileName);
1628          }
1629
1630          MEDFileData()
1631          {
1632            return MEDFileData::New();
1633          }
1634
1635          std::string __str__() const throw(INTERP_KERNEL::Exception)
1636          {
1637            return self->simpleRepr();
1638          }
1639
1640          MEDFileMeshes *getMeshes() const throw(INTERP_KERNEL::Exception)
1641          {
1642            MEDFileMeshes *ret=self->getMeshes();
1643            if(ret)
1644              ret->incrRef();
1645            return ret;
1646          }
1647
1648          MEDFileFields *getFields() const throw(INTERP_KERNEL::Exception)
1649          {
1650            MEDFileFields *ret=self->getFields();
1651            if(ret)
1652              ret->incrRef();
1653            return ret;
1654          }
1655
1656          bool changeMeshNames(PyObject *li) throw(INTERP_KERNEL::Exception)
1657          {
1658            std::vector< std::pair<std::string,std::string> > modifTab=convertVecPairStStFromPy(li);
1659            return self->changeMeshNames(modifTab);
1660          }
1661        }
1662   };
1663
1664   class SauvReader : public RefCountObject
1665   {
1666   public:
1667     static SauvReader* New(const char *fileName) throw(INTERP_KERNEL::Exception);
1668     MEDFileData * loadInMEDFileDS() throw(INTERP_KERNEL::Exception);
1669   };
1670
1671   class SauvWriter : public RefCountObject
1672   {
1673   public:
1674     static SauvWriter * New();
1675     void setMEDFileDS(const MEDFileData* medData, unsigned meshIndex = 0) throw(INTERP_KERNEL::Exception);
1676     void write(const char* fileName) throw(INTERP_KERNEL::Exception);
1677   };
1678
1679 }