From: azv Date: Wed, 10 Jul 2019 11:45:11 +0000 (+0300) Subject: More tests to improve coverage of filters X-Git-Tag: VEDF2019Lot4~101^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bafadb922d2445099e7fbbdbe6fdae1327761534;p=modules%2Fshaper.git More tests to improve coverage of filters --- diff --git a/src/FiltersPlugin/CMakeLists.txt b/src/FiltersPlugin/CMakeLists.txt index bf09153ad..ab179ee48 100644 --- a/src/FiltersPlugin/CMakeLists.txt +++ b/src/FiltersPlugin/CMakeLists.txt @@ -98,6 +98,8 @@ ADD_UNIT_TESTS( TestFilters.py TestFilters_Mixed1.py TestFilters_Mixed2.py + TestFilters_Supported.py + TestFilters_Xml.py TestFilter_BelongsTo.py TestFilter_BelongsTo_Exclude.py TestFilter_OnPlane.py diff --git a/src/FiltersPlugin/Test/TestFilters_Supported.py b/src/FiltersPlugin/Test/TestFilters_Supported.py new file mode 100644 index 000000000..418a68707 --- /dev/null +++ b/src/FiltersPlugin/Test/TestFilters_Supported.py @@ -0,0 +1,63 @@ +# Copyright (C) 2014-2019 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +from salome.shaper import model +from ModelAPI import * +from GeomAPI import * +from ModelHighAPI import * + +# Whole list of supported filters +FILTER_BELONGS_TO = "BelongsTo" +FILTER_ON_PLANE = "OnPlane" +FILTER_ON_LINE = "OnLine" +FILTER_ON_GEOMETRY = "OnGeometry" +FILTER_ON_PLANE_SIDE = "OnPlaneSide" +FILTER_OPPOSITE_TO_EDGE = "OppositeToEdge" +FILTER_RELATIVE_TO_SOLID = "RelativeToSolid" +FILTER_EXTERNAL_FACES = "ExternalFaces" +FILTER_HORIZONTAL_FACES = "HorizontalFaces" +FILTER_VERTICAL_FACES = "VerticalFaces" +FILTER_CONNECTED_FACES = "TopoConnectedFaces" + +# Reference data (supported filters) for each type of shape +Reference = { + GeomAPI_Shape.VERTEX : [FILTER_BELONGS_TO, FILTER_ON_PLANE, FILTER_ON_LINE, FILTER_ON_PLANE_SIDE, FILTER_RELATIVE_TO_SOLID], + 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], + GeomAPI_Shape.WIRE : [FILTER_BELONGS_TO, FILTER_ON_PLANE, FILTER_ON_PLANE_SIDE, FILTER_RELATIVE_TO_SOLID], + 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], + GeomAPI_Shape.SHELL : [FILTER_BELONGS_TO, FILTER_ON_PLANE, FILTER_ON_PLANE_SIDE, FILTER_RELATIVE_TO_SOLID], + GeomAPI_Shape.SOLID : [FILTER_BELONGS_TO, FILTER_ON_PLANE_SIDE, FILTER_RELATIVE_TO_SOLID], +} + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +# load 'Filters' plugin +model.filters(Part_1_doc, []) + +filtersFactory = ModelAPI_Session.get().filters() +for type, res in Reference.items(): + filtersList = filtersFactory.filters(type) + for filter in filtersList: + filterID = filtersFactory.id(filter) + assert(filterID in res), "Filter \"{}\" is not applicable for {}".format(filterID, strByShapeType(type)) + res.remove(filterID) + assert(len(res) == 0), "There are more filters {}, which should be supported for {}".format(res, strByShapeType(type)) +model.end() diff --git a/src/FiltersPlugin/Test/TestFilters_Xml.py b/src/FiltersPlugin/Test/TestFilters_Xml.py new file mode 100644 index 000000000..e53c4b671 --- /dev/null +++ b/src/FiltersPlugin/Test/TestFilters_Xml.py @@ -0,0 +1,52 @@ +# Copyright (C) 2014-2019 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +from salome.shaper import model +from ModelAPI import * +from GeomAPI import * +from ModelHighAPI import * + +# Map filter and emptyness of its XML representation +Reference = { + "BelongsTo" : False, + "OnPlane" : False, + "OnLine" : False, + "OnGeometry" : False, + "OnPlaneSide" : False, + "OppositeToEdge" : False, + "RelativeToSolid" : False, + "ExternalFaces" : True, + "HorizontalFaces" : True, + "VerticalFaces" : True, + "TopoConnectedFaces" : False, +} + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +# load 'Filters' plugin +model.filters(Part_1_doc, []) + +filtersFactory = ModelAPI_Session.get().filters() +for id, res in Reference.items(): + filter = filtersFactory.filter(id) + xmlString = filter.xmlRepresentation() + assert((len(xmlString) == 0) == res) +model.end() diff --git a/src/ModelAPI/ModelAPI.i b/src/ModelAPI/ModelAPI.i index 6f6a1f784..dc76645c8 100644 --- a/src/ModelAPI/ModelAPI.i +++ b/src/ModelAPI/ModelAPI.i @@ -66,6 +66,7 @@ %shared_ptr(ModelAPI_Feature) %shared_ptr(ModelAPI_CompositeFeature) %shared_ptr(ModelAPI_Data) +%shared_ptr(ModelAPI_Filter) %shared_ptr(ModelAPI_FiltersFeature) %shared_ptr(ModelAPI_Folder) %shared_ptr(ModelAPI_Attribute) @@ -170,6 +171,7 @@ %template(FeatureList) std::list >; %template(ResultList) std::list >; %template(DocumentList) std::list >; +%template(FilterList) std::list >; // std::set -> [] %template(AttributeSet) std::set >; %template(FeatureSet) std::set >;