]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge remote-tracking branch 'origin/cgt/primitives_1'
authorcg246364 <clarisse.genrault@cea.fr>
Fri, 18 Mar 2022 09:27:38 +0000 (10:27 +0100)
committercg246364 <clarisse.genrault@cea.fr>
Fri, 18 Mar 2022 09:27:38 +0000 (10:27 +0100)
13 files changed:
src/FeaturesPlugin/Test/TestPipe_DoNotMovePath.py [new file with mode: 0644]
src/FeaturesPlugin/tests.set
src/FiltersAPI/FiltersAPI_Selection.cpp
src/FiltersAPI/FiltersAPI_Selection.h
src/FiltersPlugin/Test/TestFilters_Select.py [new file with mode: 0644]
src/FiltersPlugin/tests.set
src/GeomAPI/GeomAPI_Shape.cpp
src/GeomAPI/GeomAPI_Shape.h
src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp
src/Model/Model_FiltersFactory.cpp
src/Model/Model_FiltersFactory.h
src/ModelAPI/ModelAPI_FiltersFactory.h
src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp

diff --git a/src/FeaturesPlugin/Test/TestPipe_DoNotMovePath.py b/src/FeaturesPlugin/Test/TestPipe_DoNotMovePath.py
new file mode 100644 (file)
index 0000000..67b5246
--- /dev/null
@@ -0,0 +1,410 @@
+# Copyright (C) 2018-2021  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 SketchAPI import *
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+
+### Create Part
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+### Create Sketch
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
+
+### Create SketchLine
+SketchLine_1 = Sketch_1.addLine(-592.0852359208525, -262.5570776255708, -625.5707762557078, -186.4535768645358)
+SketchLine_1.setAuxiliary(True)
+
+### Create SketchLine
+SketchLine_2 = Sketch_1.addLine(-625.5707762557078, -186.4535768645358, -639.2694063926941, -108.8280060882801)
+SketchLine_2.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+
+### Create SketchLine
+SketchLine_3 = Sketch_1.addLine(-639.2694063926941, -108.8280060882801, -637.7473363774735, -9.893455098934579)
+SketchLine_3.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+
+### Create SketchLine
+SketchLine_4 = Sketch_1.addLine(-637.7473363774735, -9.893455098934579, -614.9162861491628, 101.2176560121766)
+SketchLine_4.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+
+### Create SketchLine
+SketchLine_5 = Sketch_1.addLine(-614.9162861491628, 101.2176560121766, -573.8203957382038, 200.1522070015221)
+SketchLine_5.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
+
+### Create SketchLine
+SketchLine_6 = Sketch_1.addLine(-573.8203957382038, 200.1522070015221, -532.724505327245, 200.1522070015221)
+SketchLine_6.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+
+### Create SketchLine
+SketchLine_7 = Sketch_1.addLine(-532.724505327245, 200.1522070015221, 80.66971080669715, 200.1522070015221)
+SketchLine_7.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
+Sketch_1.setHorizontal(SketchLine_7.result())
+
+### Create SketchLine
+SketchLine_8 = Sketch_1.addLine(80.66971080669715, 200.1522070015221, 68.49315068493158, 101.2176560121766)
+SketchLine_8.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
+
+### Create SketchLine
+SketchLine_9 = Sketch_1.addLine(68.49315068493158, 101.2176560121766, 54.79452054794545, -9.893455098934579)
+SketchLine_9.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
+
+### Create SketchLine
+SketchLine_10 = Sketch_1.addLine(54.79452054794545, -9.893455098934579, 63.92694063926946, -108.8280060882801)
+SketchLine_10.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
+
+### Create SketchLine
+SketchLine_11 = Sketch_1.addLine(63.92694063926946, -108.8280060882801, 66.97108066971103, -186.4535768645358)
+SketchLine_11.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint())
+
+### Create SketchLine
+SketchLine_12 = Sketch_1.addLine(66.97108066971103, -186.4535768645358, 92.84627092846273, -262.5570776255708)
+SketchLine_12.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint())
+
+### Create SketchLine
+SketchLine_13 = Sketch_1.addLine(92.84627092846273, -262.5570776255708, -546.4231354642313, -262.5570776255708)
+SketchLine_13.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint())
+Sketch_1.setHorizontal(SketchLine_13.result())
+
+### Create SketchLine
+SketchLine_14 = Sketch_1.addLine(-546.4231354642313, -262.5570776255708, -584.4748858447489, -186.4535768645358)
+SketchLine_14.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint())
+
+### Create SketchLine
+SketchLine_15 = Sketch_1.addLine(-584.4748858447489, -186.4535768645358, -593.6073059360729, -108.8280060882801)
+SketchLine_15.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_14.endPoint(), SketchLine_15.startPoint())
+
+### Create SketchLine
+SketchLine_16 = Sketch_1.addLine(-593.6073059360729, -108.8280060882801, -573.8203957382038, -9.893455098934577)
+SketchLine_16.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint())
+
+### Create SketchLine
+SketchLine_17 = Sketch_1.addLine(-573.8203957382038, -9.893455098934577, -558.599695585997, 101.2176560121766)
+SketchLine_17.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_16.endPoint(), SketchLine_17.startPoint())
+
+### Create SketchLine
+SketchLine_18 = Sketch_1.addLine(-558.599695585997, 101.2176560121766, -532.724505327245, 200.1522070015221)
+SketchLine_18.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_17.endPoint(), SketchLine_18.startPoint())
+Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_18.endPoint())
+
+### Create SketchLine
+SketchLine_19 = Sketch_1.addLine(-592.0852359208525, -262.5570776255708, -546.4231354642313, -262.5570776255708)
+SketchLine_19.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_19.startPoint())
+Sketch_1.setCoincident(SketchLine_13.endPoint(), SketchLine_19.endPoint())
+
+### Create SketchLine
+SketchLine_20 = Sketch_1.addLine(-625.5707762557078, -186.4535768645358, -584.4748858447489, -186.4535768645358)
+SketchLine_20.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_20.startPoint())
+Sketch_1.setCoincident(SketchLine_14.endPoint(), SketchLine_20.endPoint())
+
+### Create SketchLine
+SketchLine_21 = Sketch_1.addLine(-639.2694063926941, -108.8280060882801, -593.6073059360729, -108.8280060882801)
+SketchLine_21.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_21.startPoint())
+Sketch_1.setCoincident(SketchLine_15.endPoint(), SketchLine_21.endPoint())
+
+### Create SketchLine
+SketchLine_22 = Sketch_1.addLine(-637.7473363774735, -9.893455098934579, -573.8203957382038, -9.893455098934577)
+SketchLine_22.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_22.startPoint())
+Sketch_1.setCoincident(SketchLine_16.endPoint(), SketchLine_22.endPoint())
+Sketch_1.setHorizontal(SketchLine_22.result())
+
+### Create SketchLine
+SketchLine_23 = Sketch_1.addLine(-614.9162861491628, 101.2176560121766, -558.599695585997, 101.2176560121766)
+SketchLine_23.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_23.startPoint())
+Sketch_1.setCoincident(SketchLine_17.endPoint(), SketchLine_23.endPoint())
+
+### Create SketchLine
+SketchLine_24 = Sketch_1.addLine(-558.599695585997, 101.2176560121766, 68.49315068493158, 101.2176560121766)
+SketchLine_24.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_17.endPoint(), SketchLine_24.startPoint())
+Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_24.endPoint())
+
+### Create SketchLine
+SketchLine_25 = Sketch_1.addLine(-573.8203957382038, -9.893455098934577, 54.79452054794545, -9.893455098934579)
+SketchLine_25.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_16.endPoint(), SketchLine_25.startPoint())
+Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_25.endPoint())
+Sketch_1.setHorizontal(SketchLine_25.result())
+
+### Create SketchLine
+SketchLine_26 = Sketch_1.addLine(-593.6073059360729, -108.8280060882801, 63.92694063926946, -108.8280060882801)
+SketchLine_26.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_15.endPoint(), SketchLine_26.startPoint())
+Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_26.endPoint())
+Sketch_1.setHorizontal(SketchLine_26.result())
+
+### Create SketchLine
+SketchLine_27 = Sketch_1.addLine(-584.4748858447489, -186.4535768645358, 66.97108066971103, -186.4535768645358)
+SketchLine_27.setAuxiliary(True)
+Sketch_1.setCoincident(SketchLine_14.endPoint(), SketchLine_27.startPoint())
+Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_27.endPoint())
+Sketch_1.setHorizontal(SketchLine_27.result())
+Sketch_1.setHorizontal(SketchLine_6.result())
+Sketch_1.setHorizontal(SketchLine_23.result())
+Sketch_1.setHorizontal(SketchLine_24.result())
+Sketch_1.setHorizontal(SketchLine_21.result())
+Sketch_1.setHorizontal(SketchLine_20.result())
+Sketch_1.setHorizontal(SketchLine_19.result())
+model.do()
+
+### Create Plane
+Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), model.selection("VERTEX", "Sketch_1/SketchLine_13_StartVertex"))
+
+### Create Plane
+Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), model.selection("VERTEX", "Sketch_1/SketchLine_11_EndVertex"))
+
+### Create Plane
+Plane_6 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), model.selection("VERTEX", "Sketch_1/SketchLine_11_StartVertex"))
+
+### Create Plane
+Plane_7 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), model.selection("VERTEX", "Sketch_1/SketchLine_10_StartVertex"))
+
+### Create Plane
+Plane_8 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), model.selection("VERTEX", "Sketch_1/SketchLine_24_EndVertex"))
+
+### Create Plane
+Plane_9 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), model.selection("VERTEX", "Sketch_1/SketchLine_7_EndVertex"))
+
+### Create Sketch
+Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "all-in-Plane_1"))
+
+### Create SketchProjection
+SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_13_StartVertex"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+
+### Create SketchProjection
+SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_19_EndVertex"), False)
+SketchPoint_2 = SketchProjection_2.createdFeature()
+
+### Create SketchCircle
+SketchCircle_1 = Sketch_2.addCircle(92.84627092846273, 0, 639.269406392694)
+Sketch_2.setCoincident(SketchPoint_1.result(), SketchCircle_1.center())
+Sketch_2.setCoincident(SketchPoint_2.result(), SketchCircle_1.results()[1])
+
+### Create SketchProjection
+SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex"), False)
+SketchPoint_3 = SketchProjection_3.createdFeature()
+
+### Create SketchCircle
+SketchCircle_2 = Sketch_2.addCircle(96.29157651318411, -4.925446150925168, 688.3944333858536)
+Sketch_2.setCoincident(SketchPoint_3.result(), SketchCircle_2.results()[1])
+model.do()
+
+### Create Sketch
+Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "all-in-Plane_2"))
+
+### Create SketchProjection
+SketchProjection_4 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_11_EndVertex"), False)
+SketchPoint_4 = SketchProjection_4.createdFeature()
+
+### Create SketchProjection
+SketchProjection_5 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_20_EndVertex"), False)
+SketchPoint_5 = SketchProjection_5.createdFeature()
+
+### Create SketchCircle
+SketchCircle_3 = Sketch_3.addCircle(66.97108066971103, 0, 651.4459665144599)
+Sketch_3.setCoincident(SketchPoint_4.result(), SketchCircle_3.center())
+Sketch_3.setCoincident(SketchPoint_5.result(), SketchCircle_3.results()[1])
+
+### Create SketchProjection
+SketchProjection_6 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex"), False)
+SketchPoint_6 = SketchProjection_6.createdFeature()
+
+### Create SketchCircle
+SketchCircle_4 = Sketch_3.addCircle(66.97108066971103, 0, 692.5418569254188)
+Sketch_3.setCoincident(SketchAPI_Point(SketchPoint_4).coordinates(), SketchCircle_4.center())
+Sketch_3.setCoincident(SketchPoint_6.result(), SketchCircle_4.results()[1])
+model.do()
+
+### Create Sketch
+Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "all-in-Plane_3"))
+
+### Create SketchProjection
+SketchProjection_7 = Sketch_4.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_11_StartVertex"), False)
+SketchPoint_7 = SketchProjection_7.createdFeature()
+
+### Create SketchProjection
+SketchProjection_8 = Sketch_4.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_15_EndVertex"), False)
+SketchPoint_8 = SketchProjection_8.createdFeature()
+
+### Create SketchCircle
+SketchCircle_5 = Sketch_4.addCircle(63.92694063926946, 0, 657.5342465753423)
+Sketch_4.setCoincident(SketchPoint_7.result(), SketchCircle_5.center())
+Sketch_4.setCoincident(SketchPoint_8.result(), SketchCircle_5.results()[1])
+
+### Create SketchProjection
+SketchProjection_9 = Sketch_4.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_21_StartVertex"), False)
+SketchPoint_9 = SketchProjection_9.createdFeature()
+
+### Create SketchCircle
+SketchCircle_6 = Sketch_4.addCircle(63.92694063926946, 0, 703.1963470319636)
+Sketch_4.setCoincident(SketchAPI_Point(SketchPoint_7).coordinates(), SketchCircle_6.center())
+Sketch_4.setCoincident(SketchPoint_9.result(), SketchCircle_6.results()[1])
+model.do()
+
+### Create Sketch
+Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "all-in-Plane_4"))
+
+### Create SketchProjection
+SketchProjection_10 = Sketch_5.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_10_StartVertex"), False)
+SketchPoint_10 = SketchProjection_10.createdFeature()
+
+### Create SketchProjection
+SketchProjection_11 = Sketch_5.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_22_EndVertex"), False)
+SketchPoint_11 = SketchProjection_11.createdFeature()
+
+### Create SketchCircle
+SketchCircle_7 = Sketch_5.addCircle(54.79452054794545, 0, 628.6149162861493)
+Sketch_5.setCoincident(SketchPoint_10.result(), SketchCircle_7.center())
+Sketch_5.setCoincident(SketchPoint_11.result(), SketchCircle_7.results()[1])
+
+### Create SketchProjection
+SketchProjection_12 = Sketch_5.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_4_StartVertex"), False)
+SketchPoint_12 = SketchProjection_12.createdFeature()
+
+### Create SketchCircle
+SketchCircle_8 = Sketch_5.addCircle(54.79452054794545, 0, 692.541856925419)
+Sketch_5.setCoincident(SketchAPI_Point(SketchPoint_10).coordinates(), SketchCircle_8.center())
+Sketch_5.setCoincident(SketchPoint_12.result(), SketchCircle_8.results()[1])
+model.do()
+
+### Create Sketch
+Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "all-in-Plane_5"))
+
+### Create SketchProjection
+SketchProjection_13 = Sketch_6.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_24_EndVertex"), False)
+SketchPoint_13 = SketchProjection_13.createdFeature()
+
+### Create SketchProjection
+SketchProjection_14 = Sketch_6.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_18_StartVertex"), False)
+SketchPoint_14 = SketchProjection_14.createdFeature()
+
+### Create SketchCircle
+SketchCircle_9 = Sketch_6.addCircle(68.49315068493158, 0, 627.0928462709286)
+Sketch_6.setCoincident(SketchPoint_13.result(), SketchCircle_9.center())
+Sketch_6.setCoincident(SketchPoint_14.result(), SketchCircle_9.results()[1])
+
+### Create SketchProjection
+SketchProjection_15 = Sketch_6.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_23_StartVertex"), False)
+SketchPoint_15 = SketchProjection_15.createdFeature()
+
+### Create SketchCircle
+SketchCircle_10 = Sketch_6.addCircle(68.49315068493158, 0, 683.4094368340944)
+Sketch_6.setCoincident(SketchAPI_Point(SketchPoint_13).coordinates(), SketchCircle_10.center())
+Sketch_6.setCoincident(SketchPoint_15.result(), SketchCircle_10.results()[1])
+model.do()
+
+### Create Sketch
+Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "all-in-Plane_6"))
+
+### Create SketchProjection
+SketchProjection_16 = Sketch_7.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_7_EndVertex"), False)
+SketchPoint_16 = SketchProjection_16.createdFeature()
+
+### Create SketchProjection
+SketchProjection_17 = Sketch_7.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_18_EndVertex"), False)
+SketchPoint_17 = SketchProjection_17.createdFeature()
+
+### Create SketchCircle
+SketchCircle_11 = Sketch_7.addCircle(80.66971080669715, 0, 613.3942161339421)
+Sketch_7.setCoincident(SketchPoint_16.result(), SketchCircle_11.center())
+Sketch_7.setCoincident(SketchPoint_17.result(), SketchCircle_11.results()[1])
+
+### Create SketchProjection
+SketchProjection_18 = Sketch_7.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_6_StartVertex"), False)
+SketchPoint_18 = SketchProjection_18.createdFeature()
+
+### Create SketchCircle
+SketchCircle_12 = Sketch_7.addCircle(80.66971080669715, 0, 654.490106544901)
+Sketch_7.setCoincident(SketchAPI_Point(SketchPoint_16).coordinates(), SketchCircle_12.center())
+Sketch_7.setCoincident(SketchPoint_18.result(), SketchCircle_12.results()[1])
+model.do()
+
+### Create Wire
+Wire_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_8"),
+                  model.selection("EDGE", "Sketch_1/SketchLine_9"),
+                  model.selection("EDGE", "Sketch_1/SketchLine_10"),
+                  model.selection("EDGE", "Sketch_1/SketchLine_11"),
+                  model.selection("EDGE", "Sketch_1/SketchLine_12")]
+Wire_1 = model.addWire(Part_1_doc, Wire_1_objects, False)
+
+### Create Pipe
+Pipe_1_objects_1 = [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2f"),
+                    model.selection("FACE", "Sketch_3/Face-SketchCircle_3_2f"),
+                    model.selection("FACE", "Sketch_4/Face-SketchCircle_5_2f"),
+                    model.selection("FACE", "Sketch_5/Face-SketchCircle_7_2f"),
+                    model.selection("FACE", "Sketch_6/Face-SketchCircle_9_2f"),
+                    model.selection("FACE", "Sketch_7/Face-SketchCircle_11_2f")]
+Pipe_1 = model.addPipe(Part_1_doc, Pipe_1_objects_1, model.selection("WIRE", "Wire_1_1"), [])
+
+### Create Wire
+Wire_2_objects = [model.selection("EDGE", "Sketch_1/SketchLine_8"),
+                  model.selection("EDGE", "Sketch_1/SketchLine_9"),
+                  model.selection("EDGE", "Sketch_1/SketchLine_10"),
+                  model.selection("EDGE", "Sketch_1/SketchLine_11"),
+                  model.selection("EDGE", "Sketch_1/SketchLine_12")]
+Wire_2 = model.addWire(Part_1_doc, Wire_2_objects)
+
+### Create Pipe
+Pipe_2_objects_1 = [model.selection("EDGE", "Sketch_2/SketchCircle_2_2"),
+                    model.selection("EDGE", "Sketch_3/SketchCircle_4_2"),
+                    model.selection("EDGE", "Sketch_4/SketchCircle_6_2"),
+                    model.selection("EDGE", "Sketch_5/SketchCircle_8_2"),
+                    model.selection("EDGE", "Sketch_6/SketchCircle_10_2"),
+                    model.selection("EDGE", "Sketch_7/SketchCircle_12_2")]
+Pipe_2 = model.addPipe(Part_1_doc, Pipe_2_objects_1, model.selection("WIRE", "Wire_2_1"), [])
+
+model.end()
+
+# Check results
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Pipe_1, 1)
+model.testNbSubShapes(Pipe_1, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Pipe_1, GeomAPI_Shape.FACE, [7])
+model.testResultsAreas(Pipe_1, [4399065.64794281])
+
+model.testNbResults(Pipe_2, 1)
+model.testNbSubShapes(Pipe_2, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Pipe_2, GeomAPI_Shape.FACE, [5])
+model.testResultsAreas(Pipe_2, [2063250.44226183])
index b1d33e64d97ed043c29d36ffa9ac34b6a2744e51..1274228bc8b2c3c7c39ae96359b0c1fec7317c76 100644 (file)
@@ -110,6 +110,7 @@ SET(TEST_NAMES
                TestRemoveSubShapes5.py
                TestRemoveSubShapes6.py
                TestPipe.py
+               TestPipe_DoNotMovePath.py
                TestPipe_Edge.py
                TestPipe_Wire.py
                TestPipe_Compound.py
index 09eee7debf2c6016fadb1a97e39d207b45759849..378365131cc5e756ebed039f4dba59475d88cc28 100644 (file)
 
 #include "FiltersAPI_Selection.h"
 
+#include "GeomAPI_Edge.h"
+#include "ModelAPI_Session.h"
+#include "ModelAPI_FiltersFactory.h"
+#include "ModelHighAPI_Services.h"
+
 FiltersAPI_Selection::FiltersAPI_Selection(const FiltersPtr & theFeature)
 {
   myVariantType = VT_Filtering;
@@ -34,6 +39,33 @@ FiltersFeaturePtr FiltersAPI_Selection::feature() const
   return myFilterFeature;
 }
 
+std::list<ModelHighAPI_Selection> FiltersAPI_Selection::select
+                                  (const std::string theShapeType) const
+{
+  return select(GeomAPI_Shape::shapeTypeByStr(theShapeType));
+}
+
+std::list<ModelHighAPI_Selection> FiltersAPI_Selection::select
+                                  (const GeomAPI_Shape::ShapeType theShapeType) const
+{
+  // finish operation to make sure the selection is done on the current state of the history
+  apply();
+
+  std::list<ModelHighAPI_Selection> aSelList;
+  static SessionPtr aSession = ModelAPI_Session::get();
+  std::list< std::pair<ResultPtr, GeomShapePtr> > aResList =
+    aSession->filters()->select(myFilterFeature, theShapeType);
+
+  std::list< std::pair<ResultPtr, GeomShapePtr> >::const_iterator itSelected = aResList.cbegin();
+  for (; itSelected != aResList.cend(); itSelected++) {
+    ResultPtr aCurRes = (*itSelected).first;
+    GeomShapePtr aSubShape = (*itSelected).second;
+    aSelList.push_back(ModelHighAPI_Selection(aCurRes, aSubShape));
+  }
+
+  return aSelList;
+}
+
 // ================================================================================================
 FiltersAPI_Selection filters(const std::shared_ptr<ModelAPI_Document>& thePart,
                              const std::list<FilterAPIPtr>& theFilters)
index 9a9756a07842cc2890c7c83f06f8ec2914d82246..a520097f715650b55349f34920e5dfe1bb80b0f8 100644 (file)
@@ -44,6 +44,12 @@ public:
   /// Return filters feature
   FILTERSAPI_EXPORT
   FiltersFeaturePtr feature() const;
+
+  /// Return selected entities
+  FILTERSAPI_EXPORT
+  std::list<ModelHighAPI_Selection> select(const std::string theShapeType) const;
+  FILTERSAPI_EXPORT
+  std::list<ModelHighAPI_Selection> select(const GeomAPI_Shape::ShapeType theShapeType) const;
 };
 
 /// Create list of filters
diff --git a/src/FiltersPlugin/Test/TestFilters_Select.py b/src/FiltersPlugin/Test/TestFilters_Select.py
new file mode 100644 (file)
index 0000000..165ede3
--- /dev/null
@@ -0,0 +1,64 @@
+# Copyright (C) 2014-2021  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from salome.shaper import model
+from ModelAPI import *
+from GeomAPI import *
+from ModelHighAPI import *
+import math
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+### Create Box
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+model.do()
+
+### Create Filters
+filter_1 = model.addFilter(name = "OnPlane",
+                           args = [model.selection("FACE", "Box_1_1/Left")])
+
+filter_2 = model.addFilter(name = "OnPlane",
+                           args = [model.selection("FACE", "Box_1_1/Top")])
+
+filters = model.filters(Part_1_doc, [filter_1, filter_2])
+
+### Select all (one) suitable edges
+selected_edges = filters.select("Edges")
+
+group_1 = model.addGroup(Part_1_doc, "Edges", selected_edges)
+assert(group_1.feature().results().size() == 1)
+
+# Check the selected edge
+aResult = group_1.results()[0].resultSubShapePair()[0]
+aShape = aResult.shape()
+aShapeExplorer = GeomAPI_ShapeExplorer(aShape, GeomAPI_Shape.EDGE)
+assert(aShapeExplorer.more())
+anEdge = aShapeExplorer.current()
+assert(anEdge.edge().isLine() and math.fabs(anEdge.edge().line().direction().x() - 1.0) < 1.e-7)
+aLoc = anEdge.edge().line().location()
+assert(math.fabs(aLoc.x()) < 1.e-7)
+assert(math.fabs(aLoc.y()) < 1.e-7)
+assert(math.fabs(aLoc.z() - 10.0) < 1.e-7)
+aShapeExplorer.next()
+assert(not aShapeExplorer.more())
+
+model.end()
index 98aa0c3404835d86882b10545df937860cc9c5b0..2a61388bb3aacf3da299958d74f24fbf31f191fb 100644 (file)
@@ -27,6 +27,7 @@ SET(TEST_NAMES
   TestFilters_FilterName.py
   TestFilters_IsReversed.py
   TestFilters_Remove.py
+  TestFilters_Select.py
   TestFilter_BelongsTo.py
   TestFilter_BelongsTo_Exclude.py
   TestFilter_OnPlane.py
index 7168ccdb5ac04c8bfc87a3aec94ac45d3a7b6a2b..5e1c8f2142a08888e382190121ced8a426c3473b 100644 (file)
@@ -419,21 +419,25 @@ std::shared_ptr<GeomAPI_Solid> GeomAPI_Shape::solid() const
 }
 
 std::list<std::shared_ptr<GeomAPI_Shape> >
-GeomAPI_Shape::subShapes(ShapeType theSubShapeType) const
+GeomAPI_Shape::subShapes(const ShapeType theSubShapeType, const bool theOnlyUnique) const
 {
   ListOfShape aSubs;
   const TopoDS_Shape& aShape = impl<TopoDS_Shape>();
   if (aShape.IsNull())
     return aSubs;
 
+  TopTools_MapOfShape alreadyThere;
+
   // process multi-level compounds
   if (shapeType() == COMPOUND && theSubShapeType == COMPOUND) {
     for (TopoDS_Iterator anIt(aShape); anIt.More(); anIt.Next()) {
       const TopoDS_Shape& aCurrent = anIt.Value();
       if (aCurrent.ShapeType() == TopAbs_COMPOUND) {
-        GeomShapePtr aSub(new GeomAPI_Shape);
-        aSub->setImpl(new TopoDS_Shape(aCurrent));
-        aSubs.push_back(aSub);
+        if (!theOnlyUnique || alreadyThere.Add(aCurrent)) {
+          GeomShapePtr aSub(new GeomAPI_Shape);
+          aSub->setImpl(new TopoDS_Shape(aCurrent));
+          aSubs.push_back(aSub);
+        }
       }
     }
     // add self
@@ -444,9 +448,11 @@ GeomAPI_Shape::subShapes(ShapeType theSubShapeType) const
   else {
     for (TopExp_Explorer anExp(aShape, (TopAbs_ShapeEnum)theSubShapeType);
          anExp.More(); anExp.Next()) {
-      GeomShapePtr aSub(new GeomAPI_Shape);
-      aSub->setImpl(new TopoDS_Shape(anExp.Current()));
-      aSubs.push_back(aSub);
+      if (!theOnlyUnique || alreadyThere.Add(anExp.Current())) {
+        GeomShapePtr aSub(new GeomAPI_Shape);
+        aSub->setImpl(new TopoDS_Shape(anExp.Current()));
+        aSubs.push_back(aSub);
+      }
     }
   }
   return aSubs;
index fad3425c05e15990e474458e8ac76494d1e075be..f8ed719713708a2fd715f5567db45a5cfa9dd7fe 100644 (file)
@@ -156,8 +156,12 @@ public:
   std::shared_ptr<GeomAPI_Solid> solid() const;
 
   /// Returns list of sub-shapes of the given type
+  /// \param theSubShapeType type of sub-shapes to search.
+  /// \param theOnlyUnique set it to \c true to omit subsequent
+  ///        inclusions of the same sub-shape. By default it is \c false.
   GEOMAPI_EXPORT
-  std::list<std::shared_ptr<GeomAPI_Shape> > subShapes(ShapeType theSubShapeType) const;
+  std::list< std::shared_ptr<GeomAPI_Shape> > subShapes(const ShapeType theSubShapeType,
+                                                        const bool theOnlyUnique = false) const;
 
   /// Returns the shape type
   GEOMAPI_EXPORT
index c914a708de7bd262d8d186d9088e2484f30155d7..169b63d17e31c35665995feb679150526450bdc3 100644 (file)
@@ -455,6 +455,8 @@ gp_Trsf getPathToBaseTranslation(const TopoDS_Shape& theBase, const TopoDS_Shape
           aPntPath = aStart;
         else if (aDeltaEnd < THE_THRESHOLD * aDeltaStart)
           aPntPath = anEnd;
+        else
+          aPntPath = aPntBase; // no translation
       }
     }
     aTranslation.SetTranslation(aPntPath, aPntBase);
index df0f4e061a78d7c8a2f1a46b956b06db66b6d09b..6c36f286e42c63bb596223ba799c6009d740b5ed 100644 (file)
@@ -23,6 +23,7 @@
 #include "ModelAPI_AttributeSelectionList.h"
 #include <Events_InfoMessage.h>
 
+#include "GeomAPI_Edge.h"
 
 void Model_FiltersFactory::registerFilter(const std::string& theID, ModelAPI_Filter* theFilter)
 {
@@ -112,6 +113,59 @@ bool Model_FiltersFactory::isValid(FeaturePtr theFiltersFeature,
   return true;
 }
 
+std::list< std::pair<ResultPtr, GeomShapePtr> > Model_FiltersFactory::select
+(const FiltersFeaturePtr& theFilterFeature,
+ const GeomAPI_Shape::ShapeType theShapeType)
+{
+  std::list< std::pair<ResultPtr, GeomShapePtr> > aResList;
+
+  DocumentPtr aDoc = theFilterFeature->document();
+  int aNb = aDoc->size(ModelAPI_ResultBody::group());
+  ObjectPtr aObj;
+  ResultBodyPtr aBody;
+  for (int i = 0; i < aNb; i++) {
+    aObj = aDoc->object(ModelAPI_ResultBody::group(), i);
+    aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aObj);
+    GeomShapePtr aShape = aBody->shape();
+    std::list<GeomShapePtr> aSubShapes = aShape->subShapes(theShapeType, true);
+    std::list<GeomShapePtr>::const_iterator aShapesIt;
+    for (aShapesIt = aSubShapes.cbegin(); aShapesIt != aSubShapes.cend(); aShapesIt++) {
+      GeomShapePtr aSubShape = (*aShapesIt);
+
+      // degenerated edge is not valid selection
+      if (theShapeType == GeomAPI_Shape::EDGE)
+        if (aSubShape->edge()->isDegenerated())
+          continue;
+
+      bool isValid = this->isValid(theFilterFeature, aBody, aSubShape);
+
+      if (isValid) {
+        // bos #24043: Naming on a compsolid works wrong.
+        // Find a simple sub-result for the ViewerPrs context:
+        ResultBodyPtr aContext = aBody;
+        bool isComposite = aContext->numberOfSubs() > 0;
+        while (isComposite) {
+          isComposite = false;
+          int nbSubs = aContext->numberOfSubs();
+          for (int aSubIndex = 0; aSubIndex < nbSubs; aSubIndex++) {
+            ResultBodyPtr aSubResult = aContext->subResult(aSubIndex);
+            GeomShapePtr aSubResultShape = aSubResult->shape();
+            if (aSubResultShape->isSubShape(aSubShape)) {
+              aContext = aSubResult;
+              isComposite = aContext->numberOfSubs() > 0;
+              break;
+            }
+          }
+        }
+        std::pair<ResultPtr, GeomShapePtr> aPair (aContext, aSubShape);
+        aResList.push_back(aPair);
+      }
+    }
+  }
+
+  return aResList;
+}
+
 /// Returns list of filters for the given shape type
 /// \param theType a shape type
 std::list<FilterPtr> Model_FiltersFactory::filters(GeomAPI_Shape::ShapeType theType)
index d272d0a4745cda8ec4f4a51aee3de91900622a57..8dab7427684315c94b7c79fa8b18b5c5ef8e0a91 100644 (file)
@@ -47,6 +47,14 @@ public:
                        ResultPtr theResult,
                        GeomShapePtr theShape);
 
+  /// Returns list of all shapes and subshapes in the study, satisfying
+  ///         criteria of all filters of \a theFilterFeature.
+  /// \param theFiltersFeature feature that contains all information about the filters
+  /// \param theShapeType the type of sub-shapes to find
+  virtual std::list< std::pair<ResultPtr, GeomShapePtr> > select
+    (const FiltersFeaturePtr& theFilterFeature,
+     const GeomAPI_Shape::ShapeType theShapeType);
+
   /// Returns the filters that support the given shape type
   virtual std::list<FilterPtr> filters(GeomAPI_Shape::ShapeType theType);
 
@@ -66,4 +74,4 @@ private:
   friend class Model_Session;
 };
 
-#endif
\ No newline at end of file
+#endif
index 70b93bb091195e6b37059936df94deb6cb069f3b..d82a738c8962ae1276f32b9bcb53b44ff5fa444f 100644 (file)
@@ -50,6 +50,14 @@ public:
                        ResultPtr theResult,
                        GeomShapePtr theShape) = 0;
 
+  /// Returns list of all shapes and subshapes in the study, satisfying
+  ///         criteria of all filters of \a theFilterFeature.
+  /// \param theFiltersFeature feature that contains all information about the filters
+  /// \param theShapeType the type of sub-shapes to find
+  virtual std::list< std::pair<ResultPtr, GeomShapePtr> > select
+    (const FiltersFeaturePtr& theFilterFeature,
+     const GeomAPI_Shape::ShapeType theShapeType) = 0;
+
   /// Returns the filters that support the given shape type
   virtual std::list<FilterPtr> filters(GeomAPI_Shape::ShapeType theType) = 0;
 
@@ -64,4 +72,4 @@ protected:
   ModelAPI_FiltersFactory() {}
 };
 
-#endif
\ No newline at end of file
+#endif
index acfc5c633872fb86afd492e0c2ba19a153602538..e027461f6034178b999cd2c36bfdc2631665a820 100644 (file)
@@ -454,60 +454,24 @@ void ModuleBase_WidgetSelectionFilter::onSelect()
 
   clearCurrentSelection();
 
+  FiltersFeaturePtr aFiltersFeature =
+    std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(myFeature);
+  static SessionPtr aSession = ModelAPI_Session::get();
+  std::list< std::pair<ResultPtr, GeomShapePtr> > aResList =
+    aSession->filters()->select(aFiltersFeature, (GeomAPI_Shape::ShapeType)mySelectionType);
+
   BRep_Builder aBuilder;
   TopoDS_Compound aComp;
   aBuilder.MakeCompound(aComp);
 
-  DocumentPtr aDoc = myFeature->document();
-  int aNb = aDoc->size(ModelAPI_ResultBody::group());
-  ObjectPtr aObj;
-  ResultBodyPtr aBody;
-  for (int i = 0; i < aNb; i++) {
-    aObj = aDoc->object(ModelAPI_ResultBody::group(), i);
-    aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aObj);
-    GeomShapePtr aShape = aBody->shape();
-    std::list<GeomShapePtr> aSubShapes =
-      aShape->subShapes((GeomAPI_Shape::ShapeType)mySelectionType);
-    TopTools_MapOfShape alreadyThere;
-    std::list<GeomShapePtr>::const_iterator aShapesIt;
-    for (aShapesIt = aSubShapes.cbegin(); aShapesIt != aSubShapes.cend(); aShapesIt++) {
-      GeomShapePtr aSubShape = (*aShapesIt);
-      TopoDS_Shape aTShape = aSubShape->impl<TopoDS_Shape>();
-      if (!alreadyThere.Add(aTShape))
-        continue;
-
-      // degenerated edge is not valid selection
-      if ((GeomAPI_Shape::ShapeType)mySelectionType == GeomAPI_Shape::EDGE)
-        if (aSubShape->edge()->isDegenerated())
-          continue;
-
-      static SessionPtr aSession = ModelAPI_Session::get();
-      bool isValid = aSession->filters()->isValid(myFeature, aBody, aSubShape);
-
-      if (isValid) {
-        aBuilder.Add(aComp, aTShape);
-        // bos #24043: Naming on a compsolid works wrong.
-        // Find a simple sub-result for the ViewerPrs context:
-        ResultBodyPtr aContext = aBody;
-        bool isComposite = aContext->numberOfSubs() > 0;
-        while (isComposite) {
-          isComposite = false;
-          int nbSubs = aContext->numberOfSubs();
-          for (int aSubIndex = 0; aSubIndex < nbSubs; aSubIndex++) {
-            ResultBodyPtr aSubResult = aContext->subResult(aSubIndex);
-            GeomShapePtr aSubResultShape = aSubResult->shape();
-            if (aSubResultShape->isSubShape(aSubShape)) {
-              aContext = aSubResult;
-              isComposite = aContext->numberOfSubs() > 0;
-              break;
-            }
-          }
-        }
-        ModuleBase_ViewerPrsPtr aValue(new ModuleBase_ViewerPrs(aContext, aSubShape));
-        //ModuleBase_ViewerPrsPtr aValue(new ModuleBase_ViewerPrs(aObj, aSubShape));
-        myValues.append(aValue);
-      }
-    }
+  std::list< std::pair<ResultPtr, GeomShapePtr> >::const_iterator itSelected = aResList.cbegin();
+  for (; itSelected != aResList.cend(); itSelected++) {
+    ResultPtr aCurRes = (*itSelected).first;
+    GeomShapePtr aSubShape = (*itSelected).second;
+    TopoDS_Shape aTShape = aSubShape->impl<TopoDS_Shape>();
+    aBuilder.Add(aComp, aTShape);
+    ModuleBase_ViewerPrsPtr aValue (new ModuleBase_ViewerPrs(aCurRes, aSubShape));
+    myValues.append(aValue);
   }
 
   if (myValues.size() > 0)