Salome HOME
cbf52ed19b5bb5b2dbf37f55075ff8e110f0a8a8
[modules/shaper.git] / src / FiltersPlugin / Test / TestFilter_ExternalFaces_Exclude1.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 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 Filters = model.filters(Part_1_doc, [model.addFilter(name = "ExternalFaces", exclude = True)])
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 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
40 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
41 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
42 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
43 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
44 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
45 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
46 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
47 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
48 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
49 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
50 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
51 # Faces of the cylinder
52 ResultCylinder_1 = Translation_1.result().resultSubShapePair()[0]
53 exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.FACE)
54 while exp.more():
55   Reference[model.selection(ResultCylinder_1, exp.current())] = False
56   exp.next()
57 model.checkFilter(Part_1_doc, model, Filters, Reference)
58
59 Reference = {
60     model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Back"): False,
61     model.selection("FACE", "Partition_1_1_2/Modified_Face&Plane_1/Plane_1"): False,
62     model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Bottom"): False,
63     model.selection("FACE", "Box_1_1/Right"): False,
64     model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Top"): False,
65     model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Front"): False,
66     model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Back"): False,
67     model.selection("FACE", "Box_1_1/Left"): False,
68     model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Bottom"): False,
69     model.selection("FACE", "Partition_1_1_1/Modified_Face&Plane_1/Plane_1"): False,
70     model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Top"): False,
71     model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Front"): False,
72     model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_1"): False,
73     model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_2"): False,
74     model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_3"): False,
75 }
76 model.checkFilter(Part_1_doc, model, Filters, Reference)