From: azv Date: Wed, 31 Jul 2019 08:16:13 +0000 (+0300) Subject: Change "On geometry" filter to process geometrically identical shapes instead of... X-Git-Tag: VEDF2019Lot4~65 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8cb8992a16319fa5ce66d73e4f5ab93691bbb8a4;p=modules%2Fshaper.git Change "On geometry" filter to process geometrically identical shapes instead of checking the same geometrical base. --- diff --git a/src/FiltersPlugin/CMakeLists.txt b/src/FiltersPlugin/CMakeLists.txt index 62482f88e..c90061fef 100644 --- a/src/FiltersPlugin/CMakeLists.txt +++ b/src/FiltersPlugin/CMakeLists.txt @@ -114,10 +114,16 @@ ADD_UNIT_TESTS( TestFilter_OnPlane_Exclude.py TestFilter_OnLine.py TestFilter_OnLine_Exclude.py - TestFilter_OnGeometry_Edge.py - TestFilter_OnGeometry_Face.py - TestFilter_OnGeometry_Exclude_Edge.py - TestFilter_OnGeometry_Exclude_Face.py + TestFilter_OnGeometry_Edge1.py + TestFilter_OnGeometry_Edge2.py + TestFilter_OnGeometry_Face1.py + TestFilter_OnGeometry_Face2.py + TestFilter_OnGeometry_Face3.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_OnPlaneSide_Face.py TestFilter_OnPlaneSide_Plane.py TestFilter_OnPlaneSide_Exclude_Face.py diff --git a/src/FiltersPlugin/FiltersPlugin_OnGeometry.cpp b/src/FiltersPlugin/FiltersPlugin_OnGeometry.cpp index c7fa73d32..aeeb67650 100644 --- a/src/FiltersPlugin/FiltersPlugin_OnGeometry.cpp +++ b/src/FiltersPlugin/FiltersPlugin_OnGeometry.cpp @@ -37,7 +37,9 @@ bool FiltersPlugin_OnGeometry::isOk(const GeomShapePtr& theShape, const ResultPt for (int i = 0; i < aList->size(); i++) { AttributeSelectionPtr aAttr = aList->value(i); GeomShapePtr aGeom = aAttr->value(); - if (aGeom->isSameGeometry(theShape)) + if (!aGeom) + aGeom = aAttr->context()->shape(); + if (aGeom && aGeom->isSameGeometry(theShape)) return true; } return false; diff --git a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Edge.py b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Edge.py deleted file mode 100644 index 7a14e68c4..000000000 --- a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Edge.py +++ /dev/null @@ -1,115 +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) -FilterFace = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", args = [model.selection("EDGE", "Partition_1_1_2/Generated_Edge&Plane_1/Plane_1&Box_1_1/Front"), model.selection("EDGE", "[Partition_1_1_1/Modified_Face&Box_1_1/Top][Partition_1_1_1/Modified_Face&Box_1_1/Front]")])]) -model.end() - -Reference = {} -# Faces of the box -ResultBox_1 = Partition_1.result().resultSubShapePair()[0] -exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.FACE) -while exp.more(): - 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() -# Edges of the original box (selected as a sub-shapes of the result to keep original surface). -# Note: the expected values have to be updated if ShapeExplorer will return another order of sub-shapes. -exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.EDGE) -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() -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())] = 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())] = 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())] = 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())] = 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() -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())] = True; exp.next() -# Edges of the cylinder -exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.EDGE) -while exp.more(): - Reference[model.selection(ResultCylinder_1, exp.current())] = False - exp.next() -# Vertices of the original box -exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.VERTEX) -while exp.more(): - Reference[model.selection(ResultBox_1, exp.current())] = False - exp.next() -# Vertices of the cylinder -exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.VERTEX) -while exp.more(): - Reference[model.selection(ResultCylinder_1, exp.current())] = False - exp.next() - -model.checkFilter(Part_1_doc, model, FilterFace, Reference) diff --git a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Edge1.py b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Edge1.py new file mode 100644 index 000000000..368a57918 --- /dev/null +++ b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Edge1.py @@ -0,0 +1,116 @@ +# 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) +FilterFace = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", args = [model.selection("EDGE", "Partition_1_1_2/Generated_Edge&Plane_1/Plane_1&Box_1_1/Front"), model.selection("EDGE", "[Partition_1_1_1/Modified_Face&Box_1_1/Top][Partition_1_1_1/Modified_Face&Box_1_1/Front]")])]) +model.end() + +Reference = {} +# Faces of the box +ResultBox_1 = Partition_1.result().resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.FACE) +while exp.more(): + 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() +# Edges of the original box (selected as a sub-shapes of the result to keep original surface). +# Note: the expected values have to be updated if ShapeExplorer will return another order of sub-shapes. +exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.EDGE) +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() +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())] = 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())] = 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())] = 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())] = 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() +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())] = True; exp.next() +assert(not exp.more()) +# Edges of the cylinder +exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.EDGE) +while exp.more(): + Reference[model.selection(ResultCylinder_1, exp.current())] = False + exp.next() +# Vertices of the original box +exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.VERTEX) +while exp.more(): + Reference[model.selection(ResultBox_1, exp.current())] = False + exp.next() +# Vertices of the cylinder +exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.VERTEX) +while exp.more(): + Reference[model.selection(ResultCylinder_1, exp.current())] = False + exp.next() + +model.checkFilter(Part_1_doc, model, FilterFace, Reference) diff --git a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Edge2.py b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Edge2.py new file mode 100644 index 000000000..36cf0b6be --- /dev/null +++ b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Edge2.py @@ -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 * +from SketchAPI import * + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Extrusion_1 = model.addExtrusion(Part_1_doc, [], model.selection(), 100, 0) +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(0, 0, 80) +SketchLine_1 = Sketch_1.addLine(-70.03988514133886, -38.65765757761403, 65.03214823048954, -46.59205615260649) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchCircle_1.results()[1]) +SketchLine_2 = Sketch_1.addLine(6.89273184263731, -79.70251092497334, 48.24895637932232, 63.81252391424628) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchCircle_1.results()[1]) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchAPI_Point(SketchPoint_1).coordinates()) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 80) +Extrusion_1.setNestedSketch(Sketch_1) +model.do() +Filters = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", args = [model.selection("EDGE", "[Extrusion_1_1_3/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1_3/To_Face]")])]) +model.end() + +Reference = {} +# Extrusion Solid 1 +ResultExtrusion = Extrusion_1.result().subResult(0).resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultExtrusion.shape(), GeomAPI_Shape.EDGE) +# edges of face 1 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# edges of face 2 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# edges of face 3 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# edges of face 4 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# edges of face 5 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# edges of face 6 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +assert(not exp.more()) + +# Extrusion Solid 2 +ResultExtrusion = Extrusion_1.result().subResult(1).resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultExtrusion.shape(), GeomAPI_Shape.EDGE) +# edges of face 1 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# edges of face 2 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# edges of face 3 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# edges of face 4 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# edges of face 5 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +assert(not exp.more()) + +# Extrusion Solid 3 +ResultExtrusion = Extrusion_1.result().subResult(2).resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultExtrusion.shape(), GeomAPI_Shape.EDGE) +# edges of face 1 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# edges of face 2 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# edges of face 3 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# edges of face 4 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# edges of face 5 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +assert(not exp.more()) + +# Extrusion Solid 4 +ResultExtrusion = Extrusion_1.result().subResult(3).resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultExtrusion.shape(), GeomAPI_Shape.EDGE) +# edges of face 1 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# edges of face 2 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# edges of face 3 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# edges of face 4 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# edges of face 5 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +assert(not exp.more()) + +model.checkFilter(Part_1_doc, model, Filters, Reference) diff --git a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Edge.py b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Edge.py deleted file mode 100644 index a06b537aa..000000000 --- a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Edge.py +++ /dev/null @@ -1,115 +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) -FilterFace = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", exclude = True, args = [model.selection("EDGE", "Partition_1_1_2/Generated_Edge&Plane_1/Plane_1&Box_1_1/Front"), model.selection("EDGE", "[Partition_1_1_1/Modified_Face&Box_1_1/Top][Partition_1_1_1/Modified_Face&Box_1_1/Front]")])]) -model.end() - -Reference = {} -# Faces of the box -ResultBox_1 = Partition_1.result().resultSubShapePair()[0] -exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.FACE) -while exp.more(): - 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() -# Edges of the original box (selected as a sub-shapes of the result to keep original surface). -# Note: the expected values have to be updated if ShapeExplorer will return another order of sub-shapes. -exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.EDGE) -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() -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())] = 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())] = 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())] = 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())] = 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() -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())] = False; exp.next() -# Edges of the cylinder -exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.EDGE) -while exp.more(): - Reference[model.selection(ResultCylinder_1, exp.current())] = True - exp.next() -# Vertices of the original box -exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.VERTEX) -while exp.more(): - Reference[model.selection(ResultBox_1, exp.current())] = True - exp.next() -# Vertices of the cylinder -exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.VERTEX) -while exp.more(): - Reference[model.selection(ResultCylinder_1, exp.current())] = True - exp.next() - -model.checkFilter(Part_1_doc, model, FilterFace, Reference) diff --git a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Edge1.py b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Edge1.py new file mode 100644 index 000000000..287317a83 --- /dev/null +++ b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Edge1.py @@ -0,0 +1,116 @@ +# 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) +FilterFace = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", exclude = True, args = [model.selection("EDGE", "Partition_1_1_2/Generated_Edge&Plane_1/Plane_1&Box_1_1/Front"), model.selection("EDGE", "[Partition_1_1_1/Modified_Face&Box_1_1/Top][Partition_1_1_1/Modified_Face&Box_1_1/Front]")])]) +model.end() + +Reference = {} +# Faces of the box +ResultBox_1 = Partition_1.result().resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.FACE) +while exp.more(): + 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() +# Edges of the original box (selected as a sub-shapes of the result to keep original surface). +# Note: the expected values have to be updated if ShapeExplorer will return another order of sub-shapes. +exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.EDGE) +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() +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())] = 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())] = 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())] = 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())] = 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() +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())] = False; exp.next() +assert(not exp.more()) +# Edges of the cylinder +exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.EDGE) +while exp.more(): + Reference[model.selection(ResultCylinder_1, exp.current())] = True + exp.next() +# Vertices of the original box +exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.VERTEX) +while exp.more(): + Reference[model.selection(ResultBox_1, exp.current())] = True + exp.next() +# Vertices of the cylinder +exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.VERTEX) +while exp.more(): + Reference[model.selection(ResultCylinder_1, exp.current())] = True + exp.next() + +model.checkFilter(Part_1_doc, model, FilterFace, Reference) diff --git a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Edge2.py b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Edge2.py new file mode 100644 index 000000000..1bb20d920 --- /dev/null +++ b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Edge2.py @@ -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 * +from SketchAPI import * + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Extrusion_1 = model.addExtrusion(Part_1_doc, [], model.selection(), 100, 0) +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(0, 0, 80) +SketchLine_1 = Sketch_1.addLine(-70.03988514133886, -38.65765757761403, 65.03214823048954, -46.59205615260649) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchCircle_1.results()[1]) +SketchLine_2 = Sketch_1.addLine(6.89273184263731, -79.70251092497334, 48.24895637932232, 63.81252391424628) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchCircle_1.results()[1]) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchAPI_Point(SketchPoint_1).coordinates()) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 80) +Extrusion_1.setNestedSketch(Sketch_1) +model.do() +Filters = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", exclude = True, args = [model.selection("EDGE", "[Extrusion_1_1_3/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1_3/To_Face]")])]) +model.end() + +Reference = {} +# Extrusion Solid 1 +ResultExtrusion = Extrusion_1.result().subResult(0).resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultExtrusion.shape(), GeomAPI_Shape.EDGE) +# edges of face 1 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# edges of face 2 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# edges of face 3 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# edges of face 4 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# edges of face 5 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# edges of face 6 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +assert(not exp.more()) + +# Extrusion Solid 2 +ResultExtrusion = Extrusion_1.result().subResult(1).resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultExtrusion.shape(), GeomAPI_Shape.EDGE) +# edges of face 1 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# edges of face 2 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# edges of face 3 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# edges of face 4 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# edges of face 5 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +assert(not exp.more()) + +# Extrusion Solid 3 +ResultExtrusion = Extrusion_1.result().subResult(2).resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultExtrusion.shape(), GeomAPI_Shape.EDGE) +# edges of face 1 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# edges of face 2 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# edges of face 3 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# edges of face 4 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# edges of face 5 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +assert(not exp.more()) + +# Extrusion Solid 4 +ResultExtrusion = Extrusion_1.result().subResult(3).resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultExtrusion.shape(), GeomAPI_Shape.EDGE) +# edges of face 1 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# edges of face 2 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# edges of face 3 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# edges of face 4 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# edges of face 5 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +assert(not exp.more()) + +model.checkFilter(Part_1_doc, model, Filters, Reference) diff --git a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Face.py b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Face.py deleted file mode 100644 index d4a5b62f5..000000000 --- a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Face.py +++ /dev/null @@ -1,79 +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) -FilterFace = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", exclude = True, args = [model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Top")])]) -model.end() - -Reference = {} -# Faces of the box (selected as a sub-shapes of the result to keep original surface). -# Note: the expected values have to be updated if ShapeExplorer will return another order of sub-shapes. -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())] = 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())] = 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() -# 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() -# Edges of the original box -exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.EDGE) -while exp.more(): - Reference[model.selection(ResultBox_1, exp.current())] = True - exp.next() -# Edges of the cylinder -exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.EDGE) -while exp.more(): - Reference[model.selection(ResultCylinder_1, exp.current())] = True - exp.next() -# Vertices of the original box -exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.VERTEX) -while exp.more(): - Reference[model.selection(ResultBox_1, exp.current())] = True - exp.next() -# Vertices of the cylinder -exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.VERTEX) -while exp.more(): - Reference[model.selection(ResultCylinder_1, exp.current())] = True - exp.next() - -model.checkFilter(Part_1_doc, model, FilterFace, Reference) diff --git a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Face1.py b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Face1.py new file mode 100644 index 000000000..5f519a0fe --- /dev/null +++ b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Face1.py @@ -0,0 +1,81 @@ +# 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) +FilterFace = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", exclude = True, args = [model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Top")])]) +model.end() + +Reference = {} +# Faces of the box (selected as a sub-shapes of the result to keep original surface). +# Note: the expected values have to be updated if ShapeExplorer will return another order of sub-shapes. +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())] = 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())] = 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() +assert(not exp.more()) +# Faces of the cylinder +ResultCylinder_1 = Translation_1.result().resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.FACE) +Reference[model.selection(ResultCylinder_1, exp.current())] = True; exp.next() +Reference[model.selection(ResultCylinder_1, exp.current())] = False; exp.next() +Reference[model.selection(ResultCylinder_1, exp.current())] = True; exp.next() +assert(not exp.more()) +# Edges of the original box +exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.EDGE) +while exp.more(): + Reference[model.selection(ResultBox_1, exp.current())] = True + exp.next() +# Edges of the cylinder +exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.EDGE) +while exp.more(): + Reference[model.selection(ResultCylinder_1, exp.current())] = True + exp.next() +# Vertices of the original box +exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.VERTEX) +while exp.more(): + Reference[model.selection(ResultBox_1, exp.current())] = True + exp.next() +# Vertices of the cylinder +exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.VERTEX) +while exp.more(): + Reference[model.selection(ResultCylinder_1, exp.current())] = True + exp.next() + +model.checkFilter(Part_1_doc, model, FilterFace, Reference) diff --git a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Face2.py b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Face2.py new file mode 100644 index 000000000..5f1eff72f --- /dev/null +++ b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Face2.py @@ -0,0 +1,106 @@ +# 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 * +from SketchAPI import * + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Extrusion_1 = model.addExtrusion(Part_1_doc, [], model.selection(), 100, 0) +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(0, 0, 80) +SketchLine_1 = Sketch_1.addLine(-70.03988514133886, -38.65765757761403, 65.03214823048954, -46.59205615260649) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchCircle_1.results()[1]) +SketchLine_2 = Sketch_1.addLine(6.89273184263731, -79.70251092497334, 48.24895637932232, 63.81252391424628) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchCircle_1.results()[1]) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchAPI_Point(SketchPoint_1).coordinates()) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 80) +Extrusion_1.setNestedSketch(Sketch_1) +Revolution_1 = model.addRevolution(Part_1_doc, [], model.selection("EDGE", "PartSet/OZ"), 270, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) +SketchLine_3 = Sketch_2.addLine(80, -20, 20, -20) +SketchLine_4 = Sketch_2.addLine(20, -20, 20, -100) +SketchLine_5 = Sketch_2.addLine(20, -100, 80, -100) +SketchLine_6 = Sketch_2.addLine(80, -100, 80, -20) +SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_3.result()) +SketchConstraintVertical_1 = Sketch_2.setVertical(SketchLine_4.result()) +SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_5.result()) +SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_6.result()) +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_2 = SketchProjection_2.createdFeature() +SketchConstraintDistance_1 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_6.result(), 80, True) +SketchConstraintDistance_2 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_4.result(), 20, True) +SketchConstraintDistance_3 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_3.result(), 20, True) +SketchConstraintDistance_4 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_5.result(), 100, True) +Revolution_1.setNestedSketch(Sketch_2) +model.do() +Filters = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", exclude = True, args = [model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchCircle_1_2")])]) +model.end() + +Reference = {} +# Extrusion +ResultExtrusion = Extrusion_1.result().resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultExtrusion.shape(), GeomAPI_Shape.FACE) +# faces of solid 1 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# faces of solid 2 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# faces of solid 3 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# faces of solid 4 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# Revolution +ResultRevolution = Revolution_1.result().resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultRevolution.shape(), GeomAPI_Shape.FACE) +Reference[model.selection(ResultRevolution, exp.current())] = True; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = True; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = True; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = True; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = True; exp.next() + +model.checkFilter(Part_1_doc, model, Filters, Reference) diff --git a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Face3.py b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Face3.py new file mode 100644 index 000000000..8c73804de --- /dev/null +++ b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Exclude_Face3.py @@ -0,0 +1,106 @@ +# 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 * +from SketchAPI import * + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Extrusion_1 = model.addExtrusion(Part_1_doc, [], model.selection(), 100, 0) +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(0, 0, 80) +SketchLine_1 = Sketch_1.addLine(-70.03988514133886, -38.65765757761403, 65.03214823048954, -46.59205615260649) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchCircle_1.results()[1]) +SketchLine_2 = Sketch_1.addLine(6.89273184263731, -79.70251092497334, 48.24895637932232, 63.81252391424628) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchCircle_1.results()[1]) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchAPI_Point(SketchPoint_1).coordinates()) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 80) +Extrusion_1.setNestedSketch(Sketch_1) +Revolution_1 = model.addRevolution(Part_1_doc, [], model.selection("EDGE", "PartSet/OZ"), 270, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) +SketchLine_3 = Sketch_2.addLine(80, -20, 20, -20) +SketchLine_4 = Sketch_2.addLine(20, -20, 20, -100) +SketchLine_5 = Sketch_2.addLine(20, -100, 80, -100) +SketchLine_6 = Sketch_2.addLine(80, -100, 80, -20) +SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_3.result()) +SketchConstraintVertical_1 = Sketch_2.setVertical(SketchLine_4.result()) +SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_5.result()) +SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_6.result()) +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_2 = SketchProjection_2.createdFeature() +SketchConstraintDistance_1 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_6.result(), 80, True) +SketchConstraintDistance_2 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_4.result(), 20, True) +SketchConstraintDistance_3 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_3.result(), 20, True) +SketchConstraintDistance_4 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_5.result(), 100, True) +Revolution_1.setNestedSketch(Sketch_2) +model.do() +Filters = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", exclude = True, args = [model.selection("FACE", "Extrusion_1_1_3/To_Face")])]) +model.end() + +Reference = {} +# Extrusion +ResultExtrusion = Extrusion_1.result().resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultExtrusion.shape(), GeomAPI_Shape.FACE) +# faces of solid 1 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# faces of solid 2 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# faces of solid 3 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# faces of solid 4 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# Revolution +ResultRevolution = Revolution_1.result().resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultRevolution.shape(), GeomAPI_Shape.FACE) +Reference[model.selection(ResultRevolution, exp.current())] = True; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = True; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = True; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = True; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = True; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = True; exp.next() + +model.checkFilter(Part_1_doc, model, Filters, Reference) diff --git a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Face.py b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Face.py deleted file mode 100644 index 1638b0b0e..000000000 --- a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Face.py +++ /dev/null @@ -1,79 +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) -FilterFace = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", args = [model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Top")])]) -model.end() - -Reference = {} -# Faces of the box (selected as a sub-shapes of the result to keep original surface). -# Note: the expected values have to be updated if ShapeExplorer will return another order of sub-shapes. -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())] = 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())] = 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() -# 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() -# Edges of the original box -exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.EDGE) -while exp.more(): - Reference[model.selection(ResultBox_1, exp.current())] = False - exp.next() -# Edges of the cylinder -exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.EDGE) -while exp.more(): - Reference[model.selection(ResultCylinder_1, exp.current())] = False - exp.next() -# Vertices of the original box -exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.VERTEX) -while exp.more(): - Reference[model.selection(ResultBox_1, exp.current())] = False - exp.next() -# Vertices of the cylinder -exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.VERTEX) -while exp.more(): - Reference[model.selection(ResultCylinder_1, exp.current())] = False - exp.next() - -model.checkFilter(Part_1_doc, model, FilterFace, Reference) diff --git a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Face1.py b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Face1.py new file mode 100644 index 000000000..6e6cb326c --- /dev/null +++ b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Face1.py @@ -0,0 +1,81 @@ +# 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) +FilterFace = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", args = [model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Top")])]) +model.end() + +Reference = {} +# Faces of the box (selected as a sub-shapes of the result to keep original surface). +# Note: the expected values have to be updated if ShapeExplorer will return another order of sub-shapes. +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())] = 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())] = 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() +assert(not exp.more()) +# Faces of the cylinder +ResultCylinder_1 = Translation_1.result().resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.FACE) +Reference[model.selection(ResultCylinder_1, exp.current())] = False; exp.next() +Reference[model.selection(ResultCylinder_1, exp.current())] = True; exp.next() +Reference[model.selection(ResultCylinder_1, exp.current())] = False; exp.next() +assert(not exp.more()) +# Edges of the original box +exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.EDGE) +while exp.more(): + Reference[model.selection(ResultBox_1, exp.current())] = False + exp.next() +# Edges of the cylinder +exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.EDGE) +while exp.more(): + Reference[model.selection(ResultCylinder_1, exp.current())] = False + exp.next() +# Vertices of the original box +exp = GeomAPI_ShapeExplorer(ResultBox_1.shape(), GeomAPI_Shape.VERTEX) +while exp.more(): + Reference[model.selection(ResultBox_1, exp.current())] = False + exp.next() +# Vertices of the cylinder +exp = GeomAPI_ShapeExplorer(ResultCylinder_1.shape(), GeomAPI_Shape.VERTEX) +while exp.more(): + Reference[model.selection(ResultCylinder_1, exp.current())] = False + exp.next() + +model.checkFilter(Part_1_doc, model, FilterFace, Reference) diff --git a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Face2.py b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Face2.py new file mode 100644 index 000000000..56ba0b4cc --- /dev/null +++ b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Face2.py @@ -0,0 +1,106 @@ +# 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 * +from SketchAPI import * + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Extrusion_1 = model.addExtrusion(Part_1_doc, [], model.selection(), 100, 0) +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(0, 0, 80) +SketchLine_1 = Sketch_1.addLine(-70.03988514133886, -38.65765757761403, 65.03214823048954, -46.59205615260649) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchCircle_1.results()[1]) +SketchLine_2 = Sketch_1.addLine(6.89273184263731, -79.70251092497334, 48.24895637932232, 63.81252391424628) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchCircle_1.results()[1]) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchAPI_Point(SketchPoint_1).coordinates()) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 80) +Extrusion_1.setNestedSketch(Sketch_1) +Revolution_1 = model.addRevolution(Part_1_doc, [], model.selection("EDGE", "PartSet/OZ"), 270, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) +SketchLine_3 = Sketch_2.addLine(80, -20, 20, -20) +SketchLine_4 = Sketch_2.addLine(20, -20, 20, -100) +SketchLine_5 = Sketch_2.addLine(20, -100, 80, -100) +SketchLine_6 = Sketch_2.addLine(80, -100, 80, -20) +SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_3.result()) +SketchConstraintVertical_1 = Sketch_2.setVertical(SketchLine_4.result()) +SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_5.result()) +SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_6.result()) +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_2 = SketchProjection_2.createdFeature() +SketchConstraintDistance_1 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_6.result(), 80, True) +SketchConstraintDistance_2 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_4.result(), 20, True) +SketchConstraintDistance_3 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_3.result(), 20, True) +SketchConstraintDistance_4 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_5.result(), 100, True) +Revolution_1.setNestedSketch(Sketch_2) +model.do() +Filters = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", args = [model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchCircle_1_2")])]) +model.end() + +Reference = {} +# Extrusion +ResultExtrusion = Extrusion_1.result().resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultExtrusion.shape(), GeomAPI_Shape.FACE) +# faces of solid 1 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# faces of solid 2 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# faces of solid 3 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# faces of solid 4 +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +# Revolution +ResultRevolution = Revolution_1.result().resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultRevolution.shape(), GeomAPI_Shape.FACE) +Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = True; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next() + +model.checkFilter(Part_1_doc, model, Filters, Reference) diff --git a/src/FiltersPlugin/Test/TestFilter_OnGeometry_Face3.py b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Face3.py new file mode 100644 index 000000000..d002114ef --- /dev/null +++ b/src/FiltersPlugin/Test/TestFilter_OnGeometry_Face3.py @@ -0,0 +1,106 @@ +# 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 * +from SketchAPI import * + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Extrusion_1 = model.addExtrusion(Part_1_doc, [], model.selection(), 100, 0) +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(0, 0, 80) +SketchLine_1 = Sketch_1.addLine(-70.03988514133886, -38.65765757761403, 65.03214823048954, -46.59205615260649) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchCircle_1.results()[1]) +SketchLine_2 = Sketch_1.addLine(6.89273184263731, -79.70251092497334, 48.24895637932232, 63.81252391424628) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchCircle_1.results()[1]) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchAPI_Point(SketchPoint_1).coordinates()) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 80) +Extrusion_1.setNestedSketch(Sketch_1) +Revolution_1 = model.addRevolution(Part_1_doc, [], model.selection("EDGE", "PartSet/OZ"), 270, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) +SketchLine_3 = Sketch_2.addLine(80, -20, 20, -20) +SketchLine_4 = Sketch_2.addLine(20, -20, 20, -100) +SketchLine_5 = Sketch_2.addLine(20, -100, 80, -100) +SketchLine_6 = Sketch_2.addLine(80, -100, 80, -20) +SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_3.result()) +SketchConstraintVertical_1 = Sketch_2.setVertical(SketchLine_4.result()) +SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_5.result()) +SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_6.result()) +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_2 = SketchProjection_2.createdFeature() +SketchConstraintDistance_1 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_6.result(), 80, True) +SketchConstraintDistance_2 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_4.result(), 20, True) +SketchConstraintDistance_3 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_3.result(), 20, True) +SketchConstraintDistance_4 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_5.result(), 100, True) +Revolution_1.setNestedSketch(Sketch_2) +model.do() +Filters = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", args = [model.selection("FACE", "Extrusion_1_1_3/To_Face")])]) +model.end() + +Reference = {} +# Extrusion +ResultExtrusion = Extrusion_1.result().resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultExtrusion.shape(), GeomAPI_Shape.FACE) +# faces of solid 1 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# faces of solid 2 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# faces of solid 3 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# faces of solid 4 +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = False; exp.next() +Reference[model.selection(ResultExtrusion, exp.current())] = True; exp.next() +# Revolution +ResultRevolution = Revolution_1.result().resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultRevolution.shape(), GeomAPI_Shape.FACE) +Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next() +Reference[model.selection(ResultRevolution, exp.current())] = False; exp.next() + +model.checkFilter(Part_1_doc, model, Filters, Reference) diff --git a/src/GeomAPI/GeomAPI_Cylinder.cpp b/src/GeomAPI/GeomAPI_Cylinder.cpp index 35b23e73b..87fab54e5 100644 --- a/src/GeomAPI/GeomAPI_Cylinder.cpp +++ b/src/GeomAPI/GeomAPI_Cylinder.cpp @@ -81,3 +81,26 @@ bool GeomAPI_Cylinder::isInfinite() const { return Precision::IsInfinite(myHeight); } + +//================================================================================================= +bool GeomAPI_Cylinder::isCoincident(const GeomCylinderPtr theCylinder, const double theTolerance) +{ + if (!theCylinder) + return false; + + gp_Cylinder* anOther = theCylinder->implPtr(); + if (fabs(MY_CYL->Radius() - anOther->Radius()) < theTolerance) { + gp_Dir aDir1 = MY_CYL->Position().Direction(); + gp_Dir aDir2 = anOther->Position().Direction(); + if (aDir1.IsParallel(aDir2, Precision::Angular())) { + gp_Pnt aLoc1 = MY_CYL->Location(); + gp_Pnt aLoc2 = anOther->Location(); + gp_Vec aVec12(aLoc1, aLoc2); + if (aVec12.SquareMagnitude() < theTolerance * theTolerance || + aVec12.IsParallel(aDir1, Precision::Angular())) { + return true; + } + } + } + return false; +} diff --git a/src/GeomAPI/GeomAPI_Cylinder.h b/src/GeomAPI/GeomAPI_Cylinder.h index da78aeb36..0bb627ef6 100644 --- a/src/GeomAPI/GeomAPI_Cylinder.h +++ b/src/GeomAPI/GeomAPI_Cylinder.h @@ -59,6 +59,10 @@ public: /// Return \c true is the cylinder is infinite GEOMAPI_EXPORT bool isInfinite() const; + /// Returns true if cylinders have same axis and radii. + GEOMAPI_EXPORT bool isCoincident(const std::shared_ptr theCylinder, + const double theTolerance = 1.e-7); + private: double myHeight; }; diff --git a/src/GeomAPI/GeomAPI_Edge.cpp b/src/GeomAPI/GeomAPI_Edge.cpp index f939e6559..830fbb1b1 100644 --- a/src/GeomAPI/GeomAPI_Edge.cpp +++ b/src/GeomAPI/GeomAPI_Edge.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -68,17 +69,34 @@ GeomAPI_Edge::GeomAPI_Edge(const std::shared_ptr& theShape) } } +static Handle(Geom_Curve) baseCurve(const TopoDS_Edge& theEdge) +{ + double aFirst, aLast; + Handle(Geom_Curve) aCurve = BRep_Tool::Curve(theEdge, aFirst, aLast); + while (aCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { + Handle(Geom_TrimmedCurve) tc = Handle(Geom_TrimmedCurve)::DownCast(aCurve); + aCurve = tc->BasisCurve(); + } + return aCurve; +} + bool GeomAPI_Edge::isSameGeometry(const std::shared_ptr theShape) const { if (!theShape->isEdge()) return false; + if (isSame(theShape)) + return true; + TopoDS_Edge anOwnEdge = TopoDS::Edge(impl()); TopoDS_Edge anOtherEdge = TopoDS::Edge(theShape->impl()); - double aFirst, aLast; - Handle(Geom_Curve) anOwnCurve = BRep_Tool::Curve(anOwnEdge, aFirst, aLast); - Handle(Geom_Curve) anOtherCurve = BRep_Tool::Curve(anOtherEdge, aFirst, aLast); - return anOwnCurve == anOtherCurve; + Handle(Geom_Curve) anOwnCurve = baseCurve(anOwnEdge); + Handle(Geom_Curve) anOtherCurve = baseCurve(anOtherEdge); + GeomAPI_ExtremaCurveCurve anExtrema(anOwnCurve, anOtherCurve); + + bool isSame = anExtrema.Extrema().IsParallel() && + anExtrema.TotalLowerDistance() < Precision::Confusion(); + return isSame; } bool GeomAPI_Edge::isLine() const diff --git a/src/GeomAPI/GeomAPI_Face.cpp b/src/GeomAPI/GeomAPI_Face.cpp index c03ec7f23..bb907330c 100644 --- a/src/GeomAPI/GeomAPI_Face.cpp +++ b/src/GeomAPI/GeomAPI_Face.cpp @@ -32,13 +32,17 @@ #include #include #include +#include #include #include #include #include #include +#include #include +#include #include +#include #include #include #include @@ -104,16 +108,74 @@ bool GeomAPI_Face::isEqual(std::shared_ptr theFace) const return aRes == Standard_True; } +static Handle(Geom_Surface) baseSurface(const TopoDS_Face& theFace) +{ + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(theFace); + while (aSurf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { + Handle(Geom_RectangularTrimmedSurface) rts = + Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurf); + aSurf = rts->BasisSurface(); + } + return aSurf; +} + bool GeomAPI_Face::isSameGeometry(const std::shared_ptr theShape) const { if (!theShape->isFace()) return false; + if (isSame(theShape)) + return true; + + GeomFacePtr anOther = theShape->face(); + if (isPlanar() && anOther->isPlanar()) { + GeomPlanePtr anOwnPlane = getPlane(); + GeomPlanePtr anOtherPlane = anOther->getPlane(); + return anOwnPlane->isCoincident(anOtherPlane); + } + TopoDS_Face anOwnFace = TopoDS::Face(impl()); TopoDS_Face anOtherFace = TopoDS::Face(theShape->impl()); - Handle(Geom_Surface) anOwnSurf = BRep_Tool::Surface(anOwnFace); - Handle(Geom_Surface) anOtherSurf = BRep_Tool::Surface(anOtherFace); - return anOwnSurf == anOtherSurf; + Handle(Geom_Surface) anOwnSurf = baseSurface(anOwnFace); + Handle(Geom_Surface) anOtherSurf = baseSurface(anOtherFace); + + // case of two elementary surfaces + if (anOwnSurf->IsKind(STANDARD_TYPE(Geom_ElementarySurface)) && + anOtherSurf->IsKind(STANDARD_TYPE(Geom_ElementarySurface))) + { + Handle(GeomAdaptor_HSurface) aGA1 = new GeomAdaptor_HSurface(anOwnSurf); + Handle(GeomAdaptor_HSurface) aGA2 = new GeomAdaptor_HSurface(anOtherSurf); + + Handle(BRepTopAdaptor_TopolTool) aTT1 = new BRepTopAdaptor_TopolTool(); + Handle(BRepTopAdaptor_TopolTool) aTT2 = new BRepTopAdaptor_TopolTool(); + + try { + IntPatch_ImpImpIntersection anIIInt(aGA1, aTT1, aGA2, aTT2, + Precision::Confusion(), + Precision::Confusion()); + if (!anIIInt.IsDone() || anIIInt.IsEmpty()) + return false; + + return anIIInt.TangentFaces(); + } + catch (Standard_Failure const&) { + return false; + } + } + + // case of two cylindrical surfaces, at least one of which is a swept surface + // swept surfaces: SurfaceOfLinearExtrusion, SurfaceOfRevolution + if ((anOwnSurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) || + anOwnSurf->IsKind(STANDARD_TYPE(Geom_SweptSurface))) && + (anOtherSurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) || + anOtherSurf->IsKind(STANDARD_TYPE(Geom_SweptSurface)))) + { + GeomCylinderPtr anOwnCyl = getCylinder(); + GeomCylinderPtr anOtherCyl = anOther->getCylinder(); + return anOwnCyl && anOtherCyl && anOwnCyl->isCoincident(anOtherCyl); + } + + return false; } bool GeomAPI_Face::isCylindrical() const