X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Translation.cpp;h=c3931387cf2de04422574dc778d6052237958fc7;hb=fb54db5e1466b16dfc029c4a7364a67a9a6a8c24;hp=d1ff455a2406fb7ce9d614ec5dbf027b293c41c0;hpb=fbfcc4fd956a374c8d380c2da280c61eaa57bcfd;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp b/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp index d1ff455a2..c3931387c 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp @@ -47,7 +47,8 @@ void FeaturesPlugin_Translation::execute() for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) { std::shared_ptr anObjectAttr = anObjectsSelList->value(anObjectsIndex); std::shared_ptr anObject = anObjectAttr->value(); - if(!anObject.get()) { + if(!anObject.get()) { // may be for not-activated parts + eraseResults(); return; } anObjects.push_back(anObject); @@ -78,34 +79,37 @@ void FeaturesPlugin_Translation::execute() anObjectsIt++, aContext++) { std::shared_ptr aBaseShape = *anObjectsIt; bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group(); - GeomAlgoAPI_Translation aMovementAlgo(aBaseShape, anAxis, aDistance, isPart); - - // Checking that the algorithm worked properly. - if(!aMovementAlgo.isDone()) { - static const std::string aFeatureError = "Movement algorithm failed"; - setError(aFeatureError); - break; - } - if(aMovementAlgo.shape()->isNull()) { - static const std::string aShapeError = "Resulting shape is Null"; - setError(aShapeError); - break; - } - if(!aMovementAlgo.isValid()) { - std::string aFeatureError = "Warning: resulting shape is not valid"; - setError(aFeatureError); - break; - } // Setting result. if (isPart) { + std::shared_ptr aTrsf(new GeomAPI_Trsf()); + aTrsf->setTranslation(anAxis, aDistance); ResultPartPtr anOrigin = std::dynamic_pointer_cast(*aContext); ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex); - aResultPart->setTrsf(*aContext, aMovementAlgo.transformation()); + aResultPart->setTrsf(*aContext, aTrsf); setResult(aResultPart); } else { + GeomAlgoAPI_Translation aTranslationAlgo(aBaseShape, anAxis, aDistance); + + // Checking that the algorithm worked properly. + if(!aTranslationAlgo.isDone()) { + static const std::string aFeatureError = "Error: Translation 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()) { + std::string aFeatureError = "Error: Resulting shape is not valid."; + setError(aFeatureError); + break; + } + ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - LoadNamingDS(aMovementAlgo, aResultBody, aBaseShape); + loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape); setResult(aResultBody, aResultIndex); } aResultIndex++; @@ -115,19 +119,19 @@ void FeaturesPlugin_Translation::execute() removeResults(aResultIndex); } -void FeaturesPlugin_Translation::LoadNamingDS(const GeomAlgoAPI_Translation& theMovementAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape) +void FeaturesPlugin_Translation::loadNamingDS(GeomAlgoAPI_Translation& theTranslationAlgo, + std::shared_ptr theResultBody, + std::shared_ptr theBaseShape) { // Store result. - theResultBody->storeModified(theBaseShape, theMovementAlgo.shape()); + theResultBody->storeModified(theBaseShape, theTranslationAlgo.shape()); - std::shared_ptr aSubShapes = theMovementAlgo.mapOfShapes(); + std::shared_ptr aSubShapes = theTranslationAlgo.mapOfSubShapes(); - int aMovedTag = 1; - std::string aMovedName = "Moved"; - theResultBody->loadAndOrientModifiedShapes(theMovementAlgo.makeShape().get(), - theBaseShape, GeomAPI_Shape::FACE, - aMovedTag, aMovedName, *aSubShapes.get()); + int aTranslatedTag = 1; + std::string aTranslatedName = "Translated"; + theResultBody->loadAndOrientModifiedShapes(&theTranslationAlgo, + theBaseShape, GeomAPI_Shape::FACE, + aTranslatedTag, aTranslatedName, *aSubShapes.get()); }