From: ageay Date: Wed, 25 Apr 2012 16:13:42 +0000 (+0000) Subject: bug in checkButterfly X-Git-Tag: TRIPOLI_323~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e0a9c002ca51d5259c5174835def6da3b85c2168;p=tools%2Fmedcoupling.git bug in checkButterfly --- diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx index 5df23abb8..c85d413c5 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx @@ -131,6 +131,19 @@ void QuadraticPolygon::circularPermute() } } +bool QuadraticPolygon::isButterflyAbs() +{ + INTERP_KERNEL::Bounds b; + double xBary,yBary; + b.prepareForAggregation(); + fillBounds(b); + double dimChar=b.getCaracteristicDim(); + b.getBarycenter(xBary,yBary); + applyGlobalSimilarity(xBary,yBary,dimChar); + // + return isButterfly(); +} + bool QuadraticPolygon::isButterfly() const { for(std::list::const_iterator it=_sub_edges.begin();it!=_sub_edges.end();it++) diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx index 41e95812b..a7beda997 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx @@ -46,6 +46,7 @@ namespace INTERP_KERNEL ~QuadraticPolygon(); void closeMe() const; void circularPermute(); + bool isButterflyAbs(); bool isButterfly() const; void dumpInXfigFile(const char *fileName) const; void dumpInXfigFileWithOther(const ComposedEdge& other, const char *fileName) const; diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx index b64b3f216..68c1b9aea 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx @@ -819,3 +819,26 @@ void MEDCouplingBasicsTest5::testComputeNeighborsOfCells1() d2->decrRef(); m->decrRef(); } + +void MEDCouplingBasicsTest5::testCheckButterflyCellsBug1() +{ + double mesh2DCoords[10]={323.85,120.983748908684,317.5,131.982271536747,336.55,120.983748908686,330.2,131.982271536751,323.85,142.98079416481}; + int mesh2DConn[5]={4,1,0,2,3}; + MEDCouplingUMesh *mesh2D=MEDCouplingUMesh::New("mesh",2); + mesh2D->allocateCells(1); + mesh2D->insertNextCell(INTERP_KERNEL::NORM_POLYGON,5,mesh2DConn); + mesh2D->finishInsertingCells(); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(5,2); + std::copy(mesh2DCoords,mesh2DCoords+10,myCoords->getPointer()); + mesh2D->setCoords(myCoords); + myCoords->decrRef(); + mesh2D->checkCoherency(); + // + mesh2D->writeVTK("pupu.vtu"); + std::vector v; + mesh2D->checkButterflyCells(v); + CPPUNIT_ASSERT_EQUAL(0,(int)v.size()); + // + mesh2D->decrRef(); +} diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx index 9052099bd..8ac380b1a 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx @@ -49,6 +49,7 @@ namespace ParaMEDMEM CPPUNIT_TEST( testGetNodeIdsOfCell2 ); CPPUNIT_TEST( testRenumberNodesInConn1 ); CPPUNIT_TEST( testComputeNeighborsOfCells1 ); + CPPUNIT_TEST( testCheckButterflyCellsBug1 ); CPPUNIT_TEST_SUITE_END(); public: void testUMeshTessellate2D1(); @@ -65,6 +66,7 @@ namespace ParaMEDMEM void testGetNodeIdsOfCell2(); void testRenumberNodesInConn1(); void testComputeNeighborsOfCells1(); + void testCheckButterflyCellsBug1(); }; } diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index 026159374..5698dc976 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -1172,10 +1172,10 @@ namespace ParaMEDMEM PyList_SetItem(res,2,SWIG_From_int(ret2)); return res; } - PyObject *checkButterflyCells() throw(INTERP_KERNEL::Exception) + PyObject *checkButterflyCells(double eps=1e-12) throw(INTERP_KERNEL::Exception) { std::vector cells; - self->checkButterflyCells(cells); + self->checkButterflyCells(cells,eps); DataArrayInt *ret=DataArrayInt::New(); ret->alloc((int)cells.size(),1); std::copy(cells.begin(),cells.end(),ret->getPointer()); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 6fecf729b..4488ecc63 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -9754,6 +9754,21 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(expected2,d1.getValues()); pass + def testCheckButterflyCellsBug1(self): + mesh2DCoords=[323.85,120.983748908684,317.5,131.982271536747,336.55,120.983748908686,330.2,131.982271536751,323.85,142.98079416481] + mesh2DConn=[4,1,0,2,3] + mesh2D=MEDCouplingUMesh.New("mesh",2); + mesh2D.allocateCells(1); + mesh2D.insertNextCell(NORM_POLYGON,5,mesh2DConn[0:5]) + mesh2D.finishInsertingCells(); + myCoords=DataArrayDouble.New(mesh2DCoords,5,2); + mesh2D.setCoords(myCoords); + mesh2D.checkCoherency(); + # + v=mesh2D.checkButterflyCells(); + self.assertTrue(v.empty()); + pass + def setUp(self): pass pass