]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
getUndergroundDataArrayExt is available for MEDFileIntField1TS and MEDFileFloatField1TS
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 16 Oct 2017 06:25:56 +0000 (08:25 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 16 Oct 2017 06:25:56 +0000 (08:25 +0200)
src/MEDLoader/Swig/MEDLoaderCommon.i
src/MEDLoader/Swig/MEDLoaderTest3.py
src/MEDLoader/Swig/MEDLoaderTypemaps.i

index b2694f7e627b1c1bb1b3256ad5de73f26acb6ea6..e2bf73373292cea47155b1f4af8526402e5ea9fa 100644 (file)
@@ -2379,29 +2379,7 @@ namespace MEDCoupling
 
          PyObject *getUndergroundDataArrayExt() const throw(INTERP_KERNEL::Exception)
          {
-           std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > 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<sz;i++)
-             {
-               PyObject *elt1=PyTuple_New(2);
-               PyObject *elt2=PyTuple_New(2);
-               PyTuple_SetItem(elt2,0,SWIG_From_int((int)elt1Cpp[i].first.first));
-               PyTuple_SetItem(elt2,1,SWIG_From_int(elt1Cpp[i].first.second));
-               PyObject *elt3=PyTuple_New(2);
-               PyTuple_SetItem(elt3,0,SWIG_From_int(elt1Cpp[i].second.first));
-               PyTuple_SetItem(elt3,1,SWIG_From_int(elt1Cpp[i].second.second));
-               PyTuple_SetItem(elt1,0,elt2);
-               PyTuple_SetItem(elt1,1,elt3);
-               PyList_SetItem(elt,i,elt1);
-             }
-           PyTuple_SetItem(ret,1,elt);
-           return ret;
+           return MEDFileField1TS_getUndergroundDataArrayExt<double>(self);
          }
        }
   };
@@ -2474,6 +2452,11 @@ namespace MEDCoupling
           ret->incrRef();
         return ret;
       }
+
+      PyObject *getUndergroundDataArrayExt() const throw(INTERP_KERNEL::Exception)
+      {
+        return MEDFileField1TS_getUndergroundDataArrayExt<int>(self);
+      }
     }
   };
 
@@ -2545,6 +2528,11 @@ namespace MEDCoupling
           ret->incrRef();
         return ret;
       }
+      
+      PyObject *getUndergroundDataArrayExt() const throw(INTERP_KERNEL::Exception)
+      {
+        return MEDFileField1TS_getUndergroundDataArrayExt<float>(self);
+      }
     }
   };
 
index 54c30077701e75726b5748e68050e523dd826167..28e0b2f03caa52f7d534c29dfae6780cc5c746be 100644 (file)
@@ -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])
index 379036af67afefe1d5b3acd01031425ebe58dc7a..77d53506d87e8558fc013fbc4c400bc03e8cf927 100644 (file)
@@ -413,3 +413,30 @@ PyObject *MEDFileField1TS_getFieldWithProfile(const typename MLFieldTraits<T>::F
   return ret;
 }
 
+template<class T>
+PyObject *MEDFileField1TS_getUndergroundDataArrayExt(const typename MLFieldTraits<T>::F1TSType *self)
+{
+  std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > elt1Cpp;
+  typename MEDCoupling::Traits<T>::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<T>::TI, SWIG_POINTER_OWN | 0 ));
+  std::size_t sz=elt1Cpp.size();
+  PyObject *elt=PyList_New(sz);
+  for(std::size_t i=0;i<sz;i++)
+    {
+      PyObject *elt1=PyTuple_New(2);
+      PyObject *elt2=PyTuple_New(2);
+      PyTuple_SetItem(elt2,0,SWIG_From_int((int)elt1Cpp[i].first.first));
+      PyTuple_SetItem(elt2,1,SWIG_From_int(elt1Cpp[i].first.second));
+      PyObject *elt3=PyTuple_New(2);
+      PyTuple_SetItem(elt3,0,SWIG_From_int(elt1Cpp[i].second.first));
+      PyTuple_SetItem(elt3,1,SWIG_From_int(elt1Cpp[i].second.second));
+      PyTuple_SetItem(elt1,0,elt2);
+      PyTuple_SetItem(elt1,1,elt3);
+      PyList_SetItem(elt,i,elt1);
+    }
+  PyTuple_SetItem(ret,1,elt);
+  return ret;
+}