]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
Ze test of 1SGTUMesh.
authorageay <ageay>
Thu, 20 Jun 2013 06:27:50 +0000 (06:27 +0000)
committerageay <ageay>
Thu, 20 Jun 2013 06:27:50 +0000 (06:27 +0000)
src/MEDCoupling/MEDCoupling1GTUMesh.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index fb67f3a0e90dc5ea64b33419b9c8b5b71bd177ff..20960db90e8f2ca63197b3c63e30ef13a9477836 100644 (file)
@@ -932,33 +932,25 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshesOnSameCoords(std::ve
   std::vector<const MEDCoupling1SGTUMesh *>::const_iterator it=a.begin();
   if(!(*it))
     throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::Merge1SGTUMeshesOnSameCoords : presence of null instance !");
+  std::vector<const DataArrayInt *> ncs(a.size());
   int nbOfCells=(*it)->getNumberOfCells();
   const DataArrayDouble *coords=(*it)->getCoords();
   const INTERP_KERNEL::CellModel *cm=&((*it)->getCellModel());
   int nbNodesPerCell=(*it)->getNumberOfNodesPerCell();
+  ncs[0]=(*it)->getNodalConnectivity();
   it++;
-  for(;it!=a.end();it++)
+  for(int i=1;it!=a.end();i++,it++)
     {
       if(cm!=&((*it)->getCellModel()))
         throw INTERP_KERNEL::Exception("Geometric types mismatches, Merge1SGTUMeshes impossible !");
-      nbOfCells+=(*it)->getNumberOfCells();
+      (*it)->getNumberOfCells();//to check that all is OK
+      ncs[i]=(*it)->getNodalConnectivity();
       if(coords!=(*it)->getCoords())
         throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::Merge1SGTUMeshesOnSameCoords : not lying on same coords !");
     }
   MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(new MEDCoupling1SGTUMesh("merge",*cm));
   ret->setCoords(coords);
-  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c=DataArrayInt::New();
-  c->alloc(nbOfCells*nbNodesPerCell,1);
-  int *cPtr=c->getPointer();
-  int offset=0;
-  for(it=a.begin();it!=a.end();it++)
-    {
-      int curConnLgth=(*it)->getNodalConnectivityLength();
-      const int *curC=(*it)->_conn->begin();
-      cPtr=std::copy(curC,curC+curConnLgth,cPtr);
-    }
-  //
-  ret->_conn=c;
+  ret->_conn=DataArrayInt::Aggregate(ncs);
   return ret.retn();
 }
 
index f969265edc13815858c4f1a0ce34279d2a0a1300..71f26e55c24227e85eaaca94fef56b1cd0c9788b 100644 (file)
@@ -12996,6 +12996,18 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         mo.setNodalConnectivity(DataArrayInt([1,0,6,7,2,1,7,8,3,2,8,9,4,3,9,10,5,4,10,11]))
         self.assertTrue(m.isEqual(mo,1e-12))
         #
+        mo2=MEDCoupling1SGTUMesh.Merge1SGTUMeshesOnSameCoords([m[[0,1]],m[[2]],m[[3,4]]])
+        mo2.setName(m.getName())
+        self.assertTrue(m.isEqual(mo2,1e-12))
+        #
+        mp0=m[[0]] ; mp0.zipCoords() ; mp1=m[2] ; mp1.zipCoords() ; mp2=m[4] ; mp2.zipCoords()
+        mo3=MEDCoupling1SGTUMesh.Merge1SGTUMeshes([mp0,mp1,mp2])
+        self.assertTrue(isinstance(mo3,MEDCoupling1SGTUMesh))
+        mo3.setName(m.getName())
+        m_ref=m[(0,2,4)] ; m_ref.zipCoords()
+        m_ref.tryToShareSameCoordsPermute(mo3,1e-12)
+        self.assertTrue(m_ref.isEqual(mo3,1e-12))
+        #
         m1=um.buildDescendingConnectivity()[0]
         ids=m1.getCellIdsFullyIncludedInNodeIds(DataArrayInt.Range(0,12,1))
         m1=m1[ids]
@@ -13073,7 +13085,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         #
         invalidPfl=DataArrayInt([1,2,3,4,5])
         self.assertRaises(InterpKernelException,m.checkTypeConsistencyAndContig,[NORM_QUAD4,5,0],[invalidPfl])
-        #self.assertRaises(InterpKernelException,m.buildUnstructured().checkTypeConsistencyAndContig,[NORM_QUAD4,5,0],[invalidPfl])# should throw debug
+        self.assertRaises(InterpKernelException,m.buildUnstructured().checkTypeConsistencyAndContig,[NORM_QUAD4,5,0],[invalidPfl])
         ##
         self.assertTrue(DataArrayInt([4,4,4,4,4]).isEqual(m.computeNbOfNodesPerCell()))
         ##