1 # Copyright (C) 2018-2020 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 email : webmaster.salome@opencascade.com
20 from salome.shaper import model
24 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 Point_2 = model.addPoint(Part_1_doc, 10, 0, 0)
29 Point_3 = model.addPoint(Part_1_doc, 0, 10, 0)
30 Point_4 = model.addPoint(Part_1_doc, 20, 10, 0)
31 Point_5 = model.addPoint(Part_1_doc, 10, 20, 0)
32 Polyline_1 = model.addPolyline3D(Part_1_doc, [model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_4")], False)
33 Polyline_2 = model.addPolyline3D(Part_1_doc, [model.selection("VERTEX", "Point_2"), model.selection("VERTEX", "Point_3")], False)
34 Compound_1 = model.addCompound(Part_1_doc, [model.selection("WIRE", "Polyline_1_1"), model.selection("WIRE", "Polyline_2_1")])
35 Translation_1 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Compound_1_1_2", 1)], model.selection("EDGE", "PartSet/OY"), 10)
38 model.testNbResults(Translation_1, 1)
39 model.testNbSubResults(Translation_1, [0])
40 model.testNbSubShapes(Translation_1, GeomAPI_Shape.SOLID, [0])
41 model.testNbSubShapes(Translation_1, GeomAPI_Shape.FACE, [0])
42 model.testNbSubShapes(Translation_1, GeomAPI_Shape.EDGE, [1])
43 model.testNbSubShapes(Translation_1, GeomAPI_Shape.VERTEX, [2])
46 Part_2 = model.addPart(partSet)
47 Part_2_doc = Part_2.document()
48 Box_1 = model.addBox(Part_2_doc, 10, 10, 10)
49 Box_2 = model.addBox(Part_2_doc, 4, 4, 4)
50 Translation_2 = model.addTranslation(Part_2_doc, [model.selection("SOLID", "Box_2_1")], 3, 3, 3)
51 Compound_2 = model.addCompound(Part_2_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Translation_1_1")])
52 Translation_3 = model.addTranslation(Part_2_doc, [model.selection("SOLID", "Compound_1_1", 0)], 10, 0, 0)
55 model.testNbResults(Translation_3, 1)
56 model.testNbSubResults(Translation_3, [2])
57 model.testNbSubShapes(Translation_3, GeomAPI_Shape.SOLID, [2])
58 model.testNbSubShapes(Translation_3, GeomAPI_Shape.FACE, [12])
59 model.testNbSubShapes(Translation_3, GeomAPI_Shape.EDGE, [48])
60 model.testNbSubShapes(Translation_3, GeomAPI_Shape.VERTEX, [96])
61 model.testResultsVolumes(Translation_3, [1064])
64 Part_3 = model.addPart(partSet)
65 Part_3_doc = Part_3.document()
66 Box_3 = model.addBox(Part_3_doc, 10, 10, 10)
67 Box_4 = model.addBox(Part_3_doc, 10, 10, 10)
68 Point_6 = model.addPoint(Part_3_doc, 5, 5, 0)
69 Point_7 = model.addPoint(Part_3_doc, 5, 5, 10)
70 Axis_4 = model.addAxis(Part_3_doc, model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_2"))
71 Rotation_1 = model.addRotation(Part_3_doc, [model.selection("SOLID", "Box_2_1")], model.selection("EDGE", "Axis_1"), 45)
72 Compound_3 = model.addCompound(Part_3_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Rotation_1_1")])
73 Translation_4 = model.addTranslation(Part_3_doc, [model.selection("SOLID", "Compound_1_1", 1)], 10, 0, 0)
76 model.testNbResults(Translation_4, 1)
77 model.testNbSubResults(Translation_4, [0])
78 model.testNbSubShapes(Translation_4, GeomAPI_Shape.SOLID, [1])
79 model.testNbSubShapes(Translation_4, GeomAPI_Shape.FACE, [6])
80 model.testNbSubShapes(Translation_4, GeomAPI_Shape.EDGE, [24])
81 model.testNbSubShapes(Translation_4, GeomAPI_Shape.VERTEX, [48])
82 model.testResultsVolumes(Translation_4, [1000])
85 Part_4 = model.addPart(partSet)
86 Part_4_doc = Part_4.document()
87 Box_5 = model.addBox(Part_4_doc, 10, 10, 10)
88 Box_6 = model.addBox(Part_4_doc, 10, 10, 10)
89 Compound_4 = model.addCompound(Part_4_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Box_2_1")])
90 Translation_5 = model.addTranslation(Part_4_doc, [model.selection("SOLID", "Compound_1_1", 1)], model.selection("EDGE", "PartSet/OZ"), 10)
93 model.testNbResults(Translation_5, 1)
94 model.testNbSubResults(Translation_5, [0])
95 model.testNbSubShapes(Translation_5, GeomAPI_Shape.SOLID, [1])
96 model.testNbSubShapes(Translation_5, GeomAPI_Shape.FACE, [6])
97 model.testNbSubShapes(Translation_5, GeomAPI_Shape.EDGE, [24])
98 model.testNbSubShapes(Translation_5, GeomAPI_Shape.VERTEX, [48])
99 model.testResultsVolumes(Translation_5, [1000])