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