Salome HOME
b9d7828cc6c20925d4b854f5e5e72b415606755b
[modules/shaper.git] / src / FeaturesPlugin / Test / TestPartitionSubCompsolidWithFace5.py
1 # Copyright (C) 2014-2023  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_ExtrusionMin = model.addParameter(Part_1_doc, "ExtrusionMin", "0")
28 Param_ExtrusionMax = model.addParameter(Part_1_doc, "ExtrusionMax", "10")
29 Param_Radius = model.addParameter(Part_1_doc, "Radius", "40")
30 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
31 SketchCircle_1 = Sketch_1.addCircle(47, -3, 25)
32 SketchCircle_2 = Sketch_1.addCircle(55, 30, 40)
33 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_2.results()[1], "Radius")
34 model.do()
35 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "ExtrusionMax", "ExtrusionMin")
36 Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
37 SketchArc_1 = Sketch_2.addArc(10.01336797518561, 24.95055816041118, 7.898114670281987, -23.85096600991564, 58.22303946797933, 32.81761798074749, False)
38 SketchLine_1 = Sketch_2.addLine(58.22303949051827, 32.8176179844255, 7.898114670281987, -23.85096600991564)
39 SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchArc_1.endPoint(), SketchLine_1.startPoint())
40 SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchArc_1.startPoint(), SketchLine_1.endPoint())
41 model.do()
42 Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "Sketch_2/SketchLine_1"), 90, 0)
43 Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_2/SketchArc_1_2")])
44 Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("FACE", "Face_1_1"), model.selection("SOLID", "Extrusion_1_1_3")]
45 Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects)
46 model.do()
47
48 # check partition
49 model.testNbResults(Partition_1, 1)
50 model.testNbSubResults(Partition_1, [2])
51 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [5])
52 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [29])
53 model.testResultsVolumes(Partition_1, [58449.978429877664893865585327148])
54
55 # update extrusion and check partition
56 Param_ExtrusionMin.setValue(-5)
57 Param_ExtrusionMax.setValue(15)
58 model.do()
59
60 model.testNbResults(Partition_1, 1)
61 model.testNbSubResults(Partition_1, [2])
62 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
63 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [25])
64 model.testResultsVolumes(Partition_1, [58449.978433183350716717541217804])
65
66 # change radius of a circle and check partition
67 Param_Radius.setValue(50)
68 model.do()
69
70 model.testNbResults(Partition_1, 1)
71 model.testNbSubResults(Partition_1, [2])
72 model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
73 model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [25])
74 model.testResultsVolumes(Partition_1, [81554.943249191215727478265762329])
75
76 # check naming
77 model.testHaveNamingSubshapes(Partition_1, model, Part_1_doc)
78
79 model.end()