Salome HOME
Fix for the issue #20170 [CEA] Error when loading python dump: attribute "ExternalFea...
authormpv <mpv@opencascade.com>
Tue, 13 Oct 2020 07:58:42 +0000 (10:58 +0300)
committermpv <mpv@opencascade.com>
Tue, 13 Oct 2020 07:58:42 +0000 (10:58 +0300)
Also non-regression unit-test is added.

src/Model/Model_BodyBuilder.cpp
src/ModelAPI/CMakeLists.txt
src/ModelAPI/Test/Test20170.py [new file with mode: 0644]

index 6c3a491c5c22301e60d24268f70f4e0a0292a022..1a41196fc8a96b198e3e3dcac79a30cac7d47661 100644 (file)
@@ -714,7 +714,9 @@ void Model_BodyBuilder::loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
     bool anOldSubShapeNotInTree =
       !isShapeInTree(aData->shapeLab(), anAccess2, anOldSubShape_, anOriginalLabel);
     if (anOldSubShapeAlreadyProcessed || anOldSubShapeNotInTree) {
-      if (theSaveOldIfNotInTree) {
+      // The second condition is added due to #20170 because sub-shape must be added to real parent shape,
+      // not the reference. The naming name of pure reference is not registered in the document.
+      if (theSaveOldIfNotInTree && !aData->shapeLab().IsAttribute(TDF_Reference::GetID())) {
         std::string aSelectionName = theName + "Selected";
         generated(anOldSubShape, aSelectionName, false);
       } else
index dd2f4acd920a972c11e1a6715dc2eca41ec5d271..68b34a17718cdbc45fd0fb9155d4f5e2ed63b625 100644 (file)
@@ -267,4 +267,5 @@ ADD_UNIT_TESTS(TestConstants.py
                Test19912.py
                Test19932.py
                Test19989.py
+               Test20170.py
 )
diff --git a/src/ModelAPI/Test/Test20170.py b/src/ModelAPI/Test/Test20170.py
new file mode 100644 (file)
index 0000000..d3ed72e
--- /dev/null
@@ -0,0 +1,35 @@
+# 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()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchCircle_1 = Sketch_1.addCircle(8, 23, 2.5)
+SketchCircle_2 = Sketch_1.addCircle(14, 17, 2.5)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r"), model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f")], model.selection(), 10, 0)
+Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_1_2")])
+Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Compound_1_1_2/Modified_Face&Sketch_1/SketchCircle_2_2][Compound_1_1_2/Modified_Face&Extrusion_1_2/To_Face]")], 2, keepSubResults = True)
+Group_1 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Fillet_1_1_2/GF:Fillet&Fillet_1_1_2/FilletSelected")])
+model.end()
+
+assert(model.checkPythonDump())