-// 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<mailto:webmaster.salome@opencascade.com>
+//
#include <FeaturesPlugin_Rotation.h>
for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
anObjectsIt++, aContext++) {
std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
- bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group();
+ bool isPart = aContext->get() && (*aContext)->groupName() == ModelAPI_ResultPart::group();
// Setting result.
if (isPart) {
aResultPart->setTrsf(*aContext, aTrsf);
setResult(aResultPart, aResultIndex);
} else {
- GeomAlgoAPI_Rotation aRotationAlgo(aBaseShape, anAxis, anAngle);
+ std::shared_ptr<GeomAlgoAPI_Rotation> 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++;
aResultPart->setTrsf(*aContext, aTrsf);
setResult(aResultPart, aResultIndex);
} else {
- GeomAlgoAPI_Rotation aRotationAlgo(aBaseShape, aCenterPoint, aStartPoint, anEndPoint);
+ std::shared_ptr<GeomAlgoAPI_Rotation> 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<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape)
-{
- // Store result.
- theResultBody->storeModified(theBaseShape, theRotaionAlgo.shape());
-
- std::string aRotatedName = "Rotated";
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theRotaionAlgo.mapOfSubShapes();
-
- FeaturesPlugin_Tools::storeModifiedShapes(theRotaionAlgo, theResultBody,
- theBaseShape, 1, 2, 3, aRotatedName,
- *aSubShapes.get());
-}