]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
*** empty log message ***
authorageay <ageay>
Mon, 30 Jan 2012 09:41:21 +0000 (09:41 +0000)
committerageay <ageay>
Mon, 30 Jan 2012 09:41:21 +0000 (09:41 +0000)
src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx
src/MEDCoupling/Test/MEDCouplingBasicsTest4.hxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index 0b4a504b3a6f580a8395b72a870321d67cafdffd..7cbbf2a8faa200aaf53dc3dd9a6e962b8410f3e0 100644 (file)
@@ -1942,3 +1942,42 @@ void MEDCouplingBasicsTest4::testGetNodeIdsInUse1()
   m1->decrRef();
   m0->decrRef();
 }
+
+void MEDCouplingBasicsTest4::testBuildDescendingConnec2()
+{
+  MEDCouplingUMesh *mesh=build2DTargetMesh_1();
+  DataArrayInt *desc=DataArrayInt::New();
+  DataArrayInt *descIndx=DataArrayInt::New();
+  DataArrayInt *revDesc=DataArrayInt::New();
+  DataArrayInt *revDescIndx=DataArrayInt::New();
+  //
+  MEDCouplingUMesh *mesh2=mesh->buildDescendingConnectivity2(desc,descIndx,revDesc,revDescIndx);
+  mesh2->checkCoherency();
+  CPPUNIT_ASSERT_EQUAL(1,mesh2->getMeshDimension());
+  CPPUNIT_ASSERT_EQUAL(13,mesh2->getNumberOfCells());
+  CPPUNIT_ASSERT_EQUAL(14,revDescIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(14,revDescIndx->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(6,descIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(6,descIndx->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(18,desc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(18,desc->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(18,revDesc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(18,revDesc->getNumberOfTuples());
+  const int expected1[18]={1,2,3,4,-3,5,6, 7,8,-5,9,10,-2,11, 12,13,-7,-10};
+  CPPUNIT_ASSERT(std::equal(expected1,expected1+18,desc->getConstPointer()));
+  const int expected2[6]={0,4,7,10,14,18};
+  CPPUNIT_ASSERT(std::equal(expected2,expected2+6,descIndx->getConstPointer()));
+  const int expected3[14]={0,1,3,5,6,8,9,11,12,13,15,16,17,18};
+  CPPUNIT_ASSERT(std::equal(expected3,expected3+14,revDescIndx->getConstPointer()));
+  const int expected4[18]={0, 0,3, 0,1, 0, 1,2, 1, 2,4, 2, 3, 3,4, 3, 4, 4};
+  CPPUNIT_ASSERT(std::equal(expected4,expected4+18,revDesc->getConstPointer()));
+  DataArrayInt *conn=mesh2->getNodalConnectivity();
+  DataArrayInt *connIndex=mesh2->getNodalConnectivityIndex();
+  const int expected5[14]={0,3,6,9,12,15,18,21,24,27,30,33,36,39};
+  CPPUNIT_ASSERT(std::equal(expected5,expected5+14,connIndex->getConstPointer()));
+  const int expected6[39]={1, 0, 3, 1, 3, 4, 1, 4, 1, 1, 1, 0, 1, 4, 2, 1, 2, 1, 1, 4, 5, 1, 5, 2, 1, 6, 7, 1, 7, 4, 1, 3, 6, 1, 7, 8, 1, 8, 5};
+  CPPUNIT_ASSERT(std::equal(expected6,expected6+39,conn->getConstPointer()));
+  //
+  desc->decrRef();
+  descIndx->decrRef();
+  revDesc->decrRef();
+  revDescIndx->decrRef();
+  mesh2->decrRef();
+  mesh->decrRef();
+}
index e42a0018e70ede1800479ceae8c504faa3a8d3da..667f52d024be168d3ea10eae56784d2bdd2e0e47 100644 (file)
@@ -87,6 +87,7 @@ namespace ParaMEDMEM
     CPPUNIT_TEST( testDAIBuildOld2NewArrayFromSurjectiveFormat2 );
     CPPUNIT_TEST( testDADIReverse1 );
     CPPUNIT_TEST( testGetNodeIdsInUse1 );
+    CPPUNIT_TEST( testBuildDescendingConnec2 );
     CPPUNIT_TEST_SUITE_END();
   public:
     void testDescriptionInMeshTimeUnit1();
@@ -143,6 +144,7 @@ namespace ParaMEDMEM
     void testDAIBuildOld2NewArrayFromSurjectiveFormat2();
     void testDADIReverse1();
     void testGetNodeIdsInUse1();
+    void testBuildDescendingConnec2();
   };
 }
 
index 8f407d30383757fde2d0832594bf2a7b7d5dfbc2..f42672e9f9f8a447bc037222e7cc85b4dadc8539 100644 (file)
@@ -8065,6 +8065,33 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         expected2=[1,2,4,5]
         self.assertEqual(expected2,arr2.getValues());
         pass
+
+    def testBuildDescendingConnec2(self):
+        mesh=MEDCouplingDataForTest.build2DTargetMesh_1();
+        #
+        mesh2,desc,descIndx,revDesc,revDescIndx=mesh.buildDescendingConnectivity2();
+        mesh2.checkCoherency();
+        self.assertEqual(1,mesh2.getMeshDimension());
+        self.assertEqual(13,mesh2.getNumberOfCells());
+        self.assertEqual(14,revDescIndx.getNbOfElems()); self.assertEqual(14,revDescIndx.getNumberOfTuples());
+        self.assertEqual(6,descIndx.getNbOfElems()); self.assertEqual(6,descIndx.getNumberOfTuples());
+        self.assertEqual(18,desc.getNbOfElems()); self.assertEqual(18,desc.getNumberOfTuples());
+        self.assertEqual(18,revDesc.getNbOfElems()); self.assertEqual(18,revDesc.getNumberOfTuples());
+        expected1=[1,2,3,4,-3,5,6, 7,8,-5,9,10,-2,11, 12,13,-7,-10]
+        self.assertEqual(expected1,desc.getValues());
+        expected2=[0,4,7,10,14,18]
+        self.assertEqual(expected2,descIndx.getValues());
+        expected3=[0,1,3,5,6,8,9,11,12,13,15,16,17,18]
+        self.assertEqual(expected3,revDescIndx.getValues());
+        expected4=[0, 0,3, 0,1, 0, 1,2, 1, 2,4, 2, 3, 3,4, 3, 4, 4]
+        self.assertEqual(expected4,revDesc.getValues());
+        conn=mesh2.getNodalConnectivity();
+        connIndex=mesh2.getNodalConnectivityIndex();
+        expected5=[0,3,6,9,12,15,18,21,24,27,30,33,36,39]
+        self.assertEqual(expected5,connIndex.getValues());
+        expected6=[1, 0, 3, 1, 3, 4, 1, 4, 1, 1, 1, 0, 1, 4, 2, 1, 2, 1, 1, 4, 5, 1, 5, 2, 1, 6, 7, 1, 7, 4, 1, 3, 6, 1, 7, 8, 1, 8, 5]
+        self.assertEqual(expected6,conn.getValues());
+        pass
     
     def setUp(self):
         pass