Salome HOME
c959182daeea34e2380093e165a14c454d1d72a1
[modules/shaper.git] / src / CollectionPlugin / Test / TestGroup1799.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 # This test is based on the issue 1799: after faces are splitted and group is moved
22 # down, the group-faces also must be splitted, the AttributeSelectionList should contain
23 # 4 times more faces.
24 # The biggest part of the code is python dump of the updated_for_1799.hdf file from this issue.
25
26 from salome.shaper import model
27 from ModelAPI import *
28
29 model.begin()
30 partSet = model.moduleDocument()
31 Part_1 = model.addPart(partSet)
32 Part_1_doc = Part_1.document()
33 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
34 SketchLine_1 = Sketch_1.addLine(350, 250, 1.524660639134633e-014, 250)
35 SketchLine_2 = Sketch_1.addLine(-350, 1.720151798778602e-014, -350, -250)
36 SketchLine_3 = Sketch_1.addLine(-350, -250, 1.524660628546721e-014, -250)
37 SketchLine_4 = Sketch_1.addLine(350, -250, 350, 1.720151798778602e-014)
38 SketchLine_5 = Sketch_1.addLine(350, 1.720151798778602e-014, 350, 250)
39 SketchLine_5.setName("SketchLine_7")
40 SketchLine_5.result().setName("SketchLine_7")
41 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_1.startPoint())
42 SketchLine_6 = Sketch_1.addLine(1.524660639134633e-014, 250, -350, 250)
43 SketchLine_6.setName("SketchLine_5")
44 SketchLine_6.result().setName("SketchLine_5")
45 SketchLine_7 = Sketch_1.addLine(-350, 250, -350, 1.720151798778602e-014)
46 SketchLine_7.setName("SketchLine_6")
47 SketchLine_7.result().setName("SketchLine_6")
48 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
49 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
50 SketchLine_8 = Sketch_1.addLine(1.524660628546721e-014, -250, 350, -250)
51 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_4.startPoint())
52 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
53 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
54 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
55 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
56 SketchCircle_1 = Sketch_1.addCircle(0, 0, 101.5814068355669)
57 SketchPoint_1 = Sketch_1.addPoint(1.524660639134633e-014, 250)
58 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_1.endPoint())
59 SketchPoint_2 = Sketch_1.addPoint(-350, 1.720151798778602e-014)
60 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_2.startPoint())
61 SketchPoint_3 = Sketch_1.addPoint(1.524660628546721e-014, -250)
62 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchPoint_3.coordinates(), SketchLine_3.endPoint())
63 SketchPoint_4 = Sketch_1.addPoint(101.5814068355669, 1.720151798778602e-014)
64 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchPoint_4.coordinates(), SketchCircle_1.results()[1])
65 SketchPoint_5 = Sketch_1.addPoint(-101.5814068355669, 1.720151798778602e-014)
66 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchPoint_5.coordinates(), SketchCircle_1.results()[1])
67 SketchPoint_6 = Sketch_1.addPoint(1.524660639134633e-014, 101.5814068355669)
68 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchPoint_6.coordinates(), SketchCircle_1.results()[1])
69 SketchPoint_7 = Sketch_1.addPoint(1.524660628546721e-014, -101.5814068355669)
70 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchPoint_7.coordinates(), SketchCircle_1.results()[1])
71 SketchPoint_8 = Sketch_1.addPoint(350, 1.720151798778602e-014)
72 SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchPoint_8.coordinates(), SketchLine_4.endPoint())
73 SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_6.startPoint())
74 SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_1.result(), SketchLine_6.result())
75 SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_2.startPoint())
76 SketchConstraintParallel_2 = Sketch_1.setParallel(SketchLine_2.result(), SketchLine_7.result())
77 SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
78 SketchConstraintParallel_3 = Sketch_1.setParallel(SketchLine_4.result(), SketchLine_5.result())
79 SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_8.startPoint())
80 SketchConstraintParallel_4 = Sketch_1.setParallel(SketchLine_3.result(), SketchLine_8.result())
81 SketchLine_9 = Sketch_1.addLine(1.524660639134633e-014, 250, 1.524660639134633e-014, 101.5814068355669)
82 SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_9.startPoint())
83 SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_9.startPoint())
84 SketchConstraintCoincidence_19 = Sketch_1.setCoincident(SketchLine_6.startPoint(), SketchLine_9.startPoint())
85 SketchConstraintCoincidence_20 = Sketch_1.setCoincident(SketchPoint_6.coordinates(), SketchLine_9.endPoint())
86 SketchLine_10 = Sketch_1.addLine(-101.5814068355669, 1.720151798778602e-014, -350, 1.720151798778602e-014)
87 SketchConstraintCoincidence_21 = Sketch_1.setCoincident(SketchPoint_5.coordinates(), SketchLine_10.startPoint())
88 SketchConstraintCoincidence_22 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchLine_10.endPoint())
89 SketchConstraintCoincidence_23 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_10.endPoint())
90 SketchConstraintCoincidence_24 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_10.endPoint())
91 SketchLine_11 = Sketch_1.addLine(1.524660628546721e-014, -250, 1.524660628546721e-014, -101.5814068355669)
92 SketchConstraintCoincidence_25 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_11.startPoint())
93 SketchConstraintCoincidence_26 = Sketch_1.setCoincident(SketchPoint_3.coordinates(), SketchLine_11.startPoint())
94 SketchConstraintCoincidence_27 = Sketch_1.setCoincident(SketchLine_8.startPoint(), SketchLine_11.startPoint())
95 SketchConstraintCoincidence_28 = Sketch_1.setCoincident(SketchPoint_7.coordinates(), SketchLine_11.endPoint())
96 SketchLine_12 = Sketch_1.addLine(350, 1.720151798778602e-014, 101.5814068355669, 1.720151798778602e-014)
97 SketchConstraintCoincidence_29 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_12.startPoint())
98 SketchConstraintCoincidence_30 = Sketch_1.setCoincident(SketchPoint_8.coordinates(), SketchLine_12.startPoint())
99 SketchConstraintCoincidence_31 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchLine_12.startPoint())
100 SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_9.result())
101 SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_11.result())
102 SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_10.result())
103 SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_12.result())
104 SketchConstraintCoincidence_32 = Sketch_1.setCoincident(SketchLine_9.result(), SketchLine_11.endPoint())
105 SketchConstraintCoincidence_33 = Sketch_1.setCoincident(SketchLine_10.result(), SketchLine_12.startPoint())
106 SketchConstraintCoincidence_34 = Sketch_1.setCoincident(SketchPoint_4.coordinates(), SketchLine_12.endPoint())
107 SketchPoint_9 = Sketch_1.addPoint(model.selection("VERTEX", "PartSet/Origin"))
108 SketchConstraintCoincidence_35 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchPoint_9.coordinates())
109 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_6.result())
110 SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_3.result(), SketchLine_8.result())
111 SketchConstraintEqual_3 = Sketch_1.setEqual(SketchLine_10.result(), SketchLine_12.result())
112 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_6.result(), 350)
113 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_7.result(), 250)
114 SketchConstraintEqual_4 = Sketch_1.setEqual(SketchLine_9.result(), SketchLine_11.result())
115 SketchConstraintEqual_5 = Sketch_1.setEqual(SketchLine_7.result(), SketchLine_2.result())
116 model.do()
117 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r-SketchLine_5f-SketchLine_6f-SketchLine_9r-SketchLine_10r"), model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchCircle_1_2r-SketchLine_7f-SketchLine_9f-SketchLine_12r"), model.selection("FACE", "Sketch_1/Face-SketchLine_4f-SketchCircle_1_2r-SketchLine_8f-SketchLine_11r-SketchLine_12f"), model.selection("FACE", "Sketch_1/Face-SketchLine_2f-SketchLine_3f-SketchCircle_1_2r-SketchLine_10f-SketchLine_11f")], model.selection(), 150, 0)
118 Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Extrusion_1_1/To_Face_1"), model.selection("FACE", "Extrusion_1_1/To_Face_4"), model.selection("FACE", "Extrusion_1_1/To_Face_3"), model.selection("FACE", "Extrusion_1_1/To_Face_2")])
119 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_12"), 150, True)
120 Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_7"), 150, True)
121 Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Plane_1"), model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("FACE", "Plane_2")])
122 Plane_6 = model.addPlane(Part_1_doc, model.selection("FACE", "Partition_1_1/Modified_Face_1_2_1"), 110, True)
123 Plane_7 = model.addPlane(Part_1_doc, model.selection("FACE", "Partition_1_1/Modified_Face_1_9_1"), 380, True)
124 Partition_2 = model.addPartition(Part_1_doc, [model.selection("FACE", "Plane_3"), model.selection("COMPSOLID", "Partition_1_1"), model.selection("FACE", "Plane_4")])
125 model.do()
126
127 # check that group contains only 4 faces
128 selectionList = Group_1.feature().selectionList("group_list")
129 assert(selectionList.size() == 4)
130 aFactory = ModelAPI_Session.get().validators()
131 assert(aFactory.validate(Group_1.feature()))
132 # move group to the end: it must be recomputed, faces are splitted
133 Part_1_doc.moveFeature(Group_1.feature(), Partition_2.feature())
134 model.end()
135
136 # check that number of faces becomes 4*4=16 and Group is valid
137 assert(selectionList.size() == 16)
138 assert(aFactory.validate(Group_1.feature()))