Salome HOME
Copyright update 2022
[modules/shaper.git] / src / FeaturesPlugin / Test / TestPartitionSubCompsolidWithSolid1.py
1 # Copyright (C) 2014-2022  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 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, 50, 100, "BoxHeight")
38 Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Box_1_1")])
39 model.do()
40
41 # check partition
42 model.testNbResults(Partition_1, 1)
43 model.testNbSubResults(Partition_1, [5])
44 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [5])
45 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [31])
46 model.testResultsVolumes(Partition_1, [88456.153365924168610945343971252])
47
48 # change box height and check partition
49 Param_BoxH.setValue(20)
50 model.do()
51
52 model.testNbResults(Partition_1, 1)
53 model.testNbSubResults(Partition_1, [5])
54 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [5])
55 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [36])
56 model.testResultsVolumes(Partition_1, [138456.153365848527755588293075562])
57
58 # update extrusion and check partition
59 Param_ExtrusionMin.setValue(-5)
60 Param_ExtrusionMax.setValue(15)
61 model.do()
62
63 model.testNbResults(Partition_1, 1)
64 model.testNbSubResults(Partition_1, [5])
65 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [5])
66 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [41])
67 model.testResultsVolumes(Partition_1, [138456.153365793754346668720245361])
68
69 # change radius of a circle and check partition
70 Param_Radius.setValue(50)
71 model.do()
72
73 model.testNbResults(Partition_1, 1)
74 model.testNbSubResults(Partition_1, [6])
75 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [6])
76 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [42])
77 model.testResultsVolumes(Partition_1, [151872.052359062305185943841934204])
78
79 # check naming
80 model.testHaveNamingSubshapes(Partition_1, model, Part_1_doc)
81
82 model.end()