Salome HOME
[On behalf of Anthony] Switching to MEDFile 3.0.7
authorbruneton <bruneton>
Mon, 18 Nov 2013 14:02:55 +0000 (14:02 +0000)
committerbruneton <bruneton>
Mon, 18 Nov 2013 14:02:55 +0000 (14:02 +0000)
12 files changed:
src/MEDLoader/MEDFileField.cxx
src/MEDLoader/MEDFileField.hxx
src/MEDLoader/MEDFileMesh.cxx
src/MEDLoader/MEDFileMesh.hxx
src/MEDLoader/MEDFileMeshElt.cxx
src/MEDLoader/MEDFileMeshLL.cxx
src/MEDLoader/MEDFileMeshLL.hxx
src/MEDLoader/MEDLoader.cxx
src/MEDLoader/MEDLoader.hxx
src/MEDLoader/Swig/MEDLoaderCommon.i
src/MEDLoader/Swig/MEDLoaderTest.py
src/MEDLoader/Swig/MEDLoaderTest3.py

index 735e1af6e2091b31e7e4b29a2a4aeceb4a32dedd..278c7168fa0fbbb9ebf304a03ef5f744eadb230d 100644 (file)
@@ -36,7 +36,7 @@
 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
 extern med_geometry_type typmainoeud[1];
-extern med_geometry_type typmai3[32];
+extern med_geometry_type typmai3[34];
 
 using namespace ParaMEDMEM;
 
@@ -66,7 +66,7 @@ MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const char *locName):_name(locName
   INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
   INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
   MEDlocalizationInfoByName(fid,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
-  _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
+  _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
   _nb_node_per_cell=cm.getNumberOfNodes();
   _ref_coo.resize(_dim*_nb_node_per_cell);
@@ -85,7 +85,7 @@ MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
   INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
   MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
   _name=locName;
-  _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
+  _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
   _nb_node_per_cell=cm.getNumberOfNodes();
   _ref_coo.resize(_dim*_nb_node_per_cell);
@@ -437,7 +437,7 @@ MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFiel
 {
 }
 
-MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_tmp_work1(other._tmp_work1)
+MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(other),_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_tmp_work1(other._tmp_work1)
 {
 }
 
@@ -4394,7 +4394,6 @@ int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDou
   if(!arr->isAllocated())
     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
   _dt=field->getTime(_iteration,_order);
-  int nbOfComponents=arr->getNumberOfComponents();
   getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
   if(!getOrCreateAndGetArray()->isAllocated())
     {
@@ -5969,11 +5968,11 @@ MEDFileField1TS *MEDFileField1TS::New()
  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
  * following the given input policy.
  *
- * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
+ * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
  *                            By default (true) the globals are deeply copied.
  * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
  */
-MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool deepCpyGlobs) const
+MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
 {
   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
@@ -5987,7 +5986,7 @@ MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool deepCpyGlobs) const
     }
   else
     ret=MEDFileIntField1TS::New();
-  if(deepCpyGlobs)
+  if(isDeepCpyGlobs)
     ret->deepCpyGlobs(*this);
   else
     ret->shallowCpyGlobs(*this);
@@ -6408,11 +6407,11 @@ MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
  * following the given input policy.
  *
- * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
+ * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
  *                            By default (true) the globals are deeply copied.
  * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
  */
-MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool deepCpyGlobs) const
+MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
 {
   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
@@ -6426,7 +6425,7 @@ MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool deepCpyGlobs) const
     }
   else
     ret=MEDFileField1TS::New();
-  if(deepCpyGlobs)
+  if(isDeepCpyGlobs)
     ret->deepCpyGlobs(*this);
   else
     ret->shallowCpyGlobs(*this);
@@ -8278,7 +8277,8 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double
 /*!
  * This method groups not null items in \a vectFMTS per time step series. Two time series are considered equal if the list of their pair of integers iteration,order are equal.
  * The float64 value of time attached to the pair of integers are not considered here.
- * 
+ * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
+ *
  * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
  * \throw If there is a null pointer in \a vectFMTS.
  */
@@ -8324,6 +8324,7 @@ std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMult
  * \param [in] vectFMTS - list of multi times step part all defined each on a same spatial discretization along time and pointing to a mesh whose name is equal to \c mesh->getName().
  * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
  * \param [out] fsc - A vector having same size than returned vector. It specifies the support comporator of the corresponding vector of MEDFileAnyTypeFieldMultiTS in returned vector of vector.
+ * \return - A vector of vector of objects that contains the same pointers (objects) than thoose in \a vectFMTS except that there are organized differently. So pointers included in returned vector of vector should \b not been dealt by the caller.
  *
  * \throw If an element in \a vectFMTS has not only one spatial discretization set.
  * \throw If an element in \a vectFMTS change of spatial discretization along time.
@@ -8343,14 +8344,17 @@ std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMult
     return ret;
   std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
   MEDFileAnyTypeFieldMultiTS *frstElt(*it);
+  if(!frstElt)
+    throw INTERP_KERNEL::Exception(msg);
   std::size_t i=0;
   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
   for(;it!=vectFMTS.end();it++,i++)
     {
+      if(!(*it))
+        throw INTERP_KERNEL::Exception(msg);
       TypeOfField tof0,tof1;
-      int ret=CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1);
-      if(ret>0)
+      if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
         {
           if(tof1!=ON_NODES)
             vectFMTSNotNodes.push_back(*it);
@@ -8564,11 +8568,11 @@ void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1t
  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
  * following the given input policy.
  *
- * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
+ * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
  *                            By default (true) the globals are deeply copied.
  * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
  */
-MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool deepCpyGlobs) const
+MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
 {
   MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
@@ -8582,7 +8586,7 @@ MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool deepCpyGlobs) con
     }
   else
     ret=MEDFileIntFieldMultiTS::New();
-  if(deepCpyGlobs)
+  if(isDeepCpyGlobs)
     ret->deepCpyGlobs(*this);
   else
     ret->shallowCpyGlobs(*this);
@@ -8997,11 +9001,11 @@ MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTS
  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
  * following the given input policy.
  *
- * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
+ * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
  *                            By default (true) the globals are deeply copied.
  * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
  */
-MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool deepCpyGlobs) const
+MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
 {
   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
@@ -9015,7 +9019,7 @@ MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool deepCpyGlobs)
     }
   else
     ret=MEDFileFieldMultiTS::New();
-  if(deepCpyGlobs)
+  if(isDeepCpyGlobs)
     ret->deepCpyGlobs(*this);
   else
     ret->shallowCpyGlobs(*this);
index 3b33b8acd72b893f46923da29190644bff94ce5f..0ff3e041bd3d67831ba122ee5bbb0d90018216f2 100644 (file)
@@ -706,7 +706,7 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT static MEDFileField1TS *New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll=true);
     MEDLOADER_EXPORT static MEDFileField1TS *New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent);
     MEDLOADER_EXPORT static MEDFileField1TS *New();
-    MEDLOADER_EXPORT MEDFileIntField1TS *convertToInt(bool deepCpyGlobs=true) const;
+    MEDLOADER_EXPORT MEDFileIntField1TS *convertToInt(bool isDeepCpyGlobs=true) const;
     //
     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const;
     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const;
@@ -748,7 +748,7 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT static MEDFileIntField1TS *New(const char *fileName, const char *fieldName, bool loadAll=true);
     MEDLOADER_EXPORT static MEDFileIntField1TS *New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll=true);
     MEDLOADER_EXPORT static MEDFileIntField1TS *New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent);
-    MEDLOADER_EXPORT MEDFileField1TS *convertToDouble(bool deepCpyGlobs=true) const;
+    MEDLOADER_EXPORT MEDFileField1TS *convertToDouble(bool isDeepCpyGlobs=true) const;
     MEDLOADER_EXPORT MEDFileAnyTypeField1TS *shallowCpy() const;
     //
     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const;
@@ -989,7 +989,7 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const;
     MEDLOADER_EXPORT void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const;
-    MEDLOADER_EXPORT MEDFileIntFieldMultiTS *convertToInt(bool deepCpyGlobs=true) const;
+    MEDLOADER_EXPORT MEDFileIntFieldMultiTS *convertToInt(bool isDeepCpyGlobs=true) const;
     //
     MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStepAtPos(int pos) const;
     MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStep(int iteration, int order) const;
@@ -1030,7 +1030,7 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const;
     MEDLOADER_EXPORT void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const;
     MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStepAtPos(int pos) const;
-    MEDLOADER_EXPORT MEDFileFieldMultiTS *convertToDouble(bool deepCpyGlobs=true) const;
+    MEDLOADER_EXPORT MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) const;
     //
     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const;
     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol=0) const;
index 1a9e8cfccb210058f0e4a8768a21a3139db082d0..a873bdfae3987c6570ea5ccebf2b647130673177 100644 (file)
@@ -3460,6 +3460,23 @@ void MEDFileUMesh::removeMeshAtLevel(int meshDimRelToMax)
   _ms[pos]=0;
 }
 
+/*!
+ * Sets a new MEDCoupling1GTUMesh at a given level in \a this mesh.
+ *  \param [in] meshDimRelToMax - a relative level to set the mesh at.
+ *  \param [in] m - the new mesh to set.
+ *  \throw If the name or the description of \a this mesh and \a m are not empty and are
+ *         different. 
+ *  \throw If the node coordinates array is set \a this in mesh and \a m refers to
+ *         another node coordinates array.
+ *  \throw If the mesh dimension of \a m does not correspond to \a meshDimRelToMax or
+ *         to the existing meshes of other levels of \a this mesh.
+ */
+void MEDFileUMesh::setMeshAtLevel(int meshDimRelToMax, MEDCoupling1GTUMesh *m)
+{
+  MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> elt(new MEDFileUMeshSplitL1(m));
+  checkAndGiveEntryInSplitL1(meshDimRelToMax,m)=elt;
+}
+
 /*!
  * Sets a new MEDCouplingUMesh at a given level in \a this mesh.
  *  \param [in] meshDimRelToMax - a relative level to set the mesh at.
@@ -3474,6 +3491,12 @@ void MEDFileUMesh::removeMeshAtLevel(int meshDimRelToMax)
  *         to the existing meshes of other levels of \a this mesh.
  */
 void MEDFileUMesh::setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld)
+{
+  MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> elt(new MEDFileUMeshSplitL1(m,newOrOld));
+  checkAndGiveEntryInSplitL1(meshDimRelToMax,m)=elt;
+}
+
+MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1>& MEDFileUMesh::checkAndGiveEntryInSplitL1(int meshDimRelToMax, MEDCouplingPointSet *m)
 {
   dealWithTinyInfo(m);
   std::vector<int> levSet=getNonEmptyLevels();
@@ -3492,10 +3515,10 @@ void MEDFileUMesh::setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m, bool
       if(sz>=(int)_ms.size())
         _ms.resize(sz);
       checkMeshDimCoherency(m->getMeshDimension(),meshDimRelToMax);
-      _ms[sz-1]=new MEDFileUMeshSplitL1(m,newOrOld);
+      return _ms[sz-1];
     }
   else
-    _ms[-meshDimRelToMax]=new MEDFileUMeshSplitL1(m,newOrOld);
+    return _ms[-meshDimRelToMax];
 }
 
 /*!
index 5e66c8c2a4423fa1eff0c9619dca8d161b5f92de..87455300a39ab340c6139dc7e0c3023c048added 100644 (file)
@@ -254,6 +254,7 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT void addNodeGroup(const DataArrayInt *ids);
     MEDLOADER_EXPORT void addGroup(int meshDimRelToMaxExt, const DataArrayInt *ids);
     MEDLOADER_EXPORT void removeMeshAtLevel(int meshDimRelToMax);
+    MEDLOADER_EXPORT void setMeshAtLevel(int meshDimRelToMax, MEDCoupling1GTUMesh *m);
     MEDLOADER_EXPORT void setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld=false);
     MEDLOADER_EXPORT void setMeshes(const std::vector<const MEDCouplingUMesh *>& ms, bool renum=false);
     MEDLOADER_EXPORT void setGroupsFromScratch(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms, bool renum=false);
@@ -277,6 +278,7 @@ namespace ParaMEDMEM
     void changeFamilyIdArr(int oldId, int newId);
     std::list< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > getAllNonNullFamilyIds() const;
     void addGroupUnderground(bool isNodeGroup, const DataArrayInt *ids, DataArrayInt *famArr);
+    MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1>& checkAndGiveEntryInSplitL1(int meshDimRelToMax, MEDCouplingPointSet *m);
   private:
     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> > _ms;
     MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
index 537ceb64a55052f568ccfd03ef7e73dd6ad151b0..9a8d48813c3c73b39b2ef6e06755f3acaf450cfe 100644 (file)
@@ -28,7 +28,7 @@
 
 #include <iostream>
 
-extern med_geometry_type typmai3[32];
+extern med_geometry_type typmai3[34];
 
 using namespace ParaMEDMEM;
 
@@ -96,7 +96,7 @@ MEDFileUMeshPerType::MEDFileUMeshPerType(med_idt fid, const char *mName, int dt,
       loadFromStaticType(fid,mName,dt,it,mdim,curNbOfElem,geoElt,type,entity,mrs);
       return;
     }
-  if(type==INTERP_KERNEL::NORM_POLYGON)
+  if(type==INTERP_KERNEL::NORM_POLYGON || type==INTERP_KERNEL::NORM_QPOLYG)
     {
       loadPolyg(fid,mName,dt,it,mdim,curNbOfElem,geoElt,entity,mrs);
       return;
@@ -164,16 +164,16 @@ void MEDFileUMeshPerType::loadPolyg(med_idt fid, const char *mName, int dt, int
                                     med_entity_type entity, MEDFileMeshReadSelector *mrs)
 {
   med_bool changement,transformation;
-  med_int curNbOfElem=MEDmeshnEntity(fid,mName,dt,it,entity,MED_POLYGON,MED_INDEX_NODE,MED_NODAL,&changement,&transformation)-1;
-  _m=MEDCoupling1DGTUMesh::New(mName,INTERP_KERNEL::NORM_POLYGON);
+  med_int curNbOfElem=MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_INDEX_NODE,MED_NODAL,&changement,&transformation)-1;
+  _m=MEDCoupling1DGTUMesh::New(mName,geoElt==MED_POLYGON?INTERP_KERNEL::NORM_POLYGON:INTERP_KERNEL::NORM_QPOLYG);
   MEDCoupling1DGTUMesh *mc(dynamic_cast<MEDCoupling1DGTUMesh *>((MEDCoupling1GTUMesh *)_m));
   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(DataArrayInt::New()),connI(DataArrayInt::New());
   conn->alloc(arraySize,1); connI->alloc(curNbOfElem+1,1);
-  MEDmeshPolygonRd(fid,mName,dt,it,MED_CELL,MED_NODAL,connI->getPointer(),conn->getPointer());
+  MEDmeshPolygon2Rd(fid,mName,dt,it,MED_CELL,geoElt,MED_NODAL,connI->getPointer(),conn->getPointer());
   std::transform(conn->begin(),conn->end(),conn->getPointer(),std::bind2nd(std::plus<int>(),-1));
   std::transform(connI->begin(),connI->end(),connI->getPointer(),std::bind2nd(std::plus<int>(),-1));
   mc->setNodalConnectivity(conn,connI);
-  loadCommonPart(fid,mName,dt,it,mdim,curNbOfElem,MED_POLYGON,entity,mrs);
+  loadCommonPart(fid,mName,dt,it,mdim,curNbOfElem,geoElt,entity,mrs);
 }
 
 void MEDFileUMeshPerType::loadPolyh(med_idt fid, const char *mName, int dt, int it, int mdim, int connFaceLgth, med_geometry_type geoElt,
@@ -236,12 +236,12 @@ void MEDFileUMeshPerType::Write(med_idt fid, const char *mname, int mdim, const
       const MEDCoupling1DGTUMesh *m0(dynamic_cast<const MEDCoupling1DGTUMesh *>(m));
       if(!m0)
         throw INTERP_KERNEL::Exception("MEDFileUMeshPerType::Write : internal error #2 !");
-      if(ikt==INTERP_KERNEL::NORM_POLYGON)
+      if(ikt==INTERP_KERNEL::NORM_POLYGON || ikt==INTERP_KERNEL::NORM_QPOLYG)
         {
           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr(m0->getNodalConnectivity()->deepCpy()),arrI(m0->getNodalConnectivityIndex()->deepCpy());
           std::transform(arr->begin(),arr->end(),arr->getPointer(),std::bind2nd(std::plus<int>(),1));
           std::transform(arrI->begin(),arrI->end(),arrI->getPointer(),std::bind2nd(std::plus<int>(),1));
-          MEDmeshPolygonWr(fid,mname,dt,it,timm,MED_CELL,MED_NODAL,nbOfCells+1,arrI->begin(),arr->begin());
+          MEDmeshPolygon2Wr(fid,mname,dt,it,timm,MED_CELL,ikt==INTERP_KERNEL::NORM_POLYGON?MED_POLYGON:MED_POLYGON2,MED_NODAL,nbOfCells+1,arrI->begin(),arr->begin());
         }
       else
         {
index 79ea1141a59ee6dcff2c41fcd3086f77aca057fb..cbc4dc6e6c1a037280ecac40587f3ce4767fa49a 100644 (file)
@@ -552,6 +552,13 @@ MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *m
     }
 }
 
+MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCoupling1GTUMesh *m):_m(this)
+{
+  std::vector< const MEDCoupling1GTUMesh * > v(1);
+  v[0]=m;
+  assignParts(v);
+}
+
 MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCouplingUMesh *m):_m(this)
 {
   assignMesh(m,true);
@@ -691,8 +698,19 @@ void MEDFileUMeshSplitL1::assignMesh(MEDCouplingUMesh *m, bool newOrOld)
       m->incrRef();
       _m_by_types.assignUMesh(m);
     }
+  assignCommonPart();
+}
+
+void MEDFileUMeshSplitL1::assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts)
+{
+  _m_by_types.assignParts(mParts);
+  assignCommonPart();
+}
+
+void MEDFileUMeshSplitL1::assignCommonPart()
+{
   _fam=DataArrayInt::New();
-  _fam->alloc(m->getNumberOfCells(),1);
+  _fam->alloc(_m_by_types.getSize(),1);
   _fam->fillWithValue(0);
 }
 
index c956ce7b4546245ae87c7ceeeafc11f42b8b469a..172b9c8d51f069c7b6a66623a30c9abacd148778 100644 (file)
@@ -176,6 +176,7 @@ namespace ParaMEDMEM
   public:
     MEDFileUMeshSplitL1(const MEDFileUMeshSplitL1& other);
     MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *mName, int id);
+    MEDFileUMeshSplitL1(MEDCoupling1GTUMesh *m);
     MEDFileUMeshSplitL1(MEDCouplingUMesh *m);
     MEDFileUMeshSplitL1(MEDCouplingUMesh *m, bool newOrOld);
     std::size_t getHeapMemorySizeWithoutChildren() const;
@@ -186,6 +187,7 @@ namespace ParaMEDMEM
     void clearNonDiscrAttributes() const;
     void synchronizeTinyInfo(const MEDFileMesh& master) const;
     void assignMesh(MEDCouplingUMesh *m, bool newOrOld);
+    void assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts);
     bool empty() const;
     bool presenceOfOneFams(const std::vector<int>& ids) const;
     int getMeshDimension() const;
@@ -221,6 +223,7 @@ namespace ParaMEDMEM
     static DataArrayInt *Renumber(const DataArrayInt *renum, const DataArrayInt *da);
     static MEDCouplingUMesh *Renumber2(const DataArrayInt *renum, MEDCouplingUMesh *m, const int *cellIds);
   private:
+    void assignCommonPart();
     MEDCouplingUMesh *renumIfNeeded(MEDCouplingUMesh *m, const int *cellIds) const;
     DataArrayInt *renumIfNeededArr(const DataArrayInt *da) const;
     void computeRevNum() const;
index f5e835bd7b0339798e753a06616974a656f9552b..f14e17a152833858b9415a9582f24c854815dd3f 100644 (file)
@@ -64,6 +64,7 @@ med_geometry_type typmai[MED_N_CELL_FIXED_GEO] = { MED_POINT1,
                                                    MED_HEXA20,
                                                    MED_HEXA27,
                                                    MED_POLYGON,
+                                                   MED_POLYGON2,
                                                    MED_POLYHEDRON };
 
 med_geometry_type typmainoeud[1] = { MED_NONE };
@@ -89,6 +90,7 @@ INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO] = { INTERP_KERNE
                                                                     INTERP_KERNEL::NORM_HEXA20,
                                                                     INTERP_KERNEL::NORM_HEXA27,
                                                                     INTERP_KERNEL::NORM_POLYGON,
+                                                                    INTERP_KERNEL::NORM_QPOLYG,
                                                                     INTERP_KERNEL::NORM_POLYHED };
 
 med_geometry_type typmai3[34] = { MED_POINT1,//0
@@ -123,7 +125,7 @@ med_geometry_type typmai3[34] = { MED_POINT1,//0
                                   MED_NONE,//29
                                   MED_HEXA20,//30
                                   MED_POLYHEDRON,//31
-                                  MED_NONE,//32
+                                  MED_POLYGON2,//32
                                   MED_NONE//33
 };
 
@@ -291,6 +293,18 @@ bool MEDLoader::HasXDR()
 #endif
 }
 
+std::string MEDLoader::MEDFileVersionStr()
+{
+  return std::string(MED_VERSION_STR);
+}
+
+void MEDLoader::MEDFileVersion(int& major, int& minor, int& release)
+{
+  major=MED_NUM_MAJEUR;
+  minor=MED_NUM_MINEUR;
+  release=MED_NUM_RELEASE;
+}
+
 /*!
  * This method sets the epsilon value used for node comparison when trying to buid a profile for a field on node/cell on an already written mesh.
  */
@@ -1046,7 +1060,55 @@ std::vector< std::pair<int,int> > MEDLoader::GetNodeFieldIterations(const char *
   return ret;
 }
 
-MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax)
+ParaMEDMEM::MEDCouplingMesh *MEDLoader::ReadMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax)
+{
+  CheckFileForRead(fileName);
+  MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm=MEDFileMesh::New(fileName,meshName);
+  MEDFileMesh *mmPtr(mm);
+  MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
+  if(mmuPtr)
+    return mmuPtr->getMeshAtLevel(meshDimRelToMax,true);
+  MEDFileCMesh *mmcPtr=dynamic_cast<MEDFileCMesh *>(mmPtr);
+  if(mmcPtr)
+    {
+      const MEDCouplingCMesh *ret(mmcPtr->getMesh()); ret->incrRef();
+      return const_cast<MEDCouplingCMesh *>(ret);
+    }
+  MEDFileCurveLinearMesh *mmc2Ptr=dynamic_cast<MEDFileCurveLinearMesh *>(mmPtr);
+  if(mmc2Ptr)
+    {
+      const MEDCouplingCurveLinearMesh *ret(mmc2Ptr->getMesh()); ret->incrRef();
+      return const_cast<MEDCouplingCurveLinearMesh *>(ret);
+    }
+  std::ostringstream oss; oss << "MEDLoader::ReadMeshFromFile : The mesh \"" << meshName << "\" in file \"" << fileName << "\" has not a recognized type !";
+  throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+ParaMEDMEM::MEDCouplingMesh *MEDLoader::ReadMeshFromFile(const char *fileName, int meshDimRelToMax)
+{
+  CheckFileForRead(fileName);
+  MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm=MEDFileMesh::New(fileName);
+  MEDFileMesh *mmPtr(mm);
+  MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
+  if(mmuPtr)
+    return mmuPtr->getMeshAtLevel(meshDimRelToMax,true);
+  MEDFileCMesh *mmcPtr=dynamic_cast<MEDFileCMesh *>(mmPtr);
+  if(mmcPtr)
+    {
+      const MEDCouplingCMesh *ret(mmcPtr->getMesh()); ret->incrRef();
+      return const_cast<MEDCouplingCMesh *>(ret);
+    }
+  MEDFileCurveLinearMesh *mmc2Ptr=dynamic_cast<MEDFileCurveLinearMesh *>(mmPtr);
+  if(mmc2Ptr)
+    {
+      const MEDCouplingCurveLinearMesh *ret(mmc2Ptr->getMesh()); ret->incrRef();
+      return const_cast<MEDCouplingCurveLinearMesh *>(ret);
+    }
+  std::ostringstream oss; oss << "MEDLoader::ReadMeshFromFile (2) : The first mesh \"" << mm->getName() << "\" in file \"" << fileName << "\" has not a recognized type !";
+  throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax)
 {
   CheckFileForRead(fileName);
   MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm=MEDFileMesh::New(fileName,meshName);
@@ -1281,6 +1343,44 @@ ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldGaussNE(const char *file
   return ret.retn();
 }
 
+void MEDLoader::WriteMesh(const char *fileName, const ParaMEDMEM::MEDCouplingMesh *mesh, bool writeFromScratch)
+{
+  if(!mesh)
+    throw INTERP_KERNEL::Exception("MEDLoader::WriteMesh : input mesh is null !");
+  const MEDCouplingUMesh *um(dynamic_cast<const MEDCouplingUMesh *>(mesh));
+  if(um)
+    {
+      WriteUMesh(fileName,um,writeFromScratch);
+      return ;
+    }
+  int mod=writeFromScratch?2:0;
+  const MEDCoupling1GTUMesh *um2(dynamic_cast<const MEDCoupling1GTUMesh *>(mesh));
+  if(um2)
+    {
+      MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> mmu=MEDFileUMesh::New();
+      mmu->setMeshAtLevel(0,const_cast<MEDCoupling1GTUMesh *>(um2));
+      mmu->write(fileName,mod);
+      return ;
+    }
+  const MEDCouplingCMesh *um3(dynamic_cast<const MEDCouplingCMesh *>(mesh));
+  if(um3)
+    {
+      MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> mmc=MEDFileCMesh::New();
+      mmc->setMesh(const_cast<MEDCouplingCMesh *>(um3));
+      mmc->write(fileName,mod);
+      return ;
+    }
+  const MEDCouplingCurveLinearMesh *um4(dynamic_cast<const MEDCouplingCurveLinearMesh *>(mesh));
+  if(um4)
+    {
+      MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> mmc=MEDFileCurveLinearMesh::New();
+      mmc->setMesh(const_cast<MEDCouplingCurveLinearMesh *>(um4));
+      mmc->write(fileName,mod);
+      return ;
+    }
+  throw INTERP_KERNEL::Exception("MEDLoader::WriteMesh : only MEDCouplingUMesh, MEDCoupling1GTUMesh, MEDCouplingCMesh, MEDCouplingCurveLinear are dealed in this API for the moment !");
+}
+
 void MEDLoader::WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch)
 {
   if(!mesh)
@@ -1332,8 +1432,11 @@ void MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(const char *fil
 {
   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ff=MEDFileField1TS::New();
   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f2(f->deepCpy());
-  const MEDCouplingMesh *m=f2->getMesh();
-  const MEDCouplingUMesh *um=dynamic_cast<const MEDCouplingUMesh *>(m);
+  const MEDCouplingMesh *m(f2->getMesh());
+  const MEDCouplingUMesh *um(dynamic_cast<const MEDCouplingUMesh *>(m));
+  const MEDCoupling1GTUMesh *um2(dynamic_cast<const MEDCoupling1GTUMesh *>(m));
+  const MEDCouplingCMesh *um3(dynamic_cast<const MEDCouplingCMesh *>(m));
+  const MEDCouplingCurveLinearMesh *um4(dynamic_cast<const MEDCouplingCurveLinearMesh *>(m));
   MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
   int mod=writeFromScratch?2:0;
   if(um)
@@ -1347,8 +1450,29 @@ void MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(const char *fil
       ff->setFieldNoProfileSBT(f2);
       mmu->write(fileName,mod);
     }
+  else if(um2)
+    {
+      MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> mmu=MEDFileUMesh::New();
+      mmu->setMeshAtLevel(0,const_cast<MEDCoupling1GTUMesh *>(um2));
+      ff->setFieldNoProfileSBT(f2);
+      mmu->write(fileName,mod);
+    }
+  else if(um3)
+    {
+      MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> mmc=MEDFileCMesh::New();
+      mmc->setMesh(const_cast<MEDCouplingCMesh *>(um3));
+      ff->setFieldNoProfileSBT(f2);
+      mmc->write(fileName,mod);
+    }
+  else if(um4)
+    {
+      MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> mmc=MEDFileCurveLinearMesh::New();
+      mmc->setMesh(const_cast<MEDCouplingCurveLinearMesh *>(um4));
+      ff->setFieldNoProfileSBT(f2);
+      mmc->write(fileName,mod);
+    }
   else
-    throw INTERP_KERNEL::Exception("MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile : only umeshes are dealed in this API for the moment !");
+    throw INTERP_KERNEL::Exception("MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile : only MEDCouplingUMesh, MEDCoupling1GTUMesh, MEDCouplingCMesh, MEDCouplingCurveLinear are dealed in this API for the moment !");
   ff->write(fileName,0);
 }
 
index 7cc1ee6d9c9ce0e88f3d8b41d2eb8fa6e8ad279f..5e7187a195924badd9285b1223eefdde592c686f 100644 (file)
@@ -32,6 +32,7 @@
 namespace ParaMEDMEM
 {
   class DataArrayInt;
+  class MEDCouplingMesh;
   class MEDCouplingUMesh;
   class MEDCouplingFieldDouble;
 }
@@ -43,6 +44,8 @@ class MEDLOADER_EXPORT MEDLoader
   static void SetCompPolicyForCell(int val);
   static void SetTooLongStrPolicy(int val);
   static bool HasXDR();
+  static std::string MEDFileVersionStr();
+  static void MEDFileVersion(int& major, int& minor, int& release);
   static void CheckFileForRead(const char *fileName);
   static std::vector<std::string> GetMeshNames(const char *fileName);
   static std::vector< std::vector< std::pair<INTERP_KERNEL::NormalizedCellType,int> > > GetUMeshGlobalInfo(const char *fileName, const char *meshName, int &meshDim, int& spaceDim, int& numberOfNodes);
@@ -65,6 +68,8 @@ class MEDLOADER_EXPORT MEDLoader
   static double GetTimeAttachedOnFieldIteration(const char *fileName, const char *fieldName, int iteration, int order);
   static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector<std::string>& fams);
   static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector<std::string>& grps);
+  static ParaMEDMEM::MEDCouplingMesh *ReadMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0);
+  static ParaMEDMEM::MEDCouplingMesh *ReadMeshFromFile(const char *fileName, int meshDimRelToMax=0);
   static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0);
   static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0);
   static int ReadUMeshDimFromFile(const char *fileName, const char *meshName);
@@ -83,6 +88,7 @@ class MEDLOADER_EXPORT MEDLoader
   static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order);
   static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order);
   static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order);
+  static void WriteMesh(const char *fileName, const ParaMEDMEM::MEDCouplingMesh *mesh, bool writeFromScratch);
   static void WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch);
   static void WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch);
   static void WriteUMeshesPartition(const char *fileName, const char *meshName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch);
index e67fde2d0b492ffdd04901a1cb136150c869e111..7d915e52a76d139e68ef0444aeb1626660bdbca6 100644 (file)
@@ -72,6 +72,7 @@ using namespace ParaMEDMEM;
 %newobject MEDLoader::ReadUMeshFromFamilies;
 %newobject MEDLoader::ReadUMeshFromGroups;
 %newobject MEDLoader::ReadUMeshFromFile;
+%newobject MEDLoader::ReadMeshFromFile;
 %newobject MEDLoader::ReadField;
 %newobject MEDLoader::ReadFieldCell;
 %newobject MEDLoader::ReadFieldNode;
@@ -219,6 +220,7 @@ class MEDLoader
 {
 public:
   static bool HasXDR();
+  static std::string MEDFileVersionStr();
   static void SetEpsilonForNodeComp(double val) throw(INTERP_KERNEL::Exception);
   static void SetCompPolicyForCell(int val) throw(INTERP_KERNEL::Exception);
   static void SetTooLongStrPolicy(int val) throw(INTERP_KERNEL::Exception);
@@ -237,6 +239,17 @@ public:
   static double GetTimeAttachedOnFieldIteration(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
   %extend
      {
+       static PyObject *MEDFileVersion()
+       {
+         int major,minor,release;
+         MEDLoader::MEDFileVersion(major,minor,release);
+         PyObject *ret(PyTuple_New(3));
+         PyTuple_SetItem(ret,0,SWIG_From_int(major));
+         PyTuple_SetItem(ret,1,SWIG_From_int(minor));
+         PyTuple_SetItem(ret,2,SWIG_From_int(release));
+         return ret;
+       }
+
        static PyObject *GetFieldIterations(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
        {
          std::vector< std::pair<int,int> > res=MEDLoader::GetFieldIterations(type,fileName,meshName,fieldName);
@@ -384,6 +397,8 @@ public:
          return MEDLoader::ReadUMeshFromFamilies(fileName,meshName,meshDimRelToMax,fams);
        }
      }
+  static ParaMEDMEM::MEDCouplingMesh *ReadMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
+  static ParaMEDMEM::MEDCouplingMesh *ReadMeshFromFile(const char *fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
   static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
   static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
   static int ReadUMeshDimFromFile(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
@@ -392,6 +407,7 @@ public:
   static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
   static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
   static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+  static void WriteMesh(const char *fileName, const ParaMEDMEM::MEDCouplingMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
   static void WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
   static void WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
   static void WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
@@ -714,6 +730,7 @@ namespace ParaMEDMEM
     void addNodeGroup(const DataArrayInt *ids) throw(INTERP_KERNEL::Exception);
     void addGroup(int meshDimRelToMaxExt, const DataArrayInt *ids) throw(INTERP_KERNEL::Exception);
     void removeMeshAtLevel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception);
+    void setMeshAtLevel(int meshDimRelToMax, MEDCoupling1GTUMesh *m) throw(INTERP_KERNEL::Exception);
     void setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld=false) throw(INTERP_KERNEL::Exception);
     void optimizeFamilies() throw(INTERP_KERNEL::Exception);
     DataArrayInt *zipCoords() throw(INTERP_KERNEL::Exception);
@@ -1318,7 +1335,7 @@ namespace ParaMEDMEM
     static MEDFileField1TS *New(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
     static MEDFileField1TS *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
     static MEDFileField1TS *New();
-    ParaMEDMEM::MEDFileIntField1TS *convertToInt(bool deepCpyGlobs=true) const throw(INTERP_KERNEL::Exception);
+    ParaMEDMEM::MEDFileIntField1TS *convertToInt(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception);
     MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
@@ -1452,7 +1469,7 @@ namespace ParaMEDMEM
     static MEDFileIntField1TS *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
     static MEDFileIntField1TS *New(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
     static MEDFileIntField1TS *New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception);
-    ParaMEDMEM::MEDFileField1TS *convertToDouble(bool deepCpyGlobs=true) const throw(INTERP_KERNEL::Exception);
+    ParaMEDMEM::MEDFileField1TS *convertToDouble(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception);
     //
     void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception);
     void setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
@@ -1945,7 +1962,7 @@ namespace ParaMEDMEM
     //
     void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
     void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
-    ParaMEDMEM::MEDFileIntFieldMultiTS *convertToInt(bool deepCpyGlobs=true) const throw(INTERP_KERNEL::Exception);
+    ParaMEDMEM::MEDFileIntFieldMultiTS *convertToInt(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception);
     %extend
        {
          MEDFileFieldMultiTS()
@@ -2076,7 +2093,7 @@ namespace ParaMEDMEM
     //
     void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception);
     void appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
-    ParaMEDMEM::MEDFileFieldMultiTS *convertToDouble(bool deepCpyGlobs=true) const throw(INTERP_KERNEL::Exception);
+    ParaMEDMEM::MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception);
     %extend
     {
       MEDFileIntFieldMultiTS()
index 149c40a26f88c6bd1a5e504dde31bb9505ea3b10..3440231357fa0f289a016c8d4b9f443ee1ffea89 100644 (file)
@@ -561,6 +561,103 @@ class MEDLoaderTest(unittest.TestCase):
         f2=MEDLoader.MEDLoader.ReadFieldCell(fileName,m.getName(),0,f.getName(),-1,-1)
         self.assertTrue(f.isEqual(f2,1e-12,1e-12))
         pass
+
+    def testMultiMeshTypeWrite0(self):
+        fname="Pyfile73.med"
+        m=MEDLoader.MEDCoupling1SGTUMesh("mesh",MEDLoader.NORM_QUAD4) ; m.allocateCells()
+        m.insertNextCell([0,2,1,3])
+        m.setCoords(MEDLoader.DataArrayDouble([0.,0.,1.,1.,1.,0.,0.,1.],4,2))
+        #
+        ms=[m.deepCpy() for i in xrange(4)]
+        for i,elt in enumerate(ms):
+            elt.translate([float(i)*1.5,0.])
+            pass
+        #
+        m0=MEDLoader.MEDCoupling1SGTUMesh.Merge1SGTUMeshes(ms)
+        f=m0.getMeasureField(False) ; f.getArray().setInfoOnComponents(["ABC [defg]"])
+        MEDLoader.MEDLoader.WriteField(fname,f,True)
+        #
+        fRead=MEDLoader.MEDLoader.ReadFieldCell(fname,"merge",0,f.getName(),-1,-1)
+        fRead.setMesh(MEDLoader.MEDCoupling1SGTUMesh(fRead.getMesh()))
+        self.assertTrue(f.isEqual(fRead,1e-12,1e-12))
+        #
+        m0=m0.buildUnstructured() ; m0.convertAllToPoly()
+        m0=MEDLoader.MEDCoupling1DGTUMesh(m0)
+        f=m0.getMeasureField(False) ; f.getArray().setInfoOnComponents(["ABC [defg]"])
+        MEDLoader.MEDLoader.WriteField(fname,f,True)
+        #
+        fRead=MEDLoader.MEDLoader.ReadFieldCell(fname,"merge",0,f.getName(),-1,-1)
+        fRead.setMesh(MEDLoader.MEDCoupling1DGTUMesh(fRead.getMesh()))
+        self.assertTrue(f.isEqual(fRead,1e-12,1e-12))
+        #
+        m0=MEDLoader.MEDCouplingCMesh()
+        arr=MEDLoader.DataArrayDouble(4) ; arr.iota()
+        m0.setCoords(arr,arr)
+        m0.setName("mesh")
+        f=m0.getMeasureField(False) ; f.getArray().setInfoOnComponents(["ABC [defg]"])
+        MEDLoader.MEDLoader.WriteField(fname,f,True)
+        #
+        fRead=MEDLoader.MEDLoader.ReadFieldCell(fname,"mesh",0,f.getName(),-1,-1)
+        self.assertTrue(f.isEqual(fRead,1e-12,1e-12))
+        #
+        c=m0.buildUnstructured().getCoords()
+        m0=MEDLoader.MEDCouplingCurveLinearMesh("mesh")
+        m0.setNodeGridStructure([4,4])
+        m0.setCoords(c)
+        f=m0.getMeasureField(False) ; f.getArray().setInfoOnComponents(["ABC [defg]"])
+        MEDLoader.MEDLoader.WriteField(fname,f,True)
+        #
+        fRead=MEDLoader.MEDLoader.ReadFieldCell(fname,"mesh",0,f.getName(),-1,-1)
+        self.assertTrue(f.isEqual(fRead,1e-12,1e-12))
+        pass
+    
+    def testMultiMeshTypeWrite1(self):
+        fname="Pyfile74.med"
+        m=MEDLoader.MEDCoupling1SGTUMesh("mesh",MEDLoader.NORM_QUAD4) ; m.allocateCells()
+        m.insertNextCell([0,2,1,3])
+        m.setCoords(MEDLoader.DataArrayDouble([0.,0.,1.,1.,1.,0.,0.,1.],4,2))
+        #
+        ms=[m.deepCpy() for i in xrange(4)]
+        for i,elt in enumerate(ms):
+            elt.translate([float(i)*1.5,0.])
+            pass
+        m0=MEDLoader.MEDCoupling1SGTUMesh.Merge1SGTUMeshes(ms)
+        MEDLoader.MEDLoader.WriteMesh(fname,m0,True)
+        #
+        mRead=MEDLoader.MEDLoader.ReadMeshFromFile(fname,"merge",0)
+        self.assertTrue(isinstance(mRead,MEDLoader.MEDCouplingUMesh))
+        mRead=MEDLoader.MEDCoupling1SGTUMesh(mRead)
+        self.assertTrue(m0.isEqual(mRead,1e-12))
+        #
+        m0=m0.buildUnstructured() ; m0.convertAllToPoly()
+        m0=MEDLoader.MEDCoupling1DGTUMesh(m0)
+        MEDLoader.MEDLoader.WriteMesh(fname,m0,True)
+        #
+        mRead=MEDLoader.MEDLoader.ReadMeshFromFile(fname,"merge",0)
+        mRead=MEDLoader.MEDCoupling1DGTUMesh(mRead)
+        self.assertTrue(m0.isEqual(mRead,1e-12))
+        #
+        m0=MEDLoader.MEDCouplingCMesh()
+        arr=MEDLoader.DataArrayDouble(4) ; arr.iota()
+        m0.setCoords(arr,arr)
+        m0.setName("mesh")
+        MEDLoader.MEDLoader.WriteMesh(fname,m0,True)
+        #
+        mRead=MEDLoader.MEDLoader.ReadMeshFromFile(fname,0)
+        self.assertTrue(isinstance(mRead,MEDLoader.MEDCouplingCMesh))
+        self.assertTrue(m0.isEqual(mRead,1e-12))
+        #
+        c=m0.buildUnstructured().getCoords()
+        m0=MEDLoader.MEDCouplingCurveLinearMesh("mesh")
+        m0.setNodeGridStructure([4,4])
+        m0.setCoords(c)
+        MEDLoader.MEDLoader.WriteMesh(fname,m0,True)
+        #
+        mRead=MEDLoader.MEDLoader.ReadMeshFromFile(fname,0)
+        self.assertTrue(isinstance(mRead,MEDLoader.MEDCouplingCurveLinearMesh))
+        self.assertTrue(m0.isEqual(mRead,1e-12))
+        pass
+
     pass
 
 unittest.main()
index 6c4c3d182311a00defd978beb937ff8230d6e8f3..21654c9d07835090aa84a521adeb9d30e9510ad5 100644 (file)
@@ -3362,7 +3362,7 @@ class MEDLoaderTest(unittest.TestCase):
         self.assertTrue(m.getFamilyFieldAtLevel(1).isEqual(DataArrayInt([-1,-1,-1,-1,-1,-2,-2,-2,-2,-2,-2,0,-1,-3,-3,-3])))
         pass
 
-    @unittest.skipUnless(False,"requires Vadim's green light")
+    #@unittest.skipUnless(False,"requires Vadim's green light")
     def testWRQPolyg1(self):
         fname="Pyfile72.med"
         m=MEDCoupling1SGTUMesh("mesh",NORM_QUAD4) ; m.allocateCells()