Salome HOME
74d776f223832243e4d1ece3c2c4dc5de6eaed44
[modules/shaper.git] / src / FiltersPlugin / Test / TestFilter_TopoConnectedFaces_Exclude_Face1.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 Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Front"), model.selection("FACE", "Box_1_1/Back"))
30 Partition_1_objects = [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1"), model.selection("FACE", "Plane_2")]
31 Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects, keepSubResults = True)
32 Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
33 Filters = model.filters(Part_1_doc, [model.addFilter(name = "TopoConnectedFaces", exclude = True, args = [model.selection("FACE", "Partition_1_1_3/Modified_Face&Box_1_1/Left"), False])])
34 model.end()
35
36 Reference = {}
37 # Faces of the box
38 ResultBox_0 = Partition_1.result().subResult(0).resultSubShapePair()[0]
39 exp = GeomAPI_ShapeExplorer(ResultBox_0.shape(), GeomAPI_Shape.FACE)
40 Reference[model.selection(ResultBox_0, exp.current())] = True;  exp.next()
41 Reference[model.selection(ResultBox_0, exp.current())] = False; exp.next()
42 Reference[model.selection(ResultBox_0, exp.current())] = True;  exp.next()
43 Reference[model.selection(ResultBox_0, exp.current())] = False; exp.next()
44 Reference[model.selection(ResultBox_0, exp.current())] = False; exp.next()
45 Reference[model.selection(ResultBox_0, exp.current())] = False; exp.next()
46
47 ResultBox_1 = Partition_1.result().subResult(1).resultSubShapePair()[0]
48 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.FACE)
49 while exp.more():
50   Reference[model.selection(ResultBox_1, exp.current())] = True
51   exp.next()
52
53 ResultBox_2 = Partition_1.result().subResult(2).resultSubShapePair()[0]
54 exp = GeomAPI_ShapeExplorer(ResultBox_2.shape(), GeomAPI_Shape.FACE)
55 Reference[model.selection(ResultBox_2, exp.current())] = False; exp.next()
56 Reference[model.selection(ResultBox_2, exp.current())] = False; exp.next()
57 Reference[model.selection(ResultBox_2, exp.current())] = True;  exp.next()
58 Reference[model.selection(ResultBox_2, exp.current())] = False; exp.next()
59 Reference[model.selection(ResultBox_2, exp.current())] = False; exp.next()
60 Reference[model.selection(ResultBox_2, exp.current())] = False; exp.next()
61
62 ResultBox_3 = Partition_1.result().subResult(3).resultSubShapePair()[0]
63 exp = GeomAPI_ShapeExplorer(ResultBox_3.shape(), GeomAPI_Shape.FACE)
64 while exp.more():
65   Reference[model.selection(ResultBox_3, exp.current())] = True
66   exp.next()
67
68 # Faces of the cylinder
69 ResultCylinder_1 = Cylinder_1.result().resultSubShapePair()[0]
70 exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.FACE)
71 while exp.more():
72   Reference[model.selection(ResultCylinder_1, exp.current())] = True
73   exp.next()
74
75 model.checkFilter(Part_1_doc, model, Filters, Reference)