Salome HOME
Updated copyright comment
[modules/shaper.git] / src / FeaturesPlugin / Test / TestSewing_Groups.py
1 import sys
2 import salome
3
4 salome.salome_init()
5
6 from SketchAPI import *
7 from GeomAPI import GeomAPI_Shape
8
9 from salome.shaper import model
10
11
12 model.begin()
13 partSet = model.moduleDocument()
14
15 ### Create Part
16 Part_1 = model.addPart(partSet)
17 Part_1_doc = Part_1.document()
18
19 ### Create Sketch
20 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
21
22 ### Create SketchLine
23 SketchLine_1 = Sketch_1.addLine(60, 0, 0, 0)
24
25 ### Create SketchProjection
26 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
27 SketchPoint_1 = SketchProjection_1.createdFeature()
28 Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchPoint_1.result())
29
30 ### Create SketchLine
31 SketchLine_2 = Sketch_1.addLine(0, 0, 0, 75)
32
33 ### Create SketchLine
34 SketchLine_3 = Sketch_1.addLine(0, 75, 60, 75)
35
36 ### Create SketchLine
37 SketchLine_4 = Sketch_1.addLine(60, 75, 60, 0)
38 Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
39 Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
40 Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
41 Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
42 Sketch_1.setHorizontal(SketchLine_1.result())
43 Sketch_1.setVertical(SketchLine_2.result())
44 Sketch_1.setHorizontal(SketchLine_3.result())
45 Sketch_1.setVertical(SketchLine_4.result())
46 model.do()
47
48 ### Create Face
49 Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")])
50
51 ### Create Sketch
52 Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ"))
53
54 ### Create SketchLine
55 SketchLine_5 = Sketch_2.addLine(75, 0.0001, 0, 0)
56
57 ### Create SketchProjection
58 SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex"), False)
59 SketchPoint_2 = SketchProjection_2.createdFeature()
60 Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchPoint_2.result())
61
62 ### Create SketchLine
63 SketchLine_6 = Sketch_2.addLine(0, 0, 0, 50)
64
65 ### Create SketchLine
66 SketchLine_7 = Sketch_2.addLine(0, 50, 75, 50)
67
68 ### Create SketchLine
69 SketchLine_8 = Sketch_2.addLine(75, 50, 75, 0.0001)
70 Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_5.startPoint())
71 Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
72 Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
73 Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
74 Sketch_2.setVertical(SketchLine_6.result())
75 Sketch_2.setHorizontal(SketchLine_7.result())
76 Sketch_2.setVertical(SketchLine_8.result())
77
78 ### Create SketchProjection
79 SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OY"), False)
80 SketchLine_9 = SketchProjection_3.createdFeature()
81 Sketch_2.setDistance(SketchLine_5.startPoint(), SketchLine_9.result(), 0.0001, True)
82
83 ### Create SketchProjection
84 SketchProjection_4 = Sketch_2.addProjection(model.selection("VERTEX", "Face_1_1/Modified_Vertex&Sketch_1/SketchLine_2_EndVertex&Sketch_1/SketchLine_3_StartVertex"), False)
85 SketchPoint_3 = SketchProjection_4.createdFeature()
86 Sketch_2.setHorizontalDistance(SketchLine_8.endPoint(), SketchAPI_Point(SketchPoint_3).coordinates(), 0)
87 model.do()
88
89 ### Create Face
90 Face_2 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_5r")])
91
92 ### Create Group
93 Group_1_objects = [model.selection("EDGE", "Face_1_1/Modified_Edge&Sketch_1/SketchLine_4"),
94                    model.selection("EDGE", "Face_1_1/Modified_Edge&Sketch_1/SketchLine_1"),
95                    model.selection("EDGE", "Face_1_1/Modified_Edge&Sketch_1/SketchLine_3"),
96                    model.selection("EDGE", "Face_1_1/Modified_Edge&Sketch_1/SketchLine_2")]
97 Group_1 = model.addGroup(Part_1_doc, "Edges", Group_1_objects)
98 model.do()
99
100 model.testNbResults(Group_1, 1)
101 model.testNbSubShapes(Group_1, GeomAPI_Shape.EDGE, [4])
102
103 ### Create Group
104 Group_2_objects = [model.selection("EDGE", "Face_2_1/Modified_Edge&Sketch_2/SketchLine_6"),
105                    model.selection("EDGE", "Face_2_1/Modified_Edge&Sketch_2/SketchLine_5"),
106                    model.selection("EDGE", "Face_2_1/Modified_Edge&Sketch_2/SketchLine_7"),
107                    model.selection("EDGE", "Face_2_1/Modified_Edge&Sketch_2/SketchLine_8")]
108 Group_2 = model.addGroup(Part_1_doc, "Edges", Group_2_objects)
109 model.do()
110
111 model.testNbResults(Group_2, 1)
112 model.testNbSubShapes(Group_2, GeomAPI_Shape.EDGE, [4])
113
114 ### Create Sewing
115 Sewing_1 = model.addSewing(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1")], 0.0001, allowNonManifold = True, alwaysCreateResult = False)
116 model.do()
117
118 model.testResults(Sewing_1, 1, [0], [1], [2], [7], [6])
119
120 # Move the groups after Sewing (move to the end)
121 Part_1_doc.moveFeature(Group_1.feature(), Sewing_1.feature())
122 Part_1_doc.moveFeature(Group_2.feature(), Sewing_1.feature())
123 model.end()
124
125 print("-------------------------------------------------------------------------")
126 print("IMPORTANT NOTE:")
127 print("The following checks will fail, as long as bos #33216 does not get fixed!")
128 print("-------------------------------------------------------------------------")
129 model.testNbResults(Group_1, 1)
130 model.testNbSubShapes(Group_1, GeomAPI_Shape.EDGE, [4])
131 model.testNbResults(Group_2, 1)
132 model.testNbSubShapes(Group_2, GeomAPI_Shape.EDGE, [4])
133
134 # Perform same test, but moving groups after Shell feature
135 model.undo()
136 model.undo()
137 model.testNbSubShapes(Group_1, GeomAPI_Shape.EDGE, [4])
138 model.testNbSubShapes(Group_2, GeomAPI_Shape.EDGE, [4])
139
140 ### Build Shell
141 model.begin()
142 Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1")])
143 model.do()
144
145 model.testResults(Shell_1, 2, [0,0], [1,1], [1,1], [4,4], [4,4])
146 model.testNbSubShapes(Shell_1, GeomAPI_Shape.EDGE, [4,4])
147
148 # Move the groups after Shell (move to the end)
149 Part_1_doc.moveFeature(Group_1.feature(), Shell_1.feature())
150 Part_1_doc.moveFeature(Group_2.feature(), Shell_1.feature())
151 model.end()
152
153 model.testNbResults(Group_1, 1)
154 model.testNbSubShapes(Group_1, GeomAPI_Shape.EDGE, [4])
155 model.testNbResults(Group_2, 1)
156 model.testNbSubShapes(Group_2, GeomAPI_Shape.EDGE, [4])