X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Scale.cpp;h=bdb4cdd52fde517cc999053ac555b78368b7d3f9;hb=e60b61962b051180dab78bb91977d58d59ca7614;hp=4e854c22a5f491e742f68ad57121d9b4c916382b;hpb=95bf0a0de36129d80569e2b4634650b9cc38733e;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Scale.cpp b/src/FeaturesPlugin/FeaturesPlugin_Scale.cpp index 4e854c22a..bdb4cdd52 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Scale.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Scale.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// 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 @@ -12,15 +12,15 @@ // // 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 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include #include +#include #include #include @@ -90,7 +90,6 @@ void FeaturesPlugin_Scale::performScaleByFactor() anObjectsSelList->value(anObjectsIndex); std::shared_ptr anObject = anObjectAttr->value(); if(!anObject.get()) { // may be for not-activated parts - eraseResults(); return; } anObjects.push_back(anObject); @@ -115,39 +114,38 @@ void FeaturesPlugin_Scale::performScaleByFactor() double aScaleFactor = real(FeaturesPlugin_Scale::SCALE_FACTOR_ID())->value(); // Moving each object. + std::string anError; int aResultIndex = 0; std::list::iterator aContext = aContextes.begin(); for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); anObjectsIt++, aContext++) { std::shared_ptr aBaseShape = *anObjectsIt; - GeomAlgoAPI_Scale aScaleAlgo(aBaseShape, aCenterPoint, aScaleFactor); + std::shared_ptr aScaleAlgo( + new GeomAlgoAPI_Scale(aBaseShape, aCenterPoint, aScaleFactor)); - if (!aScaleAlgo.check()) { - setError(aScaleAlgo.getError()); + if (!aScaleAlgo->check()) { + setError(aScaleAlgo->getError()); return; } - aScaleAlgo.build(); + aScaleAlgo->build(); // Checking that the algorithm worked properly. - if(!aScaleAlgo.isDone()) { - static const std::string aFeatureError = "Error: Symmetry algorithm failed."; - setError(aFeatureError); - break; - } - if(aScaleAlgo.shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - break; - } - if(!aScaleAlgo.isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aScaleAlgo, getKind(), anError)) { + setError(anError); break; } ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aScaleAlgo, aResultBody, aBaseShape); + + ListOfShape aShapes; + aShapes.push_back(aBaseShape); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aShapes, + ListOfShape(), + aScaleAlgo, + aScaleAlgo->shape(), + "Scaled"); setResult(aResultBody, aResultIndex); aResultIndex++; } @@ -172,7 +170,6 @@ void FeaturesPlugin_Scale::performScaleByDimensions() anObjectsSelList->value(anObjectsIndex); std::shared_ptr anObject = anObjectAttr->value(); if(!anObject.get()) { // may be for not-activated parts - eraseResults(); return; } anObjects.push_back(anObject); @@ -199,40 +196,41 @@ void FeaturesPlugin_Scale::performScaleByDimensions() double aScaleFactorZ = real(FeaturesPlugin_Scale::SCALE_FACTOR_Z_ID())->value(); // Moving each object. + std::string anError; int aResultIndex = 0; std::list::iterator aContext = aContextes.begin(); for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); anObjectsIt++, aContext++) { std::shared_ptr aBaseShape = *anObjectsIt; - GeomAlgoAPI_Scale aScaleAlgo(aBaseShape, aCenterPoint, - aScaleFactorX, aScaleFactorY, aScaleFactorZ); - - if (!aScaleAlgo.check()) { - setError(aScaleAlgo.getError()); + std::shared_ptr aScaleAlgo(new GeomAlgoAPI_Scale(aBaseShape, + aCenterPoint, + aScaleFactorX, + aScaleFactorY, + aScaleFactorZ)); + + if (!aScaleAlgo->check()) { + setError(aScaleAlgo->getError()); return; } - aScaleAlgo.build(); + aScaleAlgo->build(); // Checking that the algorithm worked properly. - if(!aScaleAlgo.isDone()) { - static const std::string aFeatureError = "Error: Symmetry algorithm failed."; - setError(aFeatureError); - break; - } - if(aScaleAlgo.shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - break; - } - if(!aScaleAlgo.isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aScaleAlgo, getKind(), anError)) { + setError(anError); break; } ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aScaleAlgo, aResultBody, aBaseShape); + + ListOfShape aShapes; + aShapes.push_back(aBaseShape); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aShapes, + ListOfShape(), + aScaleAlgo, + aScaleAlgo->shape(), + "Scaled"); setResult(aResultBody, aResultIndex); aResultIndex++; } @@ -240,19 +238,3 @@ void FeaturesPlugin_Scale::performScaleByDimensions() // Remove the rest results if there were produced in the previous pass. removeResults(aResultIndex); } - -//================================================================================================= -void FeaturesPlugin_Scale::loadNamingDS(GeomAlgoAPI_Scale& theScaleAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape) -{ - // Store and name the result. - theResultBody->storeModified(theBaseShape, theScaleAlgo.shape()); - - // Name the faces - std::shared_ptr aSubShapes = theScaleAlgo.mapOfSubShapes(); - std::string aScaledName = "Scaled"; - FeaturesPlugin_Tools::storeModifiedShapes(theScaleAlgo, theResultBody, - theBaseShape, 1, 2, 3, aScaledName, - *aSubShapes.get()); -}