Salome HOME
Fix "External faces" filter to avoid faces with INTERNAL flag
authorazv <azv@opencascade.com>
Wed, 31 Jul 2019 09:38:35 +0000 (12:38 +0300)
committerazv <azv@opencascade.com>
Wed, 31 Jul 2019 09:38:35 +0000 (12:38 +0300)
src/FiltersPlugin/CMakeLists.txt
src/FiltersPlugin/FiltersPlugin_ExternalFaces.cpp
src/FiltersPlugin/Test/TestFilter_ExternalFaces.py [deleted file]
src/FiltersPlugin/Test/TestFilter_ExternalFaces1.py [new file with mode: 0644]
src/FiltersPlugin/Test/TestFilter_ExternalFaces2.py [new file with mode: 0644]
src/FiltersPlugin/Test/TestFilter_ExternalFaces_Exclude.py [deleted file]
src/FiltersPlugin/Test/TestFilter_ExternalFaces_Exclude1.py [new file with mode: 0644]
src/FiltersPlugin/Test/TestFilter_ExternalFaces_Exclude2.py [new file with mode: 0644]

index c90061fef0720a127492f9fae8903e6d208e4e16..8cebbbaa6dfa7a832898b15b276da0506c57d5e7 100644 (file)
@@ -142,8 +142,10 @@ ADD_UNIT_TESTS(
   TestFilter_RelativeToSolid_Exclude_NotOn.py
   TestFilter_RelativeToSolid_Exclude_InAndOn.py
   TestFilter_RelativeToSolid_Exclude_OutAndOn.py
-  TestFilter_ExternalFaces.py
-  TestFilter_ExternalFaces_Exclude.py
+  TestFilter_ExternalFaces1.py
+  TestFilter_ExternalFaces2.py
+  TestFilter_ExternalFaces_Exclude1.py
+  TestFilter_ExternalFaces_Exclude2.py
   TestFilter_HorizontalFaces.py
   TestFilter_HorizontalFaces_Exclude.py
   TestFilter_VerticalFaces.py
index 1ad322537f1817e6f6d3a84f7f6130f90b96fa6c..93fea41c60fce395bf4f49c8cb4dfae272b255b0 100644 (file)
@@ -36,6 +36,12 @@ bool FiltersPlugin_ExternalFaces::isOk(const GeomShapePtr& theShape,
   if (!theShape->isFace())
     return false;
 
+  // verify INTERNAL flag
+  TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+  if (aShape.Orientation() == TopAbs_INTERNAL)
+    return false;
+
+  // check number of solids containing the face
   ResultBodyPtr anOwner = ModelAPI_Tools::bodyOwner(theResult, true);
   if (!anOwner) {
     anOwner = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
@@ -47,6 +53,6 @@ bool FiltersPlugin_ExternalFaces::isOk(const GeomShapePtr& theShape,
   TopTools_IndexedDataMapOfShapeListOfShape aMapFS;
   TopExp::MapShapesAndUniqueAncestors(anOwnerShape->impl<TopoDS_Shape>(),
                                       TopAbs_FACE, TopAbs_SOLID, aMapFS);
-  const TopTools_ListOfShape& aSolids = aMapFS.FindFromKey(theShape->impl<TopoDS_Shape>());
+  const TopTools_ListOfShape& aSolids = aMapFS.FindFromKey(aShape);
   return aSolids.Extent() <= 1;
 }
diff --git a/src/FiltersPlugin/Test/TestFilter_ExternalFaces.py b/src/FiltersPlugin/Test/TestFilter_ExternalFaces.py
deleted file mode 100644 (file)
index 58f2145..0000000
+++ /dev/null
@@ -1,76 +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)
-Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), model.selection("FACE", "Box_1_1/Right"))
-Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1")], 20190506)
-Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
-Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], model.selection("EDGE", "PartSet/OX"), 20)
-Filters = model.filters(Part_1_doc, [model.addFilter(name = "ExternalFaces")])
-model.end()
-
-Reference = {}
-# Faces of the box
-ResultBox_1 = Partition_1.result().resultSubShapePair()[0]
-exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.FACE)
-Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
-# Faces of the cylinder
-ResultCylinder_1 = Translation_1.result().resultSubShapePair()[0]
-exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.FACE)
-while exp.more():
-  Reference[model.selection(ResultCylinder_1, exp.current())] = True
-  exp.next()
-model.checkFilter(Part_1_doc, model, Filters, Reference)
-
-Reference = {
-    model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Back"): True,
-    model.selection("FACE", "Partition_1_1_2/Modified_Face&Plane_1/Plane_1"): True,
-    model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Bottom"): True,
-    model.selection("FACE", "Box_1_1/Right"): True,
-    model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Top"): True,
-    model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Front"): True,
-    model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Back"): True,
-    model.selection("FACE", "Box_1_1/Left"): True,
-    model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Bottom"): True,
-    model.selection("FACE", "Partition_1_1_1/Modified_Face&Plane_1/Plane_1"): True,
-    model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Top"): True,
-    model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Front"): True,
-    model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_1"): True,
-    model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_2"): True,
-    model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_3"): True,
-}
-model.checkFilter(Part_1_doc, model, Filters, Reference)
diff --git a/src/FiltersPlugin/Test/TestFilter_ExternalFaces1.py b/src/FiltersPlugin/Test/TestFilter_ExternalFaces1.py
new file mode 100644 (file)
index 0000000..58f2145
--- /dev/null
@@ -0,0 +1,76 @@
+# 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)
+Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), model.selection("FACE", "Box_1_1/Right"))
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1")], 20190506)
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], model.selection("EDGE", "PartSet/OX"), 20)
+Filters = model.filters(Part_1_doc, [model.addFilter(name = "ExternalFaces")])
+model.end()
+
+Reference = {}
+# Faces of the box
+ResultBox_1 = Partition_1.result().resultSubShapePair()[0]
+exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.FACE)
+Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = True; exp.next()
+# Faces of the cylinder
+ResultCylinder_1 = Translation_1.result().resultSubShapePair()[0]
+exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.FACE)
+while exp.more():
+  Reference[model.selection(ResultCylinder_1, exp.current())] = True
+  exp.next()
+model.checkFilter(Part_1_doc, model, Filters, Reference)
+
+Reference = {
+    model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Back"): True,
+    model.selection("FACE", "Partition_1_1_2/Modified_Face&Plane_1/Plane_1"): True,
+    model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Bottom"): True,
+    model.selection("FACE", "Box_1_1/Right"): True,
+    model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Top"): True,
+    model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Front"): True,
+    model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Back"): True,
+    model.selection("FACE", "Box_1_1/Left"): True,
+    model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Bottom"): True,
+    model.selection("FACE", "Partition_1_1_1/Modified_Face&Plane_1/Plane_1"): True,
+    model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Top"): True,
+    model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Front"): True,
+    model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_1"): True,
+    model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_2"): True,
+    model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_3"): True,
+}
+model.checkFilter(Part_1_doc, model, Filters, Reference)
diff --git a/src/FiltersPlugin/Test/TestFilter_ExternalFaces2.py b/src/FiltersPlugin/Test/TestFilter_ExternalFaces2.py
new file mode 100644 (file)
index 0000000..5e3121c
--- /dev/null
@@ -0,0 +1,69 @@
+# 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 SketchAPI import *
+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)
+Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), model.selection("FACE", "Box_1_1/Right"))
+Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
+SketchLine_1 = Sketch_1.addLine(15, 2, 5, 2)
+SketchLine_2 = Sketch_1.addLine(5, 2, 5, 8)
+SketchLine_3 = Sketch_1.addLine(5, 8, 15, 8)
+SketchLine_4 = Sketch_1.addLine(15, 8, 15, 2)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_2.result(), 5, True)
+SketchConstraintDistance_2 = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_4.result(), 15, True)
+SketchConstraintDistance_3 = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_1.result(), 2, True)
+SketchConstraintDistance_4 = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_3.result(), 8, True)
+model.do()
+Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")])
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Face_1_1")], 20190506)
+Filters = model.filters(Part_1_doc, [model.addFilter(name = "ExternalFaces")])
+model.end()
+
+Reference = {}
+
+ResultPartition = Partition_1.result().resultSubShapePair()[0]
+exp = GeomAPI_ShapeExplorer(ResultPartition.shape(), GeomAPI_Shape.FACE)
+Reference[model.selection(ResultPartition, exp.current())] = True; exp.next()
+Reference[model.selection(ResultPartition, exp.current())] = True; exp.next()
+Reference[model.selection(ResultPartition, exp.current())] = True; exp.next()
+Reference[model.selection(ResultPartition, exp.current())] = True; exp.next()
+Reference[model.selection(ResultPartition, exp.current())] = True; exp.next()
+Reference[model.selection(ResultPartition, exp.current())] = True; exp.next()
+Reference[model.selection(ResultPartition, exp.current())] = False; exp.next()
+Reference[model.selection(ResultPartition, exp.current())] = True; exp.next()
+assert(not exp.more())
+
+model.checkFilter(Part_1_doc, model, Filters, Reference)
diff --git a/src/FiltersPlugin/Test/TestFilter_ExternalFaces_Exclude.py b/src/FiltersPlugin/Test/TestFilter_ExternalFaces_Exclude.py
deleted file mode 100644 (file)
index 4a5e962..0000000
+++ /dev/null
@@ -1,76 +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)
-Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), model.selection("FACE", "Box_1_1/Right"))
-Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1")], 20190506)
-Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
-Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], model.selection("EDGE", "PartSet/OX"), 20)
-Filters = model.filters(Part_1_doc, [model.addFilter(name = "ExternalFaces", exclude = True)])
-model.end()
-
-Reference = {}
-# Faces of the box
-ResultBox_1 = Partition_1.result().resultSubShapePair()[0]
-exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.FACE)
-Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
-Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
-# Faces of the cylinder
-ResultCylinder_1 = Translation_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()
-model.checkFilter(Part_1_doc, model, Filters, Reference)
-
-Reference = {
-    model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Back"): False,
-    model.selection("FACE", "Partition_1_1_2/Modified_Face&Plane_1/Plane_1"): False,
-    model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Bottom"): False,
-    model.selection("FACE", "Box_1_1/Right"): False,
-    model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Top"): False,
-    model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Front"): False,
-    model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Back"): False,
-    model.selection("FACE", "Box_1_1/Left"): False,
-    model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Bottom"): False,
-    model.selection("FACE", "Partition_1_1_1/Modified_Face&Plane_1/Plane_1"): False,
-    model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Top"): False,
-    model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Front"): False,
-    model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_1"): False,
-    model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_2"): False,
-    model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_3"): False,
-}
-model.checkFilter(Part_1_doc, model, Filters, Reference)
diff --git a/src/FiltersPlugin/Test/TestFilter_ExternalFaces_Exclude1.py b/src/FiltersPlugin/Test/TestFilter_ExternalFaces_Exclude1.py
new file mode 100644 (file)
index 0000000..4a5e962
--- /dev/null
@@ -0,0 +1,76 @@
+# 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)
+Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), model.selection("FACE", "Box_1_1/Right"))
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1")], 20190506)
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], model.selection("EDGE", "PartSet/OX"), 20)
+Filters = model.filters(Part_1_doc, [model.addFilter(name = "ExternalFaces", exclude = True)])
+model.end()
+
+Reference = {}
+# Faces of the box
+ResultBox_1 = Partition_1.result().resultSubShapePair()[0]
+exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.FACE)
+Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = True;  exp.next()
+Reference[model.selection(ResultBox_1, exp.current())] = False; exp.next()
+# Faces of the cylinder
+ResultCylinder_1 = Translation_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()
+model.checkFilter(Part_1_doc, model, Filters, Reference)
+
+Reference = {
+    model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Back"): False,
+    model.selection("FACE", "Partition_1_1_2/Modified_Face&Plane_1/Plane_1"): False,
+    model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Bottom"): False,
+    model.selection("FACE", "Box_1_1/Right"): False,
+    model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Top"): False,
+    model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_1_1/Front"): False,
+    model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Back"): False,
+    model.selection("FACE", "Box_1_1/Left"): False,
+    model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Bottom"): False,
+    model.selection("FACE", "Partition_1_1_1/Modified_Face&Plane_1/Plane_1"): False,
+    model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Top"): False,
+    model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Front"): False,
+    model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_1"): False,
+    model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_2"): False,
+    model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_3"): False,
+}
+model.checkFilter(Part_1_doc, model, Filters, Reference)
diff --git a/src/FiltersPlugin/Test/TestFilter_ExternalFaces_Exclude2.py b/src/FiltersPlugin/Test/TestFilter_ExternalFaces_Exclude2.py
new file mode 100644 (file)
index 0000000..9148ba3
--- /dev/null
@@ -0,0 +1,69 @@
+# 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 SketchAPI import *
+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)
+Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), model.selection("FACE", "Box_1_1/Right"))
+Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
+SketchLine_1 = Sketch_1.addLine(15, 2, 5, 2)
+SketchLine_2 = Sketch_1.addLine(5, 2, 5, 8)
+SketchLine_3 = Sketch_1.addLine(5, 8, 15, 8)
+SketchLine_4 = Sketch_1.addLine(15, 8, 15, 2)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_2.result(), 5, True)
+SketchConstraintDistance_2 = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_4.result(), 15, True)
+SketchConstraintDistance_3 = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_1.result(), 2, True)
+SketchConstraintDistance_4 = Sketch_1.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_3.result(), 8, True)
+model.do()
+Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")])
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Face_1_1")], 20190506)
+Filters = model.filters(Part_1_doc, [model.addFilter(name = "ExternalFaces", exclude = True)])
+model.end()
+
+Reference = {}
+
+ResultPartition = Partition_1.result().resultSubShapePair()[0]
+exp = GeomAPI_ShapeExplorer(ResultPartition.shape(), GeomAPI_Shape.FACE)
+Reference[model.selection(ResultPartition, exp.current())] = False; exp.next()
+Reference[model.selection(ResultPartition, exp.current())] = False; exp.next()
+Reference[model.selection(ResultPartition, exp.current())] = False; exp.next()
+Reference[model.selection(ResultPartition, exp.current())] = False; exp.next()
+Reference[model.selection(ResultPartition, exp.current())] = False; exp.next()
+Reference[model.selection(ResultPartition, exp.current())] = False; exp.next()
+Reference[model.selection(ResultPartition, exp.current())] = True;  exp.next()
+Reference[model.selection(ResultPartition, exp.current())] = False; exp.next()
+assert(not exp.more())
+
+model.checkFilter(Part_1_doc, model, Filters, Reference)