Salome HOME
Copyright update 2022
[modules/shaper.git] / src / FiltersPlugin / Test / Test19190.py
1 # Copyright (C) 2020-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 salome.shaper import model
21
22 model.begin()
23 partSet = model.moduleDocument()
24 Part_1 = model.addPart(partSet)
25 Part_1_doc = Part_1.document()
26 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
27 SketchLine_1 = Sketch_1.addLine(87.62648221343873, 42.39493620569578, -76.44861660079052, 42.39493620569578)
28 SketchLine_2 = Sketch_1.addLine(-76.44861660079052, 42.39493620569578, -76.44861660079052, -42.23747486149789)
29 SketchLine_3 = Sketch_1.addLine(-76.44861660079052, -42.23747486149789, 87.62648221343873, -42.23747486149789)
30 SketchLine_4 = Sketch_1.addLine(87.62648221343873, -42.23747486149789, 87.62648221343873, 42.39493620569578)
31 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
32 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
33 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
34 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
35 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
36 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
37 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
38 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
39 SketchLine_5 = Sketch_1.addLine(-32.93478260869566, 42.39493620569578, -17.36561264822134, -42.23747486149789)
40 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchLine_1.result())
41 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_3.result())
42 SketchLine_6 = Sketch_1.addLine(34.93083003952569, -42.23747486149789, 44.11264822134387, 42.39493620569579)
43 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_6.startPoint(), SketchLine_3.result())
44 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_1.result())
45 model.do()
46 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_1")], model.selection(), 100, 0)
47 Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 35, 120)
48 Fuse_1_objects_1 = [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Cylinder_1_1"), model.selection("SOLID", "Extrusion_1_1_3")]
49 Fuse_1 = model.addFuse(Part_1_doc, Fuse_1_objects_1, removeEdges = True, keepSubResults = True)
50 Fuse_1.result().setColor(76, 76, 153)
51 Fuse_1.result().subResult(0).setColor(254, 127, 127)
52 Fuse_1.result().subResult(1).setColor(153, 153, 76)
53 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Fuse_1_1_2/Modified_Face&Sketch_1/SketchLine_2"), 75, True)
54 Filters = model.filters(Part_1_doc, [model.addFilter(name = "RelativeToSolid", args = [model.selection("SOLID", "Fuse_1_1_2"), "on"])])
55 model.end()
56
57 from GeomAPI import *
58
59 model.testNbResults(Fuse_1, 1)
60 model.testNbSubResults(Fuse_1, [2])
61 model.testNbSubShapes(Fuse_1, GeomAPI_Shape.SOLID, [2])
62 model.testNbSubShapes(Fuse_1, GeomAPI_Shape.FACE, [14])
63 model.testNbSubShapes(Fuse_1, GeomAPI_Shape.EDGE, [54])
64 model.testNbSubShapes(Fuse_1, GeomAPI_Shape.VERTEX, [108])
65 model.testResultsVolumes(Fuse_1, [1465576.14])
66
67 solid1 = Fuse_1.result().subResult(0).resultSubShapePair()[0]
68 solid2 = Fuse_1.result().subResult(1).resultSubShapePair()[0]
69
70 Reference = {}
71 exp = GeomAPI_ShapeExplorer(solid1.shape(), GeomAPI_Shape.FACE)
72 Reference[model.selection(solid1, exp.current())] = False; exp.next()
73 Reference[model.selection(solid1, exp.current())] = True;  exp.next()
74 while exp.more():
75     Reference[model.selection(solid1, exp.current())] = False
76     exp.next()
77 exp = GeomAPI_ShapeExplorer(solid2.shape(), GeomAPI_Shape.FACE)
78 while exp.more():
79     Reference[model.selection(solid1, exp.current())] = True
80     exp.next()
81
82 model.checkFilter(Part_1_doc, model, Filters, Reference)