1 # Copyright (C) 2014-2023 CEA, EDF
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 *
25 # Whole list of supported filters
26 FILTER_BELONGS_TO = "BelongsTo"
27 FILTER_ON_PLANE = "OnPlane"
28 FILTER_ON_LINE = "OnLine"
29 FILTER_ON_GEOMETRY = "OnGeometry"
30 FILTER_ON_PLANE_SIDE = "OnPlaneSide"
31 FILTER_OPPOSITE_TO_EDGE = "OppositeToEdge"
32 FILTER_RELATIVE_TO_SOLID = "RelativeToSolid"
33 FILTER_EXTERNAL_FACES = "ExternalFaces"
34 FILTER_HORIZONTAL_FACES = "HorizontalFaces"
35 FILTER_VERTICAL_FACES = "VerticalFaces"
36 FILTER_CONNECTED_FACES = "TopoConnectedFaces"
37 FILTER_EDGE_SIZE = "EdgeSize"
38 FILTER_FACE_SIZE = "FaceSize"
39 FILTER_VOLUME_SIZE = "VolumeSize"
40 FILTER_FEATURE_EDGES = "FeatureEdges"
41 FILTER_CONTINUOUS_FACES= "ContinuousFaces"
42 FILTER_ON_SHAPE_NAME = "OnShapeName"
44 # Reference data (supported filters) for each type of shape
46 GeomAPI_Shape.VERTEX : [FILTER_BELONGS_TO, FILTER_ON_PLANE, FILTER_ON_LINE, FILTER_ON_PLANE_SIDE, FILTER_RELATIVE_TO_SOLID,FILTER_ON_SHAPE_NAME],
47 GeomAPI_Shape.EDGE : [FILTER_BELONGS_TO, FILTER_ON_PLANE, FILTER_ON_LINE, FILTER_ON_GEOMETRY, FILTER_ON_PLANE_SIDE, FILTER_OPPOSITE_TO_EDGE, FILTER_RELATIVE_TO_SOLID, FILTER_EDGE_SIZE, FILTER_FEATURE_EDGES,FILTER_ON_SHAPE_NAME],
48 GeomAPI_Shape.WIRE : [FILTER_BELONGS_TO, FILTER_ON_PLANE, FILTER_ON_PLANE_SIDE, FILTER_RELATIVE_TO_SOLID,FILTER_ON_SHAPE_NAME],
49 GeomAPI_Shape.FACE : [FILTER_BELONGS_TO, FILTER_ON_PLANE, FILTER_ON_GEOMETRY, FILTER_ON_PLANE_SIDE, FILTER_RELATIVE_TO_SOLID, FILTER_EXTERNAL_FACES, FILTER_HORIZONTAL_FACES, FILTER_VERTICAL_FACES, FILTER_CONNECTED_FACES, FILTER_FACE_SIZE, FILTER_CONTINUOUS_FACES,FILTER_ON_SHAPE_NAME],
50 GeomAPI_Shape.SHELL : [FILTER_BELONGS_TO, FILTER_ON_PLANE, FILTER_ON_PLANE_SIDE, FILTER_RELATIVE_TO_SOLID,FILTER_ON_SHAPE_NAME],
51 GeomAPI_Shape.SOLID : [FILTER_BELONGS_TO, FILTER_ON_PLANE_SIDE, FILTER_VOLUME_SIZE,FILTER_ON_SHAPE_NAME],
55 partSet = model.moduleDocument()
56 Part_1 = model.addPart(partSet)
57 Part_1_doc = Part_1.document()
58 # load 'Filters' plugin
59 model.filters(Part_1_doc, [])
61 filtersFactory = ModelAPI_Session.get().filters()
62 for type, res in Reference.items():
63 filtersList = filtersFactory.filters(type)
64 for filter in filtersList:
65 filterID = filtersFactory.id(filter)
66 assert(filterID in res), "Filter \"{}\" is not applicable for {}".format(filterID, strByShapeType(type))
68 assert(len(res) == 0), "There are more filters {}, which should be supported for {}".format(res, strByShapeType(type))