]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/Test/Test2901.py
Salome HOME
b93d358de947574af2e4b92b4ba1364ae1053726
[modules/shaper.git] / src / ModelAPI / Test / Test2901.py
1 # Copyright (C) 2014-2019  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 email : webmaster.salome@opencascade.com
18 #
19
20 # -*- coding: utf-8 -*-
21
22 from SketchAPI import *
23 from ModelAPI import *
24 from GeomAPI import *
25
26 from salome.shaper import model
27
28 model.begin()
29 partSet = model.moduleDocument()
30 Part_1 = model.addPart(partSet)
31 Part_1_doc = Part_1.document()
32 model.addParameter(Part_1_doc, "l", "200")
33 model.addParameter(Part_1_doc, "b", "100")
34 model.addParameter(Part_1_doc, "h", "25")
35 model.addParameter(Part_1_doc, "r", "25")
36 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
37 SketchLine_1 = Sketch_1.addLine(200, 0, 0, 0)
38 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
39 SketchPoint_1 = SketchProjection_1.createdFeature()
40 SketchLine_2 = Sketch_1.addLine(0, 0, 0, 100)
41 SketchLine_3 = Sketch_1.addLine(0, 100, 200, 100)
42 SketchLine_4 = Sketch_1.addLine(200, 100, 200, 0)
43 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
44 SketchConstraintCoincidence_1.setName("SketchConstraintCoincidence_2")
45 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
46 SketchConstraintCoincidence_2.setName("SketchConstraintCoincidence_3")
47 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
48 SketchConstraintCoincidence_3.setName("SketchConstraintCoincidence_4")
49 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
50 SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_5")
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 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), "l")
56 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), "b")
57 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchAPI_Point(SketchPoint_1).coordinates())
58 SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_6")
59 SketchCircle_1 = Sketch_1.addCircle(50, 50, 25)
60 SketchCircle_2 = Sketch_1.addCircle(150, 50, 25)
61 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], "r")
62 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchCircle_1.results()[1], SketchCircle_2.results()[1])
63 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchCircle_1.center(), SketchLine_2.result(), "l/4", True)
64 SketchConstraintDistance_2 = Sketch_1.setDistance(SketchCircle_1.center(), SketchLine_1.result(), "b/2", True)
65 SketchLine_5 = Sketch_1.addLine(50, 50, 150, 50)
66 SketchLine_5.setAuxiliary(True)
67 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_5.startPoint())
68 SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_7")
69 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchCircle_2.center(), SketchLine_5.endPoint())
70 SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_8")
71 SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_5.result())
72 SketchConstraintDistance_3 = Sketch_1.setDistance(SketchLine_5.endPoint(), SketchLine_4.result(), "l/4", True)
73 model.do()
74 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "h", 0)
75 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/YOZ"), 100, False)
76 Partition_1 = model.addPartition(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("FACE", "Plane_1")])
77 Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_2")])
78 Group_1.setName("Inlet")
79 Group_1.result().setName("Inlet")
80 Group_2 = model.addGroup(Part_1_doc, [model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4")])
81 Group_2.setName("Outlet")
82 Group_2.result().setName("Outlet")
83 Group_3_objects = [model.selection("FACE", "Partition_1_1_1/Modified_Face&Extrusion_1_1_1/To_Face"), model.selection("FACE", "Partition_1_1_1/Modified_Face&Sketch_1/SketchLine_1"), model.selection("FACE", "Partition_1_1_1/Modified_Face&Extrusion_1_1_1/From_Face"), model.selection("FACE", "Partition_1_1_1/Modified_Face&Sketch_1/SketchLine_3"), model.selection("FACE", "Partition_1_1_2/Modified_Face&Sketch_1/SketchLine_3"), model.selection("FACE", "Partition_1_1_2/Modified_Face&Extrusion_1_1_1/From_Face"), model.selection("FACE", "Partition_1_1_2/Modified_Face&Sketch_1/SketchLine_1"), model.selection("FACE", "Partition_1_1_2/Modified_Face&Extrusion_1_1_1/To_Face")]
84 Group_3 = model.addGroup(Part_1_doc, Group_3_objects)
85 Group_3.setName("Wall")
86 Group_3.result().setName("Wall")
87 Group_4 = model.addGroup(Part_1_doc, [model.selection("SOLID", "Partition_1_1_3"), model.selection("SOLID", "Partition_1_1_4")])
88 Group_4.setName("Cylinders")
89 Group_4.result().setName("Cylinders")
90 Group_4.result().setColor(170, 0, 0)
91 Group_5 = model.addGroup(Part_1_doc, [model.selection("SOLID", "Partition_1_1_1"), model.selection("SOLID", "Partition_1_1_2")])
92 Group_5.setName("Fluide")
93 Group_5.result().setName("Fluide")
94 Group_5.result().setColor(0, 0, 255)
95 Group_6 = model.addGroup(Part_1_doc, [model.selection("FACE", "Extrusion_1_1_2/Generated_Face&Sketch_1/SketchCircle_1_2"), model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchCircle_2_2")])
96 Group_6.setName("Faces_cyl")
97 Group_6.result().setName("Faces_cyl")
98 Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), 10, False)
99 Partition_2 = model.addPartition(Part_1_doc, [model.selection("COMPSOLID", "Partition_1_1"), model.selection("FACE", "Plane_2")])
100 model.do()
101 # move groups after the latest partitiion
102 Part_1_doc.moveFeature(Group_1.feature(), Partition_2.feature())
103 Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
104 Part_1_doc.moveFeature(Group_3.feature(), Group_2.feature())
105 Part_1_doc.moveFeature(Group_4.feature(), Group_3.feature())
106 Part_1_doc.moveFeature(Group_5.feature(), Group_4.feature())
107 Part_1_doc.moveFeature(Group_6.feature(), Group_5.feature())
108 model.end()
109
110 # check groups are correct: group name, number of elements, elements type
111 Group_Info = [
112 (Group_1, 2, GeomAPI_Shape.FACE), # Inlet
113 (Group_2, 2, GeomAPI_Shape.FACE), # Outlet
114 (Group_3, 12, GeomAPI_Shape.FACE), # Wall
115 (Group_4, 4, GeomAPI_Shape.SOLID), # Cylinders
116 (Group_5, 4, GeomAPI_Shape.SOLID), # Fluide
117 (Group_6, 4, GeomAPI_Shape.FACE)] # Faces_cyl
118
119 aFactory = ModelAPI_Session.get().validators()
120 for group in Group_Info:
121   selectionList = group[0].feature().selectionList("group_list")
122   assert(selectionList.size() == group[1])
123   assert(aFactory.validate(group[0].feature()))
124   for i in range(group[1]):
125     assert(group[0].groupList().value(i).value().shapeType() == group[2])
126
127 assert(model.checkPythonDump())