From: azv Date: Tue, 20 Aug 2019 12:37:42 +0000 (+0300) Subject: Improve code coverage of Filters plugin. X-Git-Tag: VEDF2019Lot4~47 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7107f1712c2299b000d018a84430b05f6c13edf7;p=modules%2Fshaper.git Improve code coverage of Filters plugin. --- diff --git a/src/FiltersAPI/FiltersAPI_Feature.cpp b/src/FiltersAPI/FiltersAPI_Feature.cpp index 301f51670..14bdbf665 100644 --- a/src/FiltersAPI/FiltersAPI_Feature.cpp +++ b/src/FiltersAPI/FiltersAPI_Feature.cpp @@ -29,6 +29,7 @@ FiltersAPI_Feature::FiltersAPI_Feature( : ModelHighAPI_Interface(theFeature) { initialize(); + std::dynamic_pointer_cast(theFeature)->initAttributes(); } FiltersAPI_Feature::~FiltersAPI_Feature() diff --git a/src/FiltersPlugin/CMakeLists.txt b/src/FiltersPlugin/CMakeLists.txt index 8cebbbaa6..8cabb8606 100644 --- a/src/FiltersPlugin/CMakeLists.txt +++ b/src/FiltersPlugin/CMakeLists.txt @@ -119,11 +119,13 @@ ADD_UNIT_TESTS( TestFilter_OnGeometry_Face1.py TestFilter_OnGeometry_Face2.py TestFilter_OnGeometry_Face3.py + TestFilter_OnGeometry_Face4.py TestFilter_OnGeometry_Exclude_Edge1.py TestFilter_OnGeometry_Exclude_Edge2.py TestFilter_OnGeometry_Exclude_Face1.py TestFilter_OnGeometry_Exclude_Face2.py TestFilter_OnGeometry_Exclude_Face3.py + TestFilter_OnGeometry_Exclude_Face4.py TestFilter_OnPlaneSide_Face.py TestFilter_OnPlaneSide_Plane.py TestFilter_OnPlaneSide_Exclude_Face.py diff --git a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Face4.py b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Face4.py new file mode 100644 index 000000000..310521869 --- /dev/null +++ b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Face4.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 GeomAPI import * + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10, 45) +Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Cylinder_1_1/Face_4")) +SketchArc_1 = Sketch_1.addArc(2.402631123626777, 4.538350751693263, 2.946623076146047, 2.768866376496988, 3.159520035183744, 6.227765257973941, False) +model.do() +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2")]) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "PartSet/OZ"), 0, 90) +FiltersCyl = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", exclude = True, args = [model.selection("FACE", "Cylinder_1_1/Face_1")])]) +FiltersRev = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", exclude = True, args = [model.selection("FACE", "Revolution_1_1")])]) +model.end() + +Reference = {} +ResultRevolution = Revolution_1.result().resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultRevolution.shape(), GeomAPI_Shape.FACE) +Reference[model.selection(ResultRevolution, exp.current())] = True; exp.next() +assert(not exp.more()) + +model.checkFilter(Part_1_doc, model, FiltersCyl, Reference) + +Reference = {} +ResultCylinder = Cylinder_1.result().resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultCylinder.shape(), GeomAPI_Shape.FACE) +while exp.more(): + Reference[model.selection(ResultCylinder, exp.current())] = True + exp.next() + +model.checkFilter(Part_1_doc, model, FiltersRev, Reference) diff --git a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Face4.py b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Face4.py new file mode 100644 index 000000000..8734e0549 --- /dev/null +++ b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Face4.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 GeomAPI import * + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10, 45) +Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Cylinder_1_1/Face_4")) +SketchArc_1 = Sketch_1.addArc(2.402631123626777, 4.538350751693263, 2.946623076146047, 2.768866376496988, 3.159520035183744, 6.227765257973941, False) +model.do() +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2")]) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "PartSet/OZ"), 0, 90) +FiltersCyl = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", args = [model.selection("FACE", "Cylinder_1_1/Face_1")])]) +FiltersRev = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", args = [model.selection("FACE", "Revolution_1_1")])]) +model.end() + +Reference = {} +ResultRevolution = Revolution_1.result().resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultRevolution.shape(), GeomAPI_Shape.FACE) +Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next() +assert(not exp.more()) + +model.checkFilter(Part_1_doc, model, FiltersCyl, Reference) + +Reference = {} +ResultCylinder = Cylinder_1.result().resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultCylinder.shape(), GeomAPI_Shape.FACE) +while exp.more(): + Reference[model.selection(ResultCylinder, exp.current())] = False + exp.next() + +model.checkFilter(Part_1_doc, model, FiltersRev, Reference) diff --git a/src/FiltersPlugin/Test/TestFilters.py b/src/FiltersPlugin/Test/TestFilters.py index 75b480faf..a0fd32cc4 100644 --- a/src/FiltersPlugin/Test/TestFilters.py +++ b/src/FiltersPlugin/Test/TestFilters.py @@ -25,7 +25,8 @@ partSet = model.moduleDocument() Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() Box_1 = model.addBox(Part_1_doc, 10, 10, 10) -Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Box_1_1/Bottom"), model.filters(Part_1_doc, [model.addFilter(name = "BelongsTo", args = [model.selection("SOLID", "Box_1_1")]), model.addFilter(name = "HorizontalFaces"), model.addFilter(name = "OnGeometry", args = [model.selection("FACE", "PartSet/XOY")])])]) +Filters = model.filters(Part_1_doc, [model.addFilter(name = "BelongsTo", args = [model.selection("SOLID", "Box_1_1")]), model.addFilter(name = "HorizontalFaces"), model.addFilter(name = "OnGeometry", args = [model.selection("FACE", "PartSet/XOY")])]) +Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Box_1_1/Bottom"), Filters]) model.end() aFactory = ModelAPI_Session.get().validators()