]> SALOME platform Git repositories - modules/shaper.git/blob - test.models/flange.py
Salome HOME
Issue #2577: EDF 2018-2 Fusion of connected faces.
[modules/shaper.git] / test.models / flange.py
1 ## Copyright (C) 2014-2017  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
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
21 from salome.shaper import model
22
23 model.begin()
24 partSet = model.moduleDocument()
25 Part_1 = model.addPart(partSet)
26 Part_1_doc = Part_1.document()
27 Parameter_dint = model.addParameter(Part_1_doc, "dint", "58")
28 Parameter_thick = model.addParameter(Part_1_doc, "thick", "16")
29 Parameter_length = model.addParameter(Part_1_doc, "length", "172")
30 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
31 SketchLine_1 = Sketch_1.addLine(model.selection("EDGE", "PartSet/OZ"))
32 SketchArc_1 = Sketch_1.addArc(-1.656176621148808e-020, 61, -36.69142117459658, 34.94736842105263, -1.927105092898643e-024, 106, True)
33 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.result(), SketchArc_1.center())
34 SketchLine_2 = Sketch_1.addLine(model.selection("EDGE", "PartSet/OX"))
35 SketchLine_3 = Sketch_1.addLine(-46.47580015448901, 16.00000000000001, -86, 16)
36 SketchLine_4 = Sketch_1.addLine(-86, 16, -86, -1.232595164407831e-032)
37 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
38 SketchLine_5 = Sketch_1.addLine(-86, -1.232595164407831e-032, -46.47580015448901, 7.497132070176856e-024)
39 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
40 SketchArc_2 = Sketch_1.addArc(5.604803279647422e-025, 61, -23.64558253474002, 44.21052631578948, -7.759334428649666e-022, 90, True)
41 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_1.center(), SketchArc_2.center())
42 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_3.result())
43 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_5.result())
44 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_4.result())
45 SketchArc_3 = Sketch_1.addArc(-46.47580015448901, 28.00000000000001, -36.69142117459658, 34.94736842105264, -46.47580015448901, 16.00000000000001, True)
46 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchArc_3.startPoint())
47 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchArc_3.endPoint())
48 SketchArc_4 = Sketch_1.addArc(-46.475800154489, 28, -23.64558253474002, 44.21052631578947, -46.475800154489, -2.594279994652913e-031, True)
49 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchArc_2.startPoint(), SketchArc_4.startPoint())
50 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchArc_4.endPoint(), SketchLine_5.endPoint())
51 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_3.results()[1], 12)
52 SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchArc_3.results()[1])
53 SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_3.results()[1], SketchLine_3.result())
54 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchArc_4.center(), SketchArc_3.center())
55 SketchConstraintTangent_3 = Sketch_1.setTangent(SketchArc_4.results()[1], SketchLine_5.result())
56 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchArc_2.center(), SketchLine_5.result(), 61)
57 SketchConstraintTangent_4 = Sketch_1.setTangent(SketchArc_4.results()[1], SketchArc_2.results()[1])
58 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_5.result())
59 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_4.result(), "thick")
60 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.result())
61 SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_1.result())
62 SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_1.startPoint(), SketchLine_4.result(), "length/2")
63 SketchConstraintMirror_1_objects = [SketchArc_2.results()[1], SketchArc_4.results()[1], SketchLine_5.result(), SketchLine_4.result(), SketchLine_3.result(), SketchArc_3.results()[1], SketchArc_1.results()[1]]
64 SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_1.result(), SketchConstraintMirror_1_objects)
65 [SketchArc_5, SketchArc_6, SketchLine_6, SketchLine_7, SketchLine_8, SketchArc_7, SketchArc_8] = SketchConstraintMirror_1.mirrored()
66 SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_2.results()[1], "dint/2")
67 model.do()
68 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchArc_2_2r-SketchArc_3_2r-SketchArc_4_2f-SketchArc_5_2r-SketchArc_6_2f-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchArc_7_2r-SketchArc_8_2f")], model.selection(), 35, 35)
69 Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
70 SketchArc_9 = Sketch_2.addArc(0, 106, 0, 78, 0, 134, True)
71 SketchConstraintRadius_3 = Sketch_2.setRadius(SketchArc_9.results()[1], 28)
72 SketchLine_9 = Sketch_2.addLine(model.selection("EDGE", "PartSet/OX"))
73 SketchConstraintDistance_3 = Sketch_2.setDistance(SketchArc_9.center(), SketchLine_9.result(), "61+dint/2+thick")
74 SketchLine_10 = Sketch_2.addLine(model.selection("EDGE", "PartSet/OZ"))
75 SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchArc_9.startPoint(), SketchLine_10.result())
76 SketchConstraintCoincidence_14 = Sketch_2.setCoincident(SketchArc_9.endPoint(), SketchLine_10.result())
77 SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchArc_9.center(), SketchLine_10.result())
78 SketchLine_11 = Sketch_2.addLine(0, 78, 0, 134)
79 SketchConstraintCoincidence_16 = Sketch_2.setCoincident(SketchArc_9.startPoint(), SketchLine_11.startPoint())
80 SketchConstraintCoincidence_17 = Sketch_2.setCoincident(SketchArc_9.endPoint(), SketchLine_11.endPoint())
81 model.do()
82 Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchArc_9_2f-SketchLine_11f")], model.selection("EDGE", "PartSet/OZ"), 360, 0)
83 Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Revolution_1_1")])
84 Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "PartSet/YOZ"))
85 SketchLine_12 = Sketch_3.addLine(0, 106, -4, 106)
86 SketchLine_13 = Sketch_3.addLine(-4, 106, -4, 67.34428877022477)
87 SketchConstraintCoincidence_18 = Sketch_3.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint())
88 SketchConstraintHorizontal_3 = Sketch_3.setHorizontal(SketchLine_12.result())
89 SketchConstraintVertical_2 = Sketch_3.setVertical(SketchLine_13.result())
90 SketchPoint_1 = Sketch_3.addPoint(model.selection("VERTEX", "PartSet/Origin"))
91 SketchConstraintDistance_4 = Sketch_3.setDistance(SketchPoint_1.coordinates(), SketchLine_12.result(), "61+90/2")
92 SketchLine_14 = Sketch_3.addLine(model.selection("EDGE", "PartSet/OZ"))
93 SketchLine_14.setName("SketchLine_15")
94 SketchLine_14.result().setName("SketchLine_15")
95 SketchConstraintCoincidence_19 = Sketch_3.setCoincident(SketchLine_12.startPoint(), SketchLine_14.result())
96 SketchConstraintLength_2 = Sketch_3.setLength(SketchLine_12.result(), "8/2")
97 SketchArc_10 = Sketch_3.addArc(0, 61, -4, 67.34428877022477, 4, 67.34428877022477, False)
98 SketchConstraintCoincidence_20 = Sketch_3.setCoincident(SketchLine_14.result(), SketchArc_10.center())
99 SketchConstraintRadius_4 = Sketch_3.setRadius(SketchArc_10.results()[1], "15/2")
100 SketchLine_15 = Sketch_3.addLine(model.selection("EDGE", "PartSet/OY"))
101 SketchLine_15.setName("SketchLine_16")
102 SketchLine_15.result().setName("SketchLine_16")
103 SketchConstraintDistance_5 = Sketch_3.setDistance(SketchArc_10.center(), SketchLine_15.result(), 61)
104 SketchConstraintCoincidence_21 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchArc_10.startPoint())
105 SketchConstraintMirror_2 = Sketch_3.addMirror(SketchLine_14.result(), [SketchLine_13.result(), SketchLine_12.result()])
106 [SketchLine_16, SketchLine_17] = SketchConstraintMirror_2.mirrored()
107 SketchLine_17.setName("SketchLine_18")
108 SketchLine_17.result().setName("SketchLine_18")
109 SketchLine_16.setName("SketchLine_17")
110 SketchLine_16.result().setName("SketchLine_17")
111 SketchConstraintCoincidence_22 = Sketch_3.setCoincident(SketchArc_10.endPoint(), SketchLine_16.result())
112 model.do()
113 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_3/Wire-SketchLine_12f-SketchLine_13f-SketchLine_17r-SketchLine_18r-SketchArc_10_2f")], model.selection(), "172/2", "172/2")
114 Cut_2 = model.addCut(Part_1_doc, [model.selection("SOLID", "Cut_1_1")], [model.selection("SOLID", "Extrusion_2_1")])
115 Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_10"))
116 SketchLine_18 = Sketch_4.addLine(-65, 16, -65, -16)
117 SketchLine_18.setName("SketchLine_19")
118 SketchLine_18.result().setName("SketchLine_19")
119 SketchLine_18.setAuxiliary(True)
120 SketchConstraintVertical_3 = Sketch_4.setVertical(SketchLine_18.result())
121 SketchConstraintLength_3 = Sketch_4.setLength(SketchLine_18.result(), 32)
122 SketchPoint_2 = Sketch_4.addPoint(model.selection("VERTEX", "PartSet/Origin"))
123 SketchConstraintDistance_6 = Sketch_4.setDistance(SketchPoint_2.coordinates(), SketchLine_18.result(), "130/2")
124 SketchPoint_3 = Sketch_4.addPoint(-65, 0)
125 SketchPoint_3.setAuxiliary(True)
126 SketchConstraintMiddle_1 = Sketch_4.setMiddlePoint(SketchPoint_3.coordinates(), SketchLine_18.result())
127 SketchLine_19 = Sketch_4.addLine(model.selection("EDGE", "PartSet/OX"))
128 SketchLine_19.setName("SketchLine_20")
129 SketchLine_19.result().setName("SketchLine_20")
130 SketchConstraintCoincidence_23 = Sketch_4.setCoincident(SketchPoint_3.coordinates(), SketchLine_19.result())
131 SketchArc_11 = Sketch_4.addArc(-65, 16, -59, 16, -71, 16, False)
132 SketchConstraintCoincidence_24 = Sketch_4.setCoincident(SketchLine_18.startPoint(), SketchArc_11.center())
133 SketchArc_12 = Sketch_4.addArc(-65, -16, -59, -16.00003459934639, -71, -16, True)
134 SketchConstraintCoincidence_25 = Sketch_4.setCoincident(SketchLine_18.endPoint(), SketchArc_12.center())
135 SketchConstraintRadius_5 = Sketch_4.setRadius(SketchArc_11.results()[1], 6)
136 SketchLine_20 = Sketch_4.addLine(-71, 16, -71, -16)
137 SketchLine_20.setName("SketchLine_21")
138 SketchLine_20.result().setName("SketchLine_21")
139 SketchConstraintCoincidence_26 = Sketch_4.setCoincident(SketchArc_11.endPoint(), SketchLine_20.startPoint())
140 SketchConstraintCoincidence_27 = Sketch_4.setCoincident(SketchArc_12.endPoint(), SketchLine_20.endPoint())
141 SketchLine_21 = Sketch_4.addLine(-59, 16, -59, -16.00003459934639)
142 SketchLine_21.setName("SketchLine_22")
143 SketchLine_21.result().setName("SketchLine_22")
144 SketchConstraintCoincidence_28 = Sketch_4.setCoincident(SketchArc_11.startPoint(), SketchLine_21.startPoint())
145 SketchConstraintCoincidence_29 = Sketch_4.setCoincident(SketchArc_12.startPoint(), SketchLine_21.endPoint())
146 SketchConstraintVertical_4 = Sketch_4.setVertical(SketchLine_20.result())
147 SketchConstraintVertical_5 = Sketch_4.setVertical(SketchLine_21.result())
148 SketchConstraintTangent_5 = Sketch_4.setTangent(SketchLine_20.result(), SketchArc_11.results()[1])
149 SketchConstraintTangent_6 = Sketch_4.setTangent(SketchLine_21.result(), SketchArc_11.results()[1])
150 SketchConstraintTangent_7 = Sketch_4.setTangent(SketchArc_12.results()[1], SketchLine_20.result())
151 model.do()
152 Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_4/Wire-SketchArc_11_2f-SketchArc_12_2f-SketchLine_21f-SketchLine_22r")], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face_12"), 0)
153 MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Extrusion_3_1")], model.selection("EDGE", "Extrusion_1_1/To_Face_1&Extrusion_1_1/Generated_Face_12"), -130, 2)
154 Cut_3 = model.addCut(Part_1_doc, [model.selection("SOLID", "Cut_2_1")], [model.selection("COMPOUND", "LinearCopy_1_1")])
155 model.do()
156
157 # Test reexecution after parameter change
158 Parameter_dint.setValue(62)
159 Parameter_thick.setValue(20)
160 Parameter_length.setValue(200)
161 model.do()
162 model.testResultsVolumes(Cut_3, [409550.515091864974237978458404541])
163 Parameter_dint.setValue(58)
164 Parameter_thick.setValue(16)
165 Parameter_length.setValue(172)
166
167 model.end()
168
169 from GeomAPI import GeomAPI_Shape
170
171 model.testNbResults(Cut_3, 1)
172 model.testNbSubResults(Cut_3, [0])
173 model.testNbSubShapes(Cut_3, GeomAPI_Shape.SOLID, [1])
174 model.testNbSubShapes(Cut_3, GeomAPI_Shape.FACE, [32])
175 model.testNbSubShapes(Cut_3, GeomAPI_Shape.EDGE, [192])
176 model.testNbSubShapes(Cut_3, GeomAPI_Shape.VERTEX, [384])
177 model.testResultsVolumes(Cut_3, [307084.534467286430299282073974609])
178
179 assert(model.checkPythonDump())