]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Bug correction.
authorageay <ageay>
Tue, 3 Jul 2012 15:18:52 +0000 (15:18 +0000)
committerageay <ageay>
Tue, 3 Jul 2012 15:18:52 +0000 (15:18 +0000)
src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx
src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index 53378fe9343f96004746257abfbc535373d145ce..8ffec84e1756b308948fa3a427936bd89d024b89 100644 (file)
@@ -1372,3 +1372,82 @@ void MEDCouplingBasicsTest5::testComputeSkin1()
   umesh->decrRef();
   skin->decrRef();
 }
+
+void MEDCouplingBasicsTest5::testUMeshSetPartOfMySelf2()
+{
+  // resize with explicit ids list
+  MEDCouplingUMesh *m=build2DTargetMesh_1();
+  std::set<INTERP_KERNEL::NormalizedCellType> s; s.insert(INTERP_KERNEL::NORM_TRI3); s.insert(INTERP_KERNEL::NORM_QUAD4);
+  CPPUNIT_ASSERT(s==m->getAllTypes());
+  const int ids1[3]={0,3,4};
+  MEDCouplingUMesh *part=static_cast<MEDCouplingUMesh *>(m->buildPartOfMySelf(ids1,ids1+3,true));
+  part->simplexize(0)->decrRef();
+  const int ids2[3]={1,2,5};
+  MEDCouplingUMesh *part2=static_cast<MEDCouplingUMesh *>(part->buildPartOfMySelf(ids2,ids2+3,true));
+  m->setPartOfMySelf(ids1,ids1+3,*part2);
+  const int expected1[20]={3,0,4,1,3,1,4,2,3,4,5,2,3,6,7,4,3,7,5,4};
+  CPPUNIT_ASSERT(std::equal(expected1,expected1+20,m->getNodalConnectivity()->getConstPointer()));
+  CPPUNIT_ASSERT_EQUAL(20,m->getNodalConnectivity()->getNbOfElems());
+  const int expected2[6]={0,4,8,12,16,20};
+  CPPUNIT_ASSERT(std::equal(expected2,expected2+6,m->getNodalConnectivityIndex()->getConstPointer()));
+  CPPUNIT_ASSERT_EQUAL(6,m->getNodalConnectivityIndex()->getNbOfElems());
+  s.clear(); s.insert(INTERP_KERNEL::NORM_TRI3);
+  CPPUNIT_ASSERT(s==m->getAllTypes());
+  m->decrRef(); part->decrRef(); part2->decrRef();
+  // no resize with explicit ids list
+  m=build2DTargetMesh_1();
+  part=static_cast<MEDCouplingUMesh *>(m->buildPartOfMySelf(ids1,ids1+2,true));
+  part->convertAllToPoly();
+  m->setPartOfMySelf(ids1+1,ids1+3,*part);
+  const int expected3[23]={4,0,3,4,1,3,1,4,2,3,4,5,2,5,0,3,4,1,5,6,7,4,3};
+  CPPUNIT_ASSERT(std::equal(expected3,expected3+23,m->getNodalConnectivity()->getConstPointer()));
+  CPPUNIT_ASSERT_EQUAL(23,m->getNodalConnectivity()->getNbOfElems());
+  const int expected4[6]={0,5,9,13,18,23};
+  CPPUNIT_ASSERT(std::equal(expected4,expected4+6,m->getNodalConnectivityIndex()->getConstPointer()));
+  CPPUNIT_ASSERT_EQUAL(6,m->getNodalConnectivityIndex()->getNbOfElems());
+  s.clear(); s.insert(INTERP_KERNEL::NORM_TRI3); s.insert(INTERP_KERNEL::NORM_QUAD4); s.insert(INTERP_KERNEL::NORM_POLYGON);
+  CPPUNIT_ASSERT(s==m->getAllTypes());
+  m->decrRef(); part->decrRef();
+  // resize with range ids
+  m=build2DTargetMesh_1();
+  part=static_cast<MEDCouplingUMesh *>(m->buildPartOfMySelf2(3,5,1,true));
+  m->setPartOfMySelf2(1,3,1,*part);
+  const int expected5[25]={4,0,3,4,1,4,6,7,4,3,4,7,8,5,4,4,6,7,4,3,4,7,8,5,4};
+  CPPUNIT_ASSERT(std::equal(expected5,expected5+25,m->getNodalConnectivity()->getConstPointer()));
+  CPPUNIT_ASSERT_EQUAL(25,m->getNodalConnectivity()->getNbOfElems());
+  const int expected6[6]={0,5,10,15,20,25};
+  CPPUNIT_ASSERT(std::equal(expected6,expected6+6,m->getNodalConnectivityIndex()->getConstPointer()));
+  CPPUNIT_ASSERT_EQUAL(6,m->getNodalConnectivityIndex()->getNbOfElems());
+  s.clear(); s.insert(INTERP_KERNEL::NORM_QUAD4);
+  CPPUNIT_ASSERT(s==m->getAllTypes());
+  m->decrRef(); part->decrRef();
+  // no resize with range ids
+  m=build2DTargetMesh_1();
+  part=static_cast<MEDCouplingUMesh *>(m->buildPartOfMySelf2(0,5,3,true));
+  part->convertAllToPoly();
+  m->setPartOfMySelf2(3,5,1,*part);
+  const int expected7[23]={4,0,3,4,1,3,1,4,2,3,4,5,2,5,0,3,4,1,5,6,7,4,3};
+  CPPUNIT_ASSERT(std::equal(expected7,expected7+23,m->getNodalConnectivity()->getConstPointer()));
+  CPPUNIT_ASSERT_EQUAL(23,m->getNodalConnectivity()->getNbOfElems());
+  const int expected8[6]={0,5,9,13,18,23};
+  CPPUNIT_ASSERT(std::equal(expected8,expected8+6,m->getNodalConnectivityIndex()->getConstPointer()));
+  CPPUNIT_ASSERT_EQUAL(6,m->getNodalConnectivityIndex()->getNbOfElems());
+s.clear(); s.insert(INTERP_KERNEL::NORM_TRI3); s.insert(INTERP_KERNEL::NORM_QUAD4); s.insert(INTERP_KERNEL::NORM_POLYGON);
+  CPPUNIT_ASSERT(s==m->getAllTypes());
+  m->decrRef(); part->decrRef();
+  // no resize with range ids negative direction
+  m=build2DTargetMesh_1();
+  part=static_cast<MEDCouplingUMesh *>(m->buildPartOfMySelf2(3,-1,-3,true));
+  part->convertAllToPoly();
+  m->setPartOfMySelf2(4,2,-1,*part);
+  const int expected9[23]={4,0,3,4,1,3,1,4,2,3,4,5,2,5,0,3,4,1,5,6,7,4,3};
+  CPPUNIT_ASSERT(std::equal(expected9,expected9+23,m->getNodalConnectivity()->getConstPointer()));
+  CPPUNIT_ASSERT_EQUAL(23,m->getNodalConnectivity()->getNbOfElems());
+  const int expected10[6]={0,5,9,13,18,23};
+  CPPUNIT_ASSERT(std::equal(expected10,expected10+6,m->getNodalConnectivityIndex()->getConstPointer()));
+  CPPUNIT_ASSERT_EQUAL(6,m->getNodalConnectivityIndex()->getNbOfElems());
+  s.clear(); s.insert(INTERP_KERNEL::NORM_TRI3); s.insert(INTERP_KERNEL::NORM_QUAD4); s.insert(INTERP_KERNEL::NORM_POLYGON);
+  CPPUNIT_ASSERT(s==m->getAllTypes());
+  part->decrRef();
+  m->decrRef();
+}
index d8798baa3d417b91e2dec26427adcd19c15a92c6..babcbe5d4f9d55eb19ace884d946d636a6fa7df5 100644 (file)
@@ -61,6 +61,7 @@ namespace ParaMEDMEM
     CPPUNIT_TEST( testBuildSlice3D2 );
     CPPUNIT_TEST( testComputeTupleIdsToSelectFromCellIds1 );
     CPPUNIT_TEST( testComputeSkin1 );
+    CPPUNIT_TEST( testUMeshSetPartOfMySelf2 );
     CPPUNIT_TEST_SUITE_END();
   public:
     void testUMeshTessellate2D1();
@@ -89,6 +90,7 @@ namespace ParaMEDMEM
     void testBuildSlice3D2();
     void testComputeTupleIdsToSelectFromCellIds1();
     void testComputeSkin1();
+    void testUMeshSetPartOfMySelf2();
   };
 }
 
index 5c33f07010f373857446e82e2952264b646fb041..5fa0833a8b7bd4dca6e938c6c3cec1fcdf6a218f 100644 (file)
@@ -10044,6 +10044,50 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertEqual([0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8],trad.getValues())
         pass
 
+    def testUMeshSetPartOfMySelf2(self):
+        # resize with explicit ids list
+        m=MEDCouplingDataForTest.build2DTargetMesh_1()
+        self.assertEqual([3,4],m.getAllTypes())
+        part=m[[0,3,4]]
+        part.simplexize(0)
+        part2=part[[1,2,5]]
+        m[[0,3,4]]=part2
+        self.assertEqual([3,0,4,1,3,1,4,2,3,4,5,2,3,6,7,4,3,7,5,4],m.getNodalConnectivity().getValues())
+        self.assertEqual([0,4,8,12,16,20],m.getNodalConnectivityIndex().getValues())
+        self.assertEqual([3],m.getAllTypes())
+        # no resize with explicit ids list
+        m=MEDCouplingDataForTest.build2DTargetMesh_1()
+        part=m[[0,3]]
+        part.convertAllToPoly()
+        m[[3,4]]=part
+        self.assertEqual([4,0,3,4,1,3,1,4,2,3,4,5,2,5,0,3,4,1,5,6,7,4,3],m.getNodalConnectivity().getValues())
+        self.assertEqual([0,5,9,13,18,23],m.getNodalConnectivityIndex().getValues())
+        self.assertEqual([3,4,5],m.getAllTypes())
+        # resize with range ids
+        m=MEDCouplingDataForTest.build2DTargetMesh_1()
+        part=m[3:]
+        m[1:3]=part
+        self.assertEqual([4,0,3,4,1,4,6,7,4,3,4,7,8,5,4,4,6,7,4,3,4,7,8,5,4],m.getNodalConnectivity().getValues())
+        self.assertEqual([0,5,10,15,20,25],m.getNodalConnectivityIndex().getValues())
+        self.assertEqual([4],m.getAllTypes())
+        # no resize with range ids
+        m=MEDCouplingDataForTest.build2DTargetMesh_1()
+        part=m[0::3]
+        part.convertAllToPoly()
+        m[3:]=part
+        self.assertEqual([4,0,3,4,1,3,1,4,2,3,4,5,2,5,0,3,4,1,5,6,7,4,3],m.getNodalConnectivity().getValues())
+        self.assertEqual([0,5,9,13,18,23],m.getNodalConnectivityIndex().getValues())
+        self.assertEqual([3,4,5],m.getAllTypes())
+        # no resize with range ids negative direction
+        m=MEDCouplingDataForTest.build2DTargetMesh_1()
+        part=m[3::-3]
+        part.convertAllToPoly()
+        m[:-3:-1]=part
+        self.assertEqual([4,0,3,4,1,3,1,4,2,3,4,5,2,5,0,3,4,1,5,6,7,4,3],m.getNodalConnectivity().getValues())
+        self.assertEqual([0,5,9,13,18,23],m.getNodalConnectivityIndex().getValues())
+        self.assertEqual([3,4,5],m.getAllTypes())
+        pass
+
     def setUp(self):
         pass
     pass