Salome HOME
updated copyright message
[modules/shaper.git] / src / FiltersPlugin / Test / TestFilter_TopoConnectedFaces_Prop_Vertex2.py
1 # Copyright (C) 2014-2023  CEA, EDF
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("VERTEX", "[Partition_1_1_2/Modified_Face&Box_1_1/Top][Partition_1_1_2/Modified_Face&Plane_1/Plane_1][Partition_1_1_2/Modified_Face&Plane_2/Plane_2]"), True])])
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())] = True
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 while exp.more():
47   Reference[model.selection(ResultBox_1, exp.current())] = True
48   exp.next()
49
50 ResultBox_2 = Partition_1.result().subResult(2).resultSubShapePair()[0]
51 exp = GeomAPI_ShapeExplorer(ResultBox_2.shape(), GeomAPI_Shape.FACE)
52 while exp.more():
53   Reference[model.selection(ResultBox_2, exp.current())] = True
54   exp.next()
55
56 ResultBox_3 = Partition_1.result().subResult(3).resultSubShapePair()[0]
57 exp = GeomAPI_ShapeExplorer(ResultBox_3.shape(), GeomAPI_Shape.FACE)
58 while exp.more():
59   Reference[model.selection(ResultBox_3, exp.current())] = True
60   exp.next()
61
62 # Faces of the cylinder
63 ResultCylinder_1 = Cylinder_1.result().resultSubShapePair()[0]
64 exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.FACE)
65 while exp.more():
66   Reference[model.selection(ResultCylinder_1, exp.current())] = False
67   exp.next()
68
69 model.checkFilter(Part_1_doc, model, Filters, Reference)