]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/Test/Test2358_2.py
Salome HOME
Geometrical naming for edges and intersections debug.
[modules/shaper.git] / src / ModelAPI / Test / Test2358_2.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 # -*- coding: utf-8 -*-
22
23 from salome.shaper import model
24
25 model.begin()
26 partSet = model.moduleDocument()
27 Part_1 = model.addPart(partSet)
28 Part_1_doc = Part_1.document()
29 model.addParameter(Part_1_doc, "h", "100")
30 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
31 SketchLine_1 = Sketch_1.addLine(0, 0, 0, 50)
32 SketchLine_2 = Sketch_1.addLine(0, 50, 50, 50)
33 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
34 SketchLine_3 = Sketch_1.addLine(50, 50, 50, 0)
35 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
36 SketchLine_4 = Sketch_1.addLine(50, 0, 0, 0)
37 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
38 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
39 SketchConstraintRigid_1 = Sketch_1.setFixed(SketchLine_1.startPoint())
40 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result())
41 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_4.result(), 50)
42 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_1.result(), 50)
43 SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_1.result(), SketchLine_3.result())
44 SketchConstraintParallel_2 = Sketch_1.setParallel(SketchLine_2.result(), SketchLine_4.result())
45 SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_1.result(), SketchLine_4.result())
46 model.do()
47 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 50, 0)
48 Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ"))
49 SketchLine_5 = Sketch_2.addLine(10, 21.9014765990379, 0, 21.9014765990379)
50 SketchLine_5.setName("SketchLine_9")
51 SketchLine_5.result().setName("SketchLine_9")
52 SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OZ"), False)
53 SketchLine_6 = SketchProjection_1.createdFeature()
54 SketchLine_6.setName("SketchLine_10")
55 SketchLine_6.result().setName("SketchLine_10")
56 SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.result())
57 SketchLine_7 = Sketch_2.addLine(0, 21.9014765990379, 0, 31.9014765990379)
58 SketchLine_7.setName("SketchLine_11")
59 SketchLine_7.result().setName("SketchLine_11")
60 SketchLine_8 = Sketch_2.addLine(0, 31.9014765990379, 10, 31.9014765990379)
61 SketchLine_8.setName("SketchLine_12")
62 SketchLine_8.result().setName("SketchLine_12")
63 SketchLine_9 = Sketch_2.addLine(10, 31.9014765990379, 10, 21.9014765990379)
64 SketchLine_9.setName("SketchLine_13")
65 SketchLine_9.result().setName("SketchLine_13")
66 SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_5.startPoint())
67 SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_7.startPoint())
68 SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
69 SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
70 SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_5.result())
71 SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_7.result())
72 SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_8.result())
73 SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_9.result())
74 SketchConstraintLength_3 = Sketch_2.setLength(SketchLine_9.result(), 10)
75 SketchConstraintLength_4 = Sketch_2.setLength(SketchLine_8.result(), 10)
76 model.do()
77 Sketch_2.setName("Sketch_3")
78 Sketch_2.result().setName("Sketch_3")
79 ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_3/Face-SketchLine_13r-SketchLine_12r-SketchLine_11r-SketchLine_9r_wire")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3"), 0, model.selection(), 0, [model.selection("SOLID", "Extrusion_1_1")])
80 Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
81 SketchLine_10 = Sketch_3.addLine(29.60939424565112, 0, 19.60939424565112, 0)
82 SketchLine_10.setName("SketchLine_14")
83 SketchLine_10.result().setName("SketchLine_14")
84 SketchProjection_2 = Sketch_3.addProjection(model.selection("EDGE", "PartSet/OX"), False)
85 SketchLine_11 = SketchProjection_2.createdFeature()
86 SketchLine_11.setName("SketchLine_15")
87 SketchLine_11.result().setName("SketchLine_15")
88 SketchConstraintCoincidence_10 = Sketch_3.setCoincident(SketchLine_10.endPoint(), SketchLine_11.result())
89 SketchLine_12 = Sketch_3.addLine(19.60939424565112, 0, 19.60939424565112, 5)
90 SketchLine_12.setName("SketchLine_16")
91 SketchLine_12.result().setName("SketchLine_16")
92 SketchLine_13 = Sketch_3.addLine(19.60939424565112, 5, 29.60939424565112, 5)
93 SketchLine_13.setName("SketchLine_17")
94 SketchLine_13.result().setName("SketchLine_17")
95 SketchLine_14 = Sketch_3.addLine(29.60939424565112, 5, 29.60939424565112, 0)
96 SketchLine_14.setName("SketchLine_18")
97 SketchLine_14.result().setName("SketchLine_18")
98 SketchConstraintCoincidence_11 = Sketch_3.setCoincident(SketchLine_14.endPoint(), SketchLine_10.startPoint())
99 SketchConstraintCoincidence_12 = Sketch_3.setCoincident(SketchLine_10.endPoint(), SketchLine_12.startPoint())
100 SketchConstraintCoincidence_13 = Sketch_3.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint())
101 SketchConstraintCoincidence_14 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint())
102 SketchConstraintHorizontal_3 = Sketch_3.setHorizontal(SketchLine_10.result())
103 SketchConstraintVertical_4 = Sketch_3.setVertical(SketchLine_12.result())
104 SketchConstraintHorizontal_4 = Sketch_3.setHorizontal(SketchLine_13.result())
105 SketchConstraintVertical_5 = Sketch_3.setVertical(SketchLine_14.result())
106 SketchConstraintLength_5 = Sketch_3.setLength(SketchLine_12.result(), 5)
107 SketchConstraintLength_6 = Sketch_3.setLength(SketchLine_13.result(), 10)
108 model.do()
109 Sketch_3.setName("Sketch_4")
110 Sketch_3.result().setName("Sketch_4")
111 ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_4")], model.selection(), "h", 0, [model.selection("SOLID", "ExtrusionCut_1_1")])
112 Fillet_1_objects = [model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)]"), model.selection("EDGE", "[(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2]"), model.selection("EDGE", "[(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_9)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face]"), model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_9)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)]"), model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3]"), model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1]"), model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)]"), model.selection("EDGE", "[(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_9)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3]"), model.selection("EDGE", "[(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_9)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1]"), model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)]"), model.selection("EDGE", "[(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)][_weak_name_5_ExtrusionCut_2_1]"), model.selection("EDGE", "[(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)][_weak_name_14_ExtrusionCut_2_1]")]
113 Fillet_1 = model.addFillet(Part_1_doc, Fillet_1_objects, 2)
114 Group_1_objects = [model.selection("FACE", "Fillet_1_1/Modified_Face&Sketch_1/SketchLine_4&weak_name_1"), model.selection("FACE", "Fillet_1_1/Modified_Face&Sketch_1/SketchLine_4&weak_name_4"), model.selection("FACE", "Fillet_1_1/Modified_Face&Sketch_1/SketchLine_4&weak_name_2"), model.selection("FACE", "Fillet_1_1/Modified_Face&Sketch_1/SketchLine_4&weak_name_3")]
115 Group_1 = model.addGroup(Part_1_doc, Group_1_objects)
116 Group_2 = model.addGroup(Part_1_doc, [model.selection("EDGE", "[(Fillet_1_1/Modified_Face&Sketch_1/SketchLine_3)(Fillet_1_1/Modified_Face&Extrusion_1_1/To_Face)][Fillet_1_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[Fillet_1_1/Modified_Face&Sketch_1/SketchLine_3][(Fillet_1_1/Modified_Face&Sketch_1/SketchLine_3)(Fillet_1_1/Modified_Face&Extrusion_1_1/To_Face)]")])
117 Group_3 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[Fillet_1_1/Modified_Face&Sketch_3/SketchLine_9][ExtrusionCut_1_1/Generated_Face&Sketch_3/SketchLine_13][Fillet_1_1/Modified_Face&Sketch_1/SketchLine_3]"), model.selection("VERTEX", "[ExtrusionCut_1_1/Generated_Face&Sketch_3/SketchLine_13][Fillet_1_1/Modified_Face&Sketch_1/SketchLine_3][Fillet_1_1/Modified_Face&Sketch_3/SketchLine_12]")])
118 model.do()
119
120 Folder_1 = model.addFolder(Part_1_doc, Sketch_3, ExtrusionCut_2)
121 Folder_1.setName("Box")
122 Folder_2 = model.addFolder(Part_1_doc, Group_1, Group_2)
123 Folder_2.setName("Groups")
124
125 from GeomAPI import GeomAPI_Shape
126
127 # check result shape
128 model.testNbResults(Fillet_1, 1)
129 model.testNbSubResults(Fillet_1, [0])
130 model.testNbSubShapes(Fillet_1, GeomAPI_Shape.SOLID, [1])
131 model.testNbSubShapes(Fillet_1, GeomAPI_Shape.FACE, [38])
132 model.testNbSubShapes(Fillet_1, GeomAPI_Shape.EDGE, [184])
133 model.testNbSubShapes(Fillet_1, GeomAPI_Shape.VERTEX, [368])
134 model.testResultsVolumes(Fillet_1, [117584.019523708775523118674755096])
135 # check groups
136 model.checkGroup(Group_1, GeomAPI_Shape.FACE)
137 model.checkGroup(Group_2, GeomAPI_Shape.EDGE)
138 model.checkGroup(Group_3, GeomAPI_Shape.VERTEX)
139
140 model.end()
141
142 assert(model.checkPythonDump())