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

index f65d6f5641a78627d08594a92d514209c2e114cd..0b4a504b3a6f580a8395b72a870321d67cafdffd 100644 (file)
@@ -1921,3 +1921,24 @@ void MEDCouplingBasicsTest4::testDADIReverse1()
      CPPUNIT_ASSERT_DOUBLES_EQUAL(arr2[4-i],b->getIJ(i,0),1e-14);
    b->decrRef();
 }
+
+void MEDCouplingBasicsTest4::testGetNodeIdsInUse1()
+{
+  MEDCouplingUMesh *m0=build2DTargetMesh_1();
+  const int CellIds[2]={1,2};
+  MEDCouplingUMesh *m1=static_cast<MEDCouplingUMesh *>(m0->buildPartOfMySelf(CellIds,CellIds+2,true));
+  int newNbOfNodes=-1;
+  DataArrayInt *arr=m1->getNodeIdsInUse(newNbOfNodes);
+  const int expected[9]={-1,0,1,-1,2,3,-1,-1,-1};
+  CPPUNIT_ASSERT_EQUAL(4,newNbOfNodes);
+  CPPUNIT_ASSERT_EQUAL(9,arr->getNbOfElems());
+  CPPUNIT_ASSERT(std::equal(expected,expected+9,arr->getConstPointer()));
+  DataArrayInt *arr2=arr->invertArrayO2N2N2O(newNbOfNodes);
+  CPPUNIT_ASSERT_EQUAL(4,arr2->getNbOfElems());
+  const int expected2[4]={1,2,4,5};
+  CPPUNIT_ASSERT(std::equal(expected2,expected2+4,arr2->getConstPointer()));
+  arr2->decrRef();
+  arr->decrRef();
+  m1->decrRef();
+  m0->decrRef();
+}
index c88dfd4005232d38be94f5f792a23f1bbf741615..e42a0018e70ede1800479ceae8c504faa3a8d3da 100644 (file)
@@ -86,6 +86,7 @@ namespace ParaMEDMEM
     CPPUNIT_TEST( testDADGetDifferentValues1 );
     CPPUNIT_TEST( testDAIBuildOld2NewArrayFromSurjectiveFormat2 );
     CPPUNIT_TEST( testDADIReverse1 );
+    CPPUNIT_TEST( testGetNodeIdsInUse1 );
     CPPUNIT_TEST_SUITE_END();
   public:
     void testDescriptionInMeshTimeUnit1();
@@ -141,6 +142,7 @@ namespace ParaMEDMEM
     void testDADGetDifferentValues1();
     void testDAIBuildOld2NewArrayFromSurjectiveFormat2();
     void testDADIReverse1();
+    void testGetNodeIdsInUse1();
   };
 }
 
index ea61321faf3cf092de0a0979234d616fa1977e70..8f407d30383757fde2d0832594bf2a7b7d5dfbc2 100644 (file)
@@ -8050,6 +8050,21 @@ class MEDCouplingBasicsTest(unittest.TestCase):
             self.assertAlmostEqual(arr2[4-i],b.getIJ(i,0),14);
             pass
         pass
+
+    def testGetNodeIdsInUse1(self):
+        m0=MEDCouplingDataForTest.build2DTargetMesh_1();
+        CellIds=[1,2]
+        m1=m0.buildPartOfMySelf(CellIds,True);
+        arr,newNbOfNodes=m1.getNodeIdsInUse();
+        expected=[-1,0,1,-1,2,3,-1,-1,-1]
+        self.assertEqual(4,newNbOfNodes);
+        self.assertEqual(9,arr.getNbOfElems());
+        self.assertEqual(expected,arr.getValues());
+        arr2=arr.invertArrayO2N2N2O(newNbOfNodes);
+        self.assertEqual(4,arr2.getNbOfElems());
+        expected2=[1,2,4,5]
+        self.assertEqual(expected2,arr2.getValues());
+        pass
     
     def setUp(self):
         pass