From 8e331b0d9f3086a170a778f22f7013433de00571 Mon Sep 17 00:00:00 2001 From: mpv Date: Mon, 29 Oct 2018 11:28:24 +0300 Subject: [PATCH] Fix of unit-tests. Advanced logic for the latest context searching in the filter by neighbors algorithm. --- src/FeaturesPlugin/Test/Test2394.py | 30 ++++++------- .../TestPartitionSubCompsolidWithFace1.py | 2 +- .../TestPartitionSubCompsolidWithFace3.py | 2 +- .../TestPartitionSubCompsolidWithFace4.py | 2 +- .../TestPartitionSubCompsolidWithFace5.py | 2 +- .../TestPartitionSubCompsolidWithPlane1.py | 2 +- .../TestPartitionSubCompsolidWithPlane2.py | 2 +- .../TestPartitionSubCompsolidWithPlane3.py | 2 +- .../TestPartitionSubCompsolidWithPlane5.py | 2 +- .../TestPartitionSubCompsolidWithSolid1.py | 2 +- .../TestPartitionSubCompsolidWithSolid2.py | 2 +- .../TestPartitionSubCompsolidWithSolid4.py | 2 +- .../TestPartitionSubCompsolidWithSolid5.py | 2 +- src/Model/Model_AttributeSelection.cpp | 43 +++++++++++++++++++ src/Model/Model_Objects.cpp | 10 +++-- 15 files changed, 76 insertions(+), 31 deletions(-) diff --git a/src/FeaturesPlugin/Test/Test2394.py b/src/FeaturesPlugin/Test/Test2394.py index c60225714..47e885512 100644 --- a/src/FeaturesPlugin/Test/Test2394.py +++ b/src/FeaturesPlugin/Test/Test2394.py @@ -20,6 +20,7 @@ # -*- coding: utf-8 -*- +from GeomAPI import * from SketchAPI import * from salome.shaper import model @@ -39,7 +40,6 @@ model.addParameter(Part_1_doc, "z", "R*cos(phi/180*pi)") model.addParameter(Part_1_doc, "haut_ext_tuyau", "5") model.addParameter(Part_1_doc, "haut_int_tuyau", "14") Param_Diam = model.addParameter(Part_1_doc, "diam_tuyau", "10") - Revolution_1 = model.addRevolution(Part_1_doc, [], model.selection("EDGE", "PartSet/OZ"), 90, 0) Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) @@ -83,13 +83,13 @@ SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_4.startPoint( Extrusion_1.setNestedSketch(Sketch_2) Fill_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "Revolution_1_1")], [model.selection("SOLID", "Extrusion_1_1")]) Point_2 = model.addPoint(Part_1_doc, "x", "y", "-z") -Axis_4 = model.addAxis(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "[Fill_1_1_2/Modified_Face&Sketch_2/SketchLine_4&Revolution_1_1/From_Face][Fill_1_1_2/Modified_Face&Extrusion_1_1/To_Face&Sketch_1/SketchLine_3][Fill_1_1_2/Modified_Face&Sketch_2/SketchLine_5&Revolution_1_1/To_Face]")) +Axis_4 = model.addAxis(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "[Fill_1_1_2/Modified_Face&Sketch_2/SketchLine_5&Revolution_1_1/To_Face][Fill_1_1_2/Modified_Face&Sketch_2/SketchLine_4&Revolution_1_1/From_Face][Fill_1_1_2/Modified_Face&Extrusion_1_1/To_Face&Sketch_1/SketchLine_3]")) Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "Axis_1"), model.selection("VERTEX", "Point_1"), True) Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_1"), "haut_ext_tuyau", True) Plane_5.result().setName("Plane_2 arrivee tuyau") -Plane_6 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6"), model.selection("EDGE", "[Extrusion_1_1/From_Face][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6]"), 45) +Plane_6 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6][Extrusion_1_1/From_Face]"), 45) Plane_7 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7][Extrusion_1_1/From_Face]"), 45) -Plane_8 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6]"), "90+45") +Plane_8 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7]"), "90+45") Fill_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Fill_1_1_1")], [model.selection("FACE", "Plane_5")]) Fill_3 = model.addFill(Part_1_doc, [model.selection("SOLID", "Fill_2_1_2")], [model.selection("FACE", "Plane_3")]) Fill_4 = model.addFill(Part_1_doc, [model.selection("SOLID", "Fill_3_1_2")], [model.selection("FACE", "Plane_4")]) @@ -141,10 +141,10 @@ model.do() Extrusion_2_objects = [model.selection("FACE", "Sketch_3/Face-SketchCircle_1_2f-SketchLine_14r-SketchLine_11f-SketchLine_16r"), model.selection("FACE", "Sketch_3/Face-SketchCircle_1_2f-SketchCircle_1_2f-SketchLine_17r-SketchLine_10f-SketchLine_14f"), model.selection("FACE", "Sketch_3/Face-SketchCircle_1_2f-SketchLine_15r-SketchLine_13f-SketchLine_17f"), model.selection("FACE", "Sketch_3/Face-SketchCircle_1_2f-SketchLine_16f-SketchLine_12f-SketchLine_15f")] Extrusion_2 = model.addExtrusion(Part_1_doc, Extrusion_2_objects, model.selection(), 10, 0) Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_13r-SketchLine_12r-SketchLine_11r-SketchLine_10r")], model.selection(), "haut_int_tuyau", 0) -Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1/To_Face_3")) -SketchProjection_6 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_1][Extrusion_2_1/To_Face_3][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15]"), False) +Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1_3/To_Face")) +SketchProjection_6 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15][Extrusion_2_1_3/To_Face]"), False) SketchPoint_3 = SketchProjection_6.createdFeature() -SketchProjection_7 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_2_1/To_Face_2][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_17][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_2]"), False) +SketchProjection_7 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_2_1_2/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_1][Extrusion_2_1_2/Generated_Face&Sketch_3/SketchLine_17][Extrusion_2_1_2/To_Face]"), False) SketchPoint_4 = SketchProjection_7.createdFeature() SketchArc_2 = Sketch_4.addArc(0, 0, -7.071067811865476, -7.071067811865472, 7.071067811865476, 7.071067811865472, True) SketchConstraintCoincidence_26 = Sketch_4.setCoincident(SketchPoint_3.result(), SketchArc_2.startPoint()) @@ -152,22 +152,22 @@ SketchConstraintCoincidence_27 = Sketch_4.setCoincident(SketchPoint_4.result(), SketchLine_18 = Sketch_4.addLine(7.071067811865476, 7.071067811865472, -7.071067811865476, -7.071067811865472) SketchConstraintCoincidence_28 = Sketch_4.setCoincident(SketchArc_2.endPoint(), SketchLine_18.startPoint()) SketchConstraintCoincidence_29 = Sketch_4.setCoincident(SketchAPI_Point(SketchPoint_3).coordinates(), SketchLine_18.endPoint()) -SketchProjection_8 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_5][Extrusion_2_1/To_Face_1][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_14]"), False) +SketchProjection_8 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_14][Extrusion_2_1_1/To_Face]"), False) SketchPoint_5 = SketchProjection_8.createdFeature() SketchConstraintCoincidence_30 = Sketch_4.setCoincident(SketchArc_2.endPoint(), SketchAPI_Point(SketchPoint_5).coordinates()) model.do() Revolution_2 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchArc_2_2f-SketchLine_18r")], model.selection("EDGE", "Sketch_4/SketchLine_18"), 0, 180) Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Revolution_2_1")], [model.selection("SOLID", "Extrusion_3_1")]) Cut_1.result().setName("demi-sphere") -Plane_9 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_11][Extrusion_2_1/From_Face_1][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_16]"), model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_11][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_16][Extrusion_2_1/To_Face_1]"), model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_5][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_16][Extrusion_2_1/To_Face_1]")) -Plane_10 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_11][Extrusion_2_1/To_Face_1][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_14]"), model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_5][Extrusion_2_1/To_Face_1][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_14]"), model.selection("VERTEX", "[Extrusion_2_1/From_Face_1][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_5][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_14]")) -Plane_11 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1/To_Face_2][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_17][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_2]"), model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_10][Extrusion_2_1/To_Face_2][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_17]"), model.selection("VERTEX", "[Extrusion_2_1/From_Face_2][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_17][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_2]")) -Plane_12 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1/To_Face_3][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_13]"), model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_1][Extrusion_2_1/To_Face_3][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15]"), model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_1][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15][Extrusion_2_1/From_Face_3]")) +Plane_9 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_11][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_16][Extrusion_2_1_1/From_Face]"), model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_11][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_16][Extrusion_2_1_1/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_16][Extrusion_2_1_1/To_Face]")) +Plane_10 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_14][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_11][Extrusion_2_1_1/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_14][Extrusion_2_1_1/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_14][Extrusion_2_1_1/From_Face]")) +Plane_11 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1_2/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_1][Extrusion_2_1_2/Generated_Face&Sketch_3/SketchLine_17][Extrusion_2_1_2/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_2/Generated_Face&Sketch_3/SketchLine_17][Extrusion_2_1_2/Generated_Face&Sketch_3/SketchLine_10][Extrusion_2_1_2/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_2/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_1][Extrusion_2_1_2/Generated_Face&Sketch_3/SketchLine_17][Extrusion_2_1_2/From_Face]")) +Plane_12 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_13][Extrusion_2_1_3/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15][Extrusion_2_1_3/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15][Extrusion_2_1_3/From_Face]")) Recover_1 = model.addRecover(Part_1_doc, Cut_1, [Extrusion_3.result()]) Plane_13 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape_4"), model.selection("EDGE", "[Recover_1_1/Shape_4][Recover_1_1/Shape_6]"), "90+45") -Plane_14 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape_1"), model.selection("EDGE", "[Recover_1_1/Shape_6][Recover_1_1/Shape_1]"), "90+45") -Plane_15 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape_2"), model.selection("EDGE", "[Recover_1_1/Shape_6][Recover_1_1/Shape_2]"), "90+45") -Plane_16 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape_6"), model.selection("EDGE", "[Recover_1_1/Shape_6][Recover_1_1/Shape_3]"), 45) +Plane_14 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape_1"), model.selection("EDGE", "[Recover_1_1/Shape_1][Recover_1_1/Shape_6]"), "90+45") +Plane_15 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape_2"), model.selection("EDGE", "[Recover_1_1/Shape_2][Recover_1_1/Shape_6]"), "90+45") +Plane_16 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape_6"), model.selection("EDGE", "[Recover_1_1/Shape_3][Recover_1_1/Shape_6]"), 45) Fill_5_objects_2 = [model.selection("FACE", "Plane_6"), model.selection("FACE", "Plane_7"), model.selection("FACE", "Plane_8"), model.selection("FACE", "Plane_9"), model.selection("FACE", "Plane_10"), model.selection("FACE", "Plane_11"), model.selection("FACE", "Plane_12"), model.selection("FACE", "Plane_13")] Fill_5 = model.addFill(Part_1_doc, [model.selection("SOLID", "demi-sphere")], Fill_5_objects_2) Fill_5.result().subResult(0).setName("Fill_5_1_1") diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace1.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace1.py index fc00daa1c..9ba9d1360 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace1.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace1.py @@ -44,7 +44,7 @@ SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchArc_1.startPoint(), model.do() Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "Sketch_2/SketchLine_1"), 90, 0) Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_2/SketchArc_1_2")]) -Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("FACE", "Face_1_1")]) +Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("FACE", "Face_1_1")]) model.do() # check partition diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace3.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace3.py index 767544192..1a3a6c59c 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace3.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace3.py @@ -44,7 +44,7 @@ SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchArc_1.startPoint(), model.do() Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "Sketch_2/SketchLine_1"), 90, 0) Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_2/SketchArc_1_2")]) -Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("FACE", "Face_1_1")]) +Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_3"), model.selection("FACE", "Face_1_1")]) model.do() # check partition diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace4.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace4.py index c9587cbe9..a11e6bba5 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace4.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace4.py @@ -44,7 +44,7 @@ SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchArc_1.startPoint(), model.do() Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "Sketch_2/SketchLine_1"), 90, 0) Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_2/SketchArc_1_2")]) -Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Extrusion_1_1_2"), model.selection("FACE", "Face_1_1")] +Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Extrusion_1_1_3"), model.selection("FACE", "Face_1_1")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace5.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace5.py index 410c58649..8bacb70a9 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace5.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace5.py @@ -44,7 +44,7 @@ SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchArc_1.startPoint(), model.do() Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "Sketch_2/SketchLine_1"), 90, 0) Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_2/SketchArc_1_2")]) -Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("FACE", "Face_1_1"), model.selection("SOLID", "Extrusion_1_1_3")] +Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("FACE", "Face_1_1"), model.selection("SOLID", "Extrusion_1_1_3")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane1.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane1.py index a2c3723c0..68efb9325 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane1.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane1.py @@ -36,7 +36,7 @@ SketchCircle_2 = Sketch_1.addCircle(55, 30, 40) SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_2.results()[1], "Radius") model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "ExtrusionMax", "ExtrusionMin") -Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("FACE", "PartSet/XOZ")]) +Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("FACE", "PartSet/XOZ")]) model.do() # check partition diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane2.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane2.py index 8cd4be4f7..0d8668bd1 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane2.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane2.py @@ -36,7 +36,7 @@ SketchCircle_2 = Sketch_1.addCircle(55, 30, 40) SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_2.results()[1], "Radius") model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "ExtrusionMax", "ExtrusionMin") -Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("FACE", "PartSet/XOZ")]) +Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("FACE", "PartSet/XOZ")]) model.do() # check partition diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane3.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane3.py index 38551ef73..c44f1b6dd 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane3.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane3.py @@ -36,7 +36,7 @@ SketchCircle_2 = Sketch_1.addCircle(55, 30, 40) SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_2.results()[1], "Radius") model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "ExtrusionMax", "ExtrusionMin") -Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("FACE", "PartSet/XOZ")]) +Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_3"), model.selection("FACE", "PartSet/XOZ")]) model.do() # check partition diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane5.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane5.py index 76d096236..e2f6f34d2 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane5.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane5.py @@ -36,7 +36,7 @@ SketchCircle_2 = Sketch_1.addCircle(55, 30, 40) SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_2.results()[1], "Radius") model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "ExtrusionMax", "ExtrusionMin") -Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Extrusion_1_1_3"), model.selection("FACE", "PartSet/XOZ")] +Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Extrusion_1_1_3"), model.selection("FACE", "PartSet/XOZ")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid1.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid1.py index 5eb28b156..c7adbf2c9 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid1.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid1.py @@ -38,7 +38,7 @@ SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_2.results()[1], "Radi model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "ExtrusionMax", "ExtrusionMin") Box_1 = model.addBox(Part_1_doc, 50, 100, "BoxHeight") -Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Box_1_1")]) +Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Box_1_1")]) model.do() # check partition diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid2.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid2.py index 75e447ae9..5097340fe 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid2.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid2.py @@ -38,7 +38,7 @@ SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_2.results()[1], "Radi model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "ExtrusionMax", "ExtrusionMin") Box_1 = model.addBox(Part_1_doc, 50, 100, "BoxHeight") -Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Extrusion_1_1_3"), model.selection("SOLID", "Box_1_1")] +Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Box_1_1")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid4.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid4.py index 340689eef..718d72037 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid4.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid4.py @@ -38,7 +38,7 @@ SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_2.results()[1], "Radi model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "ExtrusionMax", "ExtrusionMin") Box_1 = model.addBox(Part_1_doc, 50, 100, "BoxHeight") -Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Extrusion_1_1_3")] +Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Extrusion_1_1_1")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid5.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid5.py index 30333235d..61627dbed 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid5.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid5.py @@ -38,7 +38,7 @@ SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_2.results()[1], "Radi model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "ExtrusionMax", "ExtrusionMin") Box_1 = model.addBox(Part_1_doc, 50, 100, "BoxHeight") -Partition_1_objects = [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Extrusion_1_1_3")] +Partition_1_objects = [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Extrusion_1_1_2")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 7dc0453dd..c33a30195 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -1741,6 +1742,48 @@ ResultPtr Model_AttributeSelection::newestContext( } } } + if (theAnyValue) { // only for neighbours for now + // try to find modification of sub-shapes: the best number of matches + std::map aMatches; // result -> number of matches of shapes to find the best + TDF_Label aResLab = std::dynamic_pointer_cast(aResult->data())->shapeLab(); + TDF_ChildIDIterator aModifIter(aResLab, TNaming_NamedShape::GetID()); + for(; aModifIter.More(); aModifIter.Next()) { + Handle(TNaming_NamedShape) aNS = Handle(TNaming_NamedShape)::DownCast(aModifIter.Value()); + if (aNS->Evolution() == TNaming_MODIFY || aNS->Evolution() == TNaming_GENERATED) { + for(TNaming_Iterator aNSIter(aNS); aNSIter.More(); aNSIter.Next()) { + TNaming_NewShapeIterator aNewIter(aNSIter.NewShape(), aNS->Label()); + for(; aNewIter.More(); aNewIter.Next()) { + TDF_Label aLab = aNewIter.Label(); + if (isLater(aLab, aNS->Label()) && isLater(selectionLabel(), aLab)) { + ResultPtr aRes = aDoc->resultByLab(aLab); + if (aRes.get()) { + if (aMatches.find(aRes) == aMatches.end()) + aMatches[aRes] = 0; + aMatches[aRes]++; // found result, add matches + } + } + } + } + } + } + // searching for the best result-candidate + int aBest = 0; + ResultPtr aBestResult; + std::map::iterator aMatchIter = aMatches.begin(); + for(; aMatchIter != aMatches.end(); aMatchIter++) { + if (aMatchIter->second > aBest) { + aBest = aMatchIter->second; + aBestResult = aMatchIter->first; + } + } + if (aBestResult.get()) { + aResult = aBestResult; + aFindNewContext = true; + continue; + } + } + + // TestFillWireVertex.py - sketch constructions for wire may participate too //if (aResult->groupName() == ModelAPI_ResultBody::group()) { // try to search newer context by the concealment references diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 2a66adc60..18dfb8573 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -627,15 +627,17 @@ std::shared_ptr Model_Objects::objectByName( createHistory(theGroupID); if (theGroupID == ModelAPI_Feature::group()) { // searching among features (in history or not) std::list > allObjs = allFeatures(); - std::list >::iterator anObjIter = allObjs.begin(); - for(; anObjIter != allObjs.end(); anObjIter++) { + // from the end to find the latest result with such name + std::list >::reverse_iterator anObjIter = allObjs.rbegin(); + for(; anObjIter != allObjs.rend(); anObjIter++) { if ((*anObjIter)->data()->name() == theName) return *anObjIter; } } else { // searching among results (concealed or not) std::list > allObjs = allFeatures(); - std::list >::iterator anObjIter = allObjs.begin(); - for(; anObjIter != allObjs.end(); anObjIter++) { + // from the end to find the latest result with such name + std::list >::reverse_iterator anObjIter = allObjs.rbegin(); + for(; anObjIter != allObjs.rend(); anObjIter++) { std::list allRes; ModelAPI_Tools::allResults(*anObjIter, allRes); for(std::list::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) { -- 2.39.2