1 # Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 from salome.shaper import model
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 LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 20, 2, model.selection("EDGE", "PartSet/OY"), 20, 3)
29 Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
30 Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], model.selection("EDGE", "PartSet/OX"), 50)
31 Filters = model.filters(Part_1_doc, [model.addFilter(name = "BelongsTo", args = [model.selection("SOLID", "LinearCopy_1_1_1"), model.selection("SOLID", "Translation_1_1")])])
35 # Faces of the original box
36 ResultBox_1 = LinearCopy_1.result().subResult(0).resultSubShapePair()[0]
37 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.FACE)
39 Reference[model.selection(ResultBox_1, exp.current())] = True
41 # Faces of another box
42 ResultBox_2 = LinearCopy_1.result().subResult(1).resultSubShapePair()[0]
43 exp = GeomAPI_ShapeExplorer(ResultBox_2.shape(), GeomAPI_Shape.FACE)
45 Reference[model.selection(ResultBox_2, exp.current())] = False
47 # Faces of the cylinder
48 ResultCylinder_1 = Translation_1.result().resultSubShapePair()[0]
49 exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.FACE)
51 Reference[model.selection(ResultCylinder_1, exp.current())] = True
53 # Edges of the original box
54 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.EDGE)
56 Reference[model.selection(ResultBox_1, exp.current())] = True
58 # Edges of another box
59 exp = GeomAPI_ShapeExplorer(ResultBox_2.shape(), GeomAPI_Shape.EDGE)
61 Reference[model.selection(ResultBox_2, exp.current())] = False
63 # Edges of the cylinder
64 exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.EDGE)
66 Reference[model.selection(ResultCylinder_1, exp.current())] = True
68 # Vertices of the original box
69 exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.VERTEX)
71 Reference[model.selection(ResultBox_1, exp.current())] = True
73 # Vertices of another box
74 exp = GeomAPI_ShapeExplorer(ResultBox_2.shape(), GeomAPI_Shape.VERTEX)
76 Reference[model.selection(ResultBox_2, exp.current())] = False
78 # Vertices of the cylinder
79 exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.VERTEX)
81 Reference[model.selection(ResultCylinder_1, exp.current())] = True
84 model.checkFilter(Part_1_doc, model, Filters, Reference)