Salome HOME
Updated copyright comment
[modules/shaper.git] / src / FiltersPlugin / Test / TestFilter_OnGeometry_Face1.py
1 # Copyright (C) 2014-2024  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 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 FilterFace = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", args = [model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Top")])])
33 model.end()
34
35 Reference = {}
36 # Faces of the box (selected as a sub-shapes of the result to keep original surface).
37 # Note: the expected values have to be updated if ShapeExplorer will return another order of sub-shapes.
38 ResultBox_1 = Partition_1.result().resultSubShapePair()[0]
39 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.FACE)
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())] = 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())] = False; exp.next()
52 assert(not exp.more())
53 # Faces of the cylinder
54 ResultCylinder_1 = Translation_1.result().resultSubShapePair()[0]
55 exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.FACE)
56 Reference[model.selection(ResultCylinder_1, exp.current())] = False; exp.next()
57 Reference[model.selection(ResultCylinder_1, exp.current())] = True;  exp.next()
58 Reference[model.selection(ResultCylinder_1, exp.current())] = False; exp.next()
59 assert(not exp.more())
60 # Edges of the original box
61 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.EDGE)
62 while exp.more():
63   Reference[model.selection(ResultBox_1, exp.current())] = False
64   exp.next()
65 # Edges of the cylinder
66 exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.EDGE)
67 while exp.more():
68   Reference[model.selection(ResultCylinder_1, exp.current())] = False
69   exp.next()
70 # Vertices of the original box
71 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.VERTEX)
72 while exp.more():
73   Reference[model.selection(ResultBox_1, exp.current())] = False
74   exp.next()
75 # Vertices of the cylinder
76 exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.VERTEX)
77 while exp.more():
78   Reference[model.selection(ResultCylinder_1, exp.current())] = False
79   exp.next()
80
81 model.checkFilter(Part_1_doc, model, FilterFace, Reference)