1 ## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 ## See http:##www.salome-platform.org/ or
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 # -*- coding: utf-8 -*-
23 from salome.shaper import model
26 partSet = model.moduleDocument()
27 Part_1 = model.addPart(partSet)
28 Part_1_doc = Part_1.document()
29 model.addParameter(Part_1_doc, "l", "10")
30 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
31 SketchLine_1 = Sketch_1.addLine(0, 60, 10, 60)
32 SketchLine_2 = Sketch_1.addLine(model.selection("EDGE", "PartSet/OY"))
33 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_2.result())
34 SketchLine_3 = Sketch_1.addLine(10, 60, 10, 40)
35 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint())
36 SketchLine_4 = Sketch_1.addLine(10, 40, 20, 40)
37 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
38 SketchLine_5 = Sketch_1.addLine(20, 40, 20, 20)
39 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
40 SketchLine_6 = Sketch_1.addLine(20, 20, 30, 20)
41 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
42 SketchLine_7 = Sketch_1.addLine(30, 20, 30, 0)
43 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
44 SketchLine_8 = Sketch_1.addLine(model.selection("EDGE", "PartSet/OX"))
45 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.result())
46 SketchLine_9 = Sketch_1.addLine(30, 0, 81.26217508737108, 0)
47 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_9.startPoint())
48 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_8.result())
49 SketchLine_10 = Sketch_1.addLine(0, 60, 0, 81.26217508737108)
50 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_10.startPoint())
51 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_2.result())
52 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
53 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_4.result())
54 SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_6.result())
55 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_3.result())
56 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_5.result())
57 SketchArc_1 = Sketch_1.addArc(4.151438510550382e-34, -3.089278765476956e-34, 81.26217508737108, 0, 0, 81.26217508737108, False)
58 SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchArc_1.center())
59 SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchArc_1.startPoint())
60 SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_2.result(), SketchArc_1.endPoint())
61 SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchArc_1.endPoint())
62 SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_7.result())
63 SketchArc_2 = Sketch_1.addArc(4.151438510550382e-34, -3.089278765476956e-34, 76.26217508737108, 0, 0, 76.26217508737108, False)
64 SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchArc_2.center())
65 SketchConstraintCoincidence_16.setName("SketchConstraintCoincidence_23")
66 SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchLine_9.result(), SketchArc_2.startPoint())
67 SketchConstraintCoincidence_17.setName("SketchConstraintCoincidence_24")
68 SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchLine_10.result(), SketchArc_2.endPoint())
69 SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_25")
70 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchArc_1.endPoint(), SketchArc_2.endPoint(), 5, False)
71 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_7.result(), "2*l")
72 SketchConstraintLength_1.setName("SketchConstraintLength_2")
73 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_6.result(), "l")
74 SketchConstraintLength_2.setName("SketchConstraintLength_3")
75 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_5.result(), SketchLine_7.result())
76 SketchConstraintEqual_1.setName("SketchConstraintEqual_2")
77 SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_6.result(), SketchLine_4.result())
78 SketchConstraintEqual_2.setName("SketchConstraintEqual_3")
79 SketchConstraintEqual_3 = Sketch_1.setEqual(SketchLine_5.result(), SketchLine_3.result())
80 SketchConstraintEqual_3.setName("SketchConstraintEqual_4")
81 SketchConstraintEqual_4 = Sketch_1.setEqual(SketchLine_4.result(), SketchLine_1.result())
82 SketchConstraintEqual_4.setName("SketchConstraintEqual_5")
84 Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
85 SketchCircle_1 = Sketch_2.addCircle(9.082839147404137, 71.32948234489588, 2.005056553640547)
86 SketchCircle_2 = Sketch_2.addCircle(20.11065019242717, 63.7102674410618, 2.268462537186828)
87 SketchCircle_3 = Sketch_2.addCircle(26.52683116407693, 51.67992811921848, 2.727171758268866)
88 SketchCircle_4 = Sketch_2.addCircle(38.35666483055617, 58.29661474623231, 3.007584830460834)
89 SketchCircle_5 = Sketch_2.addCircle(33.94554041254697, 44.0607132153844, 3.054011155390377)
90 SketchCircle_6 = Sketch_2.addCircle(48.58245325412298, 42.45666797247195, 2.346858526438435)
91 SketchCircle_7 = Sketch_2.addCircle(38.95818179664835, 31.42885692744893, 3.547307159201095)
92 SketchCircle_8 = Sketch_2.addCircle(63.82088306179116, 27.41874382016783, 4.536925074373651)
93 SketchCircle_9 = Sketch_2.addCircle(50.18649849703544, 28.4212720969881, 4.820482891521984)
94 SketchCircle_10 = Sketch_2.addCircle(49.58498153094326, 15.18789884296047, 2.552020354335177)
95 SketchCircle_11 = Sketch_2.addCircle(66.22695092615982, 10.77677442495125, 4.536925074373645)
96 SketchCircle_12 = Sketch_2.addCircle(50.98852111849166, 6.165144351577979, 3.547307159201085)
98 Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchArc_2_2f-SketchLine_10r_wire")])
99 Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_9f-SketchArc_1_2f-SketchLine_10r-SketchArc_2_2r_wire")])
100 Face_3_objects = [model.selection("EDGE", "Sketch_2/SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/SketchCircle_11_2")]
101 Face_3 = model.addFace(Part_1_doc, Face_3_objects)
102 Face_4_objects = [model.selection("EDGE", "Sketch_2/SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/SketchCircle_11_2"), model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchArc_2_2f-SketchLine_10r_wire")]
103 Face_4 = model.addFace(Part_1_doc, Face_4_objects)
104 Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
105 SketchLine_11 = Sketch_3.addLine(40, 0, 30, 0)
106 SketchPoint_1 = Sketch_3.addPoint(model.selection("VERTEX", "[Face_1_1/Edge_6]e[Face_1_1/Edge_7]e"))
107 SketchConstraintCoincidence_19 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchPoint_1.result())
108 SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_19")
109 SketchLine_12 = Sketch_3.addLine(30, 0, 30, 10)
110 SketchLine_13 = Sketch_3.addLine(30, 10, 40, 10)
111 SketchLine_14 = Sketch_3.addLine(40, 10, 40, 0)
112 SketchConstraintCoincidence_20 = Sketch_3.setCoincident(SketchLine_14.endPoint(), SketchLine_11.startPoint())
113 SketchConstraintCoincidence_20.setName("SketchConstraintCoincidence_20")
114 SketchConstraintCoincidence_21 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint())
115 SketchConstraintCoincidence_21.setName("SketchConstraintCoincidence_21")
116 SketchConstraintCoincidence_22 = Sketch_3.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint())
117 SketchConstraintCoincidence_22.setName("SketchConstraintCoincidence_22")
118 SketchConstraintCoincidence_23 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint())
119 SketchConstraintCoincidence_23.setName("SketchConstraintCoincidence_26")
120 SketchConstraintHorizontal_4 = Sketch_3.setHorizontal(SketchLine_11.result())
121 SketchConstraintVertical_4 = Sketch_3.setVertical(SketchLine_12.result())
122 SketchConstraintHorizontal_5 = Sketch_3.setHorizontal(SketchLine_13.result())
123 SketchConstraintVertical_5 = Sketch_3.setVertical(SketchLine_14.result())
124 SketchConstraintEqual_5 = Sketch_3.setEqual(SketchLine_14.result(), SketchLine_13.result())
125 SketchConstraintEqual_5.setName("SketchConstraintEqual_6")
126 SketchConstraintLength_3 = Sketch_3.setLength(SketchLine_13.result(), "l")
127 SketchConstraintLength_3.setName("SketchConstraintLength_4")
129 Face_5 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_3/Face-SketchLine_14r-SketchLine_13r-SketchLine_12r-SketchLine_11r_wire")])
130 LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Face_5_1")], model.selection("EDGE", "PartSet/OX"), "l", 4, model.selection("EDGE", "PartSet/OY"), "l", 2)
131 Recover_1 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()])
132 Translation_1 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_1_1")], model.selection("VERTEX", "[Face_4_1/Edge_6]e[Face_4_1/Edge_7]e"), model.selection("VERTEX", "[Face_4_1/Edge_4]e[Face_4_1/Edge_5]e"))
133 LinearCopy_2 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_1_1")], model.selection("EDGE", "PartSet/OX"), "l", 4, model.selection("EDGE", "PartSet/OY"), "l", 2)
134 Recover_2 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()])
135 Translation_2 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_2_1")], model.selection("VERTEX", "[Face_4_1/Edge_6]e[Face_4_1/Edge_7]e"), model.selection("VERTEX", "[Face_4_1/Edge_2]e[Face_4_1/Edge_3]e"))
136 LinearCopy_3 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_2_1")], model.selection("EDGE", "PartSet/OX"), "l", 4)
137 Recover_3 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()])
138 Translation_3 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_3_1")], model.selection("VERTEX", "[Face_4_1/Edge_6]e[Face_4_1/Edge_7]e"), model.selection("VERTEX", "[LinearCopy_3_1_1/ME:Translated_Edge&Face_5_1/Edge_1]e[LinearCopy_3_1_1/ME:Translated_Edge&Face_5_1/Edge_2]e"))
139 LinearCopy_4 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_3_1")], model.selection("EDGE", "PartSet/OX"), "l", 3)
140 Recover_4 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()])
141 Translation_4 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_4_1")], model.selection("VERTEX", "[Face_4_1/Edge_6]e[Face_4_1/Edge_7]e"), model.selection("VERTEX", "[Face_4_1/Edge_1]e[Face_4_1/Edge_9]e"))
142 LinearCopy_5 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_4_1")], model.selection("EDGE", "PartSet/OX"), "l", 2)
143 Group_1_objects = [model.selection("FACE", "LinearCopy_4_1_2"), model.selection("FACE", "LinearCopy_1_1_8"), model.selection("FACE", "LinearCopy_1_1_4"), model.selection("FACE", "LinearCopy_1_1_3"), model.selection("FACE", "LinearCopy_1_1_6"), model.selection("FACE", "LinearCopy_1_1_2"), model.selection("FACE", "LinearCopy_1_1_7"), model.selection("FACE", "LinearCopy_2_1_3"), model.selection("FACE", "LinearCopy_3_1_4"), model.selection("FACE", "LinearCopy_2_1_8"), model.selection("FACE", "LinearCopy_2_1_4"), model.selection("FACE", "LinearCopy_2_1_7"), model.selection("FACE", "LinearCopy_4_1_3"), model.selection("FACE", "LinearCopy_1_1_1"), model.selection("FACE", "LinearCopy_5_1_2"), model.selection("FACE", "LinearCopy_4_1_1"), model.selection("FACE", "LinearCopy_5_1_1"), model.selection("FACE", "LinearCopy_3_1_3"), model.selection("FACE", "LinearCopy_3_1_2"), model.selection("FACE", "LinearCopy_3_1_1"), model.selection("FACE", "LinearCopy_2_1_6"), model.selection("FACE", "LinearCopy_2_1_2"), model.selection("FACE", "LinearCopy_2_1_5"), model.selection("FACE", "LinearCopy_2_1_1"), model.selection("FACE", "LinearCopy_1_1_5")]
144 Group_1 = model.addGroup(Part_1_doc, Group_1_objects)
145 Group_1.setName("Group_3")
146 Group_1.result().setName("assemblages")
147 Group_2_objects = [model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_12")]
148 Group_2 = model.addGroup(Part_1_doc, Group_2_objects)
149 Group_2.setName("Group_1")
150 Group_2.result().setName("eau")
151 Group_2.result().setColor(0, 170, 255)
152 Group_3 = model.addGroup(Part_1_doc, [model.selection("FACE", "Face_4_1")])
153 Group_3.setName("Group_2")
154 Group_3.result().setName("acier")
155 Group_3.result().setColor(170, 85, 0)
156 Shell_1_objects = [model.selection("FACE", "LinearCopy_1_1_1"), model.selection("FACE", "LinearCopy_1_1_2"), model.selection("FACE", "LinearCopy_1_1_3"), model.selection("FACE", "LinearCopy_1_1_4"), model.selection("FACE", "LinearCopy_1_1_5"), model.selection("FACE", "LinearCopy_1_1_6"), model.selection("FACE", "LinearCopy_1_1_7"), model.selection("FACE", "LinearCopy_2_1_4"), model.selection("FACE", "LinearCopy_2_1_5"), model.selection("FACE", "LinearCopy_2_1_6"), model.selection("FACE", "LinearCopy_2_1_7"), model.selection("FACE", "LinearCopy_2_1_8"), model.selection("FACE", "LinearCopy_2_1_1"), model.selection("FACE", "LinearCopy_2_1_2"), model.selection("FACE", "LinearCopy_2_1_3"), model.selection("FACE", "LinearCopy_3_1_4"), model.selection("FACE", "LinearCopy_3_1_3"), model.selection("FACE", "LinearCopy_3_1_2"), model.selection("FACE", "LinearCopy_3_1_1"), model.selection("FACE", "LinearCopy_4_1_1"), model.selection("FACE", "LinearCopy_4_1_2"), model.selection("FACE", "LinearCopy_4_1_3"), model.selection("FACE", "LinearCopy_5_1_1"), model.selection("FACE", "LinearCopy_5_1_2"), model.selection("FACE", "LinearCopy_1_1_8")]
157 Shell_1 = model.addShell(Part_1_doc, Shell_1_objects)
158 Partition_1_objects = [model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_4_1"), model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_12"), model.selection("SHELL", "Shell_1_1")]
159 Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects)
165 Part_1_doc.moveFeature(Group_1.feature(), Partition_1.feature())
166 Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
167 Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature())
170 # check that all groups are correct
171 from ModelAPI import *
172 aFactory = ModelAPI_Session.get().validators()
174 for Group in [Group_1, Group_2, Group_3]:
175 assert(aFactory.validate(Group.feature()))
176 assert(Group.groupList().size() != 0)
177 for a in range(Group.groupList().size()):
178 assert(Group.groupList().value(a).value().shapeTypeStr() == "FACE")
179 assert(len(Group.groupList().value(a).namingName()) > 0)