X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Rotation.cpp;h=f9a11c5c6ac156b1a8c39dbcb62485c48c0836a5;hb=fbb1e5c91c5d6ed1862a7621baca9db73433689e;hp=27b1b859161cfc7f921d12b39b9a49bad5d2c2c2;hpb=b707e7178424958f7dc1ed87a0aabd813f671d88;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp b/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp index 27b1b8591..f9a11c5c6 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp @@ -1,8 +1,22 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: FeaturesPlugin_Rotation.cpp -// Created: 12 May 2015 -// Author: Dmitry Bobylev +// 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 +// #include @@ -109,7 +123,7 @@ void FeaturesPlugin_Rotation::performTranslationByAxisAndAngle() for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); anObjectsIt++, aContext++) { std::shared_ptr aBaseShape = *anObjectsIt; - bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group(); + bool isPart = aContext->get() && (*aContext)->groupName() == ModelAPI_ResultPart::group(); // Setting result. if (isPart) { @@ -120,34 +134,37 @@ void FeaturesPlugin_Rotation::performTranslationByAxisAndAngle() aResultPart->setTrsf(*aContext, aTrsf); setResult(aResultPart, aResultIndex); } else { - GeomAlgoAPI_Rotation aRotationAlgo(aBaseShape, anAxis, anAngle); + std::shared_ptr aRotationAlgo(new GeomAlgoAPI_Rotation(aBaseShape, + anAxis, + anAngle)); - if (!aRotationAlgo.check()) { - setError(aRotationAlgo.getError()); + if (!aRotationAlgo->check()) { + setError(aRotationAlgo->getError()); return; } - aRotationAlgo.build(); + aRotationAlgo->build(); // Checking that the algorithm worked properly. - if(!aRotationAlgo.isDone()) { + if(!aRotationAlgo->isDone()) { static const std::string aFeatureError = "Error: Rotation algorithm failed."; setError(aFeatureError); break; } - if(aRotationAlgo.shape()->isNull()) { + if(aRotationAlgo->shape()->isNull()) { static const std::string aShapeError = "Error: Resulting shape is Null."; setError(aShapeError); break; } - if(!aRotationAlgo.isValid()) { + if(!aRotationAlgo->isValid()) { std::string aFeatureError = "Error: Resulting shape is not valid."; setError(aFeatureError); break; } ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aRotationAlgo, aResultBody, aBaseShape); + aResultBody->storeModified(aBaseShape, aRotationAlgo->shape()); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aRotationAlgo, "Rotated"); setResult(aResultBody, aResultIndex); } aResultIndex++; @@ -224,52 +241,40 @@ void FeaturesPlugin_Rotation::performTranslationByThreePoints() aResultPart->setTrsf(*aContext, aTrsf); setResult(aResultPart, aResultIndex); } else { - GeomAlgoAPI_Rotation aRotationAlgo(aBaseShape, aCenterPoint, aStartPoint, anEndPoint); + std::shared_ptr aRotationAlgo(new GeomAlgoAPI_Rotation(aBaseShape, + aCenterPoint, + aStartPoint, + anEndPoint)); - if (!aRotationAlgo.check()) { - setError(aRotationAlgo.getError()); + if (!aRotationAlgo->check()) { + setError(aRotationAlgo->getError()); return; } - aRotationAlgo.build(); + aRotationAlgo->build(); // Checking that the algorithm worked properly. - if(!aRotationAlgo.isDone()) { + if(!aRotationAlgo->isDone()) { static const std::string aFeatureError = "Error: Rotation algorithm failed."; setError(aFeatureError); break; } - if(aRotationAlgo.shape()->isNull()) { + if(aRotationAlgo->shape()->isNull()) { static const std::string aShapeError = "Error : Resulting shape is Null."; setError(aShapeError); break; } - if(!aRotationAlgo.isValid()) { + if(!aRotationAlgo->isValid()) { std::string aFeatureError = "Error: Resulting shape is not valid."; setError(aFeatureError); break; } ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aRotationAlgo, aResultBody, aBaseShape); + aResultBody->storeModified(aBaseShape, aRotationAlgo->shape()); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aRotationAlgo, "Rotated"); setResult(aResultBody, aResultIndex); } aResultIndex++; } } - -//================================================================================================= -void FeaturesPlugin_Rotation::loadNamingDS(GeomAlgoAPI_Rotation& theRotaionAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape) -{ - // Store result. - theResultBody->storeModified(theBaseShape, theRotaionAlgo.shape()); - - std::string aRotatedName = "Rotated"; - std::shared_ptr aSubShapes = theRotaionAlgo.mapOfSubShapes(); - - FeaturesPlugin_Tools::storeModifiedShapes(theRotaionAlgo, theResultBody, - theBaseShape, 1, 2, 3, aRotatedName, - *aSubShapes.get()); -}