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