Salome HOME
Merge remote-tracking branch 'remotes/origin/occ/compounds_processing'
[modules/shaper.git] / src / FeaturesPlugin / Test / TestMultiTranslation_MultiLevelCompound_v95_3.py
1 # Copyright (C) 2020  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 from salome.shaper import model
21 from GeomAPI import *
22 from GeomAlgoAPI import *
23
24 model.begin()
25 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
29 SketchPoint_1 = Sketch_1.addPoint(44.29784155360136, 17.09942588468031)
30 SketchArc_1 = Sketch_1.addArc(44.29784155360136, 17.09942588468031, 47.1668727423061, 12.27945348765633, 45.38299232715926, 22.60269052200972, False)
31 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchArc_1.center())
32 SketchLine_1 = Sketch_1.addLine(42.5764228403785, 22.14892077680068, 39.70739165167375, 16.41085839939117)
33 SketchLine_2 = Sketch_1.addLine(39.70739165167375, 16.41085839939117, 43.03546783057126, 12.04993099255995)
34 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
35 SketchLine_3 = Sketch_1.addLine(28.57555063949931, 12.96802097294547, 15.72229091410204, 12.96802097294547)
36 SketchLine_4 = Sketch_1.addLine(15.72229091410204, 12.96802097294547, 15.72229091410204, 21.46035329151154)
37 SketchLine_5 = Sketch_1.addLine(15.72229091410204, 21.46035329151154, 28.57555063949931, 21.46035329151154)
38 SketchLine_6 = Sketch_1.addLine(28.57555063949931, 21.46035329151154, 28.57555063949931, 12.96802097294547)
39 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_3.startPoint())
40 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
41 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
42 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
43 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_3.result())
44 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_4.result())
45 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_5.result())
46 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_6.result())
47 SketchLine_7 = Sketch_1.addLine(-10.67279602198167, 14.78814178154371, -28.34602814440294, 14.78814178154371)
48 SketchLine_8 = Sketch_1.addLine(-28.34602814440294, 14.78814178154371, -28.34602814440294, 25.13271321305362)
49 SketchLine_9 = Sketch_1.addLine(-28.34602814440294, 25.13271321305362, -10.67279602198167, 25.13271321305362)
50 SketchLine_10 = Sketch_1.addLine(-10.67279602198167, 25.13271321305362, -10.67279602198167, 14.78814178154371)
51 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_7.startPoint())
52 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
53 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
54 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
55 SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_7.result())
56 SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_8.result())
57 SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_9.result())
58 SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_10.result())
59 SketchLine_11 = Sketch_1.addLine(-17.67323212242127, 25.13271321305362, -21.80463703415611, 14.78814178154371)
60 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_11.startPoint(), SketchLine_9.result())
61 SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_7.result())
62 model.do()
63 Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchArc_1")], False)
64 Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2")], False)
65 Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")], False)
66 Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r")])
67 Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_10r-SketchLine_9r-SketchLine_11f-SketchLine_7r"), model.selection("FACE", "Sketch_1/Face-SketchLine_11r-SketchLine_9r-SketchLine_8r-SketchLine_7r")])
68 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
69 Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 50)
70 Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
71 Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
72 Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_2_1"), model.selection("SOLID", "Cylinder_1_1")], keepSubResults = True)
73 Box_3 = model.addBox(Part_1_doc, 10, 10, 10)
74 Translation_2 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("EDGE", "PartSet/OY"), 50)
75 AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Translation_2_1")], model.selection("EDGE", "PartSet/OZ"), 30, 3)
76 model.end()
77
78 TOLERANCE = 1.e-7
79 DISTANCE = 20
80 COPIES = 2
81
82
83 model.begin()
84 MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
85 model.testNbResults(MultiTranslation_1, 1)
86 model.testNbSubResults(MultiTranslation_1, [COPIES])
87 model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.SOLID, [0])
88 model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.FACE, [0])
89 model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.EDGE, [0])
90 model.testNbSubShapes(MultiTranslation_1, GeomAPI_Shape.VERTEX, [COPIES])
91 model.testResultsVolumes(MultiTranslation_1, [0])
92 refPoint = Vertex_1.defaultResult().shape().middlePoint()
93 refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
94 midPoint = MultiTranslation_1.defaultResult().shape().middlePoint()
95 assert(midPoint.distance(refPoint) < TOLERANCE)
96
97 MultiTranslation_2 = model.addMultiTranslation(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
98 model.testNbResults(MultiTranslation_2, 1)
99 model.testNbSubResults(MultiTranslation_2, [COPIES])
100 model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.SOLID, [0])
101 model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.FACE, [0])
102 model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.EDGE, [COPIES])
103 model.testNbSubShapes(MultiTranslation_2, GeomAPI_Shape.VERTEX, [2 * COPIES])
104 model.testResultsVolumes(MultiTranslation_2, [0])
105 comp = GeomAlgoAPI_CompoundBuilder.compound([Edge_1.defaultResult().shape()])
106 refPoint = comp.middlePoint()
107 refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
108 midPoint = MultiTranslation_2.defaultResult().shape().middlePoint()
109 assert(midPoint.distance(refPoint) < TOLERANCE)
110
111 MultiTranslation_3 = model.addMultiTranslation(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
112 model.testNbResults(MultiTranslation_3, 1)
113 model.testNbSubResults(MultiTranslation_3, [COPIES])
114 model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.SOLID, [0])
115 model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.FACE, [0])
116 model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.EDGE, [2 * COPIES])
117 model.testNbSubShapes(MultiTranslation_3, GeomAPI_Shape.VERTEX, [4 * COPIES])
118 model.testResultsVolumes(MultiTranslation_3, [0])
119 comp = GeomAlgoAPI_CompoundBuilder.compound([Wire_1.defaultResult().shape()])
120 refPoint = comp.middlePoint()
121 refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
122 midPoint = MultiTranslation_3.defaultResult().shape().middlePoint()
123 assert(midPoint.distance(refPoint) < TOLERANCE)
124
125 MultiTranslation_4 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
126 model.testNbResults(MultiTranslation_4, 1)
127 model.testNbSubResults(MultiTranslation_4, [COPIES])
128 model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.SOLID, [0])
129 model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.FACE, [COPIES])
130 model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.EDGE, [4 * COPIES])
131 model.testNbSubShapes(MultiTranslation_4, GeomAPI_Shape.VERTEX, [8 * COPIES])
132 model.testResultsVolumes(MultiTranslation_4, [109.154152964914914 * COPIES])
133 refPoint = Face_1.defaultResult().shape().middlePoint()
134 refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
135 midPoint = MultiTranslation_4.defaultResult().shape().middlePoint()
136 assert(midPoint.distance(refPoint) < TOLERANCE)
137
138 MultiTranslation_5 = model.addMultiTranslation(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
139 model.testNbResults(MultiTranslation_5, 1)
140 model.testNbSubResults(MultiTranslation_5, [COPIES])
141 model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.SOLID, [0])
142 model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.FACE, [2 * COPIES])
143 model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.EDGE, [8 * COPIES])
144 model.testNbSubShapes(MultiTranslation_5, GeomAPI_Shape.VERTEX, [16 * COPIES])
145 model.testResultsVolumes(MultiTranslation_5, [182.822012116 * COPIES])
146 refPoint = Shell_1.defaultResult().shape().middlePoint()
147 refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
148 midPoint = MultiTranslation_5.defaultResult().shape().middlePoint()
149 assert(midPoint.distance(refPoint) < TOLERANCE)
150
151 MultiTranslation_6 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
152 model.testNbResults(MultiTranslation_6, 1)
153 model.testNbSubResults(MultiTranslation_6, [COPIES])
154 model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.SOLID, [COPIES])
155 model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.FACE, [6 * COPIES])
156 model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.EDGE, [24 * COPIES])
157 model.testNbSubShapes(MultiTranslation_6, GeomAPI_Shape.VERTEX, [48 * COPIES])
158 model.testResultsVolumes(MultiTranslation_6, [1000 * COPIES])
159 refPoint = Translation_1.defaultResult().shape().middlePoint()
160 refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
161 midPoint = MultiTranslation_6.defaultResult().shape().middlePoint()
162 assert(midPoint.distance(refPoint) < TOLERANCE)
163
164 MultiTranslation_7 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
165 model.testNbResults(MultiTranslation_7, 1)
166 model.testNbSubResults(MultiTranslation_7, [COPIES])
167 model.testNbSubShapes(MultiTranslation_7, GeomAPI_Shape.SOLID, [3 * COPIES])
168 model.testNbSubShapes(MultiTranslation_7, GeomAPI_Shape.FACE, [17 * COPIES])
169 model.testNbSubShapes(MultiTranslation_7, GeomAPI_Shape.EDGE, [66 * COPIES])
170 model.testNbSubShapes(MultiTranslation_7, GeomAPI_Shape.VERTEX, [132 * COPIES])
171 model.testResultsVolumes(MultiTranslation_7, [1589.0486226 * COPIES])
172 refPoint = Partition_1.defaultResult().shape().middlePoint()
173 refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
174 midPoint = MultiTranslation_7.defaultResult().shape().middlePoint()
175 assert(midPoint.distance(refPoint) < TOLERANCE)
176
177 MultiTranslation_8 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPOUND", "AngularCopy_1_1")], model.selection("EDGE", "PartSet/OZ"), DISTANCE, COPIES, keepSubResults = True)
178 model.testNbResults(MultiTranslation_8, 1)
179 model.testNbSubResults(MultiTranslation_8, [COPIES])
180 model.testNbSubShapes(MultiTranslation_8, GeomAPI_Shape.SOLID, [3 * COPIES])
181 model.testNbSubShapes(MultiTranslation_8, GeomAPI_Shape.FACE, [18 * COPIES])
182 model.testNbSubShapes(MultiTranslation_8, GeomAPI_Shape.EDGE, [72 * COPIES])
183 model.testNbSubShapes(MultiTranslation_8, GeomAPI_Shape.VERTEX, [144 * COPIES])
184 model.testResultsVolumes(MultiTranslation_8, [3000 * COPIES])
185 refPoint = AngularCopy_1.defaultResult().shape().middlePoint()
186 refPoint.setZ(refPoint.z() + DISTANCE / 2 * (COPIES - 1))
187 midPoint = MultiTranslation_8.defaultResult().shape().middlePoint()
188 assert(midPoint.distance(refPoint) < TOLERANCE)
189
190 model.end()
191
192 assert(model.checkPythonDump())