]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Tricky bug fix in IntersectMeshes.
authorageay <ageay>
Fri, 20 Sep 2013 07:50:43 +0000 (07:50 +0000)
committerageay <ageay>
Fri, 20 Sep 2013 07:50:43 +0000 (07:50 +0000)
src/MEDCoupling/MEDCouplingUMesh.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index bd2f9b5dc8d71f86b280c3c23e85254012d6519e..c04843cf7ec1b11e21997818d4425c4ed080cc2a 100644 (file)
@@ -8372,6 +8372,16 @@ void MEDCouplingUMesh::IntersectDescending2DMeshes(const MEDCouplingUMesh *m1, c
           INTERP_KERNEL::QuadraticPolygon *pol2=MEDCouplingUMeshBuildQPFromMesh(m2Desc,candidates2,map2);
           candidates1[0]=i;
           INTERP_KERNEL::QuadraticPolygon *pol1=MEDCouplingUMeshBuildQPFromMesh(m1Desc,candidates1,map1);
+          // this following part is to avoid that a some remove nodes (for example due to a merge between pol1 and pol2) can be replaced by a newlt created one
+          // This trick garanties that Node * are discriminant
+          std::set<INTERP_KERNEL::Node *> nodes;
+          pol1->getAllNodes(nodes); pol2->getAllNodes(nodes);
+          std::size_t szz(nodes.size());
+          std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Node> > nodesSafe(szz);
+          std::set<INTERP_KERNEL::Node *>::const_iterator itt(nodes.begin());
+          for(std::size_t iii=0;iii<szz;iii++,itt++)
+            { (*itt)->incrRef(); nodesSafe[iii]=*itt; }
+          // end of protection
           pol1->splitAbs(*pol2,map1,map2,offset1,offset2,candidates2,intersectEdge1[i],i,colinear2,subDiv2,addCoo);
           delete pol2;
           delete pol1;
index 9ad66f09324fa80ca4d00951af1dd8f3d9308848..43d1357aa7ec4980bb049c5ec469f2e7eca2c965 100644 (file)
@@ -13869,6 +13869,26 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         exp=DataArrayDouble([18.5,118.5,17.5,117.5,16.5,116.5,14.5,114.5,13.5,113.5,12.5,112.5],6,2) ; exp.setInfoOnComponents(["aa [km]","bbb [kJ]"])
         self.assertTrue(f2.getArray().isEqual(exp,1e-13))
         pass
+    
+    def testSwig2NonRegressionBugIntersectMeshes1(self):
+        src=MEDCouplingUMesh("src",2)
+        src.setCoords(DataArrayDouble([-2.5,-3,-2.5,3,2.5,3],3,2))
+        src.allocateCells()
+        src.insertNextCell(NORM_TRI3,[0,1,2])
+        #
+        trg=MEDCouplingUMesh("trg",2)
+        trg.setCoords(DataArrayDouble([-2.5,-3.,0.,-3.,0.,-2.,-2.,0.,-2.25,0.,-2.5,0.,-2.5,-1.5,0.,-2.5,-1.25,-3.,-1.414213562373095,-1.414213562373095],10,2))
+        trg.allocateCells()
+        trg.insertNextCell(NORM_QPOLYG,[2,1,0,5,3,7,8,6,4,9])
+        #
+        a,b,c=MEDCouplingUMesh.Intersect2DMeshes(src,trg,1.0e-8)
+        a.mergeNodes(1e-8)
+        self.assertTrue(a.getCoords().isEqual(DataArrayDouble([-2.5,-3.,-2.5,3.,2.5,3.,0.,-3.,0.,-2.,-2.,0.,-2.25,0.,-2.5,0.,-2.5,-1.5,0.,-2.5,-1.25,-3.,-1.414213562373095,-1.414213562373095,-1.2803687993289596,-1.5364425591947515,-1.8901843996644798,-2.2682212795973755,-1.81117884244736,-0.8483107924994473,-2.5,1.5,0.,3.,0.6098156003355202,0.7317787204026243],18,2),1e-12))
+        self.assertTrue(a.getNodalConnectivity().isEqual(DataArrayInt([32,12,0,7,5,13,8,6,14,32,7,1,2,12,5,15,16,17,14,6])))
+        self.assertTrue(a.getNodalConnectivityIndex().isEqual(DataArrayInt([0,9,20])))
+        self.assertTrue(b.isEqual(DataArrayInt([0,0])))
+        self.assertTrue(c.isEqual(DataArrayInt([0,-1])))
+        pass
 
     def setUp(self):
         pass