1 # Copyright (C) 2014-2021 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
21 from ModelAPI import *
23 from ModelHighAPI import *
27 partSet = model.moduleDocument()
28 Part_1 = model.addPart(partSet)
29 Part_1_doc = Part_1.document()
32 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
36 filter_1 = model.addFilter(name = "OnPlane",
37 args = [model.selection("FACE", "Box_1_1/Left")])
39 filter_2 = model.addFilter(name = "OnPlane",
40 args = [model.selection("FACE", "Box_1_1/Top")])
42 filters = model.filters(Part_1_doc, [filter_1, filter_2])
44 ### Select all (one) suitable edges
45 selected_edges = filters.select("Edges")
47 group_1 = model.addGroup(Part_1_doc, "Edges", selected_edges)
48 assert(group_1.feature().results().size() == 1)
50 # Check the selected edge
51 aResult = group_1.results()[0].resultSubShapePair()[0]
52 aShape = aResult.shape()
53 aShapeExplorer = GeomAPI_ShapeExplorer(aShape, GeomAPI_Shape.EDGE)
54 assert(aShapeExplorer.more())
55 anEdge = aShapeExplorer.current()
56 assert(anEdge.edge().isLine() and math.fabs(anEdge.edge().line().direction().x() - 1.0) < 1.e-7)
57 aLoc = anEdge.edge().line().location()
58 assert(math.fabs(aLoc.x()) < 1.e-7)
59 assert(math.fabs(aLoc.y()) < 1.e-7)
60 assert(math.fabs(aLoc.z() - 10.0) < 1.e-7)
62 assert(not aShapeExplorer.more())