+
+ ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
+
+ ListOfShape aShapes;
+ aShapes.push_back(aBaseShape);
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+ aShapes,
+ ListOfShape(),
+ aTranslationAlgo,
+ aTranslationAlgo->shape(),
+ "Translated");
+ setResult(aResultBody, aResultIndex);
+ }
+ aResultIndex++;
+ }
+
+ // Remove the rest results if there were produced in the previous pass.
+ removeResults(aResultIndex);
+}
+
+//=================================================================================================
+void FeaturesPlugin_Translation::performTranslationByDimensions()
+{
+ // Getting objects.
+ ListOfShape anObjects;
+ std::list<ResultPtr> aContextes;
+ AttributeSelectionListPtr anObjectsSelList =
+ selectionList(FeaturesPlugin_Translation::OBJECTS_LIST_ID());
+ if (anObjectsSelList->size() == 0) {
+ return;
+ }
+ for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
+ std::shared_ptr<ModelAPI_AttributeSelection> anObjectAttr =
+ anObjectsSelList->value(anObjectsIndex);
+ std::shared_ptr<GeomAPI_Shape> anObject = anObjectAttr->value();
+ if(!anObject.get()) { // may be for not-activated parts
+ return;
+ }
+ anObjects.push_back(anObject);
+ aContextes.push_back(anObjectAttr->context());
+ }
+
+ // Getting dimensions in X, in Y and in Z
+ double aDX = real(FeaturesPlugin_Translation::DX_ID())->value();
+ double aDY = real(FeaturesPlugin_Translation::DY_ID())->value();
+ double aDZ = real(FeaturesPlugin_Translation::DZ_ID())->value();
+
+ // Moving each object.
+ std::string anError;
+ int aResultIndex = 0;
+ std::list<ResultPtr>::iterator aContext = aContextes.begin();
+ for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
+ anObjectsIt++, aContext++) {
+ std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
+ bool isPart = aContext->get() && (*aContext)->groupName() == ModelAPI_ResultPart::group();
+
+ // Setting result.
+ if (isPart) {
+ std::shared_ptr<GeomAPI_Trsf> aTrsf(new GeomAPI_Trsf());
+ aTrsf->setTranslation(aDX, aDY, aDZ);
+ ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
+ ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex);
+ aResultPart->setTrsf(*aContext, aTrsf);
+ setResult(aResultPart, aResultIndex);
+ } else {
+ std::shared_ptr<GeomAlgoAPI_Translation> aTranslationAlgo(
+ new GeomAlgoAPI_Translation(aBaseShape, aDX, aDY, aDZ));
+
+ if (!aTranslationAlgo->check()) {
+ setError(aTranslationAlgo->getError());
+ return;