]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Intersec bug fix: point not added properly inserted in splitting.
authorabn <adrien.bruneton@cea.fr>
Mon, 14 Jan 2019 14:29:26 +0000 (15:29 +0100)
committerabn <adrien.bruneton@cea.fr>
Mon, 14 Jan 2019 14:39:23 +0000 (15:39 +0100)
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.hxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.cxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx
src/MEDCoupling_Swig/MEDCouplingIntersectTest.py

index e5b3c1efc3763da90cf013cb7cabc04bb896e19c..d2a31d0cef8335edfa796785ac762fffb654cbcd 100644 (file)
@@ -1070,8 +1070,11 @@ void Edge::fillGlobalInfoAbs(bool direction, const std::map<INTERP_KERNEL::Node
 }
 
 void Edge::fillGlobalInfoAbs2(const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
-                                 std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const
+                              unsigned skipStartOrEnd,
+                              std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const
 {
-  _start->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,edgesOther);
+  if (skipStartOrEnd != 1) // see meaning in splitAbs()
+    _start->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,edgesOther);
+  if (skipStartOrEnd != 2)
   _end->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,edgesOther);
 }
index 2ed413efe5ed1d41c85bf085954b5938987fe14f..65162a84adeb2c5c0dafb9ac66672d990fa38731 100644 (file)
@@ -285,6 +285,7 @@ namespace INTERP_KERNEL
     void fillGlobalInfoAbs(bool direction, const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
                            std::vector<int>& edgesThis, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int> mapAddCoo) const;
     void fillGlobalInfoAbs2(const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
+                            unsigned skipStartOrEnd,
                             std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const;
 
   protected:
index 3f99fcde688dba6c1af7749557fc4e8b240c3eca..43b2f1926353b5cb1982f82d8d33cb3a4a662bff 100644 (file)
@@ -230,9 +230,10 @@ void ElementaryEdge::fillGlobalInfoAbs(const std::map<INTERP_KERNEL::Node *,int>
  * unsorted because the "other" mesh is not subdivided yet.
  */
 void ElementaryEdge::fillGlobalInfoAbs2(const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
+                                        unsigned skipStartOrEnd,
                                         std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const
 {
-  _ptr->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,edgesOther,addCoo,mapAddCoo);
+  _ptr->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,skipStartOrEnd,edgesOther,addCoo,mapAddCoo);
 }
 
 /*!
index f585b9aa1b5758df82e9321142082dc4b6abe085..dfeea282ea17b627d5247b32cbeb2178edaef7aa 100644 (file)
@@ -73,6 +73,7 @@ namespace INTERP_KERNEL
     INTERPKERNEL_EXPORT void fillGlobalInfoAbs(const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
                                                std::vector<int>& edgesThis, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int> mapAddCoo) const;
     INTERPKERNEL_EXPORT void fillGlobalInfoAbs2(const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
+                                                unsigned skipStartOrEnd,
                                                 std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const;
     INTERPKERNEL_EXPORT static ElementaryEdge *BuildEdgeFromStartEndDir(bool direction, INTERP_KERNEL::Node *start, INTERP_KERNEL::Node *end);
   private:
index 76d4efeac3e8cda6ab3d83cde86178282f31e8e7..e8a71439e2801c56ab969d1c552f87a83bbb4e88 100644 (file)
@@ -185,8 +185,8 @@ void Node::fillGlobalInfoAbs2(const std::map<INTERP_KERNEL::Node *,int>& mapThis
   int tmp;
   std::size_t sz1=addCoo.size();
   fillGlobalInfoAbs(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,&tmp);
-  if(sz1!=addCoo.size()
-      || (tmp >= offset2
+  if(sz1!=addCoo.size()     // newly created point
+      || (tmp >= offset2    // or previously created point merged with a neighbour
           && (pointsOther.size() == 0 || pointsOther.back() != tmp)))
     {
       pointsOther.push_back(tmp);
@@ -195,6 +195,5 @@ void Node::fillGlobalInfoAbs2(const std::map<INTERP_KERNEL::Node *,int>& mapThis
   std::vector<int>::const_iterator it=std::find(pointsOther.begin(),pointsOther.end(),tmp);
   if(it!=pointsOther.end())
     return ;
-  if(tmp<offset1)
-    pointsOther.push_back(tmp);
+  pointsOther.push_back(tmp);
 }
index b4353458dc5227cdf8602cdff8386a886ff35027..7d23e85e21f581fca99563bf16143748ac011325 100644 (file)
@@ -362,8 +362,14 @@ void QuadraticPolygon::splitAbs(QuadraticPolygon& other,
       // Converting back to integer connectivity:
       if(otherTmp._sub_edges.size()>1)   // only if a new point has been added (i.e. an actual intersection was done)
         {
-          for(std::list<ElementaryEdge *>::const_iterator it=otherTmp._sub_edges.begin();it!=otherTmp._sub_edges.end();it++)
-            (*it)->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,/**/fact,xBaryBB,yBaryBB,/**/subDivOther[otherEdgeIds[i]],addCoo,mapAddCoo);
+          int jj = 0;
+          for(std::list<ElementaryEdge *>::const_iterator it=otherTmp._sub_edges.begin();it!=otherTmp._sub_edges.end();it++, jj++)
+            {
+              unsigned skipStartOrEnd = jj == 0 ? 1 : (jj == _sub_edges.size()-1 ? 2 : -1);  // 1 means START, 2 means END, -1 other
+              (*it)->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,
+                                      fact,xBaryBB,yBaryBB, skipStartOrEnd,
+                                      /*out*/ subDivOther[otherEdgeIds[i]],addCoo,mapAddCoo);
+            }
         }
     }
   Delete(cThis);
index f19780274ad4db7197f605a39c35d84ab2bc07ae..c4fbe92478276451509f6e30f8397aa55dbbc6ab 100644 (file)
@@ -579,6 +579,33 @@ class MEDCouplingIntersectTest(unittest.TestCase):
         self.assertEqual(res2Tool.getValues(), [0, 1, -1, -1])
         pass
 
+    def testIntersect2DMeshesTmp10(self):
+        """ Fixing issues when one of the quadratic point of the tool mesh also serves as a regular point somewhere else.
+        WARNING : the tool mesh is not conform, but this was NOT the initial cause of the problem """
+        eps = 1.0e-6
+        back = MEDCouplingUMesh('layer_1', 2)
+        coo = DataArrayDouble([(0.000000000000000,0.000000000000000),(0.000000000000007,113.449999999999960),(113.449999999999960,0.000000000000000),(80.221264325613788,80.221264325613788),(0.000000000000003,56.724999999999980),(56.724999999999980,0.000000000000000)])
+        back.setCoords(coo)
+        c = DataArrayInt([32, 0, 1, 2, 4, 3, 5])
+        cI = DataArrayInt([0, 7])
+        back.setConnectivity(c, cI)
+
+        tool = MEDCouplingUMesh('layer_2', 2)
+        coo = DataArrayDouble([(35.499999704817512,0.000000000000011),(35.413523784223756,2.476354817916448),(35.478374361065050,1.238932132335084),(35.563158391762734,2.486818288978067),(35.649999999999999,0.000000000000000),(35.628282983230761,1.244167057444159),(35.488341087993248,2.481586553447257),(35.575000000000003,0.000000000000000),(35.154516440325750,4.940645084082323),(35.305526997492230,3.710760415787641),(35.154516440325743,-4.940645084082338),(34.960674956295250,-6.164510258681856),(35.413523784223763,-2.476354817916429),(35.305526997492230,-3.710760415787643),(35.563158391762734,-2.486818288978048),(35.488341087993248,-2.481586553447238),(35.478374361018354,-1.238932133672371),(35.628282983230761,-1.244167057444150)])
+        tool.setCoords(coo)
+        c = DataArrayInt([32, 0, 1, 3, 4, 2, 6, 5, 7,        # 32,  6, 7, 9, 10, 8, 12, 11, 13
+                             32, 12, 0, 4, 14, 16, 7, 17, 15,   # 32,  18, 6, 10, 20, 22, 13, 23, 21
+                             32, 8, 1, 12, 10, 9, 0, 13, 11])   # 32,  14, 7, 18, 16, 15, 6, 19, 17
+        cI = DataArrayInt([0, 9, 18, 27])
+        tool.setConnectivity(c, cI)
+        result, res2Back, res2Tool = MEDCouplingUMesh.Intersect2DMeshes(back, tool, eps)
+
+        self.assertEqual(result.getNodalConnectivity().getValues(), [32, 10, 6, 7, 9, 25, 26, 27, 28, 32, 6, 0, 24, 14, 7, 29, 30, 31, 32, 33, 32, 24, 1, 2, 10, 9, 7, 6, 7, 14, 34, 35, 36, 37, 38, 39, 40, 41, 42])
+        self.assertEqual(result.getNodalConnectivityIndex().getValues(), [0, 9, 20, 39])
+        self.assertEqual(res2Back.getValues(), [0, 0, 0])
+        self.assertEqual(res2Tool.getValues(), [0, 2, -1])
+        pass
+
     def testSwig2Intersect2DMeshWith1DLine1(self):
         """A basic test with no colinearity between m1 and m2."""
         i=MEDCouplingIMesh("mesh",2,[5,5],[0.,0.],[1.,1.])