1 # Check patch face functionality
3 def CheckFacesOnHoles( faces ):
5 check that none of the faces in the list have holes
6 param faces - list of faces
7 return bool - *True* if all faces not have hole; *False* otherwise
10 newFaces = geompy.PatchFace(face)
11 if len(newFaces) != 1:
15 def CompareAreaAfterPatchFace( originalFace, patchFaceResult, eps=1e-06 ):
17 Specific function for check result of PatchFace operation.
18 Check that area of original face equal area first face from list (face by outer wire of original face)
19 minus the areas of the rest elements from list (holes)
20 param originalFace - original face
21 param patchFaceResult - list of faces result PatchFace operation.
22 First element - face from outer wire of original face,
23 other elements - faces from holes on original face
24 param eps - defines tolerance for comparison
25 return bool - *True* if area of original face is equal of area face[0] minus area of holes; *False* otherwise
28 for index in range(1, len(patchFaceResult)):
29 areaOfHoles += geompy.BasicProperties(patchFaceResult[index])[1]
30 return geompy.BasicProperties(originalFace)[1] - (geompy.BasicProperties(patchFaceResult[0])[1] - areaOfHoles) <= eps
34 salome.salome_init_without_session()
36 from salome.geom import geomBuilder
37 geompy = geomBuilder.New()
40 vz = geompy.MakeVectorDXDYDZ(0, 0, 1)
41 pyz = geompy.MakeVertex(0, -150, 100)
43 geomObj = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
44 sk = geompy.Sketcher2D()
45 sk.addPoint(30.0000000, 50.0000000)
46 sk.addArcAbsolute(70.0000000, 20.0000000)
47 sk.addSegmentAbsolute(0.0000000, 0.0000000)
49 sketch = sk.wire(geomObj)
50 face_1 = geompy.MakeFaceWires([sketch], 1)
51 multiTranslation = geompy.MakeMultiTranslation1D(face_1, None, 105, 3)
52 [face_2,face_3,face_4] = geompy.ExtractShapes(multiTranslation, geompy.ShapeType["FACE"], True)
53 scale_1 = geompy.MakeScaleTransform(face_3, None, 0.3)
54 scale_2 = geompy.MakeScaleTransform(face_4, None, 0.3)
56 translation_1 = geompy.MakeTranslation(scale_1, -10, 25, 0)
57 translation_2 = geompy.MakeTranslation(scale_2, -25, 20, 0)
59 rotation_1 = geompy.MakeRotation(translation_1, vz, -19*math.pi/180.0)
60 rotation_2 = geompy.MakeRotation(translation_2, vz, 15*math.pi/180.0)
62 cut = geompy.MakeCutList(face_1, [rotation_2, rotation_1], True)
65 faces = geompy.PatchFace(cut)
67 # Check, that result faces haven't holes
68 assert(CheckFacesOnHoles(faces))
71 assert(CompareAreaAfterPatchFace(cut, faces))