]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Bug fix in Intersect2DMeshWith1D: intersectEdges1 was incorrect when
authorabn <adrien.bruneton@cea.fr>
Fri, 21 Nov 2014 14:29:23 +0000 (15:29 +0100)
committerabn <adrien.bruneton@cea.fr>
Fri, 21 Nov 2014 14:29:23 +0000 (15:29 +0100)
quadratic edges are given.

src/MEDCoupling/MEDCouplingUMesh.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py
src/MEDCoupling_Swig/MEDCouplingDataForTest.py

index ce0257e6e0fa3d7ec252bd3537ffbf8dee79d5f4..f9c16dcbfd8fa186c86f9b10e6dfb830d2b122ca 100644 (file)
@@ -10045,7 +10045,8 @@ void MEDCouplingUMesh::Intersect1DMeshes(const MEDCouplingUMesh *m1Desc, const M
           delete pol1;
         }
       else
-        intersectEdge1[i].insert(intersectEdge1[i].end(),c1+ci1[i]+1,c1+ci1[i+1]);
+        // Copy the edge (take only the two first points, ie discard quadratic point at this stage)
+        intersectEdge1[i].insert(intersectEdge1[i].end(),c1+ci1[i]+1,c1+ci1[i]+3);
     }
 }
 
index 08f0fc859aee0cec873da1de1f9d2968369a46cf..96ae8c4b91fe2516108d4b3827d245f132447122 100644 (file)
@@ -15858,6 +15858,30 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertTrue(d.isEqual(DataArrayInt([(-1,-1),(1,2),(1,2),(1,2),(-1,-1)])))
         pass
 
+    def testSwig2Intersect2DMeshWith1DLine10(self):
+        """ Intersection between a circle and various lines """
+        eps = 1.0e-8
+        m_circ = MEDCouplingDataForTest.buildCircle2(0.0, 0.0, 2.0)
+        coords = [0.0,3.0,0.0,-3.0]
+        connec = [0,1]
+        m_line = MEDCouplingUMesh.New("seg", 1)  
+        m_line.allocateCells(1)
+        meshCoords = DataArrayDouble.New(coords, len(coords)/2, 2)
+        m_line.setCoords(meshCoords)
+        m_line.insertNextCell(NORM_SEG2, connec)
+        a, b, c, d = MEDCouplingUMesh.Intersect2DMeshWith1DLine(m_circ, m_line, eps)    
+        self.assertEqual([32, 1, 7, 10, 11, 12, 13, 14, 15, 32, 5, 3, 11, 10, 16, 17, 18, 19], a.getNodalConnectivity().getValues())
+        self.assertEqual([0, 9, 18],   a.getNodalConnectivityIndex().getValues())
+        self.assertEqual([1, 8, 11, 1, 11, 10, 1, 10, 9], b.getNodalConnectivity().getValues())
+        self.assertEqual([0, 3, 6, 9], b.getNodalConnectivityIndex().getValues())
+        self.assertTrue(a.getCoords()[:8].isEqual(m_circ.getCoords(),1e-12))
+        self.assertTrue(a.getCoords()[8:10].isEqual(m_line.getCoords(),1e-12))
+        coo_tgt = DataArrayDouble([2.0, 0.0, 1.4142135623730951, 1.414213562373095, 1.2246467991473532e-16, 2.0, -1.414213562373095, 1.4142135623730951, -2.0, 2.4492935982947064e-16, -1.4142135623730954, -1.414213562373095, -3.6739403974420594e-16, -2.0, 1.4142135623730947, -1.4142135623730954, 0.0, 3.0, 0.0, -3.0, 0.0, -2.0, 0.0, 2.0, 2.0, -2.220446049250313e-16, 0.7653668647301797, -1.8477590650225735, 0.0, 0.0, 0.7653668647301797, 1.8477590650225735, -1.9999999999999998, -3.2343398276365944e-16, -0.7653668647301795, 1.8477590650225735, 0.0, 0.0, -0.7653668647301795, -1.8477590650225735])
+        self.assertTrue(a.getCoords().isEqualWithoutConsideringStr(coo_tgt, 1.0e-12))
+        self.assertTrue(a.getCoords().getHiddenCppPointer()==b.getCoords().getHiddenCppPointer())
+        self.assertEqual([0, 0], c.getValues())
+        self.assertEqual([-1, -1, 0, 1, -1, -1], d.getValues())
+
     def testOrderConsecutiveCells1D1(self):
         """A line in several unconnected pieces:"""
         m2 = MEDCouplingUMesh.New("bla", 1)
index 8012a6b83fce9a4cc37deeeae1eee5914a7137b0..ed5497fd8030b1f2fed1ed72c141710baa83eb88 100644 (file)
@@ -701,6 +701,25 @@ class MEDCouplingDataForTest:
       baseMesh.finishInsertingCells()  
       return baseMesh
 
+    def buildCircle2(self, center_X, center_Y, radius):  
+      from cmath import rect
+      from math import pi  
+  
+      c = [rect(radius, i*pi/4.0) for i in range(8)]
+      coords = []
+      for i in range(8):
+          coords.extend([c[i].real,c[i].imag])
+      connec = [7,5,3,1,  6,4,2,0]
+      baseMesh = MEDCouplingUMesh.New("circle", 2)  
+      baseMesh.allocateCells(1)
+      meshCoords = DataArrayDouble.New(coords, len(coords)/2, 2)
+      meshCoords += (center_X, center_Y)
+      baseMesh.setCoords(meshCoords)
+  
+      baseMesh.insertNextCell(NORM_QPOLYG, connec)  
+      baseMesh.finishInsertingCells()  
+      return baseMesh  
+
     build2DTargetMesh_1=classmethod(build2DTargetMesh_1)
     build2DSourceMesh_1=classmethod(build2DSourceMesh_1)
     build3DTargetMesh_1=classmethod(build3DTargetMesh_1)
@@ -730,6 +749,7 @@ class MEDCouplingDataForTest:
     buildFieldOnGauss_3=classmethod(buildFieldOnGauss_3)
     buildFieldOnGauss_4=classmethod(buildFieldOnGauss_4)
     buildCircle=classmethod(buildCircle)
+    buildCircle2=classmethod(buildCircle2)
     pass