From c3a819e00709b8157dd82015c8f46d3668b86b15 Mon Sep 17 00:00:00 2001 From: azv Date: Mon, 9 Jan 2017 12:45:05 +0300 Subject: [PATCH] Fix problem with dumping names of entities copied by Multi-Rotation/Translation (issue #1924) --- src/ModelHighAPI/ModelHighAPI_Dumper.cpp | 25 +++++++++++++++------ src/SketchPlugin/CMakeLists.txt | 3 ++- src/SketchPlugin/Test/Test1924.py | 28 ++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 src/SketchPlugin/Test/Test1924.py diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index c32d2ed7f..f3b96003e 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -915,13 +915,24 @@ ModelHighAPI_Dumper& operator<<(ModelHighAPI_Dumper& theDumper, theDumper.myDumpBuffer << theEndl; if (!theDumper.myEntitiesStack.empty()) { - // Name for composite feature is dumped when all sub-entities are dumped - // (see method ModelHighAPI_Dumper::processSubs). - const ModelHighAPI_Dumper::LastDumpedEntity& aLastDumped = theDumper.myEntitiesStack.top(); - CompositeFeaturePtr aComposite = - std::dynamic_pointer_cast(aLastDumped.myEntity); - if (!aComposite) - theDumper.dumpEntitySetName(); + bool isCopy; + // all copies have been stored into stack, pop them all + do { + isCopy = false; + // Name for composite feature is dumped when all sub-entities are dumped + // (see method ModelHighAPI_Dumper::processSubs). + const ModelHighAPI_Dumper::LastDumpedEntity& aLastDumped = theDumper.myEntitiesStack.top(); + CompositeFeaturePtr aComposite = + std::dynamic_pointer_cast(aLastDumped.myEntity); + if (!aComposite) { + theDumper.dumpEntitySetName(); + FeaturePtr aFeature = std::dynamic_pointer_cast(aLastDumped.myEntity); + if (aFeature) { + AttributeBooleanPtr aCopyAttr = aFeature->boolean("Copy"); + isCopy = aCopyAttr.get() && aCopyAttr->value(); + } + } + } while (isCopy); } // store all not-dumped entities first diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index dd373fe5a..a92dcbd51 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -143,4 +143,5 @@ ADD_UNIT_TESTS(TestSketchPointLine.py TestSplit.py TestHighload.py TestSnowflake.py - TestArcBehavior.py ) + TestArcBehavior.py + Test1924.py ) diff --git a/src/SketchPlugin/Test/Test1924.py b/src/SketchPlugin/Test/Test1924.py new file mode 100644 index 000000000..0aa073dc5 --- /dev/null +++ b/src/SketchPlugin/Test/Test1924.py @@ -0,0 +1,28 @@ +""" + Test1924.py + Test case for issue #1924 "Wrong naming of multiple-rotated sketch edges on python dump" +""" + +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")) +SketchLine_1 = Sketch_1.addLine(70, 120, 50, 25) +SketchLine_2 = Sketch_1.addLine(50, 25, 170, 50) +SketchPoint_1 = Sketch_1.addPoint(model.selection("VERTEX", "PartSet/Origin")) +SketchMultiRotation_1_objects = [SketchLine_1.result(), SketchLine_2.result()] +# names of rotated objects: "SketchLine_3", "SketchLine_4" +SketchMultiRotation_1 = Sketch_1.addRotation(SketchMultiRotation_1_objects, SketchPoint_1.coordinates(), 90, 2) +# line named "SketchLine_5" +SketchLine_5 = Sketch_1.addLine(0, 100, 100, 100) +# change number of rotated objects. +# names of rotated objects: "SketchLine_3", "SketchLine_4", "SketchLine_6", "SketchLine_7" +SketchMultiRotation_1.numberOfObjects().setValue(3) + +model.end() + +assert(model.checkPythonDump()) -- 2.39.2