Salome HOME
Issue #2611: Partition of a solid belonging to a Compsolid
[modules/shaper.git] / src / FeaturesPlugin / Test / TestPartitionSubCompsolidWithFace2.py
1 ## Copyright (C) 2018-20xx  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 from salome.shaper import model
22 from GeomAPI import *
23
24 model.begin()
25 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
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 Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
38 SketchArc_1 = Sketch_2.addArc(10.01336797518561, 24.95055816041118, 7.898114670281987, -23.85096600991564, 58.22303946797933, 32.81761798074749, False)
39 SketchArc_1.result().setColor(225, 0, 0)
40 SketchArc_1.results()[1].setColor(225, 0, 0)
41 SketchLine_1 = Sketch_2.addLine(58.22303949051827, 32.8176179844255, 7.898114670281987, -23.85096600991564)
42 SketchLine_1.result().setColor(225, 0, 0)
43 SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchArc_1.endPoint(), SketchLine_1.startPoint())
44 SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchArc_1.startPoint(), SketchLine_1.endPoint())
45 model.do()
46 Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "Sketch_2/Edge-SketchLine_1"), 90, 0)
47 Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face_2")])
48 Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("FACE", "Face_1_1")])
49 model.do()
50
51 # check partition
52 model.testNbResults(Partition_1, 1)
53 model.testNbSubResults(Partition_1, [2])
54 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [3])
55 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [22])
56 model.testResultsVolumes(Partition_1, [61945.742345225989993195980787277])
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, [2])
65 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [3])
66 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [21])
67 model.testResultsVolumes(Partition_1, [60999.340090954778133891522884369])
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, [2])
75 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [3])
76 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [21])
77 model.testResultsVolumes(Partition_1, [83593.613567417080048471689224243])
78
79 # check naming
80 model.testHaveNamingSubshapes(Partition_1, model, Part_1_doc)
81
82 model.end()