Salome HOME
eeba785243d03ad713b15610f98146cc79456647
[modules/shaper.git] / src / FiltersPlugin / Test / TestFilter_OnGeometry_Exclude_Edge1.py
1 # Copyright (C) 2014-2024  CEA, EDF
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 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
28 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), model.selection("FACE", "Box_1_1/Right"))
29 Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1")], keepSubResults = True)
30 Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
31 Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], model.selection("EDGE", "PartSet/OX"), 20)
32 FilterFace = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", exclude = True, args = [model.selection("EDGE", "Partition_1_1_2/Generated_Edge&Plane_1/Plane_1&Box_1_1/Front"), model.selection("EDGE", "[Partition_1_1_1/Modified_Face&Box_1_1/Top][Partition_1_1_1/Modified_Face&Box_1_1/Front]")])])
33 model.end()
34
35 Reference = {}
36 # Faces of the box
37 ResultBox_1 = Partition_1.result().resultSubShapePair()[0]
38 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.FACE)
39 while exp.more():
40   Reference[model.selection(ResultBox_1, exp.current())] = True
41   exp.next()
42 # Faces of the cylinder
43 ResultCylinder_1 = Translation_1.result().resultSubShapePair()[0]
44 exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.FACE)
45 while exp.more():
46   Reference[model.selection(ResultCylinder_1, exp.current())] = True
47   exp.next()
48 # Edges of the original box (selected as a sub-shapes of the result to keep original surface).
49 # Note: the expected values have to be updated if ShapeExplorer will return another order of sub-shapes.
50 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.EDGE)
51 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
52 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
53 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
54 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
55 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
56 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
57 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
58 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
59 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
60 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
61 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
62 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
63 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
64 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
65 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
66 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
67 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
68 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
69 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
70 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
71 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
72 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
73 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
74 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
75 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
76 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
77 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
78 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
79 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
80 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
81 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
82 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
83 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
84 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
85 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
86 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
87 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
88 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
89 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
90 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
91 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
92 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
93 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
94 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
95 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
96 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
97 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
98 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
99 assert(not exp.more())
100 # Edges of the cylinder
101 exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.EDGE)
102 while exp.more():
103   Reference[model.selection(ResultCylinder_1, exp.current())] = True
104   exp.next()
105 # Vertices of the original box
106 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.VERTEX)
107 while exp.more():
108   Reference[model.selection(ResultBox_1, exp.current())] = True
109   exp.next()
110 # Vertices of the cylinder
111 exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.VERTEX)
112 while exp.more():
113   Reference[model.selection(ResultCylinder_1, exp.current())] = True
114   exp.next()
115
116 model.checkFilter(Part_1_doc, model, FilterFace, Reference)