- // Rotating 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->setRotation(anAxis, anAngle);
- 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_Rotation> aRotationAlgo(new GeomAlgoAPI_Rotation(aBaseShape,
- anAxis,
- anAngle));
-
- if (!aRotationAlgo->check()) {
- setError(aRotationAlgo->getError());
- return;
- }
-
- aRotationAlgo->build();
-
- // Checking that the algorithm worked properly.
- if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aRotationAlgo, getKind(), anError)) {
- setError(anError);
- break;
- }
-
- ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-
- ListOfShape aShapes;
- aShapes.push_back(aBaseShape);
- FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
- aShapes,
- ListOfShape(),
- aRotationAlgo,
- aRotationAlgo->shape(),
- "Rotated");
- setResult(aResultBody, aResultIndex);
- }
- aResultIndex++;
- }
-
- // Remove the rest results if there were produced in the previous pass.
- removeResults(aResultIndex);