Salome HOME
77eed1b26e10567a6f1ccae7c8e6b8ff31198d83
[modules/shaper.git] / src / FeaturesPlugin / Test / TestBooleanCut_Fuzzy_1.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 GeomAPI_Shape
22
23
24 model.begin()
25 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 Param_offset = model.addParameter(Part_1_doc, "offset", '5e-5')
29 Param_fuzzy = model.addParameter(Part_1_doc, "fuzzy", '1e-05')
30
31 ### Create Point
32 Point_2 = model.addPoint(Part_1_doc, "offset", "5", "5")
33
34 ### Create Box
35 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
36 Box_1.result().setColor(255, 0, 0)
37
38 ### Create Cylinder
39 Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("EDGE", "PartSet/OX"), 6, 13)
40 Cylinder_1.result().setColor(255, 255, 0)
41 Cylinder_1.result().setTransparency(0.6)
42
43 ### Create Cut
44 Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("SOLID", "Cylinder_1_1")], fuzzyParam = "fuzzy", keepSubResults = True)
45 model.do()
46
47 model.testNbResults(Cut_1, 1)
48 model.testNbSubResults(Cut_1, [0])
49 model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.SOLID, [1])
50 model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.FACE, [14])
51 model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.EDGE, [36])
52 model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [24])
53 model.testResultsVolumes(Cut_1, [49.093623770546])
54
55 ### Set a higher fuzzy value
56 Param_fuzzy.setValue(5.e-5)
57 model.do()
58
59 model.end()
60
61 model.testNbResults(Cut_1, 1)
62 model.testNbSubResults(Cut_1, [4])
63 model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.SOLID, [4])
64 model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.FACE, [20])
65 model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.EDGE, [36])
66 model.testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [24])
67 model.testResultsVolumes(Cut_1, [49.088834629314])