]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
swig of MEDCouplingUMesh.insertNextCell more general
authorageay <ageay>
Mon, 4 Feb 2013 09:34:06 +0000 (09:34 +0000)
committerageay <ageay>
Mon, 4 Feb 2013 09:34:06 +0000 (09:34 +0000)
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py
src/MEDCoupling_Swig/MEDCouplingCommon.i

index 7f38d19bdc011fd224f48760d3516c2454fb407f..59642040ea7fc3d3d7366e656ab3a2c472205000 100644 (file)
@@ -10961,6 +10961,39 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertEqual(12,b) ; self.assertEqual(125,len(a)) ; self.assertTrue(a.isIdentity())
         pass
 
+    def testSwigUMeshInsertNextCell1(self):
+        m=MEDCouplingUMesh("toto",2)
+        #
+        coords=DataArrayDouble([0.,0.,1.,1.,1.,0.]) ; m.setCoords(coords)
+        da=DataArrayInt([0,1,2])
+        m.allocateCells(0)
+        for i in xrange(5):
+            m.insertNextCell(NORM_TRI3,da)
+            pass
+        self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2])))
+        self.assertTrue(m.getNodalConnectivityIndex().isEqual(DataArrayInt([0,4,8,12,16,20])))
+        #
+        da=DataArrayInt([0,1,2,3])
+        m.allocateCells(0)
+        for i in xrange(5):
+            m.insertNextCell(NORM_TRI3,3,da)
+            pass
+        self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2])))
+        self.assertTrue(m.getNodalConnectivityIndex().isEqual(DataArrayInt([0,4,8,12,16,20])))
+        #
+        da=DataArrayInt([0,1])
+        m.allocateCells(0)
+        self.assertRaises(InterpKernelException,m.insertNextCell,NORM_TRI3,3,da)
+        #
+        da=DataArrayInt([0,1,2,0,1,3,0,1,4,0,1,5,0,1,6],5,3)
+        m.allocateCells(0)
+        for t in da:
+            m.insertNextCell(NORM_TRI3,t)
+            pass
+        self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([3,0,1,2,3,0,1,3,3,0,1,4,3,0,1,5,3,0,1,6])))
+        self.assertTrue(m.getNodalConnectivityIndex().isEqual(DataArrayInt([0,4,8,12,16,20])))
+        pass
+
     def setUp(self):
         pass
     pass
index b718ea8bba2219f796ce56668b2f24b3a1f2eaba..fa9dac3ecaa7624eeaee8ae90fa97af9541e17e2 100644 (file)
@@ -1605,11 +1605,12 @@ namespace ParaMEDMEM
 
       void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, PyObject *li) throw(INTERP_KERNEL::Exception)
       {
-        int sz;
-        INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&sz);
-        if(size>sz)
+        int szArr,sw,iTypppArr;
+        std::vector<int> stdvecTyyppArr;
+        const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr);
+        if(size>szArr)
           {
-            std::ostringstream oss; oss << "Wrap of MEDCouplingUMesh::insertNextCell : request of connectivity with length " << size << " whereas the length of input is " << sz << " !";
+            std::ostringstream oss; oss << "Wrap of MEDCouplingUMesh::insertNextCell : request of connectivity with length " << size << " whereas the length of input is " << szArr << " !";
             throw INTERP_KERNEL::Exception(oss.str().c_str());
           }
         self->insertNextCell(type,size,tmp);
@@ -1617,9 +1618,10 @@ namespace ParaMEDMEM
 
       void insertNextCell(INTERP_KERNEL::NormalizedCellType type, PyObject *li) throw(INTERP_KERNEL::Exception)
       {
-        int sz;
-        INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&sz);
-        self->insertNextCell(type,sz,tmp);
+        int szArr,sw,iTypppArr;
+        std::vector<int> stdvecTyyppArr;
+        const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr);
+        self->insertNextCell(type,szArr,tmp);
       }
       
       DataArrayInt *getNodalConnectivity() throw(INTERP_KERNEL::Exception)