X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_MultiTranslation.cpp;h=b9af9671352fd044aa1e628b1af8dad648aa5916;hb=7417054f9f86129249fdfd652f804183484986ee;hp=ffe7c5b25ab7d3cb87b6cbf04ce78ee7a6cd386b;hpb=bc250222327d0b3f7e67fb35f0a1967c746e1fc6;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp b/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp index ffe7c5b25..b9af96713 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.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,17 @@ // // 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 #include #include @@ -87,6 +89,7 @@ void FeaturesPlugin_MultiTranslation::performOneDirection() AttributeSelectionListPtr anObjectsSelList = selectionList(FeaturesPlugin_MultiTranslation::OBJECTS_LIST_ID()); if (anObjectsSelList->size() == 0) { + setError("Error: empty selection list"); return; } for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) { @@ -124,11 +127,6 @@ void FeaturesPlugin_MultiTranslation::performOneDirection() GeomAPI_ShapeIterator anIt(aShape); anEdge = anIt.current()->edge(); } - else - { - setError(aSelectionError); - return; - } if (!anEdge.get()) { @@ -173,8 +171,10 @@ void FeaturesPlugin_MultiTranslation::performOneDirection() aResultIndex++; } } else { + std::string anError; ListOfShape aListOfShape; - std::list > aListOfTranslationAlgo; + std::shared_ptr + aListOfTranslationAlgo(new GeomAlgoAPI_MakeShapeList); for (int i=0; i aTranslationAlgo( @@ -188,29 +188,22 @@ void FeaturesPlugin_MultiTranslation::performOneDirection() aTranslationAlgo->build(); // Checking that the algorithm worked properly. - if (!aTranslationAlgo->isDone()) { - static const std::string aFeatureError = "Error : Multitranslation algorithm failed."; - setError(aFeatureError); - break; - } - if (aTranslationAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error : Resulting shape is null."; - setError(aShapeError); - break; - } - if (!aTranslationAlgo->isValid()) { - static const std::string aFeatureError = "Error : Resulting shape in not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed( + aTranslationAlgo, getKind(), anError)) { + setError(anError); break; } aListOfShape.push_back(aTranslationAlgo->shape()); - aListOfTranslationAlgo.push_back(aTranslationAlgo); + aListOfTranslationAlgo->appendAlgo(aTranslationAlgo); } std::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aListOfShape); ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - aResultBody->storeModified(aBaseShape, aCompound); - loadNamingDS(aListOfTranslationAlgo, aResultBody, aBaseShape); + + ListOfShape aBaseShapes; + aBaseShapes.push_back(aBaseShape); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(), + aListOfTranslationAlgo, aCompound, "Translated"); setResult(aResultBody, aResultIndex); } @@ -230,6 +223,7 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection() AttributeSelectionListPtr anObjectsSelList = selectionList(FeaturesPlugin_MultiTranslation::OBJECTS_LIST_ID()); if (anObjectsSelList->size() == 0) { + setError("Error: empty selection list"); return; } for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) { @@ -267,11 +261,6 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection() GeomAPI_ShapeIterator anIt(aShape); anEdge = anIt.current()->edge(); } - else - { - setError(aSelectionError); - return; - } if (!anEdge.get()) { @@ -304,11 +293,6 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection() GeomAPI_ShapeIterator anIt(aShape); anEdge = anIt.current()->edge(); } - else - { - setError(aSelectionError); - return; - } if (!anEdge.get()) { @@ -380,8 +364,10 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection() } } } else { + std::string anError; ListOfShape aListOfShape; - std::list > aListOfTranslationAlgo; + std::shared_ptr + aListOfTranslationAlgo(new GeomAlgoAPI_MakeShapeList); for (int j=0; jbuild(); // Checking that the algorithm worked properly. - if (!aTranslationAlgo->isDone()) { - static const std::string aFeatureError = "Error : Multitranslation algorithm failed."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed( + aTranslationAlgo, getKind(), anError)) { + setError(anError); break; } - if (aTranslationAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error : Resulting shape is null."; - setError(aShapeError); - break; - } - if (!aTranslationAlgo->isValid()) { - static const std::string aFeatureError = "Error : Resulting shape in not valid."; - setError(aFeatureError); - break; - } aListOfShape.push_back(aTranslationAlgo->shape()); - aListOfTranslationAlgo.push_back(aTranslationAlgo); + aListOfTranslationAlgo->appendAlgo(aTranslationAlgo); } } std::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aListOfShape); ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - aResultBody->storeModified(aBaseShape, aCompound); - loadNamingDS(aListOfTranslationAlgo, aResultBody, aBaseShape); + + ListOfShape aBaseShapes; + aBaseShapes.push_back(aBaseShape); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(), + aListOfTranslationAlgo, aCompound, "Translated"); + setResult(aResultBody, aResultIndex); } aResultIndex++; @@ -431,31 +411,3 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection() // Remove the rest results if there were produced in the previous pass. removeResults(aResultIndex); } - -//================================================================================================= -void FeaturesPlugin_MultiTranslation::loadNamingDS( - std::list > theListOfTranslationAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape) -{ - for (std::list >::const_iterator anIt = - theListOfTranslationAlgo.begin(); anIt != theListOfTranslationAlgo.cend(); ++anIt) { - // naming of faces - theResultBody->loadModifiedShapes(*anIt, - theBaseShape, - GeomAPI_Shape::FACE, - "Translated_Face"); - - // naming of edges - theResultBody->loadModifiedShapes(*anIt, - theBaseShape, - GeomAPI_Shape::EDGE, - "Translated_Edge"); - - // naming of vertex - theResultBody->loadModifiedShapes(*anIt, - theBaseShape, - GeomAPI_Shape::VERTEX, - "Translated_Vertex"); - } -}