From: mpv Date: Tue, 30 Oct 2018 12:59:23 +0000 (+0300) Subject: Fix for the issue #2724 : dump with Weak naming selection leads to error X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ac8e892adab98d0f0162feb9bb878d5e695a395d;p=modules%2Fshaper.git Fix for the issue #2724 : dump with Weak naming selection leads to error --- diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 5ea94cb08..b088c904a 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -384,4 +384,5 @@ ADD_UNIT_TESTS(TestExtrusion.py Test2693.py Test2698.py Test2701.py + Test2724.py ) diff --git a/src/FeaturesPlugin/Test/Test2724.py b/src/FeaturesPlugin/Test/Test2724.py new file mode 100644 index 000000000..98272e6d0 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2724.py @@ -0,0 +1,67 @@ +## Copyright (C) 2014-2017 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 +## + +# -*- coding: utf-8 -*- + +from SketchAPI import * + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +model.addParameter(partSet, "b", "80") +model.addParameter(partSet, "a", "100") +model.addParameter(partSet, "c", "b-a") +Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(-60, -20, -60.00000000000001, 80) +SketchLine_2 = Sketch_1.addLine(-60.00000000000001, 80, 0, 0) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchLine_3 = Sketch_1.addLine(0, 0, 0, -100) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchLine_4 = Sketch_1.addLine(0, -100, -60, -20) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint()) +SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_3.result()) +SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_4.result(), SketchLine_3.result()) +SketchConstraintEqual_3 = Sketch_1.setEqual(SketchLine_2.result(), SketchLine_1.result()) +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_3.endPoint(), SketchLine_3.startPoint(), "a", True) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchAPI_Point(SketchPoint_1).coordinates()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_3.result()) +SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine_4.endPoint(), SketchLine_2.endPoint(), 60) +SketchConstraintMirror_1_objects = [SketchLine_4.result(), SketchLine_1.result(), SketchLine_2.result()] +SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_3.result(), SketchConstraintMirror_1_objects) +[SketchLine_5, SketchLine_6, SketchLine_7] = SketchConstraintMirror_1.mirrored() +SketchMultiTranslation_1_objects = [SketchLine_1.result(), SketchLine_4.result(), SketchLine_3.result(), SketchLine_5.result(), SketchLine_6.result()] +SketchMultiTranslation_1 = Sketch_1.addTranslation(SketchMultiTranslation_1_objects, SketchLine_2.endPoint(), SketchLine_4.startPoint(), 4) +[SketchLine_8, SketchLine_9, SketchLine_10, SketchLine_11, SketchLine_12, SketchLine_13, SketchLine_14, SketchLine_15, SketchLine_16, SketchLine_5, SketchLine_17, SketchLine_18, SketchLine_19, SketchLine_6, SketchLine_20, SketchLine_21, SketchLine_22] = SketchMultiTranslation_1.translated() +model.do() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Extrusion_1_objects = [model.selection("FACE", (-30, -10, 0)), model.selection("FACE", (30, -110, 0)), model.selection("FACE", (-30, -210, 0)), model.selection("FACE", (30, -310, 0))] +Extrusion_1 = model.addExtrusion(Part_1_doc, Extrusion_1_objects, model.selection(), "c", 0) +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", (30, -310, -9.999999999999998))], model.selection("EDGE", (-30, -360, 0)), "-c") +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Placement_1 = model.addPlacement(Part_1_doc, [model.selection("SOLID", (-30.00000000000001, -10, -10))], model.selection("FACE", (5, 10, 5)), model.selection("FACE", (-30, 40, -10)), True, True) +Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", (-30.00000000000001, -210, -10)), model.selection("SOLID", (18, -293.9999999999999, -9.999999999999998))]) +model.do() +assert(model.checkPythonDump(True)) +model.end() diff --git a/src/Model/Model_AttributeSelection.h b/src/Model/Model_AttributeSelection.h index 62a3e09af..45b8ba7c2 100644 --- a/src/Model/Model_AttributeSelection.h +++ b/src/Model/Model_AttributeSelection.h @@ -144,6 +144,9 @@ public: MODEL_EXPORT virtual bool isLater(const TDF_Label theResult1, const TDF_Label theResult2) const override; + /// Returns the name by context. Adds the part name if the context is located in other document + MODEL_EXPORT virtual std::string contextName(const ResultPtr& theContext) const; + protected: /// Objects are created for features automatically MODEL_EXPORT Model_AttributeSelection(TDF_Label& theLabel); @@ -177,9 +180,6 @@ protected: /// Sets the ID of the attribute in Data (called from Data): here it is used for myRef ID setting MODEL_EXPORT virtual void setID(const std::string theID); - /// Returns the name by context. Adds the part name if the context is located in other document - std::string contextName(const ResultPtr& theContext) const; - /// Sets the parent attribute void setParent(Model_AttributeSelectionList* theParent); diff --git a/src/ModelAPI/ModelAPI_AttributeSelection.h b/src/ModelAPI/ModelAPI_AttributeSelection.h index 65fd3a6c7..877cc06e5 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelection.h +++ b/src/ModelAPI/ModelAPI_AttributeSelection.h @@ -47,7 +47,7 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute /// \param theContext object where the sub-shape was selected /// \param theSubShape selected sub-shape (if null, the whole context is selected) /// \param theTemporarily if it is true, do not store and name the added in the data framework - /// (used to remove immideately, without the following updates) + /// (used to remove immediately, without the following updates) /// \returns true if attribute was updated virtual bool setValue( const ObjectPtr& theContext, const std::shared_ptr& theSubShape, @@ -78,7 +78,7 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute /// Returns the context of the selection : result or feature virtual std::shared_ptr contextObject() = 0; - /// Updates the underlied selection due to the changes in the referenced objects + /// Updates the selection due to the changes in the referenced objects /// \returns false if update is failed virtual bool update() = 0; @@ -118,6 +118,9 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute /// To virtually destroy the fields of successors MODELAPI_EXPORT virtual ~ModelAPI_AttributeSelection(); + /// Returns the name by context. Adds the part name if the context is located in other document + MODELAPI_EXPORT virtual std::string contextName(const ResultPtr& theContext) const = 0; + protected: /// Objects are created for features automatically diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index 3f39cecb2..c904de30e 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -1101,7 +1101,8 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<( GeomAlgoAPI_NExplode aNExplode(theAttrSelect->context()->shape(), aShape->shapeType()); int anIndex = aNExplode.index(aShape); if (anIndex != 0) { // found a week-naming index, so, export it - myDumpBuffer<<"\", \""<context()->data()->name()<<"\", "<contextName(theAttrSelect->context())<<"\", "<