]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Improve code coverage of Filters plugin.
authorazv <azv@opencascade.com>
Tue, 20 Aug 2019 12:37:42 +0000 (15:37 +0300)
committerazv <azv@opencascade.com>
Tue, 20 Aug 2019 12:59:37 +0000 (15:59 +0300)
src/FiltersAPI/FiltersAPI_Feature.cpp
src/FiltersPlugin/CMakeLists.txt
src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Face4.py [new file with mode: 0644]
src/FiltersPlugin/Test/TestFilter_OnGeometry_Face4.py [new file with mode: 0644]
src/FiltersPlugin/Test/TestFilters.py

index 301f5167004789f0f6330fa0e6ab1acab66a52c6..14bdbf6658c60cd8c39246a5c5428455b47cb201 100644 (file)
@@ -29,6 +29,7 @@ FiltersAPI_Feature::FiltersAPI_Feature(
 : ModelHighAPI_Interface(theFeature)
 {
   initialize();
+  std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(theFeature)->initAttributes();
 }
 
 FiltersAPI_Feature::~FiltersAPI_Feature()
index 8cebbbaa6dfa7a832898b15b276da0506c57d5e7..8cabb86066339fd58286657a7f54a8e5b95c719d 100644 (file)
@@ -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 (file)
index 0000000..3105218
--- /dev/null
@@ -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 (file)
index 0000000..8734e05
--- /dev/null
@@ -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)
index 75b480faf75736cc2679cf9881095411c6888d06..a0fd32cc413535c338559b9fb6bbb99a2de4c7a9 100644 (file)
@@ -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()