]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
bug in checkButterfly
authorageay <ageay>
Wed, 25 Apr 2012 16:13:42 +0000 (16:13 +0000)
committerageay <ageay>
Wed, 25 Apr 2012 16:13:42 +0000 (16:13 +0000)
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx
src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx
src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx
src/MEDCoupling_Swig/MEDCoupling.i
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index 5df23abb829784fb201541398252f1e648b91955..c85d413c56a2da71472a951384097816392d022c 100644 (file)
@@ -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<ElementaryEdge *>::const_iterator it=_sub_edges.begin();it!=_sub_edges.end();it++)
index 41e95812be812d26bbb424da05bae8b4c696fb18..a7beda997e8009cba1a0bc16e776c48bd676ad94 100644 (file)
@@ -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;
index b64b3f2169156fc3b76d0c549803b473c4857301..68c1b9aea3cd5916a5da2647b20d5974bcce79ae 100644 (file)
@@ -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<int> v;
+  mesh2D->checkButterflyCells(v);
+  CPPUNIT_ASSERT_EQUAL(0,(int)v.size());
+  //
+  mesh2D->decrRef();
+}
index 9052099bd24de87fed81e4cb407d4ac98a0e6e83..8ac380b1a0d39a5648f38e50417b2ff782334a33 100644 (file)
@@ -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();
   };
 }
 
index 026159374eaa29de5f272f76226aa7b7be39a6c8..5698dc976cef988380cd25c445c1166c5a146322 100644 (file)
@@ -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<int> 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());
index 6fecf729b9106e0da8d0b742502b41d8de5a2dcc..4488ecc638118a2f89078cb9d2b915a6852f1157 100644 (file)
@@ -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