]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Add useful method AllGeometricTypes in python wrapping
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 2 Jan 2020 10:26:33 +0000 (11:26 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 2 Jan 2020 10:26:33 +0000 (11:26 +0100)
src/INTERP_KERNEL/Bases/NormalizedGeometricTypes
src/INTERP_KERNEL/CellModel.hxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest7.py
src/MEDCoupling_Swig/MEDCouplingCommon.i

index c4ea82210a6a1e57b963202811d9f2c252dd846c..0a083da4970f63b02875a448b81a44c3acdf2b77 100644 (file)
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-// Author : Anthony Geay (CEA/DEN)
+// Author : Anthony Geay (EDF R&D)
 
-#ifndef __NORMALIZEDGEOMETRICTYPES__
-#define __NORMALIZEDGEOMETRICTYPES__
+#pragma once
 
 namespace INTERP_KERNEL
 {
   typedef enum
-    {
+    {// think to update the following arrays : MEDMEM_ORDER (MEDCouplingUMesh) and MEDCOUPLING2VTKTYPETRADUCER (CellModel.hxx)
       NORM_POINT1  =  0,
       NORM_SEG2    =  1,
       NORM_SEG3    =  2,
@@ -68,4 +67,3 @@ namespace INTERP_KERNEL
   typedef enum  { PLANAR_FACE_5 = 5, PLANAR_FACE_6 = 6, GENERAL_24 = 24, GENERAL_48 = 48 } SplittingPolicy;
 }
 
-#endif
index a221be52e6ac452afab26c24aa109c9273e14ce0..8d2500b7be38fc1e7e970078ba6c4a7521b30d2d 100644 (file)
@@ -32,7 +32,7 @@ constexpr int MEDCOUPLING2VTKTYPETRADUCER_LGTH=INTERP_KERNEL::NORM_MAXTYPE+1;
 
 constexpr unsigned char MEDCOUPLING2VTKTYPETRADUCER_NONE = 255;
 
-INTERPKERNEL_EXPORT extern unsigned char MEDCOUPLING2VTKTYPETRADUCER[INTERP_KERNEL::NORM_MAXTYPE+1];
+INTERPKERNEL_EXPORT extern unsigned char MEDCOUPLING2VTKTYPETRADUCER[MEDCOUPLING2VTKTYPETRADUCER_LGTH];
 
 namespace INTERP_KERNEL
 {
index 1b655eb785f95c9a2674075d1d826df411af8be4..23277fdf574f85a72f98dad5c47946374a9cf012 100644 (file)
@@ -718,6 +718,18 @@ class MEDCouplingBasicsTest7(unittest.TestCase):
         self.assertRaises(InterpKernelException,a1.findIdForEach,b1) # a1 is not single component
         pass
 
+    def testGlobalHelpers(self):
+        arr0 = vtk2med_cell_types()
+        self.assertEqual(len(arr0),43)
+        arr1 = med2vtk_cell_types()
+        self.assertEqual(len(arr1),34)
+        arr2 = AllGeometricTypes()
+        self.assertEqual(len(arr2),25)
+        for elt in arr2:
+            MEDCouplingUMesh.GetReprOfGeometricType(elt)
+            self.assertNotEqual(MEDCouplingUMesh.GetDimensionOfGeometricType(elt),-1)
+        pass
+
     pass
 
 if __name__ == '__main__':
index 184143765e704762cd0d6f3faae20a6174eb4d16..eb990f7e66af9a35115ec4fb51497ed622ea154d 100644 (file)
@@ -558,6 +558,15 @@ typedef DataArrayInt64 DataArrayIdType;
       PyList_SetItem(ret,id,PyInt_FromLong(*it));
     return ret;
   }
+
+  PyObject *AllGeometricTypes()
+  {
+    Py_ssize_t sz(MEDCouplingUMesh::N_MEDMEM_ORDER);
+    PyObject *ret(PyList_New(sz));
+    for(Py_ssize_t i=0;i<sz;i++)
+      PyList_SetItem(ret,i,PyInt_FromLong(MEDCouplingUMesh::MEDMEM_ORDER[i]));
+    return ret;
+  }
 }
 
 namespace INTERP_KERNEL