- // Moving each object.
- 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)->groupName() == ModelAPI_ResultPart::group();
-
- // Setting result.
- if (isPart) {
- std::shared_ptr<GeomAPI_Trsf> aTrsf(new GeomAPI_Trsf());
- aTrsf->setSymmetry(aPoint);
- ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
- ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex);
- aResultPart->setTrsf(*aContext, aTrsf);
- setResult(aResultPart, aResultIndex);
- } else {
- GeomAlgoAPI_Symmetry aSymmetryAlgo(aBaseShape, aPoint);
-
- if (!aSymmetryAlgo.check()) {
- setError(aSymmetryAlgo.getError());
- return;
- }
-
- aSymmetryAlgo.build();
-
- // Checking that the algorithm worked properly.
- if(!aSymmetryAlgo.isDone()) {
- static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
- setError(aFeatureError);
- break;
- }
- if(aSymmetryAlgo.shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape is Null.";
- setError(aShapeError);
- break;
- }
- if(!aSymmetryAlgo.isValid()) {
- std::string aFeatureError = "Error: Resulting shape is not valid.";
- setError(aFeatureError);
- break;
- }
-
- ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- loadNamingDS(aSymmetryAlgo, aResultBody, aBaseShape);
- setResult(aResultBody, aResultIndex);
+ GeomTrsfPtr aTrsf(new GeomAPI_Trsf);
+ aTrsf->setSymmetry(aPoint);
+ return aTrsf;
+}
+
+//=================================================================================================
+GeomTrsfPtr FeaturesPlugin_Symmetry::symmetryByAxis()
+{
+ //Getting axis.
+ static const std::string aSelectionError = "Error: The axis shape selection is bad.";
+ AttributeSelectionPtr anObjRef = selection(AXIS_OBJECT_ID());
+ GeomShapePtr aShape = anObjRef->value();
+ if (!aShape.get()) {
+ if (anObjRef->context().get()) {
+ aShape = anObjRef->context()->shape();