From: mpv Date: Wed, 22 Aug 2018 12:42:01 +0000 (+0300) Subject: Fix for the issue 2592: result after dump study / load script is different from initial X-Git-Tag: SHAPER_V9_1_0RC1~38 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ac249a5b4a0f52388541f290650906591999cca3;p=modules%2Fshaper.git Fix for the issue 2592: result after dump study / load script is different from initial --- diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 98de65383..db68e4533 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -324,4 +324,5 @@ ADD_UNIT_TESTS(TestExtrusion.py TestBooleanCommon_CompSolidCompound_Shell.py TestBooleanCommon_CompSolidCompound_CompSolidCompound.py Test2596.py + Test2592.py ) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp b/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp index d3d058ed3..16e184688 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include @@ -147,27 +149,28 @@ void FeaturesPlugin_Symmetry::performSymmetryByPoint() buildResult(anOrigin, aTrsf, aResultIndex); } else { - GeomAlgoAPI_Symmetry aSymmetryAlgo(aBaseShape, aPoint); + std::shared_ptr aSymmetryAlgo( + new GeomAlgoAPI_Symmetry(aBaseShape, aPoint)); - if (!aSymmetryAlgo.check()) { - setError(aSymmetryAlgo.getError()); + if (!aSymmetryAlgo->check()) { + setError(aSymmetryAlgo->getError()); return; } - aSymmetryAlgo.build(); + aSymmetryAlgo->build(); // Checking that the algorithm worked properly. - if(!aSymmetryAlgo.isDone()) { + if(!aSymmetryAlgo->isDone()) { static const std::string aFeatureError = "Error: Symmetry algorithm failed."; setError(aFeatureError); break; } - if(aSymmetryAlgo.shape()->isNull()) { + if(aSymmetryAlgo->shape()->isNull()) { static const std::string aShapeError = "Error: Resulting shape is Null."; setError(aShapeError); break; } - if(!aSymmetryAlgo.isValid()) { + if(!aSymmetryAlgo->isValid()) { std::string aFeatureError = "Error: Resulting shape is not valid."; setError(aFeatureError); break; @@ -223,27 +226,28 @@ void FeaturesPlugin_Symmetry::performSymmetryByAxis() buildResult(anOrigin, aTrsf, aResultIndex); } else { - GeomAlgoAPI_Symmetry aSymmetryAlgo(aBaseShape, anAxis); + std::shared_ptr aSymmetryAlgo( + new GeomAlgoAPI_Symmetry(aBaseShape, anAxis)); - if (!aSymmetryAlgo.check()) { - setError(aSymmetryAlgo.getError()); + if (!aSymmetryAlgo->check()) { + setError(aSymmetryAlgo->getError()); return; } - aSymmetryAlgo.build(); + aSymmetryAlgo->build(); // Checking that the algorithm worked properly. - if(!aSymmetryAlgo.isDone()) { + if(!aSymmetryAlgo->isDone()) { static const std::string aFeatureError = "Error: Symmetry algorithm failed."; setError(aFeatureError); break; } - if(aSymmetryAlgo.shape()->isNull()) { + if(aSymmetryAlgo->shape()->isNull()) { static const std::string aShapeError = "Error: Resulting shape is Null."; setError(aShapeError); break; } - if(!aSymmetryAlgo.isValid()) { + if(!aSymmetryAlgo->isValid()) { std::string aFeatureError = "Error: Resulting shape is not valid."; setError(aFeatureError); break; @@ -300,27 +304,28 @@ void FeaturesPlugin_Symmetry::performSymmetryByPlane() ResultPartPtr anOrigin = std::dynamic_pointer_cast(*aContext); buildResult(anOrigin, aTrsf, aResultIndex); } else { - GeomAlgoAPI_Symmetry aSymmetryAlgo(aBaseShape, aPlane); + std::shared_ptr aSymmetryAlgo( + new GeomAlgoAPI_Symmetry(aBaseShape, aPlane)); - if (!aSymmetryAlgo.check()) { - setError(aSymmetryAlgo.getError()); + if (!aSymmetryAlgo->check()) { + setError(aSymmetryAlgo->getError()); return; } - aSymmetryAlgo.build(); + aSymmetryAlgo->build(); // Checking that the algorithm worked properly. - if(!aSymmetryAlgo.isDone()) { + if(!aSymmetryAlgo->isDone()) { static const std::string aFeatureError = "Error: Symmetry algorithm failed."; setError(aFeatureError); break; } - if(aSymmetryAlgo.shape()->isNull()) { + if(aSymmetryAlgo->shape()->isNull()) { static const std::string aShapeError = "Error: Resulting shape is Null."; setError(aShapeError); break; } - if(!aSymmetryAlgo.isValid()) { + if(!aSymmetryAlgo->isValid()) { std::string aFeatureError = "Error: Resulting shape is not valid."; setError(aFeatureError); break; @@ -336,24 +341,30 @@ void FeaturesPlugin_Symmetry::performSymmetryByPlane() } //================================================================================================= -void FeaturesPlugin_Symmetry::buildResult(GeomAlgoAPI_Symmetry& theSymmetryAlgo, - std::shared_ptr theBaseShape, - int theResultIndex) +void FeaturesPlugin_Symmetry::buildResult( + std::shared_ptr& theSymmetryAlgo, + std::shared_ptr theBaseShape, int theResultIndex) { + GeomAlgoAPI_MakeShapeList anAlgoList; + anAlgoList.appendAlgo(theSymmetryAlgo); // Compose source shape and the result of symmetry. GeomShapePtr aCompound; if (boolean(KEEP_ORIGINAL_RESULT())->value()) { ListOfShape aShapes; - aShapes.push_back(theBaseShape); - aShapes.push_back(theSymmetryAlgo.shape()); + // add a copy of a base shape otherwise selection of this base shape is bad (2592) + std::shared_ptr aCopyAlgo(new GeomAlgoAPI_Copy(theBaseShape)); + aShapes.push_back(aCopyAlgo->shape()); + anAlgoList.appendAlgo(aCopyAlgo); + + aShapes.push_back(theSymmetryAlgo->shape()); aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes); } else - aCompound = theSymmetryAlgo.shape(); + aCompound = theSymmetryAlgo->shape(); // Store and name the result. ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex); aResultBody->storeModified(theBaseShape, aCompound); - loadNamingDS(theSymmetryAlgo, aResultBody, theBaseShape); + loadNamingDS(anAlgoList, aResultBody, theBaseShape); setResult(aResultBody, theResultIndex); } @@ -376,14 +387,14 @@ void FeaturesPlugin_Symmetry::buildResult(ResultPartPtr theOriginal, } //================================================================================================= -void FeaturesPlugin_Symmetry::loadNamingDS(GeomAlgoAPI_Symmetry& theSymmetryAlgo, +void FeaturesPlugin_Symmetry::loadNamingDS(GeomAlgoAPI_MakeShapeList& theAlgo, std::shared_ptr theResultBody, std::shared_ptr theBaseShape) { // Name the faces - std::shared_ptr aSubShapes = theSymmetryAlgo.mapOfSubShapes(); + std::shared_ptr aSubShapes = theAlgo.mapOfSubShapes(); std::string aReflectedName = "Symmetried"; - FeaturesPlugin_Tools::storeModifiedShapes(theSymmetryAlgo, theResultBody, + FeaturesPlugin_Tools::storeModifiedShapes(theAlgo, theResultBody, theBaseShape, 1, 2, 3, aReflectedName, *aSubShapes.get()); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Symmetry.h b/src/FeaturesPlugin/FeaturesPlugin_Symmetry.h index f0b296b46..a19d143cf 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Symmetry.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Symmetry.h @@ -26,6 +26,7 @@ #include #include +#include class GeomAPI_Trsf; @@ -137,12 +138,12 @@ private: void performSymmetryByPlane(); /// Perform the naming - void loadNamingDS(GeomAlgoAPI_Symmetry& theSymmetryAlgo, + void loadNamingDS(GeomAlgoAPI_MakeShapeList& theSymmetryAlgo, std::shared_ptr theResultBody, std::shared_ptr theBaseShape); /// Create new result on given shapes and the index of result - void buildResult(GeomAlgoAPI_Symmetry& theSymmetryAlgo, + void buildResult(std::shared_ptr& theSymmetryAlgo, std::shared_ptr theBaseShape, int theResultIndex); diff --git a/src/FeaturesPlugin/Test/Test2592.py b/src/FeaturesPlugin/Test/Test2592.py new file mode 100644 index 000000000..d102679c5 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2592.py @@ -0,0 +1,33 @@ +## 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 +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Symmetry_1 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("VERTEX", "Box_1_1/Back&Box_1_1/Left&Box_1_1/Bottom"), True) +Symmetry_2 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Symmetry_1_1_1")], model.selection("EDGE", "PartSet/OX"), True) +model.end() + +# check python dump failed before the bug fix: selection in symmetry 2 changed to the whole symmetry 1 compound +assert(model.checkPythonDump()) diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 7145cfb61..0df4bea8d 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1623,7 +1623,7 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) #ifdef DEBUG_WITH_MESSAGE_REPORT MyTCommunicator->RegisterPlugin("TKMessageView"); #endif - MyTCommunicator->RegisterPlugin("SMBrowser"); // custom plugin to view ModelAPI + //MyTCommunicator->RegisterPlugin("SMBrowser"); // custom plugin to view ModelAPI //MyTCommunicator->RegisterPlugin("TKSMBrowser"); // custom plugin to view ModelAPI MyTCommunicator->Init(aParameters);