]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Now deal with Cylindric, Spheric coordinates for UMesh, CLMesh, And only Cylindric...
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 30 Dec 2015 17:54:49 +0000 (18:54 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 31 Dec 2015 16:08:13 +0000 (17:08 +0100)
16 files changed:
src/MEDCoupling/MEDCoupling1GTUMesh.cxx
src/MEDCoupling/MEDCouplingCMesh.cxx
src/MEDCoupling/MEDCouplingCMesh.hxx
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling/MEDCouplingMemArray.hxx
src/MEDCoupling/MEDCouplingMesh.hxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py
src/MEDCoupling_Swig/MEDCouplingCommon.i
src/MEDCoupling_Swig/MEDCouplingMemArray.i
src/MEDLoader/MEDFileMesh.cxx
src/MEDLoader/MEDFileMesh.hxx
src/MEDLoader/MEDFileMeshLL.cxx
src/MEDLoader/MEDFileMeshLL.hxx
src/MEDLoader/Swig/MEDLoaderCommon.i
src/MEDLoader/Swig/MEDLoaderTest3.py
src/MEDLoader/Swig/MEDLoaderTest4.py

index 38eae7a7ef30746056951fefa014453567bcd9dc..cea42c447a8e7af073965e9104db408da85e6832 100644 (file)
@@ -2163,7 +2163,7 @@ MEDCoupling1DGTUMesh::MEDCoupling1DGTUMesh(const std::string& name, const INTERP
 {
 }
 
-MEDCoupling1DGTUMesh::MEDCoupling1DGTUMesh(const MEDCoupling1DGTUMesh& other, bool recDeepCpy):MEDCoupling1GTUMesh(other,recDeepCpy),_conn(other._conn)
+MEDCoupling1DGTUMesh::MEDCoupling1DGTUMesh(const MEDCoupling1DGTUMesh& other, bool recDeepCpy):MEDCoupling1GTUMesh(other,recDeepCpy),_conn_indx(other._conn_indx),_conn(other._conn)
 {
   if(recDeepCpy)
     {
index 597b682a6c12476e0d8e0cabfb1467a731c1017a..c0771916e2d7f0d28ca359cf91f78b939dbb122e 100644 (file)
@@ -21,6 +21,9 @@
 #include "MEDCouplingCMesh.hxx"
 #include "MEDCouplingMemArray.hxx"
 #include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingCurveLinearMesh.hxx"
+
+#include "InterpKernelAutoPtr.hxx"
 
 #include <functional>
 #include <algorithm>
@@ -81,7 +84,7 @@ MEDCouplingCMesh *MEDCouplingCMesh::New()
 
 MEDCouplingCMesh *MEDCouplingCMesh::New(const std::string& meshName)
 {
-  MEDCouplingCMesh *ret=new MEDCouplingCMesh;
+  MEDCouplingCMesh *ret(new MEDCouplingCMesh);
   ret->setName(meshName);
   return ret;
 }
@@ -96,6 +99,20 @@ MEDCouplingCMesh *MEDCouplingCMesh::clone(bool recDeepCpy) const
   return new MEDCouplingCMesh(*this,recDeepCpy);
 }
 
+MEDCouplingCurveLinearMesh *MEDCouplingCMesh::buildCurveLinear() const
+{
+  checkCoherency();
+  int dim(getSpaceDimension());
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingCurveLinearMesh> ret(MEDCouplingCurveLinearMesh::New());
+  ret->MEDCouplingStructuredMesh::operator=(*this);
+  INTERP_KERNEL::AutoPtr<int> ngs(new int[dim]);
+  getNodeGridStructure(ngs);
+  ret->setNodeGridStructure(ngs,ngs+dim);
+  MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coo(getCoordinatesAndOwner());
+  ret->setCoords(coo);
+  return ret.retn();
+}
+
 void MEDCouplingCMesh::updateTime() const
 {
   if(_x_array)
@@ -679,11 +696,10 @@ MEDCouplingMesh *MEDCouplingCMesh::mergeMyselfWith(const MEDCouplingMesh *other)
  */
 DataArrayDouble *MEDCouplingCMesh::getCoordinatesAndOwner() const
 {
-  DataArrayDouble *ret=DataArrayDouble::New();
-  int spaceDim=getSpaceDimension();
-  int nbNodes=getNumberOfNodes();
+  MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret(DataArrayDouble::New());
+  int spaceDim(getSpaceDimension()),nbNodes(getNumberOfNodes());
   ret->alloc(nbNodes,spaceDim);
-  double *pt=ret->getPointer();
+  double *pt(ret->getPointer());
   int tmp[3];
   getSplitNodeValues(tmp);
   const DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)};
@@ -700,7 +716,7 @@ DataArrayDouble *MEDCouplingCMesh::getCoordinatesAndOwner() const
       for(int j=0;j<spaceDim;j++)
         pt[i*spaceDim+j]=tabsPtr[j][tmp2[j]];
     }
-  return ret;
+  return ret.retn();
 }
 
 /*!
index 81811212ff87d3dcbb84ea86c76fec7bd37acdb6..e5359b6db71798ea34874288a44768b16e0abf22 100644 (file)
@@ -26,6 +26,8 @@
 
 namespace ParaMEDMEM
 {
+  class MEDCouplingCurveLinearMesh;
+  
   class MEDCouplingCMesh : public MEDCouplingStructuredMesh
   {
   public:
@@ -33,6 +35,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT static MEDCouplingCMesh *New(const std::string& meshName);
     MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const;
     MEDCOUPLING_EXPORT MEDCouplingCMesh *clone(bool recDeepCpy) const;
+    MEDCOUPLING_EXPORT MEDCouplingCurveLinearMesh *buildCurveLinear() const;
     MEDCOUPLING_EXPORT void updateTime() const;
     MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
     MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
index 72d3a1fe320005f0c08468ccd84a2e823f83cb0a..709fd85cd70e1e182b85aacc5ddbd676a1ef3b2e 100644 (file)
@@ -3567,14 +3567,14 @@ DataArrayDouble *DataArrayDouble::accumulatePerChunck(const int *bgOfIndex, cons
 DataArrayDouble *DataArrayDouble::fromPolarToCart() const
 {
   checkAllocated();
-  int nbOfComp=getNumberOfComponents();
+  int nbOfComp(getNumberOfComponents());
   if(nbOfComp!=2)
     throw INTERP_KERNEL::Exception("DataArrayDouble::fromPolarToCart : must be an array with exactly 2 components !");
-  int nbOfTuple=getNumberOfTuples();
-  DataArrayDouble *ret=DataArrayDouble::New();
+  int nbOfTuple(getNumberOfTuples());
+  DataArrayDouble *ret(DataArrayDouble::New());
   ret->alloc(nbOfTuple,2);
-  double *w=ret->getPointer();
-  const double *wIn=getConstPointer();
+  double *w(ret->getPointer());
+  const double *wIn(getConstPointer());
   for(int i=0;i<nbOfTuple;i++,w+=2,wIn+=2)
     {
       w[0]=wIn[0]*cos(wIn[1]);
@@ -3597,14 +3597,14 @@ DataArrayDouble *DataArrayDouble::fromPolarToCart() const
 DataArrayDouble *DataArrayDouble::fromCylToCart() const
 {
   checkAllocated();
-  int nbOfComp=getNumberOfComponents();
+  int nbOfComp(getNumberOfComponents());
   if(nbOfComp!=3)
     throw INTERP_KERNEL::Exception("DataArrayDouble::fromCylToCart : must be an array with exactly 3 components !");
-  int nbOfTuple=getNumberOfTuples();
-  DataArrayDouble *ret=DataArrayDouble::New();
+  int nbOfTuple(getNumberOfTuples());
+  DataArrayDouble *ret(DataArrayDouble::New());
   ret->alloc(getNumberOfTuples(),3);
-  double *w=ret->getPointer();
-  const double *wIn=getConstPointer();
+  double *w(ret->getPointer());
+  const double *wIn(getConstPointer());
   for(int i=0;i<nbOfTuple;i++,w+=3,wIn+=3)
     {
       w[0]=wIn[0]*cos(wIn[1]);
@@ -3629,14 +3629,14 @@ DataArrayDouble *DataArrayDouble::fromCylToCart() const
 DataArrayDouble *DataArrayDouble::fromSpherToCart() const
 {
   checkAllocated();
-  int nbOfComp=getNumberOfComponents();
+  int nbOfComp(getNumberOfComponents());
   if(nbOfComp!=3)
     throw INTERP_KERNEL::Exception("DataArrayDouble::fromSpherToCart : must be an array with exactly 3 components !");
-  int nbOfTuple=getNumberOfTuples();
-  DataArrayDouble *ret=DataArrayDouble::New();
+  int nbOfTuple(getNumberOfTuples());
+  DataArrayDouble *ret(DataArrayDouble::New());
   ret->alloc(getNumberOfTuples(),3);
-  double *w=ret->getPointer();
-  const double *wIn=getConstPointer();
+  double *w(ret->getPointer());
+  const double *wIn(getConstPointer());
   for(int i=0;i<nbOfTuple;i++,w+=3,wIn+=3)
     {
       w[0]=wIn[0]*cos(wIn[2])*sin(wIn[1]);
@@ -3646,6 +3646,56 @@ DataArrayDouble *DataArrayDouble::fromSpherToCart() const
   return ret;
 }
 
+/*!
+ * This method returns a new array containing the same number of tuples than \a this. To do this, this method needs \a at parameter to specify the convention of \a this.
+ * All the tuples of the returned array will be in cartesian sense. So if \a at equals to AX_CART the returned array is basically a deep copy of \a this.
+ * If \a at equals to AX_CYL the returned array will be the result of operation cylindric to cartesian of \a this...
+ *
+ * \param [in] atOfThis - The axis type of \a this.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble (that must be dealed by caller) containing the result of the cartesianizification of \a this.
+ */
+DataArrayDouble *DataArrayDouble::cartesianize(MEDCouplingAxisType atOfThis) const
+{
+  checkAllocated();
+  int nbOfComp(getNumberOfComponents());
+  MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret;
+  switch(atOfThis)
+    {
+    case AX_CART:
+      ret=deepCpy();
+    case AX_CYL:
+      if(nbOfComp==3)
+        {
+          ret=fromCylToCart();
+          break;
+        }
+      if(nbOfComp==2)
+        {
+          ret=fromPolarToCart();
+          break;
+        }
+      else
+        throw INTERP_KERNEL::Exception("DataArrayDouble::cartesianize : For AX_CYL, number of components must be in [2,3] !");
+    case AX_SPHER:
+      if(nbOfComp==3)
+        {
+          ret=fromSpherToCart();
+          break;
+        }
+      if(nbOfComp==2)
+        {
+          ret=fromPolarToCart();
+          break;
+        }
+      else
+        throw INTERP_KERNEL::Exception("DataArrayDouble::cartesianize : For AX_CYL, number of components must be in [2,3] !");
+    default:
+      throw INTERP_KERNEL::Exception("DataArrayDouble::cartesianize : not recognized axis type ! Only AX_CART, AX_CYL and AX_SPHER supported !");
+    }
+  ret->copyStringInfoFrom(*this);
+  return ret.retn();
+}
+
 /*!
  * Computes the doubly contracted product of every tensor defined by the tuple of \a this
  * array contating 6 components.
@@ -3658,7 +3708,7 @@ DataArrayDouble *DataArrayDouble::fromSpherToCart() const
 DataArrayDouble *DataArrayDouble::doublyContractedProduct() const
 {
   checkAllocated();
-  int nbOfComp=getNumberOfComponents();
+  int nbOfComp(getNumberOfComponents());
   if(nbOfComp!=6)
     throw INTERP_KERNEL::Exception("DataArrayDouble::doublyContractedProduct : must be an array with exactly 6 components !");
   DataArrayDouble *ret=DataArrayDouble::New();
index 201b7601e96abd7bb6cdf57550b3474fe465a047..66bbb6bd96ee17f38bcd292855c2517936306845 100644 (file)
 
 namespace ParaMEDMEM
 {
+  typedef enum
+    {
+      AX_CART = 3,
+      AX_CYL = 4,
+      AX_SPHER = 5
+    } MEDCouplingAxisType;
+  // -- WARNING this enum must be synchronized with MEDCouplingCommon.i file ! --
+
   template<class T>
   class MEDCouplingPointer
   {
@@ -323,6 +331,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT DataArrayDouble *fromPolarToCart() const;
     MEDCOUPLING_EXPORT DataArrayDouble *fromCylToCart() const;
     MEDCOUPLING_EXPORT DataArrayDouble *fromSpherToCart() const;
+    MEDCOUPLING_EXPORT DataArrayDouble *cartesianize(MEDCouplingAxisType atOfThis) const;
     MEDCOUPLING_EXPORT DataArrayDouble *doublyContractedProduct() const;
     MEDCOUPLING_EXPORT DataArrayDouble *determinant() const;
     MEDCOUPLING_EXPORT DataArrayDouble *eigenValues() const;
index b4a20e705c3c0084322a592451e5a49205ef627b..b748be9817e56fa22ce646f3b8c4cd3b73934927 100644 (file)
@@ -65,6 +65,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT void setTimeUnit(const std::string& unit) { _time_unit=unit; }
     MEDCOUPLING_EXPORT std::string getTimeUnit() const { return _time_unit; }
     MEDCOUPLING_EXPORT virtual MEDCouplingMesh *deepCpy() const = 0;
+    MEDCOUPLING_EXPORT virtual MEDCouplingMesh *clone(bool recDeepCpy) const = 0;
     MEDCOUPLING_EXPORT virtual MEDCouplingMeshType getType() const = 0;
     MEDCOUPLING_EXPORT bool isStructured() const;
     MEDCOUPLING_EXPORT virtual void copyTinyStringsFrom(const MEDCouplingMesh *other);
index 5e4dc9a4ed28aa089d502e106e2d0e3b8497007d..cd110a8995d789462713fb414d89c2214c037546 100644 (file)
@@ -4214,6 +4214,43 @@ class MEDCouplingBasicsTest5(unittest.TestCase):
         self.assertTrue(d.isEqual(DataArrayInt([0]))) # <- bug was here
         pass
 
+    def testSwig2Cartesianize1(self):
+        """Test of engine of cartesianize mechanism in medcoupling"""
+        # cyl 2D
+        arr=DataArrayDouble([(3,0.2),(2,1.6)]) ; arr.setInfoOnComponents(["A","BB"])
+        arr2=arr.cartesianize(AX_CYL)
+        arr2_exp=DataArrayDouble([(2.940199733523725,0.5960079923851836),(-0.05839904460257763,1.9991472060830102)]) ; arr2_exp.setInfoOnComponents(["A","BB"])
+        self.assertTrue(arr2_exp.isEqual(arr2,1e-14))
+        # spher 2D
+        arr3=arr.cartesianize(AX_SPHER)
+        self.assertTrue(arr2_exp.isEqual(arr3,1e-14))
+        # cyl 3D
+        arr=DataArrayDouble([(3,0.2,7.1),(2,1.6,12.3)]) ; arr.setInfoOnComponents(["A","BB","CCC"])
+        arr4=arr.cartesianize(AX_CYL)
+        arr4_exp=DataArrayDouble([(2.940199733523725,0.5960079923851836,7.1),(-0.05839904460257763,1.9991472060830102,12.3)]) ; arr4_exp.setInfoOnComponents(["A","BB","CCC"])
+        self.assertTrue(arr4_exp.isEqual(arr4,1e-14))
+        # spher 3D
+        arr=DataArrayDouble([(3,0.2,0.5),(2,1.3,5.8)]) ; arr.setInfoOnComponents(["A","BB","CCC"])
+        arr5=arr.cartesianize(AX_SPHER)
+        arr5_exp=DataArrayDouble([(0.5230462208645272,0.2857414527616764,2.940199733523725),(1.706499157790973,-0.8953424658735863,0.5349976572491747)]) ; arr5_exp.setInfoOnComponents(["A","BB","CCC"])
+        self.assertTrue(arr5_exp.isEqual(arr5,1e-14))
+        #
+        m=MEDCouplingCMesh() ; m.setName("aa") ; m.setDescription("bbb") ; m.setTime(4.125,5,6) ; m.setTimeUnit("ms")
+        arrX=DataArrayDouble([0,1,2]) ; arrX.setInfoOnComponent(0,"ccc")
+        arrY=DataArrayDouble([3,4,5,6]) ; arrY.setInfoOnComponent(0,"dddd")
+        m.setCoords(arrX,arrY)
+        m2=m.buildCurveLinear()
+        #
+        self.assertTrue(isinstance(m2,MEDCouplingCurveLinearMesh))
+        self.assertEqual(m2.getName(),"aa")
+        self.assertEqual(m2.getDescription(),"bbb")
+        self.assertEqual(m2.getTime(),[4.125,5,6])
+        self.assertEqual(m2.getTimeUnit(),"ms")
+        m2c_exp=DataArrayDouble([(0.,3.),(1.,3.),(2.,3.),(0.,4.),(1.,4.),(2.,4.),(0.,5.),(1.,5.),(2.,5.),(0.,6.),(1.,6.),(2.,6.)]) ; m2c_exp.setInfoOnComponents(["ccc","dddd"])
+        self.assertTrue(m2.getCoords().isEqual(m2c_exp,1e-14))
+        self.assertEqual(m2.getNodeGridStructure(),(3,4))
+        pass
+
     pass
 
 if __name__ == '__main__':
index 8f1717456a1d5fded43745877c8181c9d90f996b..6a6f64d0ea51c7fbb14e413c8bfbe848c2007e46 100644 (file)
@@ -230,6 +230,7 @@ using namespace INTERP_KERNEL;
 %newobject ParaMEDMEM::MEDCouplingFieldDouble::getValueOnMulti;
 %newobject ParaMEDMEM::MEDCouplingFieldTemplate::New;
 %newobject ParaMEDMEM::MEDCouplingMesh::deepCpy;
+%newobject ParaMEDMEM::MEDCouplingMesh::clone;
 %newobject ParaMEDMEM::MEDCouplingMesh::checkDeepEquivalOnSameNodesWith;
 %newobject ParaMEDMEM::MEDCouplingMesh::checkTypeConsistencyAndContig;
 %newobject ParaMEDMEM::MEDCouplingMesh::computeNbOfNodesPerCell;
@@ -270,7 +271,6 @@ using namespace INTERP_KERNEL;
 %newobject ParaMEDMEM::MEDCouplingUMesh::New;
 %newobject ParaMEDMEM::MEDCouplingUMesh::getNodalConnectivity;
 %newobject ParaMEDMEM::MEDCouplingUMesh::getNodalConnectivityIndex;
-%newobject ParaMEDMEM::MEDCouplingUMesh::clone;
 %newobject ParaMEDMEM::MEDCouplingUMesh::__iter__;
 %newobject ParaMEDMEM::MEDCouplingUMesh::cellsByType;
 %newobject ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity;
@@ -347,14 +347,13 @@ using namespace INTERP_KERNEL;
 %newobject ParaMEDMEM::MEDCouplingStructuredMesh::Build1GTNodalConnectivityOfSubLevelMesh;
 %newobject ParaMEDMEM::MEDCouplingStructuredMesh::ComputeCornersGhost;
 %newobject ParaMEDMEM::MEDCouplingCMesh::New;
-%newobject ParaMEDMEM::MEDCouplingCMesh::clone;
 %newobject ParaMEDMEM::MEDCouplingCMesh::getCoordsAt;
+%newobject ParaMEDMEM::MEDCouplingCMesh::buildCurveLinear;
 %newobject ParaMEDMEM::MEDCouplingIMesh::New;
 %newobject ParaMEDMEM::MEDCouplingIMesh::asSingleCell;
 %newobject ParaMEDMEM::MEDCouplingIMesh::buildWithGhost;
 %newobject ParaMEDMEM::MEDCouplingIMesh::convertToCartesian;
 %newobject ParaMEDMEM::MEDCouplingCurveLinearMesh::New;
-%newobject ParaMEDMEM::MEDCouplingCurveLinearMesh::clone;
 %newobject ParaMEDMEM::MEDCouplingCurveLinearMesh::getCoords;
 %newobject ParaMEDMEM::MEDCouplingMultiFields::New;
 %newobject ParaMEDMEM::MEDCouplingMultiFields::deepCpy;
@@ -554,7 +553,8 @@ namespace ParaMEDMEM
     std::string getTimeUnit() const;
     virtual MEDCouplingMeshType getType() const throw(INTERP_KERNEL::Exception);
     bool isStructured() const throw(INTERP_KERNEL::Exception);
-    virtual MEDCouplingMesh *deepCpy() const;
+    virtual MEDCouplingMesh *deepCpy() const throw(INTERP_KERNEL::Exception);
+    virtual MEDCouplingMesh *clone(bool recDeepCpy) const throw(INTERP_KERNEL::Exception);
     virtual bool isEqual(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception);
     virtual bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception);
     virtual void checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception);
@@ -1758,7 +1758,6 @@ namespace ParaMEDMEM
   public:
     static MEDCouplingUMesh *New() throw(INTERP_KERNEL::Exception);
     static MEDCouplingUMesh *New(const char *meshName, int meshDim) throw(INTERP_KERNEL::Exception);
-    MEDCouplingUMesh *clone(bool recDeepCpy) const;
     void checkCoherency() const throw(INTERP_KERNEL::Exception);
     void setMeshDimension(int meshDim) throw(INTERP_KERNEL::Exception);
     void allocateCells(int nbOfCells=0) throw(INTERP_KERNEL::Exception);
@@ -3320,6 +3319,8 @@ namespace ParaMEDMEM
     }
   };
 
+  class MEDCouplingCurveLinearMesh;
+
   //== MEDCouplingCMesh
   
   class MEDCouplingCMesh : public ParaMEDMEM::MEDCouplingStructuredMesh
@@ -3327,11 +3328,11 @@ namespace ParaMEDMEM
   public:
     static MEDCouplingCMesh *New() throw(INTERP_KERNEL::Exception);
     static MEDCouplingCMesh *New(const std::string& meshName) throw(INTERP_KERNEL::Exception);
-    MEDCouplingCMesh *clone(bool recDeepCpy) const;
     void setCoords(const DataArrayDouble *coordsX,
                    const DataArrayDouble *coordsY=0,
                    const DataArrayDouble *coordsZ=0) throw(INTERP_KERNEL::Exception);
     void setCoordsAt(int i, const DataArrayDouble *arr) throw(INTERP_KERNEL::Exception);
+    MEDCouplingCurveLinearMesh *buildCurveLinear() const throw(INTERP_KERNEL::Exception);
     %extend {
       MEDCouplingCMesh() throw(INTERP_KERNEL::Exception)
       {
@@ -3375,7 +3376,6 @@ namespace ParaMEDMEM
   public:
     static MEDCouplingCurveLinearMesh *New() throw(INTERP_KERNEL::Exception);
     static MEDCouplingCurveLinearMesh *New(const std::string& meshName) throw(INTERP_KERNEL::Exception);
-    MEDCouplingCurveLinearMesh *clone(bool recDeepCpy) const;
     void setCoords(const DataArrayDouble *coords) throw(INTERP_KERNEL::Exception);
     %extend {
       MEDCouplingCurveLinearMesh() throw(INTERP_KERNEL::Exception)
index 3e4010867a2cb4537847020b86776a334c68ed88..e47f1e1f2ac02820ee486cc052d4e5ee6753d535 100644 (file)
 %newobject ParaMEDMEM::DataArrayDouble::fromPolarToCart;
 %newobject ParaMEDMEM::DataArrayDouble::fromCylToCart;
 %newobject ParaMEDMEM::DataArrayDouble::fromSpherToCart;
+%newobject ParaMEDMEM::DataArrayDouble::cartesianize;
 %newobject ParaMEDMEM::DataArrayDouble::getDifferentValues;
 %newobject ParaMEDMEM::DataArrayDouble::findClosestTupleId;
 %newobject ParaMEDMEM::DataArrayDouble::computeNbOfInteractionsWith;
 
 namespace ParaMEDMEM
 {
+  typedef enum
+    {
+      AX_CART = 3,
+      AX_CYL = 4,
+      AX_SPHER = 5
+    } MEDCouplingAxisType;
+
   class DataArray : public RefCountObject, public TimeLabel
   {
   public:
@@ -580,6 +588,7 @@ namespace ParaMEDMEM
     DataArrayDouble *fromPolarToCart() const throw(INTERP_KERNEL::Exception);
     DataArrayDouble *fromCylToCart() const throw(INTERP_KERNEL::Exception);
     DataArrayDouble *fromSpherToCart() const throw(INTERP_KERNEL::Exception);
+    DataArrayDouble *cartesianize(MEDCouplingAxisType atOfThis) const throw(INTERP_KERNEL::Exception);
     DataArrayDouble *doublyContractedProduct() const throw(INTERP_KERNEL::Exception);
     DataArrayDouble *determinant() const throw(INTERP_KERNEL::Exception);
     DataArrayDouble *eigenValues() const throw(INTERP_KERNEL::Exception);
index f9ac17e960b23947fb11fd5e0c26a9867056f178..6c5bd3afe0b5735eb3618c341c38a004cd881f5e 100644 (file)
@@ -39,7 +39,7 @@ using namespace ParaMEDMEM;
 
 const char MEDFileMesh::DFT_FAM_NAME[]="FAMILLE_ZERO";
 
-MEDFileMesh::MEDFileMesh():_order(-1),_iteration(-1),_time(0.),_univ_wr_status(true)
+MEDFileMesh::MEDFileMesh():_order(-1),_iteration(-1),_time(0.),_univ_wr_status(true),_axis_type(AX_CART)
 {
 }
 
@@ -87,7 +87,8 @@ MEDFileMesh *MEDFileMesh::New(const std::string& fileName, MEDFileMeshReadSelect
   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
   int dt,it;
   std::string dummy2;
-  MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dt,it,dummy2);
+  ParaMEDMEM::MEDCouplingAxisType dummy3;
+  MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dummy3,dt,it,dummy2);
   MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> ret;
   switch(meshType)
   {
@@ -140,7 +141,8 @@ MEDFileMesh *MEDFileMesh::New(const std::string& fileName, const std::string& mN
   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
   int dummy0,dummy1;
   std::string dummy2;
-  MEDFileMeshL2::GetMeshIdFromName(fid,mName,meshType,dummy0,dummy1,dummy2);
+  ParaMEDMEM::MEDCouplingAxisType dummy3;
+  MEDFileMeshL2::GetMeshIdFromName(fid,mName,meshType,dummy3,dummy0,dummy1,dummy2);
   MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> ret;
   switch(meshType)
   {
@@ -2176,7 +2178,8 @@ MEDFileUMesh *MEDFileUMesh::New(const std::string& fileName, MEDFileMeshReadSele
   int dt,it;
   ParaMEDMEM::MEDCouplingMeshType meshType;
   std::string dummy2;
-  MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dt,it,dummy2);
+  ParaMEDMEM::MEDCouplingAxisType dummy3;
+  MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dummy3,dt,it,dummy2);
   return new MEDFileUMesh(fid,ms.front(),dt,it,mrs);
 }
 
@@ -2247,7 +2250,7 @@ std::vector<const BigMemoryObject *> MEDFileUMesh::getDirectChildrenWithNull() c
 
 MEDFileMesh *MEDFileUMesh::shallowCpy() const
 {
-  MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> ret=new MEDFileUMesh(*this);
+  MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> ret(new MEDFileUMesh(*this));
   return ret.retn();
 }
 
@@ -2258,7 +2261,7 @@ MEDFileMesh *MEDFileUMesh::createNewEmpty() const
 
 MEDFileMesh *MEDFileUMesh::deepCpy() const
 {
-  MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> ret=new MEDFileUMesh(*this);
+  MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> ret(new MEDFileUMesh(*this));
   ret->deepCpyEquivalences(*this);
   if((const DataArrayDouble*)_coords)
     ret->_coords=_coords->deepCpy();
@@ -2457,7 +2460,8 @@ void MEDFileUMesh::loadPartUMeshFromFile(med_idt fid, const std::string& mName,
   ParaMEDMEM::MEDCouplingMeshType meshType;
   int dummy0,dummy1;
   std::string dummy2;
-  int mid(MEDFileUMeshL2::GetMeshIdFromName(fid,mName,meshType,dummy0,dummy1,dummy2));
+  ParaMEDMEM::MEDCouplingAxisType dummy3;
+  int mid(MEDFileUMeshL2::GetMeshIdFromName(fid,mName,meshType,dummy3,dummy0,dummy1,dummy2));
   if(meshType!=UNSTRUCTURED)
     {
       std::ostringstream oss; oss << "loadPartUMeshFromFile : Trying to load as unstructured an existing mesh with name '" << mName << "' !";
@@ -2571,7 +2575,9 @@ void MEDFileUMesh::loadLL(med_idt fid, const std::string& mName, int dt, int it,
   ParaMEDMEM::MEDCouplingMeshType meshType;
   int dummy0,dummy1;
   std::string dummy2;
-  int mid(MEDFileUMeshL2::GetMeshIdFromName(fid,mName,meshType,dummy0,dummy1,dummy2));
+  ParaMEDMEM::MEDCouplingAxisType axType;
+  int mid(MEDFileUMeshL2::GetMeshIdFromName(fid,mName,meshType,axType,dummy0,dummy1,dummy2));
+  setAxType(axType);
   if(meshType!=UNSTRUCTURED)
     {
       std::ostringstream oss; oss << "Trying to load as unstructured an existing mesh with name '" << mName << "' !";
@@ -2637,7 +2643,7 @@ void MEDFileUMesh::writeLL(med_idt fid) const
       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
     }
-  MEDFILESAFECALLERWR0(MEDmeshCr,(fid,maa,spaceDim,mdim,MED_UNSTRUCTURED_MESH,desc,"",MED_SORT_DTIT,MED_CARTESIAN,comp,unit));
+  MEDFILESAFECALLERWR0(MEDmeshCr,(fid,maa,spaceDim,mdim,MED_UNSTRUCTURED_MESH,desc,"",MED_SORT_DTIT,MEDFileMeshL2::TraduceAxisTypeRev(getAxType()),comp,unit));
   if(_univ_wr_status)
     MEDFILESAFECALLERWR0(MEDmeshUniversalNameWr,(fid,maa));
   std::string meshName(MEDLoaderBase::buildStringFromFortran(maa,MED_NAME_SIZE));
@@ -3140,6 +3146,28 @@ void MEDFileUMesh::whichAreNodesFetched(const MEDFileField1TSStructItem& st, con
     }
 }
 
+MEDFileMesh *MEDFileUMesh::cartesianize() const
+{
+  if(getAxType()==AX_CART)
+    {
+      incrRef();
+      return const_cast<MEDFileUMesh *>(this);
+    }
+  else
+    {
+      MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> ret(new MEDFileUMesh(*this));
+      const DataArrayDouble *coords(_coords);
+      if(!coords)
+        throw INTERP_KERNEL::Exception("MEDFileUMesh::cartesianize : coordinates are null !");
+      MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsCart(_coords->cartesianize(getAxType()));
+      for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::iterator it=ret->_ms.begin();it!=ret->_ms.end();it++)
+        if((const MEDFileUMeshSplitL1 *)(*it))
+          *it=(*it)->shallowCpyUsingCoords(coordsCart);
+      ret->_coords=coordsCart;
+      return ret.retn();
+    }
+}
+
 /*!
  * Returns the optional numbers of mesh entities of a given dimension transformed using
  * DataArrayInt::invertArrayN2O2O2N().
@@ -3581,6 +3609,8 @@ void MEDFileUMesh::setCoords(DataArrayDouble *coords)
 {
   if(!coords)
     throw INTERP_KERNEL::Exception("MEDFileUMesh::setCoords : null pointer in input !");
+  if(coords==(DataArrayDouble *)_coords)
+    return ;
   coords->checkAllocated();
   int nbOfTuples=coords->getNumberOfTuples();
   _coords=coords;
@@ -4208,21 +4238,22 @@ void MEDFileUMesh::serialize(std::vector<double>& tinyDouble, std::vector<int>&
   forceComputationOfParts();
   tinyDouble.clear(); tinyInt.clear(); tinyStr.clear(); bigArraysI.clear(); bigArrayD=0;
   std::vector<int> layer0;
-  layer0.push_back(_order); //0 i
-  layer0.push_back(_iteration);//1 i
-  layer0.push_back(getSpaceDimension());//2 i
+  layer0.push_back(getAxType());//0 i
+  layer0.push_back(_order); //1 i
+  layer0.push_back(_iteration);//2 i
+  layer0.push_back(getSpaceDimension());//3 i
   tinyDouble.push_back(_time);//0 d
   tinyStr.push_back(_name);//0 s
   tinyStr.push_back(_desc_name);//1 s
   for(int i=0;i<getSpaceDimension();i++)
     tinyStr.push_back(_coords->getInfoOnComponent(i));
-  layer0.push_back((int)_families.size());//3 i <- key info aa layer#0
+  layer0.push_back((int)_families.size());//4 i <- key info aa layer#0
   for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
     {
       tinyStr.push_back((*it).first);
       layer0.push_back((*it).second);
     }
-  layer0.push_back((int)_groups.size());//3+aa i <- key info bb layer#0
+  layer0.push_back((int)_groups.size());//4+aa i <- key info bb layer#0
   for(std::map<std::string, std::vector<std::string> >::const_iterator it0=_groups.begin();it0!=_groups.end();it0++)
     {
       layer0.push_back((int)(*it0).second.size());
@@ -4230,7 +4261,7 @@ void MEDFileUMesh::serialize(std::vector<double>& tinyDouble, std::vector<int>&
       for(std::vector<std::string>::const_iterator it1=((*it0).second).begin();it1!=((*it0).second).end();it1++)
         tinyStr.push_back(*it1);
     }
-  // sizeof(layer0)==3+aa+1+bb layer#0
+  // sizeof(layer0)==4+aa+1+bb layer#0
   bigArrayD=_coords;// 0 bd
   bigArraysI.push_back(_fam_coords);// 0 bi
   bigArraysI.push_back(_num_coords);// 1 bi
@@ -4275,6 +4306,7 @@ void MEDFileUMesh::unserialize(std::vector<double>& tinyDouble, std::vector<int>
   std::reverse(tinyStr.begin(),tinyStr.end());
   std::reverse(bigArraysI.begin(),bigArraysI.end());
   //
+  setAxType((MEDCouplingAxisType)layer0.back()); layer0.pop_back();
   _order=layer0.back(); layer0.pop_back();
   _iteration=layer0.back(); layer0.pop_back();
   int spaceDim(layer0.back()); layer0.pop_back();
@@ -5947,7 +5979,8 @@ MEDFileCMesh *MEDFileCMesh::New(const std::string& fileName, MEDFileMeshReadSele
   int dt,it;
   ParaMEDMEM::MEDCouplingMeshType meshType;
   std::string dummy2;
-  MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dt,it,dummy2);
+  ParaMEDMEM::MEDCouplingAxisType dummy3;
+  MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dummy3,dt,it,dummy2);
   return new MEDFileCMesh(fid,ms.front(),dt,it,mrs);
 }
 
@@ -6028,7 +6061,7 @@ std::string MEDFileCMesh::advancedRepr() const
 
 MEDFileMesh *MEDFileCMesh::shallowCpy() const
 {
-  MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> ret=new MEDFileCMesh(*this);
+  MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> ret(new MEDFileCMesh(*this));
   return ret.retn();
 }
 
@@ -6039,7 +6072,7 @@ MEDFileMesh *MEDFileCMesh::createNewEmpty() const
 
 MEDFileMesh *MEDFileCMesh::deepCpy() const
 {
-  MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> ret=new MEDFileCMesh(*this);
+  MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> ret(new MEDFileCMesh(*this));
   ret->deepCpyEquivalences(*this);
   if((const MEDCouplingCMesh*)_cmesh)
     ret->_cmesh=static_cast<MEDCouplingCMesh*>(_cmesh->deepCpy());
@@ -6113,7 +6146,8 @@ void MEDFileCMesh::loadLL(med_idt fid, const std::string& mName, int dt, int it,
   ParaMEDMEM::MEDCouplingMeshType meshType;
   int dummy0,dummy1;
   std::string dtunit;
-  int mid=MEDFileMeshL2::GetMeshIdFromName(fid,mName,meshType,dummy0,dummy1,dtunit);
+  ParaMEDMEM::MEDCouplingAxisType axType;
+  int mid=MEDFileMeshL2::GetMeshIdFromName(fid,mName,meshType,axType,dummy0,dummy1,dtunit);
   if(meshType!=CARTESIAN)
     {
       std::ostringstream oss; oss << "Trying to load as cartesian an existing mesh with name '" << mName << "' that is NOT cartesian !";
@@ -6121,6 +6155,7 @@ void MEDFileCMesh::loadLL(med_idt fid, const std::string& mName, int dt, int it,
     }
   MEDFileCMeshL2 loaderl2;
   loaderl2.loadAll(fid,mid,mName,dt,it);
+  setAxType(loaderl2.getAxType());
   MEDCouplingCMesh *mesh=loaderl2.getMesh();
   mesh->incrRef();
   _cmesh=mesh;
@@ -6157,6 +6192,28 @@ void MEDFileCMesh::setMesh(MEDCouplingCMesh *m)
   _cmesh=m;
 }
 
+MEDFileMesh *MEDFileCMesh::cartesianize() const
+{
+  if(getAxType()==AX_CART)
+    {
+      incrRef();
+      return const_cast<MEDFileCMesh *>(this);
+    }
+  else
+    {
+      const MEDCouplingCMesh *cmesh(getMesh());
+      if(!cmesh)
+        throw INTERP_KERNEL::Exception("MEDFileCMesh::cartesianize : impossible to turn into cartesian because the mesh is null !");
+      MEDCouplingAutoRefCountObjectPtr<MEDCouplingCurveLinearMesh> clmesh(cmesh->buildCurveLinear());
+      MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coords(clmesh->getCoords()->cartesianize(getAxType()));
+      clmesh->setCoords(coords);
+      MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> ret(MEDFileCurveLinearMesh::New());
+      ret->MEDFileStructuredMesh::operator=(*this);
+      ret->setMesh(clmesh);
+      return ret.retn();
+    }
+}
+
 void MEDFileCMesh::writeLL(med_idt fid) const
 {
   INTERP_KERNEL::AutoPtr<char> maa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
@@ -6176,10 +6233,11 @@ void MEDFileCMesh::writeLL(med_idt fid) const
       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
     }
+  // MED_CARTESIAN and not MEDFileMeshL2::TraduceAxisTypeRev(getAxType()) ! Yes it is not a bug. The discrimination is done in MEDmeshGridTypeWr.
   MEDFILESAFECALLERWR0(MEDmeshCr,(fid,maa,spaceDim,spaceDim,MED_STRUCTURED_MESH,desc,dtunit,MED_SORT_DTIT,MED_CARTESIAN,comp,unit));
   if(_univ_wr_status)
     MEDFILESAFECALLERWR0(MEDmeshUniversalNameWr,(fid,maa));
-  MEDFILESAFECALLERWR0(MEDmeshGridTypeWr,(fid,maa,MED_CARTESIAN_GRID));
+  MEDFILESAFECALLERWR0(MEDmeshGridTypeWr,(fid,maa,MEDFileMeshL2::TraduceAxisTypeRevStruct(getAxType())));
   for(int i=0;i<spaceDim;i++)
     {
       const DataArrayDouble *da=_cmesh->getCoordsAt(i);
@@ -6218,8 +6276,9 @@ MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(const std::string& fileName,
   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
   int dt,it;
   ParaMEDMEM::MEDCouplingMeshType meshType;
+  ParaMEDMEM::MEDCouplingAxisType dummy3;
   std::string dummy2;
-  MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dt,it,dummy2);
+  MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dummy3,dt,it,dummy2);
   return new MEDFileCurveLinearMesh(fid,ms.front(),dt,it,mrs);
 }
 
@@ -6244,7 +6303,7 @@ std::vector<const BigMemoryObject *> MEDFileCurveLinearMesh::getDirectChildrenWi
 
 MEDFileMesh *MEDFileCurveLinearMesh::shallowCpy() const
 {
-  MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> ret=new MEDFileCurveLinearMesh(*this);
+  MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> ret(new MEDFileCurveLinearMesh(*this));
   return ret.retn();
 }
 
@@ -6255,7 +6314,7 @@ MEDFileMesh *MEDFileCurveLinearMesh::createNewEmpty() const
 
 MEDFileMesh *MEDFileCurveLinearMesh::deepCpy() const
 {
-  MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> ret=new MEDFileCurveLinearMesh(*this);
+  MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> ret(new MEDFileCurveLinearMesh(*this));
   ret->deepCpyEquivalences(*this);
   if((const MEDCouplingCurveLinearMesh*)_clmesh)
     ret->_clmesh=static_cast<MEDCouplingCurveLinearMesh*>(_clmesh->deepCpy());
@@ -6342,6 +6401,30 @@ void MEDFileCurveLinearMesh::setMesh(MEDCouplingCurveLinearMesh *m)
   _clmesh=m;
 }
 
+MEDFileMesh *MEDFileCurveLinearMesh::cartesianize() const
+{
+  if(getAxType()==AX_CART)
+    {
+      incrRef();
+      return const_cast<MEDFileCurveLinearMesh *>(this);
+    }
+  else
+    {
+      const MEDCouplingCurveLinearMesh *mesh(getMesh());
+      if(!mesh)
+        throw INTERP_KERNEL::Exception("MEDFileCurveLinearMesh::cartesianize : impossible to turn into cartesian because the mesh is null !");
+      const DataArrayDouble *coords(mesh->getCoords());
+      if(!coords)
+        throw INTERP_KERNEL::Exception("MEDFileCurveLinearMesh::cartesianize : coordinate pointer in mesh is null !");
+      MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> ret(new MEDFileCurveLinearMesh(*this));
+      MEDCouplingAutoRefCountObjectPtr<MEDCouplingCurveLinearMesh> mesh2(mesh->clone(false));
+      MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsCart(coords->cartesianize(getAxType()));
+      mesh2->setCoords(coordsCart);
+      ret->setMesh(mesh2);
+      return ret.retn();
+    }
+}
+
 const MEDCouplingStructuredMesh *MEDFileCurveLinearMesh::getStructuredMesh() const
 {
   synchronizeTinyInfoOnLeaves();
@@ -6385,7 +6468,7 @@ void MEDFileCurveLinearMesh::writeLL(med_idt fid) const
       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
     }
-  MEDFILESAFECALLERWR0(MEDmeshCr,(fid,maa,spaceDim,meshDim,MED_STRUCTURED_MESH,desc,dtunit,MED_SORT_DTIT,MED_CARTESIAN,comp,unit));
+  MEDFILESAFECALLERWR0(MEDmeshCr,(fid,maa,spaceDim,meshDim,MED_STRUCTURED_MESH,desc,dtunit,MED_SORT_DTIT,MEDFileMeshL2::TraduceAxisTypeRev(getAxType()),comp,unit));
   if(_univ_wr_status)
     MEDFILESAFECALLERWR0(MEDmeshUniversalNameWr,(fid,maa));
   MEDFILESAFECALLERWR0(MEDmeshGridTypeWr,(fid,maa,MED_CURVILINEAR_GRID));
@@ -6403,7 +6486,9 @@ void MEDFileCurveLinearMesh::loadLL(med_idt fid, const std::string& mName, int d
   ParaMEDMEM::MEDCouplingMeshType meshType;
   int dummy0,dummy1;
   std::string dtunit;
-  int mid=MEDFileMeshL2::GetMeshIdFromName(fid,mName,meshType,dummy0,dummy1,dtunit);
+  ParaMEDMEM::MEDCouplingAxisType axType;
+  int mid=MEDFileMeshL2::GetMeshIdFromName(fid,mName,meshType,axType,dummy0,dummy1,dtunit);
+  setAxType(axType);
   if(meshType!=CURVE_LINEAR)
     {
       std::ostringstream oss; oss << "Trying to load as curve linear an existing mesh with name '" << mName << "' that is NOT curve linear !";
@@ -6484,6 +6569,19 @@ bool MEDFileMeshMultiTS::changeNames(const std::vector< std::pair<std::string,st
   return ret;
 }
 
+void MEDFileMeshMultiTS::cartesianizeMe()
+{
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> >::iterator it=_mesh_one_ts.begin();it!=_mesh_one_ts.end();it++)
+    {
+      MEDFileMesh *cur(*it);
+      if(cur)
+        {
+          MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> ccur(cur->cartesianize());// Attention ! Do not wrap these two lines because memory leak !
+          *it=ccur;
+        }
+    }
+}
+
 MEDFileMesh *MEDFileMeshMultiTS::getOneTimeStep() const
 {
   if(_mesh_one_ts.empty())
@@ -6578,7 +6676,8 @@ try
     int dt,it;
     ParaMEDMEM::MEDCouplingMeshType meshType;
     std::string dummy2;
-    MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dt,it,dummy2);
+    ParaMEDMEM::MEDCouplingAxisType dummy3;
+    MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dummy3,dt,it,dummy2);
     loadFromFile(fileName,ms.front());
 }
 catch(INTERP_KERNEL::Exception& e)
@@ -6680,16 +6779,6 @@ std::vector<std::string> MEDFileMeshes::getMeshesNames() const
     }
   return ret;
 }
-/*const MEDFileJoints* MEDFileMeshes::getJoints() const
-{
-  const MEDFileJoints *ret=_joints;
-  if(!ret)
-  {
-    std::ostringstream oss; oss << "MEDFileMeshes::getJoints : joints is not defined !";
-    throw INTERP_KERNEL::Exception(oss.str().c_str());
-  }
-  return ret;
-}*/
 
 bool MEDFileMeshes::changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
 {
@@ -6703,6 +6792,16 @@ bool MEDFileMeshes::changeNames(const std::vector< std::pair<std::string,std::st
   return ret;
 }
 
+void MEDFileMeshes::cartesianizeMe()
+{
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS> >::iterator it=_meshes.begin();it!=_meshes.end();it++)
+    {
+      MEDFileMeshMultiTS *cur(*it);
+      if(cur)
+        cur->cartesianizeMe();
+    }
+}
+
 void MEDFileMeshes::resize(int newSize)
 {
   _meshes.resize(newSize);
index fd7992c4097079bd3c438bbca878aea2afa95f80..acbf042b10b2930b75adf83da08cf99cca4a81aa 100644 (file)
@@ -67,6 +67,8 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT double getTimeValue() const { return _time; }
     MEDLOADER_EXPORT void setTimeUnit(const std::string& unit) { _dt_unit=unit; }
     MEDLOADER_EXPORT std::string getTimeUnit() const { return _dt_unit; }
+    MEDLOADER_EXPORT void setAxType(MEDCouplingAxisType at) { _axis_type=at; }
+    MEDLOADER_EXPORT MEDCouplingAxisType getAxType() const { return _axis_type; }
     MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
     MEDLOADER_EXPORT virtual int getNumberOfNodes() const = 0;
     MEDLOADER_EXPORT virtual int getNumberOfCellsAtLevel(int meshDimRelToMaxExt) const = 0;
@@ -86,6 +88,7 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT virtual MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const = 0;
     MEDLOADER_EXPORT virtual std::vector<int> getDistributionOfTypes(int meshDimRelToMax) const;
     MEDLOADER_EXPORT virtual void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const = 0;
+    MEDLOADER_EXPORT virtual MEDFileMesh *cartesianize() const = 0;
     //
     MEDLOADER_EXPORT bool areFamsEqual(const MEDFileMesh *other, std::string& what) const;
     MEDLOADER_EXPORT bool areGrpsEqual(const MEDFileMesh *other, std::string& what) const;
@@ -217,6 +220,7 @@ namespace ParaMEDMEM
     mutable std::string _univ_name;
     bool _univ_wr_status;
     std::string _desc_name;
+    MEDCouplingAxisType _axis_type;
     MEDCouplingAutoRefCountObjectPtr<MEDFileJoints> _joints;
     MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalences> _equiv;
   protected:
@@ -266,6 +270,7 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypesAtLevel(int meshDimRelToMax) const;
     MEDLOADER_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const;
     MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const;
+    MEDLOADER_EXPORT MEDFileMesh *cartesianize() const;
     MEDLOADER_EXPORT std::vector<int> getNonEmptyLevels() const;
     MEDLOADER_EXPORT std::vector<int> getNonEmptyLevelsExt() const;
     MEDLOADER_EXPORT std::vector<int> getFamArrNonEmptyLevelsExt() const;
@@ -443,6 +448,7 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT void clearNonDiscrAttributes() const;
     MEDLOADER_EXPORT const MEDCouplingCMesh *getMesh() const;
     MEDLOADER_EXPORT void setMesh(MEDCouplingCMesh *m);
+    MEDLOADER_EXPORT MEDFileMesh *cartesianize() const;
   private:
     ~MEDFileCMesh() { }
     const MEDCouplingStructuredMesh *getStructuredMesh() const;
@@ -474,6 +480,7 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT void clearNonDiscrAttributes() const;
     MEDLOADER_EXPORT const MEDCouplingCurveLinearMesh *getMesh() const;
     MEDLOADER_EXPORT void setMesh(MEDCouplingCurveLinearMesh *m);
+    MEDLOADER_EXPORT MEDFileMesh *cartesianize() const;
   private:
     ~MEDFileCurveLinearMesh() { }
     MEDFileCurveLinearMesh();
@@ -498,12 +505,13 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT std::string getName() const;
     MEDLOADER_EXPORT void setName(const std::string& newMeshName);
     MEDLOADER_EXPORT bool changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
+    MEDLOADER_EXPORT void cartesianizeMe();
     MEDLOADER_EXPORT MEDFileMesh *getOneTimeStep() const;
     MEDLOADER_EXPORT void write(med_idt fid) const;
     MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
     MEDLOADER_EXPORT void setOneTimeStep(MEDFileMesh *mesh1TimeStep);
     MEDLOADER_EXPORT MEDFileJoints *getJoints() const;
-    MEDLOADER_EXPORT void                 setJoints( MEDFileJoints* joints );
+    MEDLOADER_EXPORT void setJoints(MEDFileJoints* joints);
   private:
     ~MEDFileMeshMultiTS() { }
     void loadFromFile(const std::string& fileName, const std::string& mName);
@@ -534,6 +542,7 @@ namespace ParaMEDMEM
     MEDLOADER_EXPORT MEDFileMesh *getMeshWithName(const std::string& mname) const;
     MEDLOADER_EXPORT std::vector<std::string> getMeshesNames() const;
     MEDLOADER_EXPORT bool changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
+    MEDLOADER_EXPORT void cartesianizeMe();
     //
     MEDLOADER_EXPORT void resize(int newSize);
     MEDLOADER_EXPORT void pushMesh(MEDFileMesh *mesh);
index 22626830aecb443972345aec32f6454a57b72529..92dd11f205e79a1dede3dcc662647b23eb2a4b67 100644 (file)
@@ -56,7 +56,7 @@ std::vector<const BigMemoryObject *> MEDFileMeshL2::getDirectChildrenWithNull()
   return std::vector<const BigMemoryObject *>();
 }
 
-int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const std::string& mname, ParaMEDMEM::MEDCouplingMeshType& meshType, int& dt, int& it, std::string& dtunit1)
+int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const std::string& mname, ParaMEDMEM::MEDCouplingMeshType& meshType, ParaMEDMEM::MEDCouplingAxisType& axType, int& dt, int& it, std::string& dtunit1)
 {
   med_mesh_type type_maillage;
   char maillage_description[MED_COMMENT_SIZE+1];
@@ -76,6 +76,7 @@ int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const std::string& mname, Para
       INTERP_KERNEL::AutoPtr<char> axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
       INTERP_KERNEL::AutoPtr<char> axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
       MEDFILESAFECALLERRD0(MEDmeshInfo,(fid,i+1,nommaa,&spaceDim,&dim,&type_maillage,maillage_description,dtunit,&stype,&nstep,&axistype,axisname,axisunit));
+      
       dtunit1=MEDLoaderBase::buildStringFromFortran(dtunit,sizeof(dtunit));
       std::string cur=MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa));
       ms.push_back(cur);
@@ -92,6 +93,7 @@ int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const std::string& mname, Para
       std::copy(ms.begin(),ms.end(),std::ostream_iterator<std::string>(oss,", "));
       throw INTERP_KERNEL::Exception(oss.str().c_str());
     }
+  axType=TraduceAxisType(axistype);
   switch(type_maillage)
   {
     case MED_UNSTRUCTURED_MESH:
@@ -109,13 +111,16 @@ int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const std::string& mname, Para
           case MED_CURVILINEAR_GRID:
             meshType=CURVE_LINEAR;
             break;
+          case MED_POLAR_GRID:// this is not a bug. A MED file POLAR_GRID is deal by CARTESIAN MEDLoader
+            meshType=CARTESIAN;
+            break;
           default:
-            throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized structured mesh type ! Supported are :\n - cartesian\n - curve linear\n");
+            throw INTERP_KERNEL::Exception("MEDFileMeshL2::getMeshIdFromName : unrecognized structured mesh type ! Supported are :\n - cartesian\n - curve linear\n");
         }
         break;
       }
     default:
-      throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized mesh type !");
+      throw INTERP_KERNEL::Exception("MEDFileMeshL2::getMeshIdFromName : unrecognized mesh type !");
   }
   med_int numdt,numit;
   med_float dtt;
@@ -147,7 +152,10 @@ double MEDFileMeshL2::CheckMeshTimeStep(med_idt fid, const std::string& mName, i
   return dtt;
 }
 
-std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId, const std::string& mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& nstep, int& Mdim)
+/*!
+ * non static and non const method because _description, _dt_unit... are set in this method.
+ */
+std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId, const std::string& mName, ParaMEDMEM::MEDCouplingMeshType& meshType, ParaMEDMEM::MEDCouplingAxisType& axType, int& nstep, int& Mdim)
 {
   med_mesh_type type_maillage;
   med_int spaceDim;
@@ -162,6 +170,7 @@ std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId,
       &stype,&nstep,&axistype,axisname,axisunit)!=0)
     throw INTERP_KERNEL::Exception("A problem has been detected when trying to get info on mesh !");
   MEDmeshUniversalNameRd(fid,nameTmp,_univ_name.getPointer());// do not protect  MEDFILESAFECALLERRD0 call : Thanks to fra.med.
+  axType=TraduceAxisType(axistype);
   switch(type_maillage)
   {
     case MED_UNSTRUCTURED_MESH:
@@ -179,13 +188,16 @@ std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId,
           case MED_CURVILINEAR_GRID:
             meshType=CURVE_LINEAR;
             break;
+        case MED_POLAR_GRID:// this is not a bug. A MED file POLAR_GRID is deal by CARTESIAN MEDLoader
+            meshType=CARTESIAN;
+            break;
           default:
-            throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getAxisInfoOnMesh : unrecognized structured mesh type ! Supported are :\n - cartesian\n - curve linear\n");
+            throw INTERP_KERNEL::Exception("MEDFileMeshL2::getAxisInfoOnMesh : unrecognized structured mesh type ! Supported are :\n - cartesian\n - curve linear\n");
         }
         break;
       }
     default:
-      throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized mesh type !");
+      throw INTERP_KERNEL::Exception("MEDFileMeshL2::getMeshIdFromName : unrecognized mesh type !");
   }
   //
   std::vector<std::string> infosOnComp(naxis);
@@ -364,11 +376,68 @@ bool MEDFileMeshL2::RenameFamiliesFromMemToFile(std::vector< std::string >& famN
       std::map<std::string,std::string>::iterator it1(zeMap.find(*it));
       if(it1!=zeMap.end())
         *it=(*it1).second;
-    }
-    
+    }    
   return true;
 }
 
+ParaMEDMEM::MEDCouplingAxisType MEDFileMeshL2::TraduceAxisType(med_axis_type at)
+{
+  switch(at)
+    {
+    case MED_CARTESIAN:
+      return AX_CART;
+    case MED_CYLINDRICAL:
+      return AX_CYL;
+    case MED_SPHERICAL:
+      return AX_SPHER;
+    case MED_UNDEF_AXIS_TYPE:
+      return AX_CART;
+    default:
+      throw INTERP_KERNEL::Exception("MEDFileMeshL2::TraduceAxisType : unrecognized axis type !");
+    }
+}
+
+ParaMEDMEM::MEDCouplingAxisType MEDFileMeshL2::TraduceAxisTypeStruct(med_grid_type gt)
+{
+  switch(gt)
+    {
+    case MED_CARTESIAN_GRID:
+      return AX_CART;
+    case MED_POLAR_GRID:
+      return AX_CYL;
+    default:
+      throw INTERP_KERNEL::Exception("MEDFileMeshL2::TraduceAxisTypeStruct : only Cartesian and Cylindrical supported by MED file !");
+    }
+}
+
+med_axis_type MEDFileMeshL2::TraduceAxisTypeRev(ParaMEDMEM::MEDCouplingAxisType at)
+{
+  switch(at)
+    {
+    case AX_CART:
+      return MED_CARTESIAN;
+    case AX_CYL:
+      return MED_CYLINDRICAL;
+    case AX_SPHER:
+      return MED_SPHERICAL;
+    default:
+      throw INTERP_KERNEL::Exception("MEDFileMeshL2::TraduceAxisTypeRev : unrecognized axis type !");
+    }
+}
+
+med_grid_type MEDFileMeshL2::TraduceAxisTypeRevStruct(ParaMEDMEM::MEDCouplingAxisType at)
+{
+  switch(at)
+    {
+    case AX_CART:
+      return MED_CARTESIAN_GRID;
+    case AX_CYL:
+      return MED_POLAR_GRID;
+    default:
+      throw INTERP_KERNEL::Exception("MEDFileMeshL2::TraduceAxisTypeRevStruct : only Cartesian and Cylindrical supported by MED file !");
+    }
+}
+
 MEDFileUMeshL2::MEDFileUMeshL2()
 {
 }
@@ -379,7 +448,8 @@ std::vector<std::string> MEDFileUMeshL2::loadCommonPart(med_idt fid, int mId, co
   _name.set(mName.c_str());
   int nstep;
   ParaMEDMEM::MEDCouplingMeshType meshType;
-  std::vector<std::string> ret(getAxisInfoOnMesh(fid,mId,mName.c_str(),meshType,nstep,Mdim));
+  ParaMEDMEM::MEDCouplingAxisType dummy3;
+  std::vector<std::string> ret(getAxisInfoOnMesh(fid,mId,mName.c_str(),meshType,dummy3,nstep,Mdim));
   if(nstep==0)
     {
       Mdim=-4;
@@ -620,7 +690,7 @@ bool MEDFileUMeshL2::isNamesDefinedOnLev(int levId) const
   return true;
 }
 
-MEDFileCMeshL2::MEDFileCMeshL2()
+MEDFileCMeshL2::MEDFileCMeshL2():_ax_type(AX_CART)
 {
 }
 
@@ -630,7 +700,8 @@ void MEDFileCMeshL2::loadAll(med_idt fid, int mId, const std::string& mName, int
   int nstep;
   int Mdim;
   ParaMEDMEM::MEDCouplingMeshType meshType;
-  std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName.c_str(),meshType,nstep,Mdim);
+  ParaMEDMEM::MEDCouplingAxisType dummy3;
+  std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName.c_str(),meshType,dummy3,nstep,Mdim);
   if(meshType!=CARTESIAN)
     throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected a structured one whereas in file it is not a structured !");
   _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
@@ -639,8 +710,9 @@ void MEDFileCMeshL2::loadAll(med_idt fid, int mId, const std::string& mName, int
   //
   med_grid_type gridtype;
   MEDFILESAFECALLERRD0(MEDmeshGridTypeRd,(fid,mName.c_str(),&gridtype));
-  if(gridtype!=MED_CARTESIAN_GRID)
-    throw INTERP_KERNEL::Exception("Invalid structured mesh ! Expected cartesian mesh type !");
+  if(gridtype!=MED_CARTESIAN_GRID && gridtype!=MED_POLAR_GRID)
+    throw INTERP_KERNEL::Exception("Invalid rectilinear mesh ! Only cartesian and polar are supported !");
+  _ax_type=TraduceAxisTypeStruct(gridtype);
   _cmesh=MEDCouplingCMesh::New();
   for(int i=0;i<Mdim;i++)
     {
@@ -680,7 +752,8 @@ void MEDFileCLMeshL2::loadAll(med_idt fid, int mId, const std::string& mName, in
   int nstep;
   int Mdim;
   ParaMEDMEM::MEDCouplingMeshType meshType;
-  std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,nstep,Mdim);
+  ParaMEDMEM::MEDCouplingAxisType dummy3;
+  std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,dummy3,nstep,Mdim);
   if(meshType!=CURVE_LINEAR)
     throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected a structured one whereas in file it is not a structured !");
   _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
@@ -850,9 +923,17 @@ std::vector<const BigMemoryObject *> MEDFileUMeshSplitL1::getDirectChildrenWithN
   return ret;
 }
 
+MEDFileUMeshSplitL1 *MEDFileUMeshSplitL1::shallowCpyUsingCoords(DataArrayDouble *coords) const
+{
+  MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> ret(new MEDFileUMeshSplitL1(*this));
+  ret->_m_by_types.shallowCpyMeshes();
+  ret->_m_by_types.setCoords(coords);
+  return ret.retn();
+}
+
 MEDFileUMeshSplitL1 *MEDFileUMeshSplitL1::deepCpy(DataArrayDouble *coords) const
 {
-  MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> ret=new MEDFileUMeshSplitL1(*this);
+  MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> ret(new MEDFileUMeshSplitL1(*this));
   ret->_m_by_types=_m_by_types.deepCpy(coords);
   if((const DataArrayInt *)_fam)
     ret->_fam=_fam->deepCpy();
@@ -1697,6 +1778,22 @@ MEDFileUMeshAggregateCompute MEDFileUMeshAggregateCompute::deepCpy(DataArrayDoub
   return ret;
 }
 
+void MEDFileUMeshAggregateCompute::shallowCpyMeshes()
+{
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+    {
+      const MEDCoupling1GTUMesh *elt(*it);
+      if(elt)
+        {
+          MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> elt2(elt->clone(false));
+          *it=DynamicCastSafe<MEDCouplingMesh,MEDCoupling1GTUMesh>(elt2);
+        }
+    }
+  const MEDCouplingUMesh *m(_m);
+  if(m)
+    _m=m->clone(false);
+}
+
 bool MEDFileUMeshAggregateCompute::isEqual(const MEDFileUMeshAggregateCompute& other, double eps, std::string& what) const
 {
   const MEDCouplingUMesh *m1(getUmesh());
index 9a8f0e8e369028e879e8bc7cf084a56e9bc374ab..f40ccf1ab37dcdfd857f696d9471dc79787e402a 100644 (file)
@@ -53,13 +53,17 @@ namespace ParaMEDMEM
     int getOrder() const { return _order; }
     double getTime() const { return _time; }
     MEDCouplingAutoRefCountObjectPtr<PartDefinition> getPartDefOfCoo() const { return _part_coords; }
-    std::vector<std::string> getAxisInfoOnMesh(med_idt fid, int mId, const std::string& mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& nstep, int& Mdim);
-    static int GetMeshIdFromName(med_idt fid, const std::string& mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& dt, int& it, std::string& dtunit1);
+    std::vector<std::string> getAxisInfoOnMesh(med_idt fid, int mId, const std::string& mName, ParaMEDMEM::MEDCouplingMeshType& meshType, ParaMEDMEM::MEDCouplingAxisType& axType, int& nstep, int& Mdim);
+    static int GetMeshIdFromName(med_idt fid, const std::string& mName, ParaMEDMEM::MEDCouplingMeshType& meshType, ParaMEDMEM::MEDCouplingAxisType& axType, int& dt, int& it, std::string& dtunit1);
     static double CheckMeshTimeStep(med_idt fid, const std::string& mname, int nstep, int dt, int it);
     static void ReadFamiliesAndGrps(med_idt fid, const std::string& mname, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps, MEDFileMeshReadSelector *mrs);
     static void WriteFamiliesAndGrps(med_idt fid, const std::string& mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps, int tooLongStrPol);
     static bool RenameFamiliesFromFileToMem(std::vector< std::string >& famNames);
     static bool RenameFamiliesFromMemToFile(std::vector< std::string >& famNames);
+    static ParaMEDMEM::MEDCouplingAxisType TraduceAxisType(med_axis_type at);
+    static ParaMEDMEM::MEDCouplingAxisType TraduceAxisTypeStruct(med_grid_type gt);
+    static med_axis_type TraduceAxisTypeRev(ParaMEDMEM::MEDCouplingAxisType at);
+    static med_grid_type TraduceAxisTypeRevStruct(ParaMEDMEM::MEDCouplingAxisType at);
   private:
     typedef bool (*RenameFamiliesPatternFunc)(std::vector< std::string >&);
     static void RenameFamiliesPatternInternal(std::vector< std::pair<std::string,std::pair<int,std::vector<std::string> > > >& crudeFams, RenameFamiliesPatternFunc func);
@@ -121,10 +125,12 @@ namespace ParaMEDMEM
     MEDFileCMeshL2();
     void loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it);
     MEDCouplingCMesh *getMesh() { return _cmesh; }
+    ParaMEDMEM::MEDCouplingAxisType getAxType() const { return _ax_type; }
   private:
     static med_data_type GetDataTypeCorrespondingToSpaceId(int id);
   private:
     MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> _cmesh;
+    ParaMEDMEM::MEDCouplingAxisType _ax_type;
   };
 
   class MEDFileCLMeshL2 : public MEDFileStrMeshL2
@@ -178,6 +184,7 @@ namespace ParaMEDMEM
     std::size_t getHeapMemorySizeWithoutChildren() const;
     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
     MEDFileUMeshAggregateCompute deepCpy(DataArrayDouble *coords) const;
+    void shallowCpyMeshes();
     bool isEqual(const MEDFileUMeshAggregateCompute& other, double eps, std::string& what) const;
     void clearNonDiscrAttributes() const;
     void synchronizeTinyInfo(const MEDFileMesh& master) const;
@@ -213,6 +220,7 @@ namespace ParaMEDMEM
     void setName(const std::string& name);
     std::size_t getHeapMemorySizeWithoutChildren() const;
     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+    MEDFileUMeshSplitL1 *shallowCpyUsingCoords(DataArrayDouble *coords) const;
     MEDFileUMeshSplitL1 *deepCpy(DataArrayDouble *coords) const;
     void setCoords(DataArrayDouble *coords);
     bool isEqual(const MEDFileUMeshSplitL1 *other, double eps, std::string& what) const;
index db8a4aa1a204e5f5fdfa25d21728dc9e337d4e7b..45f7ef9e8fc4f2db31ed28149bd10b67670beb03 100644 (file)
@@ -101,6 +101,7 @@ using namespace ParaMEDMEM;
 %newobject ParaMEDMEM::MEDFileMesh::getAllFamiliesIdsReferenced;
 %newobject ParaMEDMEM::MEDFileMesh::computeAllFamilyIdsInUse;
 %newobject ParaMEDMEM::MEDFileMesh::getEquivalences;
+%newobject ParaMEDMEM::MEDFileMesh::cartesianize;
 %newobject ParaMEDMEM::MEDFileData::getJoints;
 %newobject ParaMEDMEM::MEDFileStructuredMesh::getImplicitFaceMesh;
 %newobject ParaMEDMEM::MEDFileUMesh::New;
@@ -883,6 +884,8 @@ namespace ParaMEDMEM
     double getTimeValue() const;
     void setTimeUnit(const std::string& unit);
     std::string getTimeUnit() const;
+    void setAxType(MEDCouplingAxisType at);
+    MEDCouplingAxisType getAxType() const;
     virtual int getNumberOfNodes() const throw(INTERP_KERNEL::Exception);
     virtual int getNumberOfCellsAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
     virtual bool hasImplicitPart() const throw(INTERP_KERNEL::Exception);
@@ -893,6 +896,7 @@ namespace ParaMEDMEM
     virtual std::vector<int> getNumArrNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception);
     virtual std::vector<int> getNameArrNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception);
     virtual std::vector<int> getDistributionOfTypes(int meshDimRelToMax) const throw(INTERP_KERNEL::Exception);
+    virtual MEDFileMesh *cartesianize() const throw(INTERP_KERNEL::Exception);
     std::vector<int> getNonEmptyLevels() const throw(INTERP_KERNEL::Exception);
     std::vector<int> getNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception);
     void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception);
@@ -1510,6 +1514,7 @@ namespace ParaMEDMEM
     std::string getName() const throw(INTERP_KERNEL::Exception);
     void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception);
     void setOneTimeStep(MEDFileMesh *mesh1TimeStep) throw(INTERP_KERNEL::Exception);
+    void cartesianizeMe() throw(INTERP_KERNEL::Exception);
     %extend
        { 
          MEDFileMeshMultiTS()
@@ -1573,6 +1578,7 @@ namespace ParaMEDMEM
     void pushMesh(MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
     void setMeshAtPos(int i, MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
     void destroyMeshAtPos(int i) throw(INTERP_KERNEL::Exception);
+    void cartesianizeMe() throw(INTERP_KERNEL::Exception);
     %extend
        {
          MEDFileMeshes()
index 9bacf90f9ef85f84f6c304ee030a38337a2e0dac..b50dae7983b1b070fd05cd9bcce10ba33ece1c02 100644 (file)
@@ -4077,6 +4077,13 @@ class MEDLoaderTest(unittest.TestCase):
         st=cPickle.dumps(mm,cPickle.HIGHEST_PROTOCOL)
         mm2=cPickle.loads(st)
         self.assertTrue(mm.isEqual(mm2,1e-12)[0])
+        self.assertEqual(mm.getAxType(),AX_CART)
+        #
+        mm.setAxType(AX_CYL)
+        st=cPickle.dumps(mm,cPickle.HIGHEST_PROTOCOL)
+        mm2=cPickle.loads(st)
+        self.assertTrue(mm.isEqual(mm2,1e-12)[0])
+        self.assertEqual(mm2.getAxType(),AX_CYL)
         pass
 
     def testMEDFileFieldsLoadSpecificEntities1(self):
@@ -4740,6 +4747,104 @@ class MEDLoaderTest(unittest.TestCase):
       self.assertEqual(mm2.getFamiliesIdsOnGroup("RID"),(-4,3))# <- very important too !
       pass
 
+    def testCartesianizer1(self):
+      """ This test is advanced to be sure that no unnecessary copies had been made during cartesianization process. """
+      # UMesh non cart
+      arr=DataArrayDouble(4) ; arr.iota() ; m=MEDCouplingCMesh() ; m.setCoords(arr,arr) ; m=m.buildUnstructured()
+      mm=MEDFileUMesh() ; mm[0]=m ; mm.forceComputationOfParts() ; mm.setAxType(AX_CYL) #<- important
+      d0=DataArrayInt(16) ; d0[:]=0
+      d1=DataArrayInt(9)  ; d1[:]=0
+      mm.setFamilyFieldArr(0,d1) ; mm.setFamilyFieldArr(1,d0)
+      mm.setName("a") ; mm.setDescription("b") ; mm.setTime(3,4,5.) ; mm.addFamily("c",-4) ; mm.setFamiliesOnGroup("d",["c"]) ; mm.setTimeUnit("ms")
+      ref0=mm.getCoords().getHiddenCppPointer()
+      ref1=mm[0].getNodalConnectivity().getHiddenCppPointer()
+      self.assertEqual(ref0,mm[0].getCoords().getHiddenCppPointer())
+      ref2=mm[0].getNodalConnectivityIndex().getHiddenCppPointer()
+      ref3=mm.getDirectUndergroundSingleGeoTypeMesh(NORM_QUAD4).getNodalConnectivity().getHiddenCppPointer()
+      self.assertEqual(ref0,mm.getDirectUndergroundSingleGeoTypeMesh(NORM_QUAD4).getCoords().getHiddenCppPointer())
+      mm2=mm.cartesianize() # the trigger
+      self.assertTrue(isinstance(mm2,MEDFileUMesh))
+      self.assertTrue(mm.getHiddenCppPointer()!=mm2.getHiddenCppPointer())
+      self.assertTrue(ref0==mm.getCoords().getHiddenCppPointer()) # <- here important
+      self.assertTrue(ref0!=mm2.getCoords().getHiddenCppPointer()) # <- here important
+      self.assertEqual(mm2.getCoords().getHiddenCppPointer(),mm2[0].getCoords().getHiddenCppPointer())
+      self.assertEqual(mm2.getCoords().getHiddenCppPointer(),mm2.getDirectUndergroundSingleGeoTypeMesh(NORM_QUAD4).getCoords().getHiddenCppPointer())
+      self.assertEqual(mm2[0].getNodalConnectivity().getHiddenCppPointer(),ref1) # <- here very important
+      self.assertEqual(mm2[0].getNodalConnectivityIndex().getHiddenCppPointer(),ref2) # <- here very important
+      self.assertEqual(mm2.getDirectUndergroundSingleGeoTypeMesh(NORM_QUAD4).getNodalConnectivity().getHiddenCppPointer(),ref3) # <- here very important
+      self.assertEqual(mm2.getName(),mm.getName())
+      self.assertEqual(mm2.getDescription(),mm.getDescription())
+      self.assertEqual(mm2.getTime(),mm.getTime())
+      self.assertEqual(mm2.getTime(),mm.getTime())
+      self.assertEqual(mm2.getTimeUnit(),mm.getTimeUnit())
+      self.assertEqual(mm2.getGroupsNames(),mm.getGroupsNames())
+      self.assertEqual(mm2.getFamiliesNames(),mm.getFamiliesNames())
+      self.assertEqual([mm2.getFamilyId(elt) for elt in mm2.getFamiliesNames()],[mm.getFamilyId(elt2) for elt2 in mm.getFamiliesNames()])
+      self.assertEqual(mm.getFamilyFieldAtLevel(0).getHiddenCppPointer(),d1.getHiddenCppPointer())
+      self.assertEqual(mm2.getFamilyFieldAtLevel(0).getHiddenCppPointer(),d1.getHiddenCppPointer()) # <- here very important
+      self.assertEqual(mm.getFamilyFieldAtLevel(1).getHiddenCppPointer(),d0.getHiddenCppPointer())
+      self.assertEqual(mm2.getFamilyFieldAtLevel(1).getHiddenCppPointer(),d0.getHiddenCppPointer()) # <- here very important
+      # UMesh cart
+      mm.setAxType(AX_CART)
+      mm2=mm.cartesianize() # the trigger
+      self.assertTrue(isinstance(mm2,MEDFileUMesh))
+      self.assertTrue(mm.getHiddenCppPointer()==mm2.getHiddenCppPointer()) # optimization
+      # CurveLinearMesh non cart
+      arr=DataArrayDouble(4) ; arr.iota() ; m=MEDCouplingCMesh() ; m.setCoords(arr,arr) ; m=m.buildCurveLinear()
+      mm=MEDFileCurveLinearMesh() ; mm.setMesh(m) ; mm.setAxType(AX_CYL) #<- important
+      mm.setFamilyFieldArr(0,d1) ; mm.setFamilyFieldArr(1,d0)
+      mm.setName("a") ; mm.setDescription("b") ; mm.setTime(3,4,5.) ; mm.addFamily("c",-4) ; mm.setFamiliesOnGroup("d",["c"]) ; mm.setTimeUnit("ms")
+      ref0=mm.getMesh().getCoords().getHiddenCppPointer()
+      mm2=mm.cartesianize() # the trigger
+      self.assertTrue(isinstance(mm2,MEDFileCurveLinearMesh))
+      self.assertTrue(mm.getHiddenCppPointer()!=mm2.getHiddenCppPointer())
+      self.assertTrue(ref0==mm.getMesh().getCoords().getHiddenCppPointer()) # <- here important
+      self.assertTrue(ref0!=mm2.getMesh().getCoords().getHiddenCppPointer()) # <- here important
+      self.assertEqual(mm2.getMesh().getNodeGridStructure(),mm.getMesh().getNodeGridStructure())
+      self.assertEqual(mm2.getName(),mm.getName())
+      self.assertEqual(mm2.getDescription(),mm.getDescription())
+      self.assertEqual(mm2.getTime(),mm.getTime())
+      self.assertEqual(mm2.getTime(),mm.getTime())
+      self.assertEqual(mm2.getTimeUnit(),mm.getTimeUnit())
+      self.assertEqual(mm2.getGroupsNames(),mm.getGroupsNames())
+      self.assertEqual(mm2.getFamiliesNames(),mm.getFamiliesNames())
+      self.assertEqual([mm2.getFamilyId(elt) for elt in mm2.getFamiliesNames()],[mm.getFamilyId(elt2) for elt2 in mm.getFamiliesNames()])
+      self.assertEqual(mm.getFamilyFieldAtLevel(0).getHiddenCppPointer(),d1.getHiddenCppPointer())
+      self.assertEqual(mm2.getFamilyFieldAtLevel(0).getHiddenCppPointer(),d1.getHiddenCppPointer()) # <- here very important
+      self.assertEqual(mm.getFamilyFieldAtLevel(1).getHiddenCppPointer(),d0.getHiddenCppPointer())
+      self.assertEqual(mm2.getFamilyFieldAtLevel(1).getHiddenCppPointer(),d0.getHiddenCppPointer()) # <- here very important
+      # CurveLinearMesh cart
+      mm.setAxType(AX_CART)
+      mm2=mm.cartesianize() # the trigger
+      self.assertTrue(isinstance(mm2,MEDFileCurveLinearMesh))
+      self.assertTrue(mm.getHiddenCppPointer()==mm2.getHiddenCppPointer()) # optimization
+      # CMesh non cart
+      arr=DataArrayDouble(4) ; arr.iota() ; m=MEDCouplingCMesh() ; m.setCoords(arr,arr)
+      mm=MEDFileCMesh() ; mm.setMesh(m) ; mm.setAxType(AX_CYL) #<- important
+      mm.setFamilyFieldArr(0,d1) ; mm.setFamilyFieldArr(1,d0)
+      mm.setName("a") ; mm.setDescription("b") ; mm.setTime(3,4,5.) ; mm.addFamily("c",-4) ; mm.setFamiliesOnGroup("d",["c"]) ; mm.setTimeUnit("ms")
+      mm2=mm.cartesianize() # the trigger
+      self.assertTrue(isinstance(mm2,MEDFileCurveLinearMesh))
+      self.assertEqual(mm2.getMesh().getNodeGridStructure(),mm.getMesh().getNodeGridStructure())
+      self.assertEqual(mm2.getName(),mm.getName())
+      self.assertEqual(mm2.getDescription(),mm.getDescription())
+      self.assertEqual(mm2.getTime(),mm.getTime())
+      self.assertEqual(mm2.getTime(),mm.getTime())
+      self.assertEqual(mm2.getTimeUnit(),mm.getTimeUnit())
+      self.assertEqual(mm2.getGroupsNames(),mm.getGroupsNames())
+      self.assertEqual(mm2.getFamiliesNames(),mm.getFamiliesNames())
+      self.assertEqual([mm2.getFamilyId(elt) for elt in mm2.getFamiliesNames()],[mm.getFamilyId(elt2) for elt2 in mm.getFamiliesNames()])
+      self.assertEqual(mm.getFamilyFieldAtLevel(0).getHiddenCppPointer(),d1.getHiddenCppPointer())
+      self.assertEqual(mm2.getFamilyFieldAtLevel(0).getHiddenCppPointer(),d1.getHiddenCppPointer()) # <- here very important
+      self.assertEqual(mm.getFamilyFieldAtLevel(1).getHiddenCppPointer(),d0.getHiddenCppPointer())
+      self.assertEqual(mm2.getFamilyFieldAtLevel(1).getHiddenCppPointer(),d0.getHiddenCppPointer()) # <- here very important
+      # CMesh cart
+      mm.setAxType(AX_CART)
+      mm2=mm.cartesianize() # the trigger
+      self.assertTrue(isinstance(mm2,MEDFileCMesh))
+      self.assertTrue(mm.getHiddenCppPointer()==mm2.getHiddenCppPointer()) # optimization
+      pass
+
     pass
 
 if __name__ == "__main__":
index 706b63b09e1622a3a73f07b4a708dc806ecfa464..b7c17377ab1b20225fb0dae45d0b8814080da29d 100644 (file)
@@ -149,7 +149,7 @@ class MEDLoaderTest4(unittest.TestCase):
         a0Exp=mm.getCoords().deepCpy()
         del m,m1,mm,fs,f,fCell0,fCell1
         ########## GO for reading in MEDReader, by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False) # False is important to not read the values
         fields.removeFieldsWithoutAnyTimeStep()
         refMem=fields.getHeapMemorySize()
@@ -365,7 +365,7 @@ class MEDLoaderTest4(unittest.TestCase):
         a0Exp=mm.getCoords().deepCpy()
         del m,m1,mm,fs,f,fCell0,fCell1
         ########## GO for reading in MEDReader, by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -531,7 +531,7 @@ class MEDLoaderTest4(unittest.TestCase):
         a0Exp=mm.getCoords().deepCpy()
         del m,m1,mm,fs,f,fCell0,fCell1
         ########## GO for reading in MEDReader, by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -786,7 +786,7 @@ class MEDLoaderTest4(unittest.TestCase):
         a0Exp=mm.getCoords().deepCpy()
         del m,mm,fs1,fs2,fs3,f,fNode
         ########## GO for reading in MEDReader, by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -918,7 +918,7 @@ class MEDLoaderTest4(unittest.TestCase):
         a0Exp=mm.getCoords().deepCpy()
         del m,mm,fs1,fs2,fs3,f,fNode
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -1084,7 +1084,7 @@ class MEDLoaderTest4(unittest.TestCase):
         fs0.write(fname,0) ; fs1.write(fname,0) ; fs2.write(fname,0) ; fs3.write(fname,0) ; fs4.write(fname,0)
         del m,mm,fs1,fs2,fs3,f,fNode
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -1293,7 +1293,7 @@ class MEDLoaderTest4(unittest.TestCase):
         fs0.write(fname,0) ; fs1.write(fname,0) ; fs2.write(fname,0) ; fs3.write(fname,0) ; fs4.write(fname,0)
         del m,mm,fs1,fs2,fs3,f,fNode
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -1492,7 +1492,7 @@ class MEDLoaderTest4(unittest.TestCase):
         a0Exp=mm.getCoords().deepCpy()
         del m,mm,fs1,fs2,fs3,f,fNode
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -1640,7 +1640,7 @@ class MEDLoaderTest4(unittest.TestCase):
         a0Exp=mm.getCoords().deepCpy()
         del m,mm,fs1,fs2,fs3,f,fNode
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -1773,7 +1773,7 @@ class MEDLoaderTest4(unittest.TestCase):
         a0Exp=mm.getCoords().deepCpy()
         del m,mm,fs1,fs2,f,fNode
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -1876,7 +1876,7 @@ class MEDLoaderTest4(unittest.TestCase):
         a0Exp=mm.getCoords().deepCpy()
         del m,mm,fs0,f,fNode
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -1971,7 +1971,7 @@ class MEDLoaderTest4(unittest.TestCase):
         a0Exp=mm.getCoords().deepCpy()
         del m,mm,fs0,fs1,f,fNode
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -2088,7 +2088,7 @@ class MEDLoaderTest4(unittest.TestCase):
             a0Exp=mm.getCoords().deepCpy()
             del m,mm,fs0
             ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-            ms=MEDFileMeshes(fname)
+            ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
             fields=MEDFileFields(fname,False)
             fields.removeFieldsWithoutAnyTimeStep()
             fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -2244,7 +2244,7 @@ class MEDLoaderTest4(unittest.TestCase):
             a0Exp=mm.getCoords().deepCpy()
             del m,mm,fs0
             ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-            ms=MEDFileMeshes(fname)
+            ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
             fields=MEDFileFields(fname,False)
             fields.removeFieldsWithoutAnyTimeStep()
             fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -2406,7 +2406,7 @@ class MEDLoaderTest4(unittest.TestCase):
         mm.write(fname,2)
         ffs.write(fname,0)
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -2598,7 +2598,7 @@ class MEDLoaderTest4(unittest.TestCase):
         #
         mms.write(fname,2) ; mts.write(fname,0)
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -2674,7 +2674,7 @@ class MEDLoaderTest4(unittest.TestCase):
         f3.setName(fieldName3)
         MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f3)
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -2790,7 +2790,7 @@ class MEDLoaderTest4(unittest.TestCase):
         f3.setName(fieldName3)
         MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f3)
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -2860,7 +2860,7 @@ class MEDLoaderTest4(unittest.TestCase):
             self.assertTrue(v.isEqual(vExp1[i],1e-12))
             pass
         ## Now same exercise but with a different load strategy. All is load directly.
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname) # here all is read, the SauvReader (or other Reader) is emulated
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
         allFMTSLeavesToDisplay=[]
@@ -2964,7 +2964,7 @@ class MEDLoaderTest4(unittest.TestCase):
         mm.write(fname,2)
         ff.write(fname,0)
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -3148,7 +3148,7 @@ class MEDLoaderTest4(unittest.TestCase):
         fs.appendGlobs(fmts3,1e-12)
         fs.write(fname,0)
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -3349,7 +3349,7 @@ class MEDLoaderTest4(unittest.TestCase):
         mm.write(fname,2)
         fs.write(fname,0)
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -3461,7 +3461,7 @@ class MEDLoaderTest4(unittest.TestCase):
         mm.write(fname,2)
         fmts0.write(fname,0)
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -3566,7 +3566,7 @@ class MEDLoaderTest4(unittest.TestCase):
         mm.write(fname,2)
         fmts0.write(fname,0)
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -3674,7 +3674,7 @@ class MEDLoaderTest4(unittest.TestCase):
         m.write(fname,2)
         fmts.write(fname,0)
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False) # false is absolutely necessary for the test
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -3888,7 +3888,7 @@ class MEDLoaderTest4(unittest.TestCase):
         mm.write(fname,2)
         fs.write(fname,0)
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -4003,7 +4003,7 @@ class MEDLoaderTest4(unittest.TestCase):
         mm.write(fname,2)
         fs.write(fname,0)
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         self.assertEqual(fields[0].getMeshName(),"mesh")
@@ -4149,7 +4149,7 @@ class MEDLoaderTest4(unittest.TestCase):
         mm.write(fname,2)
         fs.write(fname,0)
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -4287,7 +4287,7 @@ class MEDLoaderTest4(unittest.TestCase):
         fGauss.setArray(arrGauss)
         MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,fGauss)
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -4395,7 +4395,7 @@ class MEDLoaderTest4(unittest.TestCase):
         cc.write(fname,2)
         fs.write(fname,0)
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -4505,7 +4505,7 @@ class MEDLoaderTest4(unittest.TestCase):
         cc.write(fname,2)
         fs.write(fname,0)
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -4605,7 +4605,7 @@ class MEDLoaderTest4(unittest.TestCase):
         cc.write(fname,2)
         fs.write(fname,0)
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -4709,7 +4709,7 @@ class MEDLoaderTest4(unittest.TestCase):
             MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,fCell0)
             pass
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -4801,7 +4801,7 @@ class MEDLoaderTest4(unittest.TestCase):
         a0Exp=mm.getCoords().deepCpy()
         del m,mm,fs0,fs1,f,fNode
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -4917,7 +4917,8 @@ class MEDLoaderTest4(unittest.TestCase):
         ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
         ms=MEDFileMeshes() # here we reproduce what is done by ParaMEDFileMeshes.ParaNew
         ms.pushMesh(MEDFileUMesh.LoadPartOf(fname,"Mesh",[NORM_QUAD4],[0,2,1],-1,-1));
-        ms[0].zipCoords() 
+        ms[0].zipCoords()
+        ms.cartesianizeMe()
         #
         fields=MEDFileFields.LoadPartOf(fname,False,ms);
         fields.removeFieldsWithoutAnyTimeStep()
@@ -5038,7 +5039,7 @@ class MEDLoaderTest4(unittest.TestCase):
         ff1.write(fname,0)
         ff4.write(fname,0)
         ###
-        ms=MEDFileMeshes(fname)
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
         fields=MEDFileFields(fname,False)
         fields.removeFieldsWithoutAnyTimeStep()
         fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
@@ -5114,6 +5115,267 @@ class MEDLoaderTest4(unittest.TestCase):
             pass
         pass
 
+    def test37(self):
+        """ Introduction of non cartesian meshes management. Here cylindrical."""
+        fname="ForMEDReader37.med"
+        meshName="mesh"
+        description="Cylindrical grid"
+        comps=["X [cm]","Y [cm]","Z [cm]"]
+        arrX=DataArrayDouble(3) ; arrX.iota() ; arrX*=0.8 ; arrX.setInfoOnComponent(0,comps[0])
+        arrY=DataArrayDouble(4) ; arrY.iota() ; arrY*=pi/(len(arrY)-1) ; arrY.setInfoOnComponent(0,comps[1])
+        arrZ=DataArrayDouble(5) ; arrZ.iota() ; arrZ*=1.6 ; arrZ-=8. ; arrZ.setInfoOnComponent(0,comps[2])
+        m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY,arrZ) ; m.setName(meshName)
+        mm=MEDFileCMesh() ; mm.setMesh(m) ; mm.setDescription(description)
+        mm.setAxType(AX_CYL) # the test is here !
+        f=MEDCouplingFieldDouble(ON_CELLS) ; f.setMesh(m) ; f.setName("Field")
+        arr=DataArrayDouble(m.getNumberOfCells()) ; arr.iota() ; arr*=0.1 ; f.setArray(arr) ; f.checkCoherency()
+        ff=MEDFileField1TS() ; ff.setFieldNoProfileSBT(f)
+        fmts=MEDFileFieldMultiTS() ; fmts.pushBackTimeStep(ff)
+        #
+        ms=MEDFileMeshes() ; ms.pushMesh(mm)
+        fields=MEDFileFields() ; fields.pushField(fmts)
+        #ms.write(fname,2) ; fields.write(fname,0)
+        # WARNING for the moment we do not reread fname ! It is not a hidden bug it is just to wait EF control. Coming soon.
+        ms.cartesianizeMe()
+        #
+        fields.removeFieldsWithoutAnyTimeStep()
+        fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
+        allFMTSLeavesToDisplay=[]
+        for fields in fields_per_mesh:
+            allFMTSLeavesToDisplay2=[]
+            for fmts in fields:
+                tmp=fmts.splitDiscretizations()
+                for itmp in tmp:
+                    self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType())
+                    pass
+                allFMTSLeavesToDisplay2+=tmp
+                pass
+            allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2)
+            pass
+        #
+        self.assertEqual(len(allFMTSLeavesToDisplay),1)
+        self.assertEqual(len(allFMTSLeavesToDisplay[0]),1)
+        allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[]))
+        self.assertEqual(len(allFMTSLeavesPerTimeSeries),1)
+        allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]])
+        self.assertEqual(len(allFMTSLeavesPerCommonSupport1),1)
+        #
+        mst=MEDFileMeshStruct.New(ms[0])
+        fcscp=allFMTSLeavesPerCommonSupport1[0][1]
+        mml=fcscp.buildFromScratchDataSetSupport(0,fields)
+        mml2=mml.prepare()
+        self.assertTrue(isinstance(mml2,MEDCurveLinearMeshMultiLev))# <- hehe it is a CurveLinear no more a CMesh !
+        a,b,c=mml2.buildVTUArrays()
+        self.assertTrue(c)# the array is thoose in structure
+        ref_a=DataArrayDouble([0.,0.,-8.,0.8,0.,-8.,1.6,0.,-8.,0.,0.,-8.,0.4,0.6928203230275509,-8.,0.8,1.3856406460551018,-8.,-0.,0.,-8.,-0.4,0.692820323027551,-8.,-0.8,1.385640646055102,-8.,-0.,0.,-8.,-0.8,0.,-8.,-1.6,0.,-8.,0.,0.,-6.4,0.8,0.,-6.4,1.6,0.,-6.4,0.,0.,-6.4,0.4,0.6928203230275509,-6.4,0.8,1.3856406460551018,-6.4,-0.,0.,-6.4,-0.4,0.692820323027551,-6.4,-0.8,1.385640646055102,-6.4,-0.,0.,-6.4,-0.8,0.,-6.4,-1.6,0.,-6.4,0.,0.,-4.8,0.8,0.,-4.8,1.6,0.,-4.8,0.,0.,-4.8,0.4,0.6928203230275509,-4.8,0.8,1.3856406460551018,-4.8,-0.,0.,-4.8,-0.4,0.692820323027551,-4.8,-0.8,1.385640646055102,-4.8,-0.,0.,-4.8,-0.8,0.,-4.8,-1.6,0.,-4.8,0.,0.,-3.2,0.8,0.,-3.2,1.6,0.,-3.2,0.,0.,-3.2,0.4,0.6928203230275509,-3.2,0.8,1.3856406460551018,-3.2,-0.,0.,-3.2,-0.4,0.692820323027551,-3.2,-0.8,1.385640646055102,-3.2,-0.,0.,-3.2,-0.8,0.,-3.2,-1.6,0.,-3.2,0.,0.,-1.6,0.8,0.,-1.6,1.6,0.,-1.6,0.,0.,-1.6,0.4,0.6928203230275509,-1.6,0.8,1.3856406460551018,-1.6,-0.,0.,-1.6,-0.4,0.692820323027551,-1.6,-0.8,1.385640646055102,-1.6,-0.,0.,-1.6,-0.8,0.,-1.6,-1.6,0.,-1.6],60,3)
+        ref_a.setInfoOnComponents(comps)
+        self.assertTrue(a.isEqual(ref_a,1e-14))
+        self.assertEqual(b,[3,4,5])
+        for i in xrange(1):
+            ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
+            fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
+            ffCell.loadArraysIfNecessary()
+            v=mml2.buildDataArray(fsst,fields,ffCell.getUndergroundDataArray())
+            self.assertEqual(v.getHiddenCppPointer(),ffCell.getUndergroundDataArray().getHiddenCppPointer())
+            self.assertTrue(v.isEqual(DataArrayDouble([0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3]),1e-14))
+            pass
+        pass
+        
+    def test38(self):
+        """ Introduction of non cartesian meshes management. Here spherical."""
+        fname="ForMEDReader38.med"
+        meshName="mesh"
+        description="Spherical grid"
+        comps=["X [cm]","Y [cm]","Z [cm]"]
+        arrX=DataArrayDouble(3) ; arrX.iota() ; arrX*=0.8 ; arrX.setInfoOnComponent(0,comps[0])
+        arrY=DataArrayDouble(4) ; arrY.iota() ; arrY*=pi/(len(arrY)-1) ; arrY.setInfoOnComponent(0,comps[1])
+        arrZ=DataArrayDouble(5) ; arrZ.iota() ; arrZ*=2*pi/(len(arrZ)-1) ; arrZ.setInfoOnComponent(0,comps[2])
+        m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY,arrZ) ; m.setName(meshName)
+        mm=MEDFileCMesh() ; mm.setMesh(m) ; mm.setDescription(description)
+        mm.setAxType(AX_SPHER) # the test is here !
+        f=MEDCouplingFieldDouble(ON_CELLS) ; f.setMesh(m) ; f.setName("Field")
+        arr=DataArrayDouble(m.getNumberOfCells()) ; arr.iota() ; arr*=0.1 ; f.setArray(arr) ; f.checkCoherency()
+        ff=MEDFileField1TS() ; ff.setFieldNoProfileSBT(f)
+        fmts=MEDFileFieldMultiTS() ; fmts.pushBackTimeStep(ff)
+        #
+        ms=MEDFileMeshes() ; ms.pushMesh(mm)
+        fields=MEDFileFields() ; fields.pushField(fmts)
+        #ms.write(fname,2) ; fields.write(fname,0)
+        # WARNING for the moment we do not reread fname ! It is not a hidden bug it is just to wait EF control. Coming soon.
+        ms.cartesianizeMe()
+        #
+        fields.removeFieldsWithoutAnyTimeStep()
+        fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
+        allFMTSLeavesToDisplay=[]
+        for fields in fields_per_mesh:
+            allFMTSLeavesToDisplay2=[]
+            for fmts in fields:
+                tmp=fmts.splitDiscretizations()
+                for itmp in tmp:
+                    self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType())
+                    pass
+                allFMTSLeavesToDisplay2+=tmp
+                pass
+            allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2)
+            pass
+        #
+        self.assertEqual(len(allFMTSLeavesToDisplay),1)
+        self.assertEqual(len(allFMTSLeavesToDisplay[0]),1)
+        allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[]))
+        self.assertEqual(len(allFMTSLeavesPerTimeSeries),1)
+        allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]])
+        self.assertEqual(len(allFMTSLeavesPerCommonSupport1),1)
+        #
+        mst=MEDFileMeshStruct.New(ms[0])
+        fcscp=allFMTSLeavesPerCommonSupport1[0][1]
+        mml=fcscp.buildFromScratchDataSetSupport(0,fields)
+        mml2=mml.prepare()
+        self.assertTrue(isinstance(mml2,MEDCurveLinearMeshMultiLev))
+        a,b,c=mml2.buildVTUArrays()
+        self.assertTrue(c)# the array is thoose in structure
+        ref_a=DataArrayDouble([0.,0.,0.,0.,0.,0.8,0.,0.,1.6,0.,0.,0.,0.6928203230275509,0.,0.4,1.3856406460551018,0.,0.8,0.,0.,-0.,0.692820323027551,0.,-0.4,1.385640646055102,0.,-0.8,0.,0.,-0.,0.,0.,-0.8,0.,0.,-1.6,0.,0.,0.,0.,0.,0.8,0.,0.,1.6,0.,0.,0.,0.,0.6928203230275509,0.4,0.,1.3856406460551018,0.8,0.,0.,-0.,0.,0.692820323027551,-0.4,0.,1.385640646055102,-0.8,0.,0.,-0.,0.,0.,-0.8,0.,0.,-1.6,-0.,0.,0.,-0.,0.,0.8,-0.,0.,1.6,-0.,0.,0.,-0.6928203230275509,0.,0.4,-1.3856406460551018,0.,0.8,-0.,0.,-0.,-0.692820323027551,0.,-0.4,-1.385640646055102,0.,-0.8,-0.,0.,-0.,0.,0.,-0.8,0.,0.,-1.6,-0.,-0.,0.,-0.,-0.,0.8,-0.,-0.,1.6,-0.,-0.,0.,0.,-0.6928203230275509,0.4,0.,-1.3856406460551018,0.8,-0.,-0.,-0.,0.,-0.692820323027551,-0.4,0.,-1.385640646055102,-0.8,-0.,-0.,-0.,0.,0.,-0.8,0.,0.,-1.6,0.,-0.,0.,0.,-0.,0.8,0.,-0.,1.6,0.,-0.,0.,0.6928203230275509,0.,0.4,1.3856406460551018,0.,0.8,0.,-0.,-0.,0.692820323027551,0.,-0.4,1.385640646055102,0.,-0.8,0.,-0.,-0.,0.,0.,-0.8,0.,0.,-1.6],60,3)
+        ref_a.setInfoOnComponents(comps)
+        self.assertTrue(a.isEqual(ref_a,1e-14))
+        self.assertEqual(b,[3,4,5])
+        for i in xrange(1):
+            ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
+            fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
+            ffCell.loadArraysIfNecessary()
+            v=mml2.buildDataArray(fsst,fields,ffCell.getUndergroundDataArray())
+            self.assertEqual(v.getHiddenCppPointer(),ffCell.getUndergroundDataArray().getHiddenCppPointer())
+            self.assertTrue(v.isEqual(DataArrayDouble([0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3]),1e-14))
+            pass
+        pass
+
+    def test39(self):
+        """Idem test37, test38, test39, test40 except that here it is an unstructured mesh."""
+        fname="ForMEDReader39.med"
+        meshName="mesh"
+        description="Spherical grid"
+        comps=["X [cm]","Y [cm]","Z [cm]"]
+        arrX=DataArrayDouble(3) ; arrX.iota() ; arrX*=0.8 ; arrX.setInfoOnComponent(0,comps[0])
+        arrY=DataArrayDouble(4) ; arrY.iota() ; arrY*=pi/(len(arrY)-1) ; arrY.setInfoOnComponent(0,comps[1])
+        arrZ=DataArrayDouble(5) ; arrZ.iota() ; arrZ*=2*pi/(len(arrZ)-1) ; arrZ.setInfoOnComponent(0,comps[2])
+        m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY,arrZ) ; m.setName(meshName) ; m=m.buildUnstructured()
+        mm=MEDFileUMesh() ; mm[0]=m ; mm.setDescription(description) # the test is here : UMesh !
+        mm.setAxType(AX_SPHER) # the test is here !
+        f=MEDCouplingFieldDouble(ON_CELLS) ; f.setMesh(m) ; f.setName("Field")
+        arr=DataArrayDouble(m.getNumberOfCells()) ; arr.iota() ; arr*=0.1 ; f.setArray(arr) ; f.checkCoherency()
+        ff=MEDFileField1TS() ; ff.setFieldNoProfileSBT(f)
+        fmts=MEDFileFieldMultiTS() ; fmts.pushBackTimeStep(ff)
+        #
+        ms=MEDFileMeshes() ; ms.pushMesh(mm)
+        fields=MEDFileFields() ; fields.pushField(fmts)
+        ms.write(fname,2) ; fields.write(fname,0)
+        #
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
+        fields=MEDFileFields(fname,False)
+        fields.removeFieldsWithoutAnyTimeStep()
+        fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
+        allFMTSLeavesToDisplay=[]
+        for fields in fields_per_mesh:
+            allFMTSLeavesToDisplay2=[]
+            for fmts in fields:
+                tmp=fmts.splitDiscretizations()
+                for itmp in tmp:
+                    self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType())
+                    pass
+                allFMTSLeavesToDisplay2+=tmp
+                pass
+            allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2)
+            pass
+        #
+        self.assertEqual(len(allFMTSLeavesToDisplay),1)
+        self.assertEqual(len(allFMTSLeavesToDisplay[0]),1)
+        allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[]))
+        self.assertEqual(len(allFMTSLeavesPerTimeSeries),1)
+        allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]])
+        self.assertEqual(len(allFMTSLeavesPerCommonSupport1),1)
+        #
+        mst=MEDFileMeshStruct.New(ms[0])
+        fcscp=allFMTSLeavesPerCommonSupport1[0][1]
+        mml=fcscp.buildFromScratchDataSetSupport(0,fields)
+        mml2=mml.prepare()
+        self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
+        ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays()
+        self.assertTrue(ncc)
+        ref_a=DataArrayDouble([0.,0.,0.,0.,0.,0.8,0.,0.,1.6,0.,0.,0.,0.6928203230275509,0.,0.4,1.3856406460551018,0.,0.8,0.,0.,-0.,0.692820323027551,0.,-0.4,1.385640646055102,0.,-0.8,0.,0.,-0.,0.,0.,-0.8,0.,0.,-1.6,0.,0.,0.,0.,0.,0.8,0.,0.,1.6,0.,0.,0.,0.,0.6928203230275509,0.4,0.,1.3856406460551018,0.8,0.,0.,-0.,0.,0.692820323027551,-0.4,0.,1.385640646055102,-0.8,0.,0.,-0.,0.,0.,-0.8,0.,0.,-1.6,-0.,0.,0.,-0.,0.,0.8,-0.,0.,1.6,-0.,0.,0.,-0.6928203230275509,0.,0.4,-1.3856406460551018,0.,0.8,-0.,0.,-0.,-0.692820323027551,0.,-0.4,-1.385640646055102,0.,-0.8,-0.,0.,-0.,0.,0.,-0.8,0.,0.,-1.6,-0.,-0.,0.,-0.,-0.,0.8,-0.,-0.,1.6,-0.,-0.,0.,0.,-0.6928203230275509,0.4,0.,-1.3856406460551018,0.8,-0.,-0.,-0.,0.,-0.692820323027551,-0.4,0.,-1.385640646055102,-0.8,-0.,-0.,-0.,0.,0.,-0.8,0.,0.,-1.6,0.,-0.,0.,0.,-0.,0.8,0.,-0.,1.6,0.,-0.,0.,0.6928203230275509,0.,0.4,1.3856406460551018,0.,0.8,0.,-0.,-0.,0.692820323027551,0.,-0.4,1.385640646055102,0.,-0.8,0.,-0.,-0.,0.,0.,-0.8,0.,0.,-1.6],60,3)
+        ref_a.setInfoOnComponents(comps)
+        self.assertTrue(a0.isEqual(ref_a,1e-14))#<- Test is here
+        for i in xrange(1):
+            ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
+            fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
+            ffCell.loadArraysIfNecessary()
+            v=mml2.buildDataArray(fsst,fields,ffCell.getUndergroundDataArray())
+            self.assertEqual(v.getHiddenCppPointer(),ffCell.getUndergroundDataArray().getHiddenCppPointer())
+            self.assertTrue(v.isEqual(DataArrayDouble([0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3]),1e-14))
+        pass
+
+    def test40(self):
+        """Idem test37, test38, test39, test40 except that here it is a CL mesh."""
+        fname="ForMEDReader40.med"
+        meshName="mesh"
+        description="Spherical grid"
+        comps=["X [cm]","Y [cm]","Z [cm]"]
+        arrX=DataArrayDouble(3) ; arrX.iota() ; arrX*=0.8 ; arrX.setInfoOnComponent(0,comps[0])
+        arrY=DataArrayDouble(4) ; arrY.iota() ; arrY*=pi/(len(arrY)-1) ; arrY.setInfoOnComponent(0,comps[1])
+        arrZ=DataArrayDouble(5) ; arrZ.iota() ; arrZ*=2*pi/(len(arrZ)-1) ; arrZ.setInfoOnComponent(0,comps[2])
+        m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY,arrZ) ; m.setName(meshName) ; m=m.buildCurveLinear()
+        mm=MEDFileCurveLinearMesh() ; mm.setMesh(m) ; mm.setDescription(description) # the test is here CLMesh!
+        mm.setAxType(AX_SPHER) # the test is here !
+        f=MEDCouplingFieldDouble(ON_CELLS) ; f.setMesh(m) ; f.setName("Field")
+        arr=DataArrayDouble(m.getNumberOfCells()) ; arr.iota() ; arr*=0.1 ; f.setArray(arr) ; f.checkCoherency()
+        ff=MEDFileField1TS() ; ff.setFieldNoProfileSBT(f)
+        fmts=MEDFileFieldMultiTS() ; fmts.pushBackTimeStep(ff)
+        #
+        ms=MEDFileMeshes() ; ms.pushMesh(mm)
+        fields=MEDFileFields() ; fields.pushField(fmts)
+        ms.write(fname,2) ; fields.write(fname,0)
+        #
+        ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
+        fields=MEDFileFields(fname,False)
+        fields.removeFieldsWithoutAnyTimeStep()
+        fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
+        allFMTSLeavesToDisplay=[]
+        for fields in fields_per_mesh:
+            allFMTSLeavesToDisplay2=[]
+            for fmts in fields:
+                tmp=fmts.splitDiscretizations()
+                for itmp in tmp:
+                    self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType())
+                    pass
+                allFMTSLeavesToDisplay2+=tmp
+                pass
+            allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2)
+            pass
+        #
+        self.assertEqual(len(allFMTSLeavesToDisplay),1)
+        self.assertEqual(len(allFMTSLeavesToDisplay[0]),1)
+        allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[]))
+        self.assertEqual(len(allFMTSLeavesPerTimeSeries),1)
+        allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]])
+        self.assertEqual(len(allFMTSLeavesPerCommonSupport1),1)
+        #
+        mst=MEDFileMeshStruct.New(ms[0])
+        fcscp=allFMTSLeavesPerCommonSupport1[0][1]
+        mml=fcscp.buildFromScratchDataSetSupport(0,fields)
+        mml2=mml.prepare()
+        self.assertTrue(isinstance(mml2,MEDCurveLinearMeshMultiLev))
+        a,b,c=mml2.buildVTUArrays()
+        self.assertTrue(c)
+        ref_a=DataArrayDouble([0.,0.,0.,0.,0.,0.8,0.,0.,1.6,0.,0.,0.,0.6928203230275509,0.,0.4,1.3856406460551018,0.,0.8,0.,0.,-0.,0.692820323027551,0.,-0.4,1.385640646055102,0.,-0.8,0.,0.,-0.,0.,0.,-0.8,0.,0.,-1.6,0.,0.,0.,0.,0.,0.8,0.,0.,1.6,0.,0.,0.,0.,0.6928203230275509,0.4,0.,1.3856406460551018,0.8,0.,0.,-0.,0.,0.692820323027551,-0.4,0.,1.385640646055102,-0.8,0.,0.,-0.,0.,0.,-0.8,0.,0.,-1.6,-0.,0.,0.,-0.,0.,0.8,-0.,0.,1.6,-0.,0.,0.,-0.6928203230275509,0.,0.4,-1.3856406460551018,0.,0.8,-0.,0.,-0.,-0.692820323027551,0.,-0.4,-1.385640646055102,0.,-0.8,-0.,0.,-0.,0.,0.,-0.8,0.,0.,-1.6,-0.,-0.,0.,-0.,-0.,0.8,-0.,-0.,1.6,-0.,-0.,0.,0.,-0.6928203230275509,0.4,0.,-1.3856406460551018,0.8,-0.,-0.,-0.,0.,-0.692820323027551,-0.4,0.,-1.385640646055102,-0.8,-0.,-0.,-0.,0.,0.,-0.8,0.,0.,-1.6,0.,-0.,0.,0.,-0.,0.8,0.,-0.,1.6,0.,-0.,0.,0.6928203230275509,0.,0.4,1.3856406460551018,0.,0.8,0.,-0.,-0.,0.692820323027551,0.,-0.4,1.385640646055102,0.,-0.8,0.,-0.,-0.,0.,0.,-0.8,0.,0.,-1.6],60,3)
+        ref_a.setInfoOnComponents(comps)
+        self.assertTrue(a.isEqual(ref_a,1e-14))#<- Test is here
+        self.assertEqual(b,[3,4,5])
+        for i in xrange(1):
+            ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
+            fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
+            ffCell.loadArraysIfNecessary()
+            v=mml2.buildDataArray(fsst,fields,ffCell.getUndergroundDataArray())
+            self.assertEqual(v.getHiddenCppPointer(),ffCell.getUndergroundDataArray().getHiddenCppPointer())
+            self.assertTrue(v.isEqual(DataArrayDouble([0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3]),1e-14))
+        pass
+
     pass
 
 if __name__ == "__main__":