X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling_Swig%2FMEDCouplingIntersectTest.py;h=17acd21f92b44bfd3787ec76807c6a6aba278b78;hb=5b299d506fcc63ff652df59a13f5b082fd45dabf;hp=7c2eae6f7fa796c58bb33d2d633bf69720258c9f;hpb=305e7a33835941b70e0c8037351c92476ed4a08f;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling_Swig/MEDCouplingIntersectTest.py b/src/MEDCoupling_Swig/MEDCouplingIntersectTest.py index 7c2eae6f7..17acd21f9 100644 --- a/src/MEDCoupling_Swig/MEDCouplingIntersectTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingIntersectTest.py @@ -444,6 +444,32 @@ class MEDCouplingIntersectTest(unittest.TestCase): self.assertEqual(res1_tgt, resToM1.getValues()) self.assertEqual(res2_tgt, resToM2.getValues()) + def testIntersect2DMeshesTmp8(self): + """ Arc of circle #5 in m2 was wrongly linearized and this was crashing the intersector. """ + m1 = MEDCouplingUMesh('mesh', 2) + coo = DataArrayDouble([(-18.20296424065728,-16.39845900000000),(-18.15483625715243,-16.37067229576792),(-18.17890024890485,-16.38456564788396),(-18.86345900000000,-13.93345900000000),(-18.80788559153584,-13.93345900000000),(-18.64179353311466,-15.19505343584364),(-18.83567229576791,-13.93345900000000),(-18.69547332360511,-15.20943689235543)]) + m1.setCoords(coo) + c = DataArrayInt([32, 0, 3, 4, 1, 7, 6, 5, 2]) + cI = DataArrayInt([0, 9]) + m1.setConnectivity(c, cI) + + m2 = MEDCouplingUMesh('tool', 2) + coo = DataArrayDouble([-18.863459, -13.933459, -18.71895791290684, -15.11832192648871, -18.76569937343606, -12.95654908944806, -9.00470518045063, + -13.8226177338691, -17.88089225139922, -16.8868757883568, -18.3878542250287, -16.04610264700759, -18.71815899226182, -15.12154400708064, + -18.83895821216178, -13.44256442936377, -18.15535493732867, -16.47914057756773, -18.57607919534293, -15.59206616319266, -18.82720039287268, -14.53027989414214, -18.71855872378567, -15.11993303402953, + 0.,0.,0.,0.], 14, 2) + m2.setCoords(coo) + c = DataArrayInt([32, 1, 0, 2, 4, 5, 6, # offset 8: 9, 8, 10, 12, 13, 14 + 10, 7, 3, 8, 9, 11]) # 18, 15, 11, 16, 17, 19 + cI = DataArrayInt([0, 13]) + m2.setConnectivity(c, cI) + inter, map1, map2 = MEDCouplingUMesh.Intersect2DMeshes(m1, m2, 1.0e-8) + self.assertEqual(inter.getNodalConnectivity().getValues(), [32, 13, 14, 9, 8, 4, 1, 0, 22, 23, 24, 25, 26, 27, 28]) + self.assertEqual(inter.getNodalConnectivityIndex().getValues(), [0,15]) + self.assertEqual(map1.getValues(), [0]) + self.assertEqual(map2.getValues(), [0]) + pass + def testSwig2Intersect2DMeshWith1DLine1(self): """A basic test with no colinearity between m1 and m2.""" i=MEDCouplingIMesh("mesh",2,[5,5],[0.,0.],[1.,1.]) @@ -919,6 +945,34 @@ class MEDCouplingIntersectTest(unittest.TestCase): self.assertEqual(m1.getValues(), [0,0,1,1]) self.assertEqual(m2.getValues(), [0,1, -1,-1, -1,-1, 2,3, 0,1]) + def testSwig2Intersect2DMeshWith1DLine19(self): + """ Intersection arc of circle / segment was not properly detecting tangent cases """ + eps=1.0e-5 # was working at 1.0e-8, but should also really work with 1.0e-5 + mesh = MEDCouplingUMesh('layer_1', 2) + coo = DataArrayDouble([(55.4,3.7239),(61.4,7.188),(61.4,13.943),(49.55,7.1014), + (61.4,10.5655),(58.4,5.45595),(52.475,5.41265),(55.475,10.5222), + (56.9,9.34),(56.3343,7.97431),(56.9,7.74),(57.4657,7.97431),(59.4328,7.58116), + (55.8672,5.84911), (0.,0.)]) + mesh.setCoords(coo) + c = DataArrayInt([32, 0, 3, 2, 1, 11, 9, 6, 7, 4, 12, 8, 13]) + cI = DataArrayInt([0, 13]) + mesh.setConnectivity(c, cI) + tool = MEDCouplingUMesh('segment', 1) + coo = DataArrayDouble([(-166.611,-119.951),(269.611,131.902)]) + tool.setCoords(coo) + c = DataArrayInt([1, 0, 1]) + cI = DataArrayInt([0, 3]) + tool.setConnectivity(c, cI) + + res2D, res1D, m1, m2 = MEDCouplingUMesh.Intersect2DMeshWith1DLine(mesh, tool, eps) + + self.assertEqual(res2D.getNodalConnectivity().getValues(),[32, 19, 17, 3, 2, 18, 20, 33, 34, 35, 36, 37, 38, 32, 1, 11, 20, 18, 39, 40, 41, 42, 32, 9, 0, 17, 19, 29, 30, 31, 32]) + self.assertEqual(res2D.getNodalConnectivityIndex().getValues(),[0, 13, 22, 31]) + self.assertEqual(res1D.getNodalConnectivity().getValues(),[1, 15, 17, 1, 17, 19, 1, 19, 20, 1, 20, 18, 1, 18, 16]) + self.assertEqual(res1D.getNodalConnectivityIndex().getValues(),[0, 3, 6, 9, 12, 15]) + self.assertEqual(m1.getValues(), [0, 0, 0]) + self.assertEqual(m2.getValues(), [-1, -1, 0, 2, -1, -1, 0, 1, -1, -1]) + def testSwig2Conformize2D1(self): eps = 1.0e-8 coo = [0.,-0.5,0.,0.,0.5,0.,0.5,-0.5,0.25, @@ -1015,6 +1069,23 @@ class MEDCouplingIntersectTest(unittest.TestCase): self.assertTrue(m.getNodalConnectivityIndex().isEqual(DataArrayInt([0,13,20,27]))) pass + def testSwig2Conformize2D6(self): + """ Was raising an internal error on the tiny cell #1. SegSegIntersector was faulty (eps misinterpreted).""" + eps=1.0e-6 + mesh = MEDCouplingUMesh('Intersect2D', 2) + coo = DataArrayDouble([(-8.575398341058831,39.144034061751867),(-7.163839075265572,39.460696499553713),(-8.555240716524352,39.000452491656162),(-8.575381177420400,39.143911806168589),(-8.575389759239616,39.143972933960228),(-8.565310946972376,39.072182148912376),(-8.429007892596994,39.323429450193125),(-7.276475921428452,39.552916149667766),(-7.853580170499488,39.442382740946520),(-8.501337660834821,39.233025525494369),(-8.451698830704938,39.023021732647329),(-8.575293095466966,39.143931102458232),(-7.321160265208347,39.250835031152391),(-7.193377962393479,39.421292562742188),(-8.503477261299500,39.011771463728323),(-7.257269113800913,39.336063796947286),(-8.575337136449106,39.143921454338184),(-8.513495963085951,39.083476417552781),(-7.178608518829526,39.440994531147950),(-8.575345718262898,39.143982582105053),(-7.887252103212342,39.141010366774864),(-7.885555090015171,39.288688127112323),(-7.223911296170824,39.502221445493511)]) + mesh.setCoords(coo) + c = DataArrayInt([32, 2, 3, 11, 10, 5, 16, 17, 14, 32, 3, 0, 11, 4, 19, 16, 32, 13, 12, 10, 11, 15, 20, 17, 21, 32, 7, 1, 13, 11, 0, 6, 22, 18, 21, 19, 9, 8]) + cI = DataArrayInt([0, 9, 16, 25, 38]) + mesh.setConnectivity(c, cI) + + mesh.conformize2D(eps) # internal error was here + + c2, cI2 = mesh.getNodalConnectivity().getValues(), mesh.getNodalConnectivityIndex().getValues() + self.assertEqual(c2, c.getValues()) + self.assertEqual(cI2, cI.getValues()) + pass + def testSwig2Conformize3D1(self): """ Simple test where no edge merge is required, only face merging (first part of the algo) """ mesh = MEDCouplingUMesh('merge', 3)