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