Salome HOME
Fir for the issue #3020 : Error in console after dump/load python script.
authormpv <mpv@opencascade.com>
Thu, 26 Sep 2019 13:45:45 +0000 (16:45 +0300)
committermpv <mpv@opencascade.com>
Thu, 26 Sep 2019 13:45:45 +0000 (16:45 +0300)
Fixed the problem of dump naming name of selected circle center of the other part.

src/Model/Model_AttributeIntArray.cpp
src/Model/Model_AttributeSelection.cpp
src/ModelAPI/CMakeLists.txt
src/ModelAPI/Test/Test3020.py [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_SketchEntity.h

index 3ee8a25dec8776e40f3ef32a561e20ec95510fea..3ee99ee6af12816746d0d9833473e54c1333b34b 100644 (file)
@@ -39,7 +39,7 @@ int Model_AttributeIntArray::size()
     myIsInitialized = myLab.FindAttribute(TDataStd_IntegerArray::GetID(), myArray) == Standard_True;
   }
   // checking the validity because attribute (as a field) may be presented,
-  // but without label: it is undoed
+  // but without label: it is undone
   return (myArray.IsNull() || !myArray->IsValid()) ? 0 : myArray->Length();
 }
 
@@ -52,7 +52,7 @@ void Model_AttributeIntArray::setSize(const int theSize)
     }
   } else { // reset the old array
     if (theSize) {
-      if (theSize != myArray->Length()) { // old data is not keept, a new array is created
+      if (theSize != myArray->Length()) { // old data is not kept, a new array is created
         Handle(TColStd_HArray1OfInteger) aNewArray = new TColStd_HArray1OfInteger(0, theSize - 1);
         myArray->ChangeArray(aNewArray);
         owner()->data()->sendAttributeUpdated(this);
index 41df2868ae3046805af2afb7565384ee8c464f20..e7a974e2e9f10be824427173820da54894455d5d 100644 (file)
@@ -785,14 +785,13 @@ std::string Model_AttributeSelection::namingName(const std::string& theDefaultNa
   if (aCont->groupName() == ModelAPI_ResultPart::group()) {
     ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aCont);
     int anIndex;
-    GeomShapePtr aValue = value();
-    if (aValue.get())
-      return aPart->data()->name() + "/" + aPart->nameInPart(aValue, anIndex);
-    else
-      return aPart->data()->name();
+    std::string aResult = aSubSh.get() ?
+      aPart->data()->name() + "/" + aPart->nameInPart(aSubSh, anIndex) : aPart->data()->name();
+    if (aCenterType != NOT_CENTER)
+      aResult += centersMap()[aCenterType];
+    return aResult;
   }
 
-
   // whole infinitive construction
   if (aCont->groupName() == ModelAPI_ResultConstruction::group()) {
     ResultConstructionPtr aConstr = std::dynamic_pointer_cast<Model_ResultConstruction>(aCont);
index 2fe3426cedb429b7217c267e3522f6dd7123cc5e..1ef43263f40abdae8a3f11daf77b0c21f49d7d9c 100644 (file)
@@ -253,4 +253,5 @@ ADD_UNIT_TESTS(TestConstants.py
                Test2873.py
                Test2901.py
                Test2903.py
+               Test3020.py
 )
diff --git a/src/ModelAPI/Test/Test3020.py b/src/ModelAPI/Test/Test3020.py
new file mode 100644 (file)
index 0000000..429dd91
--- /dev/null
@@ -0,0 +1,42 @@
+# Copyright (C) 2014-2019  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
+from ModelAPI import *
+
+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(25, 20, 10)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 20, 0)
+Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face"))
+SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face]__cc"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchCircle_2 = Sketch_2.addCircle(25, 20, 5)
+SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchPoint_1.result(), SketchCircle_2.center())
+model.end()
+# check the sketch_2 projection and the whole sketch is valid after selection of the circle center from another part
+aFactory = ModelAPI_Session.get().validators()
+assert(aFactory.validate(SketchProjection_1.feature()))
+assert(aFactory.validate(Sketch_2.feature()))
+
+assert(model.checkPythonDump())
index c207dd72b264b3f279483e3fa17021978e59a006..eb50851fa4b2552de343f896214801e0163c321a 100644 (file)
@@ -156,7 +156,7 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
       if (theResult.get() && ModelAPI_Session::get()->isOperation()) {
         AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID());
         aColorAttr->setSize(3);
-        // Set the color attribute in order do not use default colors in the perasentation object
+        // Set the color attribute in order do not use default colors in the presentation object
         for (int i = 0; i < 3; i++)
           aColorAttr->setValue(i, aColor[i]);
       }