Salome HOME
aa046b9d5c2733bcf859bcea2b50b369f8fa2e7e
[modules/shaper.git] / src / FeaturesPlugin / Test / TestPartitionSubCompsolidWithCompSolid1.py
1 # Copyright (C) 2014-2024  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 from salome.shaper import model
21 from GeomAPI import *
22
23 model.begin()
24 partSet = model.moduleDocument()
25 Part_1 = model.addPart(partSet)
26 Part_1_doc = Part_1.document()
27 Param_BoxH = model.addParameter(Part_1_doc, "BoxHeight", "10")
28 Param_ExtrusionMin = model.addParameter(Part_1_doc, "ExtrusionMin", "0")
29 Param_ExtrusionMax = model.addParameter(Part_1_doc, "ExtrusionMax", "10")
30 Param_Radius = model.addParameter(Part_1_doc, "Radius", "40")
31 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
32 SketchCircle_1 = Sketch_1.addCircle(47, -3, 25)
33 SketchCircle_2 = Sketch_1.addCircle(55, 30, 40)
34 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_2.results()[1], "Radius")
35 model.do()
36 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "ExtrusionMax", "ExtrusionMin")
37 Box_1 = model.addBox(Part_1_doc, 80, 80, "BoxHeight")
38 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), model.selection("FACE", "Box_1_1/Right"))
39 Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Back"), model.selection("FACE", "Box_1_1/Front"))
40 Partition_1_objects = [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1"), model.selection("FACE", "Plane_2")]
41 Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects)
42 Partition_2 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Partition_1_1_3")])
43 model.do()
44
45 # check partition
46 model.testNbResults(Partition_2, 1)
47 model.testNbSubResults(Partition_2, [7])
48 model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [7])
49 model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [53])
50 model.testResultsVolumes(Partition_2, [82157.197962046673637814819812775])
51
52 # change box height and check partition
53 Param_BoxH.setValue(20)
54 model.do()
55
56 model.testNbResults(Partition_2, 1)
57 model.testNbSubResults(Partition_2, [8])
58 model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [8])
59 model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [73])
60 model.testResultsVolumes(Partition_2, [146157.197962002450367435812950134])
61
62 # update extrusion and check partition
63 Param_ExtrusionMin.setValue(-5)
64 Param_ExtrusionMax.setValue(15)
65 model.do()
66
67 model.testNbResults(Partition_2, 1)
68 model.testNbSubResults(Partition_2, [9])
69 model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [9])
70 model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [93])
71 model.testResultsVolumes(Partition_2, [146157.197961971396580338478088379])
72
73 # change radius of a circle and check partition
74 Param_Radius.setValue(50)
75 model.do()
76
77 model.testNbResults(Partition_2, 1)
78 model.testNbSubResults(Partition_2, [9])
79 model.testNbSubShapes(Partition_2, GeomAPI_Shape.SOLID, [9])
80 model.testNbSubShapes(Partition_2, GeomAPI_Shape.FACE, [92])
81 model.testResultsVolumes(Partition_2, [156418.581829168775584548711776733])
82
83 # check naming
84 model.testHaveNamingSubshapes(Partition_2, model, Part_1_doc)
85
86 model.end()