]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Add MEDFileMesh.ConvertToMEDFileGeoType method
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 14 Sep 2022 16:07:30 +0000 (18:07 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 14 Sep 2022 16:07:30 +0000 (18:07 +0200)
src/MEDLoader/MEDFileMesh.cxx
src/MEDLoader/MEDFileMesh.hxx
src/MEDLoader/Swig/MEDLoaderCommon.i
src/MEDLoader/Swig/MEDLoaderTest3.py

index dc164925273472491a0438d0ce5bdf443a8bf5b6..f712e2abdbab3b86661d5c40d3e03d593400d0a3 100644 (file)
@@ -7824,6 +7824,16 @@ INTERP_KERNEL::NormalizedCellType MEDFileMesh::ConvertFromMEDFileGeoType(med_geo
   return typmai2[std::distance(typmai,pos)];
 }
 
+med_geometry_type MEDFileMesh::ConvertToMEDFileGeoType(INTERP_KERNEL::NormalizedCellType geoType)
+{
+  INTERP_KERNEL::NormalizedCellType *pos(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,geoType));
+  if(pos==typmai2+MED_N_CELL_FIXED_GEO)
+  {
+    THROW_IK_EXCEPTION("MEDFileMesh::ConvertToMEDFileGeoType : no entry for " << geoType);
+  }
+  return typmai[std::distance(typmai2,pos)];
+}
+
 TypeOfField MEDFileMesh::ConvertFromMEDFileEntity(med_entity_type etype)
 {
   switch(etype)
index d53344d1eeb17f0e73c00c482badb5233ea69e19..9eaa94f934e3204be8f1140d0d93af30fcd096f6 100644 (file)
@@ -203,6 +203,7 @@ namespace MEDCoupling
     void killEquivalences() { _equiv=(MEDFileEquivalences *)0; }
     void initializeEquivalences() { _equiv=MEDFileEquivalences::New(this); }
     MEDLOADER_EXPORT static INTERP_KERNEL::NormalizedCellType ConvertFromMEDFileGeoType(med_geometry_type geoType);
+    MEDLOADER_EXPORT static med_geometry_type ConvertToMEDFileGeoType(INTERP_KERNEL::NormalizedCellType geoType);
     static TypeOfField ConvertFromMEDFileEntity(med_entity_type etype);
   protected:
     MEDFileMesh();
index a0368584d4bc57a67e1ca624370634ca6b0d2edd..b33167ffcffb87bd8a1cb35a0e54313370965217 100644 (file)
@@ -1242,6 +1242,11 @@ namespace MEDCoupling
             return MEDFileMesh::ConvertFromMEDFileGeoType(geoType2);
          }
 
+         static int ConvertToMEDFileGeoType(INTERP_KERNEL::NormalizedCellType geoType)
+         {
+            return (int) MEDFileMesh::ConvertToMEDFileGeoType(geoType);
+         }
+
          PyObject *getTime()
          {
            int tmp1,tmp2;
index 4d3c49a76218473fb3eb07216175a4e8d2bf810d..a9b2dff97851e6e5488df9f3fcb5bab4431957fd 100644 (file)
@@ -7009,6 +7009,7 @@ class MEDLoaderTest3(unittest.TestCase):
 
     def testMeshConvertFromMEDFileGeoType(self):
         self.assertEqual(MEDFileMesh.ConvertFromMEDFileGeoType(320),NORM_HEXA20)
+        self.assertEqual(MEDFileMesh.ConvertToMEDFileGeoType(NORM_HEXA20),320)
 
     @WriteInTmpDir
     def testFieldInt64_0(self):