]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fixes for the issue #2686
authormpv <mpv@opencascade.com>
Mon, 29 Oct 2018 13:29:08 +0000 (16:29 +0300)
committermpv <mpv@opencascade.com>
Mon, 29 Oct 2018 13:29:34 +0000 (16:29 +0300)
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/Test/Test2686.py [new file with mode: 0644]
src/Model/Model_AttributeSelection.cpp
src/ModelAPI/CMakeLists.txt
src/ModelAPI/Test/Test2685.py [new file with mode: 0644]
src/ModelHighAPI/ModelHighAPI_Tools.cpp
src/ModelHighAPI/ModelHighAPI_Tools.h
src/Selector/Selector_Selector.cpp
src/Selector/Selector_Selector.h

index 544ffa0b800a04d0699ce42886d603ff767117cc..72fa774000c89cc3246d0406b438278f986b4bb7 100644 (file)
@@ -379,4 +379,5 @@ ADD_UNIT_TESTS(TestExtrusion.py
                Test2631.py
                Test2650.py
                Test2681.py
+               Test2686.py
 )
diff --git a/src/FeaturesPlugin/Test/Test2686.py b/src/FeaturesPlugin/Test/Test2686.py
new file mode 100644 (file)
index 0000000..5367546
--- /dev/null
@@ -0,0 +1,216 @@
+## Copyright (C) 2014-2017  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<mailto:webmaster.salome@opencascade.com>
+##
+
+# -*- coding: utf-8 -*-
+
+from GeomAPI import GeomAPI_Pnt
+from SketchAPI import *
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+model.addParameter(Part_1_doc, "angle", "27.5")
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
+SketchLine_1 = Sketch_1.addLine(0, 4, 6.2, 4)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OZ"), False)
+SketchLine_2 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_2.result())
+SketchLine_3 = Sketch_1.addLine(6.2, 4, 6.2, 2.5)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint())
+SketchLine_4 = Sketch_1.addLine(6.2, 2.5, 3.5, 2)
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchLine_5 = Sketch_1.addLine(3.5, 2, 3.5, 0)
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
+SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
+SketchLine_6 = SketchProjection_2.createdFeature()
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.result())
+SketchLine_7 = Sketch_1.addLine(3.5, 0, 0, 0)
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_7.startPoint())
+SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchLine_7.endPoint())
+SketchLine_8 = Sketch_1.addLine(0, 4, 0, 0)
+SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_8.startPoint())
+SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchLine_8.endPoint())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_5.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_3.result())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_7.result(), 3.5)
+SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_1.result(), 6.2)
+SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_3.result(), 1.5)
+SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_8.result(), 4)
+SketchConstraintLength_5 = Sketch_1.setLength(SketchLine_5.result(), 2)
+model.do()
+Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", GeomAPI_Pnt(3.1, 0, 2))], model.selection("EDGE", "PartSet/OZ"), 360, 0)
+Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", GeomAPI_Pnt(0, 0, 4)))
+SketchCircle_1 = Sketch_2.addCircle(4.027018127601872, 2.325000000002457, 1.1)
+SketchCircle_2 = Sketch_2.addCircle(-4.027018127597639, 2.325000000000002, 1.1)
+SketchCircle_3 = Sketch_2.addCircle(7.188370358619843e-12, -4.650000000090492, 1.1)
+SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", GeomAPI_Pnt(0, 0, 4)), False)
+SketchPoint_1 = SketchProjection_3.createdFeature()
+SketchCircle_4 = Sketch_2.addCircle(0, 0, 4.65)
+SketchCircle_4.setAuxiliary(True)
+SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchPoint_1.result(), SketchCircle_4.center())
+SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OX"), False)
+SketchLine_9 = SketchProjection_4.createdFeature()
+SketchLine_10 = Sketch_2.addLine(0, 0, 4.027018127601872, 2.325000000002457)
+SketchLine_10.setAuxiliary(True)
+SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_10.startPoint())
+SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchCircle_1.center(), SketchLine_10.endPoint())
+SketchLine_11 = Sketch_2.addLine(0, 0, -4.027018127597639, 2.325000000000002)
+SketchLine_11.setAuxiliary(True)
+SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_11.startPoint())
+SketchConstraintCoincidence_14 = Sketch_2.setCoincident(SketchCircle_2.center(), SketchLine_11.endPoint())
+SketchLine_12 = Sketch_2.addLine(0, 0, 7.188370358619843e-12, -4.650000000090492)
+SketchLine_12.setAuxiliary(True)
+SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_12.startPoint())
+SketchConstraintCoincidence_16 = Sketch_2.setCoincident(SketchCircle_3.center(), SketchLine_12.endPoint())
+SketchConstraintCoincidence_17 = Sketch_2.setCoincident(SketchCircle_2.center(), SketchCircle_4.results()[1])
+SketchConstraintCoincidence_18 = Sketch_2.setCoincident(SketchCircle_1.center(), SketchCircle_4.results()[1])
+SketchConstraintCoincidence_19 = Sketch_2.setCoincident(SketchLine_12.endPoint(), SketchCircle_4.results()[1])
+SketchConstraintRadius_1 = Sketch_2.setRadius(SketchCircle_4.results()[1], 4.65)
+SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_1.results()[1], 1.1)
+SketchConstraintEqual_1 = Sketch_2.setEqual(SketchCircle_1.results()[1], SketchCircle_2.results()[1])
+SketchConstraintEqual_2 = Sketch_2.setEqual(SketchCircle_2.results()[1], SketchCircle_3.results()[1])
+SketchProjection_5 = Sketch_2.addProjection(model.selection("EDGE", GeomAPI_Pnt(3.1, 0, 4)), False)
+SketchLine_13 = SketchProjection_5.createdFeature()
+SketchConstraintAngle_1 = Sketch_2.setAngle(SketchLine_13.result(), SketchLine_10.result(), 30)
+SketchConstraintAngle_2 = Sketch_2.setAngle(SketchLine_10.result(), SketchLine_11.result(), 120)
+SketchConstraintAngle_3 = Sketch_2.setAngle(SketchLine_11.result(), SketchLine_12.result(), 120)
+SketchCircle_5 = Sketch_2.addCircle(4.645574230355638, 0.2028301512488116, 0.8)
+SketchConstraintCoincidence_20 = Sketch_2.setCoincident(SketchCircle_4.results()[1], SketchCircle_5.center())
+SketchCircle_6 = Sketch_2.addCircle(4.645574230355638, 0.2028301512488116, 0.65)
+SketchConstraintCoincidence_21 = Sketch_2.setCoincident(SketchCircle_5.center(), SketchCircle_6.center())
+SketchConstraintRadius_3 = Sketch_2.setRadius(SketchCircle_6.results()[1], 0.65)
+SketchConstraintRadius_4 = Sketch_2.setRadius(SketchCircle_5.results()[1], 0.8)
+SketchLine_14 = Sketch_2.addLine(0, 0, 4.645574230355638, 0.2028301512488116)
+SketchLine_14.setAuxiliary(True)
+SketchConstraintCoincidence_22 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_14.startPoint())
+SketchConstraintCoincidence_23 = Sketch_2.setCoincident(SketchCircle_5.center(), SketchLine_14.endPoint())
+SketchConstraintAngle_4 = Sketch_2.setAngle(SketchLine_14.result(), SketchLine_10.result(), "angle")
+SketchCircle_7 = Sketch_2.addCircle(2.498443178812738, 3.921770223029927, 0.65)
+SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchCircle_4.results()[1], SketchCircle_7.center())
+SketchCircle_8 = Sketch_2.addCircle(2.498443178812738, 3.921770223029927, 0.8)
+SketchConstraintCoincidence_25 = Sketch_2.setCoincident(SketchCircle_4.results()[1], SketchCircle_8.center())
+SketchConstraintCoincidence_26 = Sketch_2.setCoincident(SketchCircle_7.center(), SketchCircle_8.center())
+SketchConstraintEqual_3 = Sketch_2.setEqual(SketchCircle_6.results()[1], SketchCircle_7.results()[1])
+SketchConstraintEqual_4 = Sketch_2.setEqual(SketchCircle_8.results()[1], SketchCircle_5.results()[1])
+SketchLine_15 = Sketch_2.addLine(0, 0, 2.498443178812738, 3.921770223029927)
+SketchLine_15.setAuxiliary(True)
+SketchConstraintCoincidence_27 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_15.startPoint())
+SketchConstraintCoincidence_28 = Sketch_2.setCoincident(SketchCircle_7.center(), SketchLine_15.endPoint())
+SketchConstraintAngle_5 = Sketch_2.setAngle(SketchLine_10.result(), SketchLine_15.result(), "angle")
+SketchMultiRotation_1 = Sketch_2.addRotation([SketchCircle_8.results()[1], SketchCircle_5.results()[1]], SketchCircle_4.center(), 360, 3, True)
+[SketchCircle_9, SketchCircle_10, SketchCircle_11, SketchCircle_12] = SketchMultiRotation_1.rotated()
+SketchCircle_12.setName("SketchCircle_13")
+SketchCircle_12.result().setName("SketchCircle_13")
+SketchCircle_12.results()[1].setName("SketchCircle_13_2")
+SketchCircle_11.setName("SketchCircle_12")
+SketchCircle_11.result().setName("SketchCircle_12")
+SketchCircle_11.results()[1].setName("SketchCircle_12_2")
+SketchMultiRotation_2 = Sketch_2.addRotation([SketchCircle_6.results()[1], SketchCircle_7.results()[1]], SketchAPI_Line(SketchLine_9).startPoint(), 120, 2)
+[SketchCircle_13, SketchCircle_14] = SketchMultiRotation_2.rotated()
+SketchCircle_14.setName("SketchCircle_17")
+SketchCircle_14.result().setName("SketchCircle_17")
+SketchCircle_14.results()[1].setName("SketchCircle_17_2")
+SketchCircle_13.setName("SketchCircle_14")
+SketchCircle_13.result().setName("SketchCircle_14")
+SketchCircle_13.results()[1].setName("SketchCircle_14_2")
+SketchCircle_15 = Sketch_2.addCircle(0, 5, 0.45)
+SketchCircle_15.setName("SketchCircle_15")
+SketchCircle_15.result().setName("SketchCircle_15")
+SketchCircle_15.results()[1].setName("SketchCircle_15_2")
+SketchLine_16 = Sketch_2.addLine(0, 0, 0, 5)
+SketchLine_16.setAuxiliary(True)
+SketchConstraintCoincidence_29 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_16.startPoint())
+SketchConstraintCoincidence_30 = Sketch_2.setCoincident(SketchCircle_15.center(), SketchLine_16.endPoint())
+SketchConstraintLength_6 = Sketch_2.setLength(SketchLine_16.result(), 5)
+SketchProjection_6 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_17 = SketchProjection_6.createdFeature()
+SketchConstraintCoincidence_31 = Sketch_2.setCoincident(SketchCircle_15.center(), SketchLine_17.result())
+SketchConstraintRadius_5 = Sketch_2.setRadius(SketchCircle_15.results()[1], 0.45)
+SketchProjection_7 = Sketch_2.addProjection(model.selection("EDGE", GeomAPI_Pnt(-6.2, 7.59281015471359e-16, 4)), False)
+SketchCircle_16 = SketchProjection_7.createdFeature()
+SketchCircle_16.setName("SketchCircle_16")
+SketchCircle_16.result().setName("SketchCircle_16")
+SketchCircle_16.results()[1].setName("SketchCircle_16_2")
+SketchCircle_17 = Sketch_2.addCircle(4.259590630302756, -2.982597469025441, 0.5)
+SketchCircle_17.setName("SketchCircle_18")
+SketchCircle_17.result().setName("SketchCircle_18")
+SketchCircle_17.results()[1].setName("SketchCircle_18_2")
+SketchCircle_18 = Sketch_2.addCircle(3.276608177155966, -2.294305745404186, 0.3)
+SketchCircle_18.setName("SketchCircle_19")
+SketchCircle_18.result().setName("SketchCircle_19")
+SketchCircle_18.results()[1].setName("SketchCircle_19_2")
+SketchLine_18 = Sketch_2.addLine(0, 0, 4.259590630302756, -2.982597469025441)
+SketchLine_18.setAuxiliary(True)
+SketchConstraintCoincidence_32 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_18.startPoint())
+SketchConstraintCoincidence_33 = Sketch_2.setCoincident(SketchCircle_17.center(), SketchLine_18.endPoint())
+SketchConstraintCoincidence_34 = Sketch_2.setCoincident(SketchCircle_18.center(), SketchLine_18.result())
+SketchProjection_8 = Sketch_2.addProjection(model.selection("EDGE", GeomAPI_Pnt(3.1, 0, 4)), False)
+SketchLine_19 = SketchProjection_8.createdFeature()
+SketchConstraintAngle_6 = Sketch_2.setAngleBackward(SketchLine_19.result(), SketchLine_18.result(), 35)
+SketchConstraintRadius_6 = Sketch_2.setRadius(SketchCircle_17.results()[1], 0.5)
+SketchConstraintRadius_7 = Sketch_2.setRadius(SketchCircle_18.results()[1], 0.3)
+SketchConstraintDistance_1 = Sketch_2.setDistance(SketchCircle_4.center(), SketchCircle_18.center(), 4, True)
+SketchConstraintDistance_2 = Sketch_2.setDistance(SketchCircle_4.center(), SketchLine_18.endPoint(), 5.2, True)
+model.do()
+ExtrusionCut_1_objects_1 = [model.selection("WIRE", GeomAPI_Pnt(2.927018127601872, 2.325000000002457, 4)), model.selection("WIRE", GeomAPI_Pnt(1.848443178812738, 3.921770223029927, 4)), model.selection("WIRE", GeomAPI_Pnt(3.995574230355639, 0.2028301512488117, 4)), model.selection("WIRE_2", GeomAPI_Pnt(-3.148443178812729, 3.921770223029919, 4)), model.selection("WIRE", GeomAPI_Pnt(-5.127018127597639, 2.325000000000002, 4)), model.selection("WIRE_2", GeomAPI_Pnt(-5.29557423035565, 0.2028301512488154, 4)), model.selection("FACE", GeomAPI_Pnt(7.188472039842964e-12, -4.650000000090492, 4)), model.selection("FACE", GeomAPI_Pnt(4.259590630302756, -2.982597469025441, 4)), model.selection("FACE", GeomAPI_Pnt(3.276608177155966, -2.294305745404186, 4))]
+ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_1_objects_1, model.selection(), model.selection("FACE", GeomAPI_Pnt(0, 0, 0)), 0, model.selection(), 0, [model.selection("SOLID", GeomAPI_Pnt(-7.561538823095622e-16, 6.008767139946657e-17, 2.62684985301323))])
+ExtrusionCut_2_objects_1 = [model.selection("WIRE", GeomAPI_Pnt(-5.44557423035565, 0.2028301512488154, 4)), model.selection("WIRE", GeomAPI_Pnt(-3.298443178812729, 3.921770223029919, 4)), model.selection("WIRE", GeomAPI_Pnt(1.698443178812738, 3.921770223029927, 4)), model.selection("WIRE", GeomAPI_Pnt(3.845574230355639, 0.2028301512488117, 4))]
+ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_2_objects_1, model.selection(), 0, 0.75, [model.selection("SOLID", GeomAPI_Pnt(0.06663461012735418, 0.05143712897449785, 2.675990079155852))])
+Axis_4 = model.addAxis(Part_1_doc, 0, -1, -10)
+ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", GeomAPI_Pnt(-0.45, 5, 4))], model.selection("EDGE", GeomAPI_Pnt(0, -0.5, -5)), 10, 10, [model.selection("SOLID", GeomAPI_Pnt(0.06614791498027658, 0.06612435067467369, 2.67762623401837))])
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", GeomAPI_Pnt(-2.14713105154291, -4.124600374278729, 4)), model.selection("FACE", GeomAPI_Pnt(2.14713105154291, -4.124600374278742, 4))], model.selection(), model.selection("FACE", GeomAPI_Pnt(0, 0, 0)), 0, model.selection(), 0)
+Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOZ"))
+SketchLine_20 = Sketch_3.addLine(3.5, 2.508501119175777, 3.5, 4)
+SketchLine_21 = Sketch_3.addLine(3.5, 4, 6.2, 4)
+SketchConstraintCoincidence_35 = Sketch_3.setCoincident(SketchLine_20.endPoint(), SketchLine_21.startPoint())
+SketchLine_22 = Sketch_3.addLine(6.2, 4, 6.2, 3.008501119175777)
+SketchConstraintCoincidence_36 = Sketch_3.setCoincident(SketchLine_21.endPoint(), SketchLine_22.startPoint())
+SketchLine_23 = Sketch_3.addLine(6.2, 3.008501119175777, 3.5, 2.508501119175777)
+SketchConstraintCoincidence_37 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_23.startPoint())
+SketchConstraintCoincidence_38 = Sketch_3.setCoincident(SketchLine_23.endPoint(), SketchLine_20.startPoint())
+SketchConstraintVertical_3 = Sketch_3.setVertical(SketchLine_20.result())
+SketchProjection_9 = Sketch_3.addProjection(model.selection("EDGE_9", GeomAPI_Pnt(3.5, 0, 1)), False)
+SketchLine_24 = SketchProjection_9.createdFeature()
+SketchConstraintCoincidence_39 = Sketch_3.setCoincident(SketchLine_20.startPoint(), SketchLine_24.result())
+SketchProjection_10 = Sketch_3.addProjection(model.selection("EDGE_3", GeomAPI_Pnt(4.85, 0, 2.25)), False)
+SketchLine_25 = SketchProjection_10.createdFeature()
+SketchConstraintParallel_1 = Sketch_3.setParallel(SketchLine_23.result(), SketchLine_25.result())
+SketchConstraintVertical_4 = Sketch_3.setVertical(SketchLine_22.result())
+SketchProjection_11 = Sketch_3.addProjection(model.selection("EDGE_9", GeomAPI_Pnt(6.2, 0, 3.25)), False)
+SketchLine_26 = SketchProjection_11.createdFeature()
+SketchConstraintCoincidence_40 = Sketch_3.setCoincident(SketchLine_23.startPoint(), SketchLine_26.result())
+SketchConstraintHorizontal_2 = Sketch_3.setHorizontal(SketchLine_21.result())
+SketchConstraintDistance_3 = Sketch_3.setDistance(SketchLine_20.startPoint(), SketchLine_25.result(), 0.5, True)
+SketchProjection_12 = Sketch_3.addProjection(model.selection("EDGE_5", GeomAPI_Pnt(3.1, 0, 4)), False)
+SketchLine_27 = SketchProjection_12.createdFeature()
+SketchConstraintCoincidence_41 = Sketch_3.setCoincident(SketchLine_20.endPoint(), SketchLine_27.result())
+model.do()
+Revolution_2 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", GeomAPI_Pnt(4.850000000000001, 0, 3.254250559587889))], model.selection("EDGE", "PartSet/OZ"), 360, 0)
+Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", GeomAPI_Pnt(-2.14713105154291, -4.124600374278729, 2)), model.selection("SOLID", GeomAPI_Pnt(2.14713105154291, -4.124600374278742, 2))], [model.selection("SOLID", GeomAPI_Pnt(-1.278142456973851e-15, 2.734224632526547e-16, 3.386836255166113))])
+Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", GeomAPI_Pnt(0.06552679693747457, 0.1115566065149892, 2.681859907222054))], [model.selection("SOLID", GeomAPI_Pnt(-2.134018078943279, -4.099410579753945, 3.358593616213623)), model.selection("SOLID", GeomAPI_Pnt(2.134018071503405, -4.099410583757958, 3.358593616233432))])
+model.do()
+model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc)
+model.end()
+
+assert(model.checkPythonDump())
index 8d9b7c2ed275b96772513b59774fadd7fed81eff..c26ad0b702864765ad4bcc8e14e9980823c26bed 100644 (file)
@@ -1146,24 +1146,15 @@ void Model_AttributeSelection::selectSubShape(const std::string& theType,
   const std::string& theContextName, const int theIndex)
 {
   // selection of context by name
-  //std::string aNamingContextName = theContextName + "/";
-  //selectSubShape(theType, aNamingContextName);
-  std::shared_ptr<Model_Document> aDoc =
-    std::dynamic_pointer_cast<Model_Document>(owner()->document());
-  if (aDoc.get()) {
-    bool aUnique = true;
-    std::string aContextName = theContextName;
-    std::string anEmptySub = "";
-    ResultPtr aContext = aDoc->findByName(aContextName, anEmptySub, aUnique);
-    //ResultPtr aContext = context();
-    if (aContext.get()) {
-      GeomShapePtr aContShape = aContext->shape();
-      if (aContShape.get()) {
-        GeomAlgoAPI_NExplode aNExp(aContShape, GeomAPI_Shape::shapeTypeByStr(theType));
-        GeomShapePtr aValue = aNExp.shape(theIndex);
-        if (aValue.get())
-          setValue(aContext, aValue);
-      }
+  selectSubShape(theType, theContextName);
+  ResultPtr aContext = context();
+  if (aContext.get()) {
+    GeomShapePtr aContShape = aContext->shape();
+    if (aContShape.get()) {
+      GeomAlgoAPI_NExplode aNExp(aContShape, GeomAPI_Shape::shapeTypeByStr(theType));
+      GeomShapePtr aValue = aNExp.shape(theIndex);
+      if (aValue.get())
+        setValue(aContext, aValue);
     }
   }
 }
index 14148d04694b8d586a00cf2126519d4dadf11d59..0f513a9ca62b8099ce30fa4326f0a9de25720f52 100644 (file)
@@ -223,4 +223,5 @@ ADD_UNIT_TESTS(TestConstants.py
                TestWeakNaming2445.py
                TestWeakNaming2446.py
                TestWeakNaming2452.py
+               Test2685.py
 )
diff --git a/src/ModelAPI/Test/Test2685.py b/src/ModelAPI/Test/Test2685.py
new file mode 100644 (file)
index 0000000..a861739
--- /dev/null
@@ -0,0 +1,66 @@
+## Copyright (C) 2014-2017  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<mailto:webmaster.salome@opencascade.com>
+##
+
+# -*- coding: utf-8 -*-
+
+from SketchAPI import *
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchCircle_1 = Sketch_1.addCircle(22, 5, 10)
+SketchCircle_2 = Sketch_1.addCircle(0, 0, 7.5)
+SketchCircle_3 = Sketch_1.addCircle(29, -20, 7.5)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin", 1), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchCircle_2.center(), SketchAPI_Point(SketchPoint_1).coordinates())
+SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_1 = SketchProjection_2.createdFeature()
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchCircle_1.center(), SketchLine_1.result(), 22, True)
+SketchProjection_3 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
+SketchLine_2 = SketchProjection_3.createdFeature()
+SketchConstraintDistance_2 = Sketch_1.setDistance(SketchCircle_1.center(), SketchLine_2.result(), 5, True)
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 10)
+SketchConstraintRadius_2 = Sketch_1.setRadius(SketchCircle_2.results()[1], 7.5)
+SketchConstraintRadius_3 = Sketch_1.setRadius(SketchCircle_3.results()[1], 7.5)
+SketchLine_3 = Sketch_1.addLine(22, 5, 22, 41.96787958115183)
+SketchLine_3.setAuxiliary(True)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_3.startPoint())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_3.result())
+SketchConstraintDistance_3 = Sketch_1.setDistance(SketchCircle_3.center(), SketchLine_3.result(), 7, True)
+SketchConstraintDistance_4 = Sketch_1.setDistance(SketchCircle_3.center(), SketchLine_2.result(), 20, True)
+SketchArc_1 = Sketch_1.addArc(22, 5, 19.39053135678072, 27.42761377547613, 44.57891020979248, 5, True)
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchArc_1.center())
+SketchLine_4 = Sketch_1.addLine(22, 5, 85.59353403141361, 5)
+SketchLine_4.setAuxiliary(True)
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_4.result())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_4.result())
+SketchLine_5 = Sketch_1.addLine(44.57891020979248, 5, 44.57891020979248, -20)
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_5.startPoint())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_5.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_5.result(), 25)
+model.end()
+
+assert(model.checkPythonDump(True))
index ffdab15225c33898e756327f385a0401c7d900ea..cf9fcc35a54de9f93d91af1774af26d7a811dacb 100644 (file)
@@ -511,21 +511,29 @@ static bool checkDump(SessionPtr theSession,
   return true;
 }
 
-bool checkPythonDump()
+bool checkPythonDump(const bool theWeakNameCheck)
 {
   static const std::string anErrorByNaming("checkPythonDump by naming");
   static const std::string anErrorByGeometry("checkPythonDump by geometry");
+  static const std::string anErrorByWeak("checkPythonDump by weak naming");
 
   static char aFileForNamingDump[] = "./check_dump_byname.py";
   static char aFileForGeometryDump[] = "./check_dump_bygeom.py";
+  static char aFileForWeakDump[] = "./check_dump_weak.py";
 
   SessionPtr aSession = ModelAPI_Session::get();
-  // dump with the selection by names
-  if (!dumpToPython(aSession, aFileForNamingDump, "topological_naming", anErrorByNaming))
-    return false;
-  // dump with the selection by geometry
-  if (!dumpToPython(aSession, aFileForGeometryDump, "geometric_selection", anErrorByGeometry))
-    return false;
+  if (!theWeakNameCheck) {
+    // dump with the selection by names
+    if (!dumpToPython(aSession, aFileForNamingDump, "topological_naming", anErrorByNaming))
+      return false;
+    // dump with the selection by geometry
+    if (!dumpToPython(aSession, aFileForGeometryDump, "geometric_selection", anErrorByGeometry))
+      return false;
+  } else {
+    // dump with the selection by weak naming
+    if (!dumpToPython(aSession, aFileForWeakDump, "weak_naming", anErrorByWeak))
+      return false;
+  }
 
    // map from document name to feature name to feature data
   std::map<std::string, std::map<std::string, ModelHighAPI_FeatureStore> > aStore;
@@ -537,10 +545,15 @@ bool checkPythonDump()
     return false;
   }
 
-  // check dump with the selection by names
-  bool isOk = checkDump(aSession, aFileForNamingDump, aStore, anErrorByNaming);
-  // check dump with the selection by geometry
-  isOk = isOk && checkDump(aSession, aFileForGeometryDump, aStore, anErrorByGeometry);
+  bool isOk;
+  if (!theWeakNameCheck) {
+    // check dump with the selection by names
+    isOk = checkDump(aSession, aFileForNamingDump, aStore, anErrorByNaming);
+    // check dump with the selection by geometry
+    isOk = isOk && checkDump(aSession, aFileForGeometryDump, aStore, anErrorByGeometry);
+  } else {
+    isOk = checkDump(aSession, aFileForWeakDump, aStore, anErrorByWeak);
+  }
 
   return isOk;
 }
index aa5286d84b46dbcb5a1393ad9aaa899761a25327..a3f5293bf51616d89da85f80d83cd30e9a540848 100644 (file)
@@ -172,7 +172,7 @@ std::string strByValueType(const ModelAPI_AttributeTables::ValueType theType);
 /// model must be recreated fully, with all attributes
 /// \returns true if check is well done
 MODELHIGHAPI_EXPORT
-bool checkPythonDump();
+bool checkPythonDump(const bool theWeakNameCheck = false);
 
 //--------------------------------------------------------------------------------------
 //--------------------------------------------------------------------------------------
index 409671b5cdeb8b97bfcb782ceea84aa1858221d6..704e200b05fdd224d1759c566f4638db21040ea4 100644 (file)
@@ -247,7 +247,7 @@ static const TopoDS_Shape findNeighbor(const TopoDS_Shape theContext,
 }
 
 bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape theValue,
-  const bool theUseNeighbors)
+  const bool theUseNeighbors, const bool theUseIntersections)
 {
   if (theValue.IsNull() || theContext.IsNull())
     return false;
@@ -275,7 +275,8 @@ bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape
         aSelectionType == TopAbs_SHELL || aSelectionType == TopAbs_WIRE)
     { // iterate all sub-shapes and select them on sublabels
       for(TopoDS_Iterator aSubIter(theValue); aSubIter.More(); aSubIter.Next()) {
-        if (!selectBySubSelector(theContext, aSubIter.Value(), theUseNeighbors)) {
+        if (!selectBySubSelector(
+            theContext, aSubIter.Value(), theUseNeighbors, theUseIntersections)) {
           return false; // if some selector is failed, everything is failed
         }
       }
@@ -287,7 +288,7 @@ bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape
     bool aFacesTried = false; // for identification of vertices, faces are tried, then edges
     TopoDS_ListOfShape aLastCommon; // to store the commons not good, but may be used for weak
     TopoDS_ListOfShape aLastIntersectors;
-    while(aSelectionType != TopAbs_FACE || !aFacesTried) {
+    while(theUseIntersections && (aSelectionType != TopAbs_FACE || !aFacesTried)) {
       if (aSelectionType == TopAbs_FACE) {
         if (theValue.ShapeType() != TopAbs_VERTEX)
           break;
@@ -318,7 +319,7 @@ bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape
         mySubSelList.clear();
         TopoDS_ListOfShape::Iterator anInt(anIntList);
         for (; anInt.More(); anInt.Next()) {
-          if (!selectBySubSelector(theContext, anInt.Value(), theUseNeighbors)) {
+          if (!selectBySubSelector(theContext, anInt.Value(), theUseNeighbors, false)) {
             break; // if some selector is failed, stop and search another solution
           }
         }
@@ -335,7 +336,7 @@ bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape
     if (!theUseNeighbors)
       return false;
 
-    // searching by neighbours
+    // searching by neighbors
     std::list<std::pair<TopoDS_Shape, int> > aNBs; /// neighbor sub-shape -> level of neighborhood
     for(int aLevel = 1; true; aLevel++) {
       TopTools_MapOfShape aNewNB;
@@ -350,7 +351,7 @@ bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape
           TopoDS_Shape aNewNBShape = anOrder.Current();
           // check which can be named correctly, without "by neighbors" type
           Selector_Selector aSelector(myLab.FindChild(1));
-          if (aSelector.select(theContext, aNewNBShape, false)) { // add to the list of good NBs
+          if (aSelector.select(theContext, aNewNBShape, false, false)) { // add to list of good NBs
             aNBs.push_back(std::pair<TopoDS_Shape, int>(aNewNBShape, aLevel));
           }
         }
@@ -359,7 +360,7 @@ bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape
       if (!aResult.IsNull() && aResult.IsSame(theValue)) {
         std::list<std::pair<TopoDS_Shape, int> >::iterator aNBIter = aNBs.begin();
         for(; aNBIter != aNBs.end(); aNBIter++) {
-          if (!selectBySubSelector(theContext, aNBIter->first, false)) {
+          if (!selectBySubSelector(theContext, aNBIter->first, false, false)) {
             return false; // something is wrong because before this selection was ok
           }
           myNBLevel.push_back(aNBIter->second);
@@ -379,7 +380,7 @@ bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape
         mySubSelList.clear();
         TopoDS_ListOfShape::Iterator anInt(aLastIntersectors);
         for (; anInt.More(); anInt.Next()) {
-          if (!selectBySubSelector(theContext, anInt.Value(), theUseNeighbors)) {
+          if (!selectBySubSelector(theContext, anInt.Value(), theUseNeighbors, theUseIntersections)) {
             break; // if some selector is failed, stop and search another solution
           }
         }
@@ -390,34 +391,36 @@ bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape
       }
     }
 
-    // pure weak naming
-    myType = SELTYPE_WEAK_NAMING;
-    Selector_NExplode aNexp(theContext, theValue.ShapeType());
-    myWeakIndex = aNexp.index(theValue);
-    if (myWeakIndex != -1) {
-      myShapeType = theValue.ShapeType();
-      // searching for context shape label to store in myFinal
-      myFinal.Nullify();
-      if (TNaming_Tool::HasLabel(myLab, theContext)) {
-        for(TNaming_SameShapeIterator aShapes(theContext, myLab); aShapes.More(); aShapes.Next())
-        {
-          Handle(TNaming_NamedShape) aNS;
-          if (aShapes.Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
-            TNaming_Evolution anEvolution = aNS->Evolution();
-            if (anEvolution == TNaming_PRIMITIVE || anEvolution == TNaming_GENERATED ||
-                anEvolution == TNaming_MODIFY) {
-              // check this is a new shape
-              for(TNaming_Iterator aNSIter(aNS); aNSIter.More(); aNSIter.Next()) {
-                if (aNSIter.NewShape().IsSame(theContext)) {
-                  myFinal = aNS->Label();
-                  break;
+    // pure weak naming: there is no sense to use pure weak naming for neighbors selection
+    if (theUseNeighbors) {
+      myType = SELTYPE_WEAK_NAMING;
+      Selector_NExplode aNexp(theContext, theValue.ShapeType());
+      myWeakIndex = aNexp.index(theValue);
+      if (myWeakIndex != -1) {
+        myShapeType = theValue.ShapeType();
+        // searching for context shape label to store in myFinal
+        myFinal.Nullify();
+        if (TNaming_Tool::HasLabel(myLab, theContext)) {
+          for(TNaming_SameShapeIterator aShapes(theContext, myLab); aShapes.More(); aShapes.Next())
+          {
+            Handle(TNaming_NamedShape) aNS;
+            if (aShapes.Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
+              TNaming_Evolution anEvolution = aNS->Evolution();
+              if (anEvolution == TNaming_PRIMITIVE || anEvolution == TNaming_GENERATED ||
+                  anEvolution == TNaming_MODIFY) {
+                // check this is a new shape
+                for(TNaming_Iterator aNSIter(aNS); aNSIter.More(); aNSIter.Next()) {
+                  if (aNSIter.NewShape().IsSame(theContext)) {
+                    myFinal = aNS->Label();
+                    break;
+                  }
                 }
               }
             }
           }
         }
+        return true; // could be final empty (in case it is called recursively) or not
       }
-      return true; // could be final empty (in case it is called recursively) or not
     }
 
     return false;
@@ -508,7 +511,8 @@ bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape
           if (!aResult.IsNull() && aResult.IsSame(theValue)) {
             std::list<std::pair<TopoDS_Shape, int> >::iterator aNBIter = aNBs.begin();
             for(; aNBIter != aNBs.end(); aNBIter++) {
-              if (!selectBySubSelector(theContext, aNBIter->first, theUseNeighbors)) {
+              if (!selectBySubSelector(
+                  theContext, aNBIter->first, theUseNeighbors, theUseIntersections)) {
                 return false; // something is wrong because before this selection was ok
               }
               myNBLevel.push_back(aNBIter->second);
@@ -1024,7 +1028,7 @@ TDF_Label Selector_Selector::restoreByName(
           continue;
         }
         TopAbs_ShapeEnum aSubShapeType = TopAbs_FACE;
-        if (anEndPos != std::string::npos && anEndPos + 1 > theName.size()) {
+        if (anEndPos != std::string::npos && anEndPos + 1 < theName.size()) {
           char aShapeChar = theName[anEndPos + 1];
           if (theName[anEndPos + 1] != '[') {
             switch(aShapeChar) {
@@ -1146,10 +1150,11 @@ TDF_Label Selector_Selector::restoreByName(
 }
 
 bool Selector_Selector::selectBySubSelector(
-  const TopoDS_Shape theContext, const TopoDS_Shape theValue, const bool theUseNeighbors)
+  const TopoDS_Shape theContext, const TopoDS_Shape theValue,
+  const bool theUseNeighbors, const bool theUseIntersections)
 {
   mySubSelList.push_back(Selector_Selector(myLab.FindChild(int(mySubSelList.size()) + 1)));
-  if (!mySubSelList.back().select(theContext, theValue, theUseNeighbors)) {
+  if (!mySubSelList.back().select(theContext, theValue, theUseNeighbors, theUseIntersections)) {
     mySubSelList.clear(); // if one of the selector is failed, all become invalid
     return false;
   }
index c4aba02a981065ecbe06078c8f02e531abfa3f20..2e4bc0b29fc97000f999a6d39a1f5cd2fb4ea414 100644 (file)
@@ -68,7 +68,7 @@ class Selector_Selector
   /// Initializes the selector structure on the label.
   /// Stores the name data to restore after modification.
    SELECTOR_EXPORT bool select(const TopoDS_Shape theContext, const TopoDS_Shape theValue,
-     const bool theUseNeighbors = true);
+     const bool theUseNeighbors = true, const bool theUseIntersections = true);
 
   /// Stores the name to the label and sub-labels tree
    SELECTOR_EXPORT void store();
@@ -97,7 +97,7 @@ private:
   /// Create and keep in the list the sub-sulector that select the given value.
   /// Returns true if selection is correct.
   bool selectBySubSelector(const TopoDS_Shape theContext, const TopoDS_Shape theValue,
-    const bool theUseNeighbors = true);
+    const bool theUseNeighbors = true, const bool theUseIntersections = true);
   /// Searches the final shapes presented in all results from bases basing on modification fields
   void findModificationResult(TopoDS_ListOfShape& theCommon);
 };