Salome HOME
c1082bce52110d5aaee38cd9a058cf38c2aa34a2
[modules/shaper.git] / src / FiltersPlugin / Test / TestFilter_TopoConnectedFaces_Edge2.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 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", args = [model.selection("EDGE", "Partition_1_1_2/Generated_Edge&Plane_2/Plane_2&Box_1_1/Top"), 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 while exp.more():
41   Reference[model.selection(ResultBox_0, exp.current())] = False
42   exp.next()
43
44 ResultBox_1 = Partition_1.result().subResult(1).resultSubShapePair()[0]
45 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.FACE)
46 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
47 Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
48 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
49 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
50 Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
51 Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
52
53 ResultBox_2 = Partition_1.result().subResult(2).resultSubShapePair()[0]
54 exp = GeomAPI_ShapeExplorer(ResultBox_2.shape(), GeomAPI_Shape.FACE)
55 while exp.more():
56   Reference[model.selection(ResultBox_2, exp.current())] = False
57   exp.next()
58
59 ResultBox_3 = Partition_1.result().subResult(3).resultSubShapePair()[0]
60 exp = GeomAPI_ShapeExplorer(ResultBox_3.shape(), GeomAPI_Shape.FACE)
61 Reference[model.selection(ResultBox_3, exp.current())] = False; exp.next()
62 Reference[model.selection(ResultBox_3, exp.current())] = True;  exp.next()
63 Reference[model.selection(ResultBox_3, exp.current())] = False; exp.next()
64 Reference[model.selection(ResultBox_3, exp.current())] = False; exp.next()
65 Reference[model.selection(ResultBox_3, exp.current())] = True;  exp.next()
66 Reference[model.selection(ResultBox_3, exp.current())] = False; 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())] = False
73   exp.next()
74
75 model.checkFilter(Part_1_doc, model, Filters, Reference)