From: Anthony Geay Date: Mon, 16 Oct 2017 06:25:56 +0000 (+0200) Subject: getUndergroundDataArrayExt is available for MEDFileIntField1TS and MEDFileFloatField1TS X-Git-Tag: V9_0_0~48 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5ce0ba42fdaf100a883d049236e96cdca3e4451b;p=tools%2Fmedcoupling.git getUndergroundDataArrayExt is available for MEDFileIntField1TS and MEDFileFloatField1TS --- diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index b2694f7e6..e2bf73373 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -2379,29 +2379,7 @@ namespace MEDCoupling PyObject *getUndergroundDataArrayExt() const throw(INTERP_KERNEL::Exception) { - std::vector< std::pair,std::pair > > elt1Cpp; - DataArrayDouble *elt0=self->getUndergroundDataArrayExt(elt1Cpp); - if(elt0) - elt0->incrRef(); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(elt0),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 )); - std::size_t sz=elt1Cpp.size(); - PyObject *elt=PyList_New(sz); - for(std::size_t i=0;i(self); } } }; @@ -2474,6 +2452,11 @@ namespace MEDCoupling ret->incrRef(); return ret; } + + PyObject *getUndergroundDataArrayExt() const throw(INTERP_KERNEL::Exception) + { + return MEDFileField1TS_getUndergroundDataArrayExt(self); + } } }; @@ -2545,6 +2528,11 @@ namespace MEDCoupling ret->incrRef(); return ret; } + + PyObject *getUndergroundDataArrayExt() const throw(INTERP_KERNEL::Exception) + { + return MEDFileField1TS_getUndergroundDataArrayExt(self); + } } }; diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index 54c300777..28e0b2f03 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -2628,6 +2628,9 @@ class MEDLoaderTest3(unittest.TestCase): self.assertEqual(a.getArray().getInfoOnComponents(),['power [MW/m^3]','density [g/cm^3]','temperature [K]']) self.assertTrue(a.isEqual(f1,1e-12,0)) ff1.write(fname,0) + a,b=ff1.getUndergroundDataArrayExt() + self.assertEqual(a.getHiddenCppPointer(),ff1.getUndergroundDataArray().getHiddenCppPointer()) + self.assertEqual(b,[((3,0),(0,2)),((4,0),(2,4)),((6,0),(4,5)),((5,0),(5,6))]) ff2=MEDFileAnyTypeField1TS.New(fname) self.assertEqual(ff2.getName(),"VectorFieldOnCells") self.assertEqual(ff2.getTime(),[0,1,2.0]) @@ -2637,7 +2640,7 @@ class MEDLoaderTest3(unittest.TestCase): self.assertTrue(a.isEqual(f1,1e-12,0)) ff2.setTime(1,2,3.) c=ff2.getUndergroundDataArray() ; c*=2 - ff2.write(fname,0) # 2 time steps in + ff2.write(fname,0) # 2 time steps in ffs1=MEDFileAnyTypeFieldMultiTS.New(fname,"VectorFieldOnCells") self.assertEqual(ffs1.getTimeSteps(),[(0, 1, 2.0), (1, 2, 3.0)]) self.assertEqual(len(ffs1),2) @@ -6007,6 +6010,9 @@ class MEDLoaderTest3(unittest.TestCase): self.assertEqual(a.getArray().getInfoOnComponents(),['power [MW/m^3]','density [g/cm^3]','temperature [K]']) self.assertTrue(a.isEqual(f1,1e-12,1e-12)) ff1.write(fname,0) + a,b=ff1.getUndergroundDataArrayExt() + self.assertEqual(a.getHiddenCppPointer(),ff1.getUndergroundDataArray().getHiddenCppPointer()) + self.assertEqual(b,[((3,0),(0,2)),((4,0),(2,4)),((6,0),(4,5)),((5,0),(5,6))]) ff2=MEDFileAnyTypeField1TS.New(fname) self.assertEqual(ff2.getName(),"VectorFieldOnCells") self.assertEqual(ff2.getTime(),[0,1,2.0]) diff --git a/src/MEDLoader/Swig/MEDLoaderTypemaps.i b/src/MEDLoader/Swig/MEDLoaderTypemaps.i index 379036af6..77d53506d 100644 --- a/src/MEDLoader/Swig/MEDLoaderTypemaps.i +++ b/src/MEDLoader/Swig/MEDLoaderTypemaps.i @@ -413,3 +413,30 @@ PyObject *MEDFileField1TS_getFieldWithProfile(const typename MLFieldTraits::F return ret; } +template +PyObject *MEDFileField1TS_getUndergroundDataArrayExt(const typename MLFieldTraits::F1TSType *self) +{ + std::vector< std::pair,std::pair > > elt1Cpp; + typename MEDCoupling::Traits::ArrayType *elt0=self->getUndergroundDataArrayExt(elt1Cpp); + if(elt0) + elt0->incrRef(); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(elt0),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); + std::size_t sz=elt1Cpp.size(); + PyObject *elt=PyList_New(sz); + for(std::size_t i=0;i