From: mpv Date: Thu, 17 Jan 2019 16:22:31 +0000 (+0300) Subject: Compounds in Selection task: initial implementation of "merge" of the same topology... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FCompoundsInSelection;p=modules%2Fshaper.git Compounds in Selection task: initial implementation of "merge" of the same topology in the selection list. Also, optimization of the Filter By Neighbors algorithm. --- diff --git a/src/FeaturesPlugin/Test/Test2197_3.py b/src/FeaturesPlugin/Test/Test2197_3.py index cf01ec2dc..0299dafd3 100644 --- a/src/FeaturesPlugin/Test/Test2197_3.py +++ b/src/FeaturesPlugin/Test/Test2197_3.py @@ -37,7 +37,7 @@ SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_4.endPoint()) model.do() Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection("EDGE", "Sketch_1/SketchLine_4"), 360, 0) -Group_1_objects = [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][weak_name_3]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3]"), model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3])"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3][weak_name_3]")] +Group_1_objects = [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2]"), model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3])2"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3]"), model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3])"), model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2])2")] Group_1 = model.addGroup(Part_1_doc, Group_1_objects) model.do() model.end() diff --git a/src/FeaturesPlugin/Test/Test2197_4.py b/src/FeaturesPlugin/Test/Test2197_4.py index cdcd04e6e..a9cd2678c 100644 --- a/src/FeaturesPlugin/Test/Test2197_4.py +++ b/src/FeaturesPlugin/Test/Test2197_4.py @@ -52,7 +52,7 @@ SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_7") model.do() Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_6r-SketchLine_5r-SketchLine_3f-SketchLine_4f")], model.selection("EDGE", "Sketch_1/SketchLine_4"), 360, 0) -Group_1_objects = [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3][weak_name_3]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][weak_name_3]"), model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5])"), model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3])")] +Group_1_objects = [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3]"), model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5])2"), model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5])2"), model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5])"), model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3])")] Group_1 = model.addGroup(Part_1_doc, Group_1_objects) model.do() model.end() diff --git a/src/FeaturesPlugin/Test/Test2248.py b/src/FeaturesPlugin/Test/Test2248.py index c3dbdf15d..708505e43 100644 --- a/src/FeaturesPlugin/Test/Test2248.py +++ b/src/FeaturesPlugin/Test/Test2248.py @@ -48,7 +48,54 @@ SketchConstraintTangent_2 = Sketch_1.setTangent(SketchLine_3.result(), SketchArc SketchCircle_1 = Sketch_1.addCircle(-13.45056286489504, 169.4770920976776, 150.6703210346195) model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) -Group_1_objects = [model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1_2/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1_2/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1_2/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1_2/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1_2/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1_2/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_1]"), model.selection("EDGE", "[Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_3]"), model.selection("EDGE", "[Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1_4/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1_4/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_1][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1_4/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1_4/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_2][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_2][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_1]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_1][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_1][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_1][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2]")] +Group_1_objects = [ +model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1_2/To_Face]"), +model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1_2/From_Face]"), +model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1_2/To_Face]"), +model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1_2/From_Face]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2][Extrusion_1_1_1/To_Face]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2][Extrusion_1_1_1/From_Face]"), +model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1_2/To_Face]"), +model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1_2/From_Face]"), +model.selection("EDGE", "[(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4)(Extrusion_1_1_1/From_Face)(Extrusion_1_1_1/To_Face)(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2)2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1][Extrusion_1_1_1/To_Face]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1][Extrusion_1_1_1/From_Face]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1][(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2)(Extrusion_1_1_1/From_Face)(Extrusion_1_1_1/To_Face)(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4)2]"), +model.selection("EDGE", "[Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_3]"), +model.selection("EDGE", "[Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1_4/To_Face]"), +model.selection("EDGE", "[Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1_4/From_Face]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/From_Face]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/To_Face]"), +model.selection("EDGE", "[(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2)(Extrusion_1_1_1/From_Face)(Extrusion_1_1_1/To_Face)(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4)2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/From_Face]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/To_Face]"), +model.selection("EDGE", "[Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1_4/To_Face]"), +model.selection("EDGE", "[Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1_4/From_Face]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1_1/To_Face]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1_1/From_Face]"), +model.selection("EDGE", "[(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4)(Extrusion_1_1_1/From_Face)(Extrusion_1_1_1/To_Face)(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2)2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4]"), +model.selection("EDGE", "[(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4)(Extrusion_1_1_1/From_Face)(Extrusion_1_1_1/To_Face)(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2)2][Extrusion_1_1_1/To_Face]"), +model.selection("EDGE", "[(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4)(Extrusion_1_1_1/From_Face)(Extrusion_1_1_1/To_Face)(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2)2][Extrusion_1_1_1/From_Face]"), +model.selection("EDGE", "[(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4)(Extrusion_1_1_1/From_Face)(Extrusion_1_1_1/To_Face)(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2)2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2][Extrusion_1_1_1/From_Face]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2][Extrusion_1_1_1/To_Face]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/From_Face]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/To_Face]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/To_Face]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/From_Face]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1][Extrusion_1_1_1/From_Face]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1][Extrusion_1_1_1/To_Face]"), +model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1][(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2)(Extrusion_1_1_1/From_Face)(Extrusion_1_1_1/To_Face)(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4)2]"), +model.selection("EDGE", "[(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2)(Extrusion_1_1_1/From_Face)(Extrusion_1_1_1/To_Face)(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4)2][Extrusion_1_1_1/To_Face]"), +model.selection("EDGE", "[(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2)(Extrusion_1_1_1/From_Face)(Extrusion_1_1_1/To_Face)(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4)2][Extrusion_1_1_1/From_Face]"), +model.selection("EDGE", "[(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2)(Extrusion_1_1_1/From_Face)(Extrusion_1_1_1/To_Face)(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4)2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2]") +] Group_1 = model.addGroup(Part_1_doc, Group_1_objects) model.do() model.end() diff --git a/src/FeaturesPlugin/Test/Test2251.py b/src/FeaturesPlugin/Test/Test2251.py index d13c620cb..d8926a03d 100644 --- a/src/FeaturesPlugin/Test/Test2251.py +++ b/src/FeaturesPlugin/Test/Test2251.py @@ -56,7 +56,52 @@ SketchConstraintTangent_4 = Sketch_1.setTangent(SketchArc_3.results()[1], Sketch SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchArc_2.results()[1], SketchArc_4.endPoint()) model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 100, 0) -Group_1_objects = [model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_2"), model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2"), model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_1"), model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_2"), model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_2"), model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_3_2"), model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchLine_3"), model.selection("FACE", "Extrusion_1_1_3/From_Face"), model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchLine_2"), model.selection("FACE", "Extrusion_1_1_3/To_Face"), model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_2"), model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchLine_3"), model.selection("FACE", "Extrusion_1_1_4/From_Face"), model.selection("FACE", "Extrusion_1_1_4/To_Face"), model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchLine_1"), model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchLine_2"), model.selection("FACE", "Extrusion_1_1_2/Generated_Face&Sketch_1/SketchCircle_1_2"), model.selection("FACE", "Extrusion_1_1_6/From_Face"), model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchArc_3_2"), model.selection("FACE", "Extrusion_1_1_6/To_Face"), model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_1_2"), model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchLine_3"), model.selection("FACE", "Extrusion_1_1_5/To_Face"), model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_2_2&weak_name_1"), model.selection("FACE", "Extrusion_1_1_5/From_Face"), model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_1_2"), model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchLine_1"), model.selection("FACE", "Extrusion_1_1_2/Generated_Face&Sketch_1/SketchCircle_1_2"), model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchArc_3_2"), model.selection("FACE", "Extrusion_1_1_4/Generated_Face&Sketch_1/SketchArc_4_2"), model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchArc_4_2"), model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchLine_3"), model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2"), model.selection("FACE", "Extrusion_1_1_2/From_Face"), model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4"), model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_2_2&weak_name_2"), model.selection("FACE", "Extrusion_1_1_2/To_Face"), model.selection("FACE", "Extrusion_1_1_7/Generated_Face&Sketch_1/SketchCircle_2_2"), model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_2_2&weak_name_2"), model.selection("FACE", "Extrusion_1_1_7/To_Face"), model.selection("FACE", "Extrusion_1_1_7/From_Face"), model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1"), model.selection("FACE", "Extrusion_1_1_1/From_Face"), model.selection("FACE", "Extrusion_1_1_1/To_Face")] +Group_1_objects = [ +model.selection("FACE", "(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4)(Extrusion_1_1_1/From_Face)(Extrusion_1_1_1/To_Face)(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_4_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_3_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_3)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_2_2)2"), +model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2"), +model.selection("FACE", "(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_2)(Extrusion_1_1_1/From_Face)(Extrusion_1_1_1/To_Face)(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_4_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_3_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_3)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_2_2)2"), +model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_2"), +model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_2"), +model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_3_2"), +model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchLine_3"), +model.selection("FACE", "Extrusion_1_1_3/From_Face"), +model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchLine_2"), +model.selection("FACE", "Extrusion_1_1_3/To_Face"), +model.selection("FACE", "(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4)(Extrusion_1_1_1/From_Face)(Extrusion_1_1_1/To_Face)(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_4_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_3_2)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_3)2(Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_2_2)2"), +model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchLine_3"), +model.selection("FACE", "Extrusion_1_1_4/From_Face"), +model.selection("FACE", "Extrusion_1_1_4/To_Face"), +model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchLine_1"), +model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchLine_2"), +model.selection("FACE", "Extrusion_1_1_2/Generated_Face&Sketch_1/SketchCircle_1_2"), +model.selection("FACE", "Extrusion_1_1_6/From_Face"), +model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchArc_3_2"), +model.selection("FACE", "Extrusion_1_1_6/To_Face"), +model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_1_2"), +model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchLine_3"), +model.selection("FACE", "Extrusion_1_1_5/To_Face"), +model.selection("FACE", "(Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_1_2)(Extrusion_1_1_6/From_Face)(Extrusion_1_1_6/To_Face)(Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_3_2)2(Extrusion_1_1_6/Generated_Face&Sketch_1/SketchLine_3)2"), +model.selection("FACE", "Extrusion_1_1_5/From_Face"), +model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_1_2"), +model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchLine_1"), +model.selection("FACE", "Extrusion_1_1_2/Generated_Face&Sketch_1/SketchCircle_1_2"), +model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchArc_3_2"), +model.selection("FACE", "Extrusion_1_1_4/Generated_Face&Sketch_1/SketchArc_4_2"), +model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchArc_4_2"), +model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchLine_3"), +model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2"), +model.selection("FACE", "Extrusion_1_1_2/From_Face"), +model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4"), +model.selection("FACE", "(Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_3_2)(Extrusion_1_1_6/From_Face)(Extrusion_1_1_6/To_Face)(Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_1_2)2(Extrusion_1_1_6/Generated_Face&Sketch_1/SketchLine_3)2"), +model.selection("FACE", "Extrusion_1_1_2/To_Face"), +model.selection("FACE", "Extrusion_1_1_7/Generated_Face&Sketch_1/SketchCircle_2_2"), +model.selection("FACE", "(Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_3_2)(Extrusion_1_1_6/From_Face)(Extrusion_1_1_6/To_Face)(Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_1_2)2(Extrusion_1_1_6/Generated_Face&Sketch_1/SketchLine_3)2"), +model.selection("FACE", "Extrusion_1_1_7/To_Face"), +model.selection("FACE", "Extrusion_1_1_7/From_Face"), +model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1"), +model.selection("FACE", "Extrusion_1_1_1/From_Face"), +model.selection("FACE", "Extrusion_1_1_1/To_Face") +] Group_1 = model.addGroup(Part_1_doc, Group_1_objects) model.do() model.end() diff --git a/src/FeaturesPlugin/Test/Test2729.py b/src/FeaturesPlugin/Test/Test2729.py index 2819f1868..7f82fc5d0 100644 --- a/src/FeaturesPlugin/Test/Test2729.py +++ b/src/FeaturesPlugin/Test/Test2729.py @@ -236,7 +236,7 @@ SketchLine_39.setName("SketchLine_40") SketchLine_39.result().setName("SketchLine_40") ExtrusionCut_1.setNestedSketch(Sketch_2) ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [], model.selection(), 0, 20, [model.selection("SOLID", "ExtrusionCut_1_1")]) -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_8&weak_name_1")) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "(ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face)(ExtrusionCut_1_1/Generated_Face&Sketch_2/SketchLine_23)(ExtrusionCut_1_1/Generated_Face&Sketch_2/SketchLine_25)(ExtrusionCut_1_1/Generated_Face&Sketch_2/SketchArc_2_2)(ExtrusionCut_1_1/Generated_Face&Sketch_2/SketchLine_24)(ExtrusionCut_1_1/Generated_Face&Sketch_2/SketchArc_3_2)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_12)2(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_11)2(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1)2(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_10)2(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2)2(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3)2(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4)2(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_5)2(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_9)2(ExtrusionCut_1_1/Generated_Face&Sketch_2/SketchLine_21)2(ExtrusionCut_1_1/From_Face_1)2(ExtrusionCut_1_1/Generated_Face&Sketch_2/SketchLine_27)2")) SketchCircle_1 = Sketch_3.addCircle(-19.86097902097902, 65.28094405594405, 2.5) SketchCircle_2 = Sketch_3.addCircle(-18.51902097902098, 27.57192307692308, 2) SketchCircle_3 = Sketch_3.addCircle(-19.0558041958042, 85.54451048951049, 3) diff --git a/src/FeaturesPlugin/Test/TestExtrusionCut_ByPlanesAndOffsets.py b/src/FeaturesPlugin/Test/TestExtrusionCut_ByPlanesAndOffsets.py index 579be45ca..e66b1c099 100644 --- a/src/FeaturesPlugin/Test/TestExtrusionCut_ByPlanesAndOffsets.py +++ b/src/FeaturesPlugin/Test/TestExtrusionCut_ByPlanesAndOffsets.py @@ -52,7 +52,7 @@ checkMiddlePoint(Shape, 5, 5, 4.97049494) ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [], model.selection("EDGE", "Axis_1"), model.selection(), 0, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Box_1_1/Left"), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Front")) SketchCircle_2 = Sketch_2.addCircle(10, 10, 2.040695131136049) -SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "[ExtrusionCut_1_1/Modified_Face&Box_1_1/Right][Box_1_1/Front][ExtrusionCut_1_1/Modified_Face&Box_1_1/Top&weak_name_2]"), False) +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "[ExtrusionCut_1_1/Modified_Face&Box_1_1/Right][Box_1_1/Front][(ExtrusionCut_1_1/Modified_Face&Box_1_1/Left)(ExtrusionCut_1_1/Modified_Face&Box_1_1/Right)(Box_1_1/Front)(Box_1_1/Back)2(Box_1_1/Bottom)2]"), False) SketchPoint_1 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchCircle_2.center(), SketchAPI_Point(SketchPoint_1).coordinates()) ExtrusionCut_2.setNestedSketch(Sketch_2) diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 00736a73e..b6e174a03 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -594,13 +594,17 @@ bool Model_AttributeSelection::update() aNewShape = aNS->Get(); if (anOldShape.IsNull() || aNewShape.IsNull() || !anOldShape.IsEqual(aNewShape)) { + bool aIsRemoved = false; // this may be removed, so, don't send the "update" message // shape type should not be changed: if shape becomes compound of such shapes, then split if (myParent && !anOldShape.IsNull() && !aNewShape.IsNull() && anOldShape.ShapeType() != aNewShape.ShapeType() && aNewShape.ShapeType() == TopAbs_COMPOUND) { split(aContext, aNewShape, anOldShape.ShapeType()); + } else if (myParent && !aNewShape.IsNull()) { // merge: remove equal shapes from the list + aIsRemoved = myParent->merge(this); } - owner()->data()->sendAttributeUpdated(this); // send updated if shape is changed + if (!aIsRemoved) + owner()->data()->sendAttributeUpdated(this); // send updated if shape is changed } return aResult; } @@ -705,7 +709,7 @@ bool Model_AttributeSelection::selectPart( return !aName.empty(); } -TDF_Label Model_AttributeSelection::selectionLabel() +TDF_Label Model_AttributeSelection::selectionLabel() const { return myRef.myRef->Label().FindChild(1); } diff --git a/src/Model/Model_AttributeSelection.h b/src/Model/Model_AttributeSelection.h index 741929433..2c94e1ebd 100644 --- a/src/Model/Model_AttributeSelection.h +++ b/src/Model/Model_AttributeSelection.h @@ -168,7 +168,7 @@ protected: /// Returns the label where TNaming_Selection results are stored /// Note: there must be no attributes stored at the same label because Selector clears this lab - TDF_Label selectionLabel(); + TDF_Label selectionLabel() const; /// Sets the ID of the attribute in Data (called from Data): here it is used for myRef ID setting MODEL_EXPORT virtual void setID(const std::string theID); diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index b813dcd18..9a6c7d427 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -481,3 +481,31 @@ void Model_AttributeSelectionList::setGeometricalSelection(const bool theIsGeome myCash.clear(); // empty list as indicator that cash is not used owner()->data()->sendAttributeUpdated(this); } + +bool Model_AttributeSelectionList::merge(Model_AttributeSelection* theStart) +{ + int aSize = size(); + TDF_Label aStartLab = theStart->selectionLabel().Father(); + ResultPtr aContext = theStart->context(); + if (aContext.get()) { + GeomShapePtr aValue = theStart->value(); + if (aValue.get() && !aValue->isNull()) { + for(int anIndex = aStartLab.Tag(); anIndex < aSize; anIndex++) { + AttributeSelectionPtr aSel = value(anIndex); + if (aContext == aSel->context() && aValue->isSame(aSel->value())) { // remove theStart + std::set aRemoved; + aRemoved.insert(aStartLab.Tag() - 1); + remove(aRemoved); + // also re-select theStart to make name cover both attributes (after split of merged) + aSel = value(anIndex - 1); // attributes of this attribute were moved up by "remove" + static ObjectPtr anEmptyContext; + static GeomShapePtr anEmptyShape; + aSel->setValue(anEmptyContext, anEmptyShape); + aSel->setValue(aContext, aValue); + return true; + } + } + } + } + return false; // not merged +} diff --git a/src/Model/Model_AttributeSelectionList.h b/src/Model/Model_AttributeSelectionList.h index d84ca1ff4..7df121d22 100644 --- a/src/Model/Model_AttributeSelectionList.h +++ b/src/Model/Model_AttributeSelectionList.h @@ -122,7 +122,12 @@ protected: /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc) virtual void reinit(); + /// Tries to merge attributes in this list with the same result shape. Returns true + /// if theStart matches with some later attribute and theStart is removed from the list. + bool merge(Model_AttributeSelection* theStart); + friend class Model_Data; + friend class Model_AttributeSelection; }; #endif diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index f22dfe5bd..7efd13fe8 100755 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -616,9 +616,7 @@ void Model_BodyBuilder::loadGeneratedShapes(const GeomMakeShapePtr& theAlgo, bool aNewShapeIsSameAsOldShape = anOldSubShape->isSame(aNewShape); bool aNewShapeIsNotInResultShape = !aResultShape->isSubShape(aNewShape, false); - if (aNewShapeIsSameAsOldShape - || aNewShapeIsNotInResultShape) - { + if (aNewShapeIsSameAsOldShape || aNewShapeIsNotInResultShape) { continue; } @@ -634,8 +632,26 @@ void Model_BodyBuilder::loadGeneratedShapes(const GeomMakeShapePtr& theAlgo, storeExternalReference(anOriginalLabel, builder(aTag)->NamedShape()->Label()); } buildName(aTag, theName); - } - else { + } if (aResultShape->isSame(aNewShape)) { + // keep the generation evolution on the root level (2397 - for intersection feature) + TNaming_Builder* aBuilder = builder(0); + TDF_Label aShapeLab = aBuilder->NamedShape()->Label(); + Handle(TDF_Reference) aRef; + if (aShapeLab.FindAttribute(TDF_Reference::GetID(), aRef)) { + // Store only in case if it does not have reference. + continue; + } + + // Check if new shape was already stored. + if (isAlreadyStored(aBuilder, anOldSubShape_, aNewShape_)) continue; + + if (!aBuilder->NamedShape().IsNull() && + aBuilder->NamedShape()->Evolution() != TNaming_GENERATED) { + myBuilders.erase(0); // clear old builder to avoid different evolutions crash + aBuilder = builder(0); + } + aBuilder->Generated(anOldSubShape_, aNewShape_); + } else { int aTag = getGenerationTag(aNewShape_); if (aTag == INVALID_TAG) return; builder(aTag)->Generated(anOldSubShape_, aNewShape_); diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 19fa6c522..99132fd2e 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -238,4 +238,5 @@ ADD_UNIT_TESTS(TestConstants.py TestSaveOpen2.py TestSelectionInitialization.py Test2828.py + TestSelectionMerge.py ) diff --git a/src/ModelAPI/Test/TestSelectionMerge.py b/src/ModelAPI/Test/TestSelectionMerge.py new file mode 100644 index 000000000..7baee9948 --- /dev/null +++ b/src/ModelAPI/Test/TestSelectionMerge.py @@ -0,0 +1,63 @@ +## 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 +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Param_H = model.addParameter(Part_1_doc, "height", "3") +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), 0, "height", [model.selection("SOLID", "Box_1_1")]) +Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Top")) +SketchLine_1 = Sketch_1.addLine(6, 1, 4, 1) +SketchLine_1.setName("SketchLine_3") +SketchLine_1.result().setName("SketchLine_3") +SketchLine_2 = Sketch_1.addLine(5, -1, 4, 1) +SketchLine_2.setName("SketchLine_2") +SketchLine_2.result().setName("SketchLine_2") +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.endPoint()) +SketchLine_3 = Sketch_1.addLine(5, -1, 6, 1) +SketchLine_3.setName("SketchLine_4") +SketchLine_3.result().setName("SketchLine_4") +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint()) +ExtrusionCut_1.setNestedSketch(Sketch_1) +Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Box_1_1/Left")]) +model.do() +groupSelectionList = Group_1.feature().selectionList("group_list") +assert(groupSelectionList.size() == 1) +# cut the face fully +Param_H.setValue(10) +model.do() +assert(groupSelectionList.size() == 2) +# merge the face back +Param_H.setValue(2) +# split again +Param_H.setValue(10) +model.do() +assert(groupSelectionList.size() == 2) +# merge the face back +Param_H.setValue(2) +model.end() +assert(groupSelectionList.size() == 1) + +assert(model.checkPythonDump()) diff --git a/src/Selector/Selector_FilterByNeighbors.cpp b/src/Selector/Selector_FilterByNeighbors.cpp index e98899b66..47c43915c 100644 --- a/src/Selector/Selector_FilterByNeighbors.cpp +++ b/src/Selector/Selector_FilterByNeighbors.cpp @@ -42,19 +42,32 @@ static void findNeighbors(const TopoDS_Shape theContext, const TopoDS_Shape theV const int theLevel, TopTools_MapOfShape& theResult) { TopAbs_ShapeEnum aConnectorType = TopAbs_VERTEX; // type of the connector sub-shapes - if (theValue.ShapeType() == TopAbs_FACE) + TopAbs_ShapeEnum aValueType = theValue.ShapeType(); + if (aValueType == TopAbs_FACE) aConnectorType = TopAbs_EDGE; + else if (aValueType == TopAbs_COMPOUND) { // for geometrical naming: compound of faces + TopExp_Explorer anExp(theValue, TopAbs_FACE); + if (anExp.More()) { + aConnectorType = TopAbs_EDGE; + aValueType = TopAbs_FACE; + } else { + aValueType = TopAbs_EDGE; + } + } TopTools_MapOfShape aNBConnectors; // connector shapes that already belong to neighbors - for(TopExp_Explorer aValExp(theValue, aConnectorType); aValExp.More(); aValExp.Next()) { + for(TopExp_Explorer aValExp(theValue, aConnectorType); aValExp.More(); aValExp.Next()) aNBConnectors.Add(aValExp.Current()); - } TopTools_MapOfShape alreadyProcessed; - alreadyProcessed.Add(theValue); + if (aValueType == theValue.ShapeType()) + alreadyProcessed.Add(theValue); + else + for(TopExp_Explorer aValExp(theValue, aValueType); aValExp.More(); aValExp.Next()) + alreadyProcessed.Add(aValExp.Current()); for(int aLevel = 1; aLevel <= theLevel; aLevel++) { TopoDS_ListOfShape aGoodCandidates; - TopExp_Explorer aCandidate(theContext, theValue.ShapeType()); + TopExp_Explorer aCandidate(theContext, aValueType); for(; aCandidate.More(); aCandidate.Next()) { if (alreadyProcessed.Contains(aCandidate.Current())) continue; @@ -102,18 +115,16 @@ static const TopoDS_Shape findNeighbor(const TopoDS_Shape theContext, if (aNBIter->second == aMinLevel) { TopTools_MapOfShape aThisNBs; findNeighbors(theContext, aNBIter->first, aMinLevel, aThisNBs); - // aMatches must contain common part of all NBs lists - for(TopTools_MapOfShape::Iterator aThisNB(aThisNBs); aThisNB.More(); aThisNB.Next()) { - if (aFirst) { + if (aFirst) { // aMatches must contain common part of all NBs lists + for(TopTools_MapOfShape::Iterator aThisNB(aThisNBs); aThisNB.More(); aThisNB.Next()) { aMatches.Append(aThisNB.Value()); - } else { - // remove all in aMatches which are not in this NBs - for(TopoDS_ListOfShape::Iterator aMatch(aMatches); aMatch.More(); ) { - if (aThisNBs.Contains(aMatch.Value())) { - aMatch.Next(); - } else { - aMatches.Remove(aMatch); - } + } + } else { // remove all in aMatches which are not in this NBs + for(TopoDS_ListOfShape::Iterator aMatch(aMatches); aMatch.More(); ) { + if (aThisNBs.Contains(aMatch.Value())) { + aMatch.Next(); + } else { + aMatches.Remove(aMatch); } } } @@ -155,6 +166,7 @@ static const TopoDS_Shape findNeighbor(const TopoDS_Shape theContext, } else return TopoDS_Shape(); } + break; // no more NBs with higher levels } if (!aLevelNBs.IsEmpty()) { TopTools_MapOfShape aNBsOfCandidate; diff --git a/src/SketchPlugin/Test/Test2119.py b/src/SketchPlugin/Test/Test2119.py index e9f70c2c6..3f177b917 100644 --- a/src/SketchPlugin/Test/Test2119.py +++ b/src/SketchPlugin/Test/Test2119.py @@ -98,12 +98,12 @@ ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Ske Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&ExtrusionCut_1_1/From_Face")) SketchProjection_2 = Sketch_3.addProjection(model.selection("VERTEX", "ExtrusionCut_1_1/Generated_Vertex&ExtrusionCut_1_1/From_Face"), False) SketchPoint_3 = SketchProjection_2.createdFeature() -SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "ExtrusionCut_1_1/Generated_Edge&ExtrusionCut_1_1/From_Face&weak_name_2"), False) +SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "([ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchArc_1_2][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_9])([Extrusion_1_1/From_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_9])2([Extrusion_1_1/From_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchArc_1_2])2([ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_9])2"), False) SketchLine_11 = SketchProjection_3.createdFeature() SketchArc_3 = Sketch_3.addArc(-15, 35, -15, 46.0103340429751, -17.02045759563166, 24.17663606626138, True) SketchConstraintCoincidence_16 = Sketch_3.setCoincident(SketchPoint_3.result(), SketchArc_3.center()) SketchConstraintCoincidence_17 = Sketch_3.setCoincident(SketchLine_11.result(), SketchArc_3.startPoint()) -SketchProjection_4 = Sketch_3.addProjection(model.selection("EDGE", "ExtrusionCut_1_1/Generated_Edge&ExtrusionCut_1_1/From_Face&weak_name_1"), False) +SketchProjection_4 = Sketch_3.addProjection(model.selection("EDGE", "([ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchArc_1_2][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_9])([Extrusion_1_1/From_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_9])2([Extrusion_1_1/From_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchArc_1_2])2([ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchArc_1_2])2"), False) SketchArc_4 = SketchProjection_4.createdFeature() SketchConstraintCoincidence_18 = Sketch_3.setCoincident(SketchArc_3.endPoint(), SketchArc_4.results()[1]) SketchLine_12 = Sketch_3.addLine(-15, 46.0103340429751, -15, 35)