From: ageay Date: Tue, 3 Jul 2012 15:18:52 +0000 (+0000) Subject: Bug correction. X-Git-Tag: V6_main_FINAL~601 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=44cf144359fea6c86b217c8a7248debc107ceb6e;p=tools%2Fmedcoupling.git Bug correction. --- diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx index 53378fe93..8ffec84e1 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx @@ -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 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(m->buildPartOfMySelf(ids1,ids1+3,true)); + part->simplexize(0)->decrRef(); + const int ids2[3]={1,2,5}; + MEDCouplingUMesh *part2=static_cast(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(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(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(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(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(); +} diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx index d8798baa3..babcbe5d4 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx @@ -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(); }; } diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 5c33f0701..5fa0833a8 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -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