From: Anthony Geay Date: Thu, 2 Jan 2020 10:26:33 +0000 (+0100) Subject: Add useful method AllGeometricTypes in python wrapping X-Git-Tag: V9_5_0a1~15 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4db17dd5b9ca71863e4b74ee2b12d362e1fc4321;p=tools%2Fmedcoupling.git Add useful method AllGeometricTypes in python wrapping --- diff --git a/src/INTERP_KERNEL/Bases/NormalizedGeometricTypes b/src/INTERP_KERNEL/Bases/NormalizedGeometricTypes index c4ea82210..0a083da49 100644 --- a/src/INTERP_KERNEL/Bases/NormalizedGeometricTypes +++ b/src/INTERP_KERNEL/Bases/NormalizedGeometricTypes @@ -16,15 +16,14 @@ // // 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 diff --git a/src/INTERP_KERNEL/CellModel.hxx b/src/INTERP_KERNEL/CellModel.hxx index a221be52e..8d2500b7b 100644 --- a/src/INTERP_KERNEL/CellModel.hxx +++ b/src/INTERP_KERNEL/CellModel.hxx @@ -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 { diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest7.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest7.py index 1b655eb78..23277fdf5 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest7.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest7.py @@ -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__': diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 184143765..eb990f7e6 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -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