Salome HOME
92b3844459246819ede08a99f0e1336e05a6dac0
[modules/shaper.git] / src / FiltersPlugin / Test / TestFilter_BelongsTo_Exclude.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 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
28 LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 20, 2, model.selection("EDGE", "PartSet/OY"), 20, 3)
29 Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
30 Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], model.selection("EDGE", "PartSet/OX"), 50)
31 Filters = model.filters(Part_1_doc, [model.addFilter(name = "BelongsTo", exclude = True, args = [model.selection("SOLID", "LinearCopy_1_1_1"), model.selection("SOLID", "Translation_1_1")])])
32 model.end()
33
34 Reference = {}
35 # Faces of the original box
36 ResultBox_1 = LinearCopy_1.result().subResult(0).resultSubShapePair()[0]
37 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.FACE)
38 while exp.more():
39   Reference[model.selection(ResultBox_1, exp.current())] = False
40   exp.next()
41 # Faces of another box
42 ResultBox_2 = LinearCopy_1.result().subResult(1).resultSubShapePair()[0]
43 exp = GeomAPI_ShapeExplorer(ResultBox_2.shape(), GeomAPI_Shape.FACE)
44 while exp.more():
45   Reference[model.selection(ResultBox_2, exp.current())] = True
46   exp.next()
47 # Faces of the cylinder
48 ResultCylinder_1 = Translation_1.result().resultSubShapePair()[0]
49 exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.FACE)
50 while exp.more():
51   Reference[model.selection(ResultCylinder_1, exp.current())] = False
52   exp.next()
53 # Edges of the original box
54 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.EDGE)
55 while exp.more():
56   Reference[model.selection(ResultBox_1, exp.current())] = False
57   exp.next()
58 # Edges of another box
59 exp = GeomAPI_ShapeExplorer(ResultBox_2.shape(), GeomAPI_Shape.EDGE)
60 while exp.more():
61   Reference[model.selection(ResultBox_2, exp.current())] = True
62   exp.next()
63 # Edges of the cylinder
64 exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.EDGE)
65 while exp.more():
66   Reference[model.selection(ResultCylinder_1, exp.current())] = False
67   exp.next()
68 # Vertices of the original box
69 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.VERTEX)
70 while exp.more():
71   Reference[model.selection(ResultBox_1, exp.current())] = False
72   exp.next()
73 # Vertices of another box
74 exp = GeomAPI_ShapeExplorer(ResultBox_2.shape(), GeomAPI_Shape.VERTEX)
75 while exp.more():
76   Reference[model.selection(ResultBox_2, exp.current())] = True
77   exp.next()
78 # Vertices of the cylinder
79 exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.VERTEX)
80 while exp.more():
81   Reference[model.selection(ResultCylinder_1, exp.current())] = False
82   exp.next()
83
84 model.checkFilter(Part_1_doc, model, Filters, Reference)