Salome HOME
Fix problem with dumping names of entities copied by Multi-Rotation/Translation ...
authorazv <azv@opencascade.com>
Mon, 9 Jan 2017 09:45:05 +0000 (12:45 +0300)
committerazv <azv@opencascade.com>
Mon, 9 Jan 2017 10:30:30 +0000 (13:30 +0300)
src/ModelHighAPI/ModelHighAPI_Dumper.cpp
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/Test/Test1924.py [new file with mode: 0644]

index c32d2ed7f9ed25204b690d5c5b86f683131d9bd2..f3b96003e9e1a4a950719095161f755e36260f2b 100644 (file)
@@ -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<ModelAPI_CompositeFeature>(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<ModelAPI_CompositeFeature>(aLastDumped.myEntity);
+      if (!aComposite) {
+        theDumper.dumpEntitySetName();
+        FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aLastDumped.myEntity);
+        if (aFeature) {
+          AttributeBooleanPtr aCopyAttr = aFeature->boolean("Copy");
+          isCopy = aCopyAttr.get() && aCopyAttr->value();
+        }
+      }
+    } while (isCopy);
   }
 
   // store all not-dumped entities first
index dd373fe5a607d7aecc0eafb8b2301c8561c3913a..a92dcbd5101a822ad596751c28aaf78c3f58e163 100644 (file)
@@ -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 (file)
index 0000000..0aa073d
--- /dev/null
@@ -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())