]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add tests to improve coverage of Filters plugin.
authorazv <azv@opencascade.com>
Fri, 12 Jul 2019 12:00:13 +0000 (15:00 +0300)
committerazv <azv@opencascade.com>
Fri, 12 Jul 2019 12:00:13 +0000 (15:00 +0300)
src/FiltersPlugin/CMakeLists.txt
src/FiltersPlugin/Test/TestFilters_FilterName.py [new file with mode: 0644]
src/FiltersPlugin/Test/TestFilters_IsReversed.py [new file with mode: 0644]
src/FiltersPlugin/Test/TestFilters_Remove.py [new file with mode: 0644]
src/ModelAPI/ModelAPI_ResultField.cpp

index ab179ee4855bf30430f054d20f53ce0c4ee003fe..5deefa7333e26132ec0a6ed978c4f1c1bc4877e6 100644 (file)
@@ -100,6 +100,9 @@ ADD_UNIT_TESTS(
   TestFilters_Mixed2.py
   TestFilters_Supported.py
   TestFilters_Xml.py
+  TestFilters_FilterName.py
+  TestFilters_IsReversed.py
+  TestFilters_Remove.py
   TestFilter_BelongsTo.py
   TestFilter_BelongsTo_Exclude.py
   TestFilter_OnPlane.py
diff --git a/src/FiltersPlugin/Test/TestFilters_FilterName.py b/src/FiltersPlugin/Test/TestFilters_FilterName.py
new file mode 100644 (file)
index 0000000..853e1b3
--- /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 ModelAPI import *
+from GeomAPI import *
+from ModelHighAPI import *
+
+# List of filters
+Reference = [
+    "BelongsTo",
+    "OnPlane",
+    "OnLine",
+    "OnGeometry",
+    "OnPlaneSide",
+    "OppositeToEdge",
+    "RelativeToSolid",
+    "ExternalFaces",
+    "HorizontalFaces",
+    "VerticalFaces",
+    "TopoConnectedFaces"
+]
+
+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 in Reference:
+  filter = filtersFactory.filter(id)
+  name = filter.name()
+  assert(len(name) != 0)
+model.end()
diff --git a/src/FiltersPlugin/Test/TestFilters_IsReversed.py b/src/FiltersPlugin/Test/TestFilters_IsReversed.py
new file mode 100644 (file)
index 0000000..9b2c76e
--- /dev/null
@@ -0,0 +1,38 @@
+# 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()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OY"), 20, 3)
+Filters = model.filters(Part_1_doc, [model.addFilter(name = "BelongsTo", args = [model.selection("SOLID", "LinearCopy_1_1_3")]),
+                                     model.addFilter(name = "OnPlane", exclude = True, args = [model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Top"),
+                                                                                               model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Front")
+                                                                                               ])
+                                     ])
+model.end()
+
+assert(Filters.feature().isReversed("BelongsTo") is False)
+assert(Filters.feature().isReversed("OnPlane") is True)
+assert(Filters.feature().isReversed("OnLine") is False)
diff --git a/src/FiltersPlugin/Test/TestFilters_Remove.py b/src/FiltersPlugin/Test/TestFilters_Remove.py
new file mode 100644 (file)
index 0000000..fd557f2
--- /dev/null
@@ -0,0 +1,210 @@
+# 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()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OY"), 20, 3)
+Filters = model.filters(Part_1_doc, [model.addFilter(name = "BelongsTo", args = [model.selection("SOLID", "LinearCopy_1_1_3")]),
+                                     model.addFilter(name = "OnPlane", exclude = True, args = [model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Top"),
+                                                                                               model.selection("FACE", "LinearCopy_1_1_1/MF:Translated&Box_1_1/Front")
+                                                                                               ])
+                                     ])
+model.end()
+
+Box1 = LinearCopy_1.result().subResult(0).resultSubShapePair()[0]
+Box2 = LinearCopy_1.result().subResult(1).resultSubShapePair()[0]
+Box3 = LinearCopy_1.result().subResult(2).resultSubShapePair()[0]
+emptyShape = GeomAPI_Shape()
+
+Reference = {}
+# First box reference data
+Reference[model.selection(Box1, emptyShape)] = False
+exp = GeomAPI_ShapeExplorer(Box1.shape(), GeomAPI_Shape.FACE)
+while exp.more():
+  Reference[model.selection(Box1, exp.current())] = False
+  exp.next()
+exp = GeomAPI_ShapeExplorer(Box1.shape(), GeomAPI_Shape.EDGE)
+while exp.more():
+  Reference[model.selection(Box1, exp.current())] = False
+  exp.next()
+exp = GeomAPI_ShapeExplorer(Box1.shape(), GeomAPI_Shape.VERTEX)
+while exp.more():
+  Reference[model.selection(Box1, exp.current())] = False
+  exp.next()
+# Second box reference data
+Reference[model.selection(Box2, emptyShape)] = False
+exp = GeomAPI_ShapeExplorer(Box2.shape(), GeomAPI_Shape.FACE)
+while exp.more():
+  Reference[model.selection(Box2, exp.current())] = False
+  exp.next()
+exp = GeomAPI_ShapeExplorer(Box2.shape(), GeomAPI_Shape.EDGE)
+while exp.more():
+  Reference[model.selection(Box2, exp.current())] = False
+  exp.next()
+exp = GeomAPI_ShapeExplorer(Box2.shape(), GeomAPI_Shape.VERTEX)
+while exp.more():
+  Reference[model.selection(Box2, exp.current())] = False
+  exp.next()
+# Third box reference data
+Reference[model.selection(Box3, emptyShape)] = True
+# faces
+exp = GeomAPI_ShapeExplorer(Box3.shape(), GeomAPI_Shape.FACE)
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+assert(not exp.more())
+# edges
+exp = GeomAPI_ShapeExplorer(Box3.shape(), GeomAPI_Shape.EDGE)
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+assert(not exp.more())
+# vertices
+exp = GeomAPI_ShapeExplorer(Box3.shape(), GeomAPI_Shape.VERTEX)
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = True;  exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+Reference[model.selection(Box3, exp.current())] = False; exp.next()
+assert(not exp.more())
+
+model.checkFilter(Part_1_doc, model, Filters, Reference)
+
+model.begin()
+Filters.feature().removeFilter("OnPlane")
+model.end()
+
+Reference = {}
+# First box reference data
+Reference[model.selection(Box1, emptyShape)] = False
+exp = GeomAPI_ShapeExplorer(Box1.shape(), GeomAPI_Shape.FACE)
+while exp.more():
+  Reference[model.selection(Box1, exp.current())] = False
+  exp.next()
+exp = GeomAPI_ShapeExplorer(Box1.shape(), GeomAPI_Shape.EDGE)
+while exp.more():
+  Reference[model.selection(Box1, exp.current())] = False
+  exp.next()
+exp = GeomAPI_ShapeExplorer(Box1.shape(), GeomAPI_Shape.VERTEX)
+while exp.more():
+  Reference[model.selection(Box1, exp.current())] = False
+  exp.next()
+# Second box reference data
+Reference[model.selection(Box2, emptyShape)] = False
+exp = GeomAPI_ShapeExplorer(Box2.shape(), GeomAPI_Shape.FACE)
+while exp.more():
+  Reference[model.selection(Box2, exp.current())] = False
+  exp.next()
+exp = GeomAPI_ShapeExplorer(Box2.shape(), GeomAPI_Shape.EDGE)
+while exp.more():
+  Reference[model.selection(Box2, exp.current())] = False
+  exp.next()
+exp = GeomAPI_ShapeExplorer(Box2.shape(), GeomAPI_Shape.VERTEX)
+while exp.more():
+  Reference[model.selection(Box2, exp.current())] = False
+  exp.next()
+# Third box reference data
+Reference[model.selection(Box3, emptyShape)] = True
+exp = GeomAPI_ShapeExplorer(Box3.shape(), GeomAPI_Shape.FACE)
+while exp.more():
+  Reference[model.selection(Box3, exp.current())] = True
+  exp.next()
+exp = GeomAPI_ShapeExplorer(Box3.shape(), GeomAPI_Shape.EDGE)
+while exp.more():
+  Reference[model.selection(Box3, exp.current())] = True
+  exp.next()
+exp = GeomAPI_ShapeExplorer(Box3.shape(), GeomAPI_Shape.VERTEX)
+while exp.more():
+  Reference[model.selection(Box3, exp.current())] = True
+  exp.next()
+
+model.checkFilter(Part_1_doc, model, Filters, Reference)
index 8a997866e99af0a38514a38de50f66cedcc3e41c..398a28e6178c37c91320f11e7048e225cefa8ea0 100644 (file)
@@ -31,6 +31,7 @@ std::string ModelAPI_ResultField::groupName()
   return group();
 }
 
+// LCOV_EXCL_START
 void ModelAPI_ResultField::ModelAPI_FieldStep::setDisplayed(const bool theDisplay)
 {
   if (myIsDisplayed != theDisplay) {
@@ -60,3 +61,4 @@ void ModelAPI_ResultField::setDisplayed(const bool theDisplay)
       step(i)->setDisplayed(false);
   }
 }
+// LCOV_EXCL_STOP