-// Copyright (C) 2014-2016 CEA/DEN, EDF R&D
-
-// File: FeaturesPlugin_Translation.cpp
-// Created: 8 June 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>
//
-// Modified by Clarisse Genrault (CEA) : 17 Nov 2016
#include <FeaturesPlugin_Translation.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Lin.h>
+#include <GeomAPI_Trsf.h>
#include <GeomAlgoAPI_PointBuilder.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_Translation aTranslationAlgo(aBaseShape, anAxis, aDistance);
+ std::shared_ptr<GeomAlgoAPI_Translation> aTranslationAlgo(
+ new GeomAlgoAPI_Translation(aBaseShape, anAxis, aDistance));
- if (!aTranslationAlgo.check()) {
- setError(aTranslationAlgo.getError());
+ if (!aTranslationAlgo->check()) {
+ setError(aTranslationAlgo->getError());
return;
}
- aTranslationAlgo.build();
+ aTranslationAlgo->build();
// Checking that the algorithm worked properly.
- if(!aTranslationAlgo.isDone()) {
+ if(!aTranslationAlgo->isDone()) {
static const std::string aFeatureError = "Error: Translation algorithm failed.";
setError(aFeatureError);
break;
}
- if(aTranslationAlgo.shape()->isNull()) {
+ if(aTranslationAlgo->shape()->isNull()) {
static const std::string aShapeError = "Error: Resulting shape is Null.";
setError(aShapeError);
break;
}
- if(!aTranslationAlgo.isValid()) {
+ if(!aTranslationAlgo->isValid()) {
std::string aFeatureError = "Error: Resulting shape is not valid.";
setError(aFeatureError);
break;
}
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape);
+ aResultBody->storeModified(aBaseShape, aTranslationAlgo->shape());
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ aBaseShape,
+ aTranslationAlgo,
+ "Translated");
setResult(aResultBody, aResultIndex);
}
aResultIndex++;
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_Translation aTranslationAlgo(aBaseShape, aDX, aDY, aDZ);
+ std::shared_ptr<GeomAlgoAPI_Translation> aTranslationAlgo(
+ new GeomAlgoAPI_Translation(aBaseShape, aDX, aDY, aDZ));
- if (!aTranslationAlgo.check()) {
- setError(aTranslationAlgo.getError());
+ if (!aTranslationAlgo->check()) {
+ setError(aTranslationAlgo->getError());
return;
}
- aTranslationAlgo.build();
+ aTranslationAlgo->build();
// Checking that the algorithm worked properly.
- if(!aTranslationAlgo.isDone()) {
+ if(!aTranslationAlgo->isDone()) {
static const std::string aFeatureError = "Error: Translation algorithm failed.";
setError(aFeatureError);
break;
}
- if(aTranslationAlgo.shape()->isNull()) {
+ if(aTranslationAlgo->shape()->isNull()) {
static const std::string aShapeError = "Error: Resulting shape is Null.";
setError(aShapeError);
break;
}
- if(!aTranslationAlgo.isValid()) {
+ if(!aTranslationAlgo->isValid()) {
std::string aFeatureError = "Error: Resulting shape is not valid.";
setError(aFeatureError);
break;
}
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape);
+ aResultBody->storeModified(aBaseShape, aTranslationAlgo->shape());
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ aBaseShape,
+ aTranslationAlgo,
+ "Translated");
setResult(aResultBody, aResultIndex);
}
aResultIndex++;
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_Translation aTranslationAlgo(aBaseShape, aFirstPoint, aSecondPoint);
+ std::shared_ptr<GeomAlgoAPI_Translation> aTranslationAlgo(
+ new GeomAlgoAPI_Translation(aBaseShape, aFirstPoint, aSecondPoint));
- if (!aTranslationAlgo.check()) {
- setError(aTranslationAlgo.getError());
+ if (!aTranslationAlgo->check()) {
+ setError(aTranslationAlgo->getError());
return;
}
- aTranslationAlgo.build();
+ aTranslationAlgo->build();
// Checking that the algorithm worked properly.
- if(!aTranslationAlgo.isDone()) {
+ if(!aTranslationAlgo->isDone()) {
static const std::string aFeatureError = "Error: Translation algorithm failed.";
setError(aFeatureError);
break;
}
- if(aTranslationAlgo.shape()->isNull()) {
+ if(aTranslationAlgo->shape()->isNull()) {
static const std::string aShapeError = "Error: Resulting shape is Null.";
setError(aShapeError);
break;
}
- if(!aTranslationAlgo.isValid()) {
+ if(!aTranslationAlgo->isValid()) {
std::string aFeatureError = "Error: Resulting shape is not valid.";
setError(aFeatureError);
break;
}
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape);
+ aResultBody->storeModified(aBaseShape, aTranslationAlgo->shape());
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ aBaseShape,
+ aTranslationAlgo,
+ "Translated");
setResult(aResultBody, aResultIndex);
}
aResultIndex++;
// Remove the rest results if there were produced in the previous pass.
removeResults(aResultIndex);
}
-
-//=================================================================================================
-void FeaturesPlugin_Translation::loadNamingDS(GeomAlgoAPI_Translation& theTranslationAlgo,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::shared_ptr<GeomAPI_Shape> theBaseShape)
-{
- // Store result.
- theResultBody->storeModified(theBaseShape, theTranslationAlgo.shape());
-
- std::string aTranslatedName = "Translated";
- std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theTranslationAlgo.mapOfSubShapes();
-
- FeaturesPlugin_Tools::storeModifiedShapes(theTranslationAlgo, theResultBody,
- theBaseShape, 1, 2, 3, aTranslatedName,
- *aSubShapes.get());
-}