]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the issue #19989 : Sketch in error after edit and apply on Fuse (without...
authormpv <mpv@opencascade.com>
Thu, 17 Sep 2020 15:20:29 +0000 (18:20 +0300)
committermpv <mpv@opencascade.com>
Thu, 17 Sep 2020 15:20:29 +0000 (18:20 +0300)
src/Model/Model_BodyBuilder.cpp
src/ModelAPI/CMakeLists.txt
src/ModelAPI/Test/Test19989.py [new file with mode: 0644]

index fd33d7724a93e582d70040c160931e8b7c90a60c..7e8c253b6de27927e036f7456a9f7d2d7009f11a 100644 (file)
@@ -336,7 +336,22 @@ void Model_BodyBuilder::storeModified(const GeomShapePtr& theOldShape,
     TDF_Label anAccess2 = std::dynamic_pointer_cast<Model_Document>(
       ModelAPI_Session::get()->moduleDocument())->generalLabel();
     TDF_Label anOriginalLabel;
+    TopTools_ListOfShape anOldList;
     if (!isShapeInTree(aData->shapeLab(), anAccess2, aShapeOld, anOriginalLabel)) {
+      if (aShapeOld.ShapeType() == TopAbs_COMPOUND)  { // check this could be a compund by a whole feature selection
+        for(TopoDS_Iterator aCompIter(aShapeOld); aCompIter.More(); aCompIter.Next()) {
+          if (isShapeInTree(aData->shapeLab(), anAccess2, aCompIter.Value(), anOriginalLabel)) {
+            anOldList.Append(aCompIter.Value());
+          } else {
+            anOldList.Clear();
+            break;
+          }
+        }
+      }
+    } else {
+      anOldList.Append(aShapeOld);
+    }
+    if (anOldList.IsEmpty()) {
       if (aBuilder->NamedShape()->Get().IsNull()) { // store as primitive if alone anyway
         aBuilder->Generated(aShapeNew);
       }
@@ -345,8 +360,10 @@ void Model_BodyBuilder::storeModified(const GeomShapePtr& theOldShape,
         myBuilders.erase(0);
         aBuilder = builder(0);
       }
-
-      aBuilder->Modify(aShapeOld, aShapeNew);
+      TopTools_ListIteratorOfListOfShape anOldIter(anOldList);
+      for(; anOldIter.More(); anOldIter.Next()) {
+        aBuilder->Modify(anOldIter.Value(), aShapeNew);
+      }
       // store information about the external document reference to restore old shape on open
       storeExternalReference(anOriginalLabel, aBuilder->NamedShape()->Label());
     }
index 0934b4d05cce061479b1a1eed460336ff7849289..dd2f4acd920a972c11e1a6715dc2eca41ec5d271 100644 (file)
@@ -266,4 +266,5 @@ ADD_UNIT_TESTS(TestConstants.py
                Test19726.py
                Test19912.py
                Test19932.py
+               Test19989.py
 )
diff --git a/src/ModelAPI/Test/Test19989.py b/src/ModelAPI/Test/Test19989.py
new file mode 100644 (file)
index 0000000..c38a59d
--- /dev/null
@@ -0,0 +1,51 @@
+# Copyright (C) 2014-2020  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()
+Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
+SketchCircle_1 = Sketch_1.addCircle(12, 10, 8)
+model.do()
+Sketch_2 = model.addSketch(partSet, model.defaultPlane("XOY"))
+SketchCircle_2 = Sketch_2.addCircle(24, 10, 8)
+model.do()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "PartSet/Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0)
+Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "PartSet/Sketch_2/Face-SketchCircle_2_2r")], model.selection(), 12, 0)
+Fuse_1 = model.addFuse(Part_1_doc, [model.selection("COMPOUND", "all-in-Extrusion_1"), model.selection("COMPOUND", "all-in-Extrusion_2")], keepSubResults = True)
+ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), [model.selection("COMPOUND", "all-in-Fuse_1")])
+Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Fuse_1_1/Modified_Face&Extrusion_1_1/To_Face"))
+SketchCircle_3 = Sketch_3.addCircle(32, 10, 2)
+ExtrusionCut_1.setNestedSketch(Sketch_3)
+Group_1 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Extrusion_2_1/To_Face")])
+model.end()
+
+# cause the update in the history for the group
+model.begin()
+Part_1_doc.setCurrentFeature(Fuse_1.feature(), True)
+model.do()
+Part_1_doc.setCurrentFeature(Group_1.feature(), True)
+model.end()
+
+assert(ExtrusionCut_1.feature().firstResult().shape().isSubShape(Group_1.groupList().value(0).value()))
+
+assert(model.checkPythonDump())