Salome HOME
707e95f555943ad62fadd8eb27d02bb4bdf246d3
[modules/shaper.git] / src / FiltersPlugin / Test / TestFilter_OnPlane_Exclude.py
1 # Copyright (C) 2014-2021  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 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
27 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)
28 Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
29 Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], model.selection("EDGE", "PartSet/OX"), 50)
30 Filters = model.filters(Part_1_doc, [model.addFilter(name = "OnPlane", exclude = True, args = [model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Top"), model.selection("FACE", "LinearCopy_1_1_2/MF:Translated&Box_1_1/Left")])])
31 model.end()
32
33 Reference = {
34     # Faces of the original box
35     model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Top"): False,
36     model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Bottom"): True,
37     model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Front"): True,
38     model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Back"): True,
39     model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Right"): True,
40     model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Left"): False,
41     # Translated box
42     model.selection("FACE", "LinearCopy_1_1_2/MF:Translated&Box_1_1/Top"): False,
43     model.selection("FACE", "LinearCopy_1_1_2/MF:Translated&Box_1_1/Bottom"): True,
44     model.selection("FACE", "LinearCopy_1_1_2/MF:Translated&Box_1_1/Front"): True,
45     model.selection("FACE", "LinearCopy_1_1_2/MF:Translated&Box_1_1/Back"): True,
46     model.selection("FACE", "LinearCopy_1_1_2/MF:Translated&Box_1_1/Right"): True,
47     model.selection("FACE", "LinearCopy_1_1_2/MF:Translated&Box_1_1/Left"): False,
48     # Box translated along another direction
49     model.selection("FACE", "LinearCopy_1_1_3/MF:Translated&Box_1_1/Top"): False,
50     model.selection("FACE", "LinearCopy_1_1_3/MF:Translated&Box_1_1/Bottom"): True,
51     model.selection("FACE", "LinearCopy_1_1_3/MF:Translated&Box_1_1/Front"): True,
52     model.selection("FACE", "LinearCopy_1_1_3/MF:Translated&Box_1_1/Back"): True,
53     model.selection("FACE", "LinearCopy_1_1_3/MF:Translated&Box_1_1/Right"): True,
54     model.selection("FACE", "LinearCopy_1_1_3/MF:Translated&Box_1_1/Left"): True,
55     # Faces of the cylinder
56     model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_1"): True,
57     model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_2"): False,
58     model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_3"): True,
59     # Edges of the original box
60     model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Left][LinearCopy_1_1_1/MF:Translated&Box_1_1/Top]"): False,
61     model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Right][LinearCopy_1_1_1/MF:Translated&Box_1_1/Top]"): False,
62     model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Front][LinearCopy_1_1_1/MF:Translated&Box_1_1/Top]"): False,
63     model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Back][LinearCopy_1_1_1/MF:Translated&Box_1_1/Top]"): False,
64     model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Back][LinearCopy_1_1_1/MF:Translated&Box_1_1/Left]"): False,
65     model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Front][LinearCopy_1_1_1/MF:Translated&Box_1_1/Left]"): False,
66     model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Front][LinearCopy_1_1_1/MF:Translated&Box_1_1/Right]"): True,
67     model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Back][LinearCopy_1_1_1/MF:Translated&Box_1_1/Right]"): True,
68     model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Left][LinearCopy_1_1_1/MF:Translated&Box_1_1/Bottom]"): False,
69     model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Right][LinearCopy_1_1_1/MF:Translated&Box_1_1/Bottom]"): True,
70     model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Front][LinearCopy_1_1_1/MF:Translated&Box_1_1/Bottom]"): True,
71     model.selection("EDGE", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Back][LinearCopy_1_1_1/MF:Translated&Box_1_1/Bottom]"): True,
72     # Edges of translated box
73     model.selection("EDGE", "[LinearCopy_1_1_6/MF:Translated&Box_1_1/Left][LinearCopy_1_1_6/MF:Translated&Box_1_1/Top]"): False,
74     model.selection("EDGE", "[LinearCopy_1_1_6/MF:Translated&Box_1_1/Right][LinearCopy_1_1_6/MF:Translated&Box_1_1/Top]"): False,
75     model.selection("EDGE", "[LinearCopy_1_1_6/MF:Translated&Box_1_1/Front][LinearCopy_1_1_6/MF:Translated&Box_1_1/Top]"): False,
76     model.selection("EDGE", "[LinearCopy_1_1_6/MF:Translated&Box_1_1/Back][LinearCopy_1_1_6/MF:Translated&Box_1_1/Top]"): False,
77     model.selection("EDGE", "[LinearCopy_1_1_6/MF:Translated&Box_1_1/Back][LinearCopy_1_1_6/MF:Translated&Box_1_1/Left]"): True,
78     model.selection("EDGE", "[LinearCopy_1_1_6/MF:Translated&Box_1_1/Front][LinearCopy_1_1_6/MF:Translated&Box_1_1/Left]"): True,
79     model.selection("EDGE", "[LinearCopy_1_1_6/MF:Translated&Box_1_1/Front][LinearCopy_1_1_6/MF:Translated&Box_1_1/Right]"): True,
80     model.selection("EDGE", "[LinearCopy_1_1_6/MF:Translated&Box_1_1/Back][LinearCopy_1_1_6/MF:Translated&Box_1_1/Right]"): True,
81     model.selection("EDGE", "[LinearCopy_1_1_6/MF:Translated&Box_1_1/Left][LinearCopy_1_1_6/MF:Translated&Box_1_1/Bottom]"): True,
82     model.selection("EDGE", "[LinearCopy_1_1_6/MF:Translated&Box_1_1/Right][LinearCopy_1_1_6/MF:Translated&Box_1_1/Bottom]"): True,
83     model.selection("EDGE", "[LinearCopy_1_1_6/MF:Translated&Box_1_1/Front][LinearCopy_1_1_6/MF:Translated&Box_1_1/Bottom]"): True,
84     model.selection("EDGE", "[LinearCopy_1_1_6/MF:Translated&Box_1_1/Back][LinearCopy_1_1_6/MF:Translated&Box_1_1/Bottom]"): True,
85     # Edges of the cylinder
86     model.selection("EDGE", "[Translation_1_1/MF:Translated&Cylinder_1_1/Face_1][Translation_1_1/MF:Translated&Cylinder_1_1/Face_2]"): False,
87     model.selection("EDGE", "[Translation_1_1/MF:Translated&Cylinder_1_1/Face_1][Translation_1_1/MF:Translated&Cylinder_1_1/Face_3]"): True,
88     model.selection("EDGE", "([Translation_1_1/MF:Translated&Cylinder_1_1/Face_1][Translation_1_1/MF:Translated&Cylinder_1_1/Face_2])([Translation_1_1/MF:Translated&Cylinder_1_1/Face_1][Translation_1_1/MF:Translated&Cylinder_1_1/Face_3])"): False,
89     # Vertices of the original box
90     model.selection("VERTEX", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Back][LinearCopy_1_1_1/MF:Translated&Box_1_1/Right][LinearCopy_1_1_1/MF:Translated&Box_1_1/Bottom]"): True,
91     model.selection("VERTEX", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Front][LinearCopy_1_1_1/MF:Translated&Box_1_1/Left][LinearCopy_1_1_1/MF:Translated&Box_1_1/Top]"): False,
92     model.selection("VERTEX", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Back][LinearCopy_1_1_1/MF:Translated&Box_1_1/Left][LinearCopy_1_1_1/MF:Translated&Box_1_1/Top]"): False,
93     model.selection("VERTEX", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Front][LinearCopy_1_1_1/MF:Translated&Box_1_1/Right][LinearCopy_1_1_1/MF:Translated&Box_1_1/Top]"): False,
94     model.selection("VERTEX", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Back][LinearCopy_1_1_1/MF:Translated&Box_1_1/Right][LinearCopy_1_1_1/MF:Translated&Box_1_1/Top]"): False,
95     model.selection("VERTEX", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Front][LinearCopy_1_1_1/MF:Translated&Box_1_1/Left][LinearCopy_1_1_1/MF:Translated&Box_1_1/Bottom]"): False,
96     model.selection("VERTEX", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Back][LinearCopy_1_1_1/MF:Translated&Box_1_1/Left][LinearCopy_1_1_1/MF:Translated&Box_1_1/Bottom]"): False,
97     model.selection("VERTEX", "[LinearCopy_1_1_1/MF:Translated&Box_1_1/Front][LinearCopy_1_1_1/MF:Translated&Box_1_1/Right][LinearCopy_1_1_1/MF:Translated&Box_1_1/Bottom]"): True,
98     # Vertices of translated box
99     model.selection("VERTEX", "[LinearCopy_1_1_5/MF:Translated&Box_1_1/Front][LinearCopy_1_1_5/MF:Translated&Box_1_1/Left][LinearCopy_1_1_5/MF:Translated&Box_1_1/Top]"): False,
100     model.selection("VERTEX", "[LinearCopy_1_1_5/MF:Translated&Box_1_1/Back][LinearCopy_1_1_5/MF:Translated&Box_1_1/Left][LinearCopy_1_1_5/MF:Translated&Box_1_1/Top]"): False,
101     model.selection("VERTEX", "[LinearCopy_1_1_5/MF:Translated&Box_1_1/Front][LinearCopy_1_1_5/MF:Translated&Box_1_1/Right][LinearCopy_1_1_5/MF:Translated&Box_1_1/Top]"): False,
102     model.selection("VERTEX", "[LinearCopy_1_1_5/MF:Translated&Box_1_1/Back][LinearCopy_1_1_5/MF:Translated&Box_1_1/Right][LinearCopy_1_1_5/MF:Translated&Box_1_1/Top]"): False,
103     model.selection("VERTEX", "[LinearCopy_1_1_5/MF:Translated&Box_1_1/Front][LinearCopy_1_1_5/MF:Translated&Box_1_1/Left][LinearCopy_1_1_5/MF:Translated&Box_1_1/Bottom]"): True,
104     model.selection("VERTEX", "[LinearCopy_1_1_5/MF:Translated&Box_1_1/Back][LinearCopy_1_1_5/MF:Translated&Box_1_1/Left][LinearCopy_1_1_5/MF:Translated&Box_1_1/Bottom]"): True,
105     model.selection("VERTEX", "[LinearCopy_1_1_5/MF:Translated&Box_1_1/Front][LinearCopy_1_1_5/MF:Translated&Box_1_1/Right][LinearCopy_1_1_5/MF:Translated&Box_1_1/Bottom]"): True,
106     model.selection("VERTEX", "[LinearCopy_1_1_5/MF:Translated&Box_1_1/Back][LinearCopy_1_1_5/MF:Translated&Box_1_1/Right][LinearCopy_1_1_5/MF:Translated&Box_1_1/Bottom]"): True,
107     }
108 model.checkFilter(Part_1_doc, model, Filters, Reference)