Salome HOME
a161a69e896b7a3df7df8fc0d8e8c808f0d789e2
[modules/shaper.git] / src / FeaturesPlugin / Test / TestBooleanCut_MultiLevelCompound_v20190506_1.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 SketchAPI import *
21
22 from salome.shaper import model
23
24 model.begin()
25 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
29 SketchCircle_1 = Sketch_1.addCircle(10, 25, 5)
30 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
31 SketchPoint_1 = SketchProjection_1.createdFeature()
32 SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchCircle_1.center(), 10)
33 SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchCircle_1.center(), 25)
34 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 5)
35 model.do()
36 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0)
37 AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], model.selection("EDGE", "PartSet/OZ"), 30, 2)
38 LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPOUND", "AngularCopy_1_1")], model.selection("EDGE", "PartSet/OY"), 20, 2)
39 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "LinearCopy_1_1_1_2/MF:Translated&Extrusion_1_1/To_Face"))
40 SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "[LinearCopy_1_1_1_2/MF:Translated&Sketch_1/SketchCircle_1_2][LinearCopy_1_1_1_2/MF:Translated&Extrusion_1_1/To_Face]__cc"), False)
41 SketchPoint_2 = SketchProjection_2.createdFeature()
42 SketchCircle_2 = Sketch_2.addCircle(-3.839745962155611, 26.65063509461097, 3)
43 SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchPoint_2.result(), SketchCircle_2.center())
44 SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_2.results()[1], 3)
45 model.do()
46 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f")], model.selection(), 5, 5)
47 Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "LinearCopy_1_1_1_2")], [model.selection("SOLID", "Extrusion_2_1")], keepSubResults = True)
48
49 model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc)
50
51 model.end()
52
53 from GeomAPI import GeomAPI_Shape
54
55 model.testNbResults(Cut_1, 1)
56 model.testNbSubResults(Cut_1, [2])
57 model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [4])
58 model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [14])
59 model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [30])
60 model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [60])
61 model.testResultsVolumes(Cut_1, [3000.22098417825282])
62
63 assert(model.checkPythonDump())