]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
More test to improve coverage of filters
authorazv <azv@opencascade.com>
Wed, 10 Jul 2019 07:24:06 +0000 (10:24 +0300)
committerazv <azv@opencascade.com>
Wed, 10 Jul 2019 07:24:06 +0000 (10:24 +0300)
src/FiltersPlugin/CMakeLists.txt
src/FiltersPlugin/Test/TestFilters_Mixed.py [deleted file]
src/FiltersPlugin/Test/TestFilters_Mixed1.py [new file with mode: 0644]
src/FiltersPlugin/Test/TestFilters_Mixed2.py [new file with mode: 0644]

index 50318f1d3e3d0bb6906086e1a8383b2fa00ff5ff..bf09153ad3438f9c52012586a2ef134f5319a1ae 100644 (file)
@@ -96,6 +96,8 @@ INSTALL(FILES ${PROJECT_PYFILES} DESTINATION ${SHAPER_INSTALL_ADDONS})
 
 ADD_UNIT_TESTS(
   TestFilters.py
+  TestFilters_Mixed1.py
+  TestFilters_Mixed2.py
   TestFilter_BelongsTo.py
   TestFilter_BelongsTo_Exclude.py
   TestFilter_OnPlane.py
diff --git a/src/FiltersPlugin/Test/TestFilters_Mixed.py b/src/FiltersPlugin/Test/TestFilters_Mixed.py
deleted file mode 100644 (file)
index c81cd5b..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-# 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)
-Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Top"))
-SketchCircle_1 = Sketch_1.addCircle(5, 5, 3)
-SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), False)
-SketchLine_1 = SketchProjection_1.createdFeature()
-SketchConstraintDistance_1 = Sketch_1.setDistance(SketchCircle_1.center(), SketchLine_1.result(), 5, True)
-SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Top]"), False)
-SketchLine_2 = SketchProjection_2.createdFeature()
-SketchConstraintDistance_2 = Sketch_1.setDistance(SketchCircle_1.center(), SketchLine_2.result(), 5, True)
-SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 3)
-model.do()
-Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_1_2r_wire")], model.selection(), 5, 0)
-Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_1_2r_wire")], model.selection(), 10, -5)
-Filters = model.filters(Part_1_doc, [model.addFilter(name = "RelativeToSolid", args = [model.selection("SOLID", "Box_1_1"), "not_in"]),
-                                     model.addFilter(name = "TopoConnectedFaces", args = [model.selection("VERTEX", "[Extrusion_2_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_2_1/To_Face]")])])
-model.end()
-
-Reference = {}
-# Faces of the box
-ResultBox = Box_1.result().resultSubShapePair()[0]
-exp = GeomAPI_ShapeExplorer(ResultBox.shape(), GeomAPI_Shape.FACE)
-while exp.more():
-  Reference[model.selection(ResultBox, exp.current())] = False
-  exp.next()
-
-# Faces of the first cylinder
-ResultCylinder_1 = Extrusion_1.result().resultSubShapePair()[0]
-exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.FACE)
-while exp.more():
-  Reference[model.selection(ResultCylinder_1, exp.current())] = False
-  exp.next()
-
-# Faces of the second cylinder
-ResultCylinder_2 = Extrusion_2.result().resultSubShapePair()[0]
-exp = GeomAPI_ShapeExplorer(ResultCylinder_2.shape(), GeomAPI_Shape.FACE)
-Reference[model.selection(ResultCylinder_2, exp.current())] = True;  exp.next()
-Reference[model.selection(ResultCylinder_2, exp.current())] = False; exp.next()
-Reference[model.selection(ResultCylinder_2, exp.current())] = True;  exp.next()
-
-model.checkFilter(Part_1_doc, model, Filters, Reference)
-
-model.begin()
-Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Extrusion_2_1/To_Face"), model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_1/SketchCircle_1_2"), Filters])
-model.end()
-assert(model.checkPythonDump())
diff --git a/src/FiltersPlugin/Test/TestFilters_Mixed1.py b/src/FiltersPlugin/Test/TestFilters_Mixed1.py
new file mode 100644 (file)
index 0000000..c81cd5b
--- /dev/null
@@ -0,0 +1,71 @@
+# 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)
+Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Top"))
+SketchCircle_1 = Sketch_1.addCircle(5, 5, 3)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), False)
+SketchLine_1 = SketchProjection_1.createdFeature()
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchCircle_1.center(), SketchLine_1.result(), 5, True)
+SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Top]"), False)
+SketchLine_2 = SketchProjection_2.createdFeature()
+SketchConstraintDistance_2 = Sketch_1.setDistance(SketchCircle_1.center(), SketchLine_2.result(), 5, True)
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 3)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_1_2r_wire")], model.selection(), 5, 0)
+Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_1_2r_wire")], model.selection(), 10, -5)
+Filters = model.filters(Part_1_doc, [model.addFilter(name = "RelativeToSolid", args = [model.selection("SOLID", "Box_1_1"), "not_in"]),
+                                     model.addFilter(name = "TopoConnectedFaces", args = [model.selection("VERTEX", "[Extrusion_2_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_2_1/To_Face]")])])
+model.end()
+
+Reference = {}
+# Faces of the box
+ResultBox = Box_1.result().resultSubShapePair()[0]
+exp = GeomAPI_ShapeExplorer(ResultBox.shape(), GeomAPI_Shape.FACE)
+while exp.more():
+  Reference[model.selection(ResultBox, exp.current())] = False
+  exp.next()
+
+# Faces of the first cylinder
+ResultCylinder_1 = Extrusion_1.result().resultSubShapePair()[0]
+exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.FACE)
+while exp.more():
+  Reference[model.selection(ResultCylinder_1, exp.current())] = False
+  exp.next()
+
+# Faces of the second cylinder
+ResultCylinder_2 = Extrusion_2.result().resultSubShapePair()[0]
+exp = GeomAPI_ShapeExplorer(ResultCylinder_2.shape(), GeomAPI_Shape.FACE)
+Reference[model.selection(ResultCylinder_2, exp.current())] = True;  exp.next()
+Reference[model.selection(ResultCylinder_2, exp.current())] = False; exp.next()
+Reference[model.selection(ResultCylinder_2, exp.current())] = True;  exp.next()
+
+model.checkFilter(Part_1_doc, model, Filters, Reference)
+
+model.begin()
+Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Extrusion_2_1/To_Face"), model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_1/SketchCircle_1_2"), Filters])
+model.end()
+assert(model.checkPythonDump())
diff --git a/src/FiltersPlugin/Test/TestFilters_Mixed2.py b/src/FiltersPlugin/Test/TestFilters_Mixed2.py
new file mode 100644 (file)
index 0000000..fdce076
--- /dev/null
@@ -0,0 +1,166 @@
+# 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()
+Group_1_objects = [model.selection("FACE", "LinearCopy_1_1_3/MF:Translated&Box_1_1/Back"), model.selection("FACE", "LinearCopy_1_1_3/MF:Translated&Box_1_1/Left"), model.selection("FACE", "LinearCopy_1_1_3/MF:Translated&Box_1_1/Right"), model.selection("FACE", "LinearCopy_1_1_3/MF:Translated&Box_1_1/Bottom"), Filters]
+Group_1 = model.addGroup(Part_1_doc, Group_1_objects)
+model.end()
+assert(model.checkPythonDump())