]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
Adding test of self intersecting quadratic mesh.
authorbruneton <bruneton>
Tue, 14 Jan 2014 10:46:01 +0000 (10:46 +0000)
committerbruneton <bruneton>
Tue, 14 Jan 2014 10:46:01 +0000 (10:46 +0000)
src/INTERP_KERNELTest/QuadraticPlanarInterpTest5.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index 3a1b63e24379589ee5a0e732d4b6a518e0e70702..1472341ad57e3a9581a34337e7e61e0c5edca40f 100644 (file)
@@ -1181,10 +1181,6 @@ void QuadraticPlanarInterpTest::checkIsInOrOut()
   coords[4] = (coords[0] + coords[2]) / 2.0;
   coords[5] = (coords[1] + coords[3]) / 2.0;
 
-/*  double r = 0.55495557248864675969;
-  coords[6] = coords[4];
-  coords[7] = coords[5] + r;*/
-
   int tab4[4]={ 0, 1, 2, 3};
   QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab4,4);
   Node * n = new Node(0.3175267678416348, -0.4890996430954449);
index 2acf8e0dc2e7b8c90e917b04cce7cf5bfffce66c..58372b3ebff88c2c32019ff2741b93be40190a00 100644 (file)
@@ -10367,6 +10367,58 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertEqual(expected2,d2.getValues())
         pass
 
+    def testSwig2Intersect2DMeshesQuadra1(self):
+        import cmath
+        def createDiagCircle(lX, lY, R, cells=[0,1]):  
+            """ A circle in a square box, cut along the diagonal. 
+            """    
+            c = []
+            for i in range(8):
+              c.append(cmath.rect(R, i*pi/4))
+        
+            coords = [0.0,0.0,          c[3].real,c[3].imag,       -lX/2.0, lY/2.0,
+                      0.0, lY/2.0,      lX/2.0,lY/2.0,             lX/2.0,0.0,
+                      #   6                  7                              8
+                      lX/2.0,-lY/2.0,   c[7].real,c[7].imag,       c[1].real,c[1].imag,
+                      #   9                  10                            11  
+                      c[5].real,c[5].imag,   -lX/2.0,-lY/2.0,      0.0, -lY/2.0,
+                      #   12                  13                            14
+                      -lX/2.0,0.0,         0.0,0.0,                  0.0, 0.0]
+            # Points 13 (reps. 14) are average of points (6,7) (resp (1,2))
+            coords[13*2]   = 0.5*(coords[6*2]+coords[7*2])
+            coords[13*2+1] = 0.5*(coords[6*2+1]+coords[7*2+1])
+            coords[14*2]   = 0.5*(coords[1*2]+coords[2*2])
+            coords[14*2+1] = 0.5*(coords[1*2+1]+coords[2*2+1])
+            connec  = [1,7,8,0]      # half circle up right
+            connec3 = [6,7,1,2,4,13,8,14,3,5]
+            
+            baseMesh = MEDCouplingUMesh.New("box_circle", 2)  
+            baseMesh.allocateCells(2)
+            meshCoords = DataArrayDouble.New(coords, len(coords)/2, 2)
+            meshCoords.setInfoOnComponents(["X [au]", "Y [au]"])
+            baseMesh.setCoords(meshCoords)
+            
+            if 0 in cells:
+              baseMesh.insertNextCell(NORM_QPOLYG, connec)  
+            if 1 in cells: 
+              baseMesh.insertNextCell(NORM_QPOLYG, connec3) 
+            baseMesh.finishInsertingCells()  
+            baseMesh.checkCoherency() 
+            return baseMesh 
+        
+        eps = 1.0e-7
+        m1 = createDiagCircle(1.0, 1.0, 0.5*0.90, cells=[0,1])  
+        m2 = createDiagCircle(1.0, 1.0, 0.5*0.95, cells=[0])
+        m3, _, _= MEDCouplingUMesh.Intersect2DMeshes(m1, m2, eps)
+        m3.mergeNodes(eps)
+        m3.convertDegeneratedCells()
+        m3.zipCoords()        
+        m4 = m3.deepCpy()
+        m5, _, _ = MEDCouplingUMesh.Intersect2DMeshes(m3, m4, eps)
+        m5.mergeNodes(eps)
+        # Check coordinates:
+        self.assertTrue(m3.getCoords().isEqual(m5.getCoords(), eps))
+
     def testDAIBuildUnique1(self):
         d=DataArrayInt([1,2,2,3,3,3,3,4,5,5,7,7,7,19])
         e=d.buildUnique()
@@ -14133,4 +14185,5 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         pass
     pass
 
-unittest.main()
+if __name__ == '__main__':
+    unittest.main()