Salome HOME
updated copyright message
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintMultiRotation.cpp
index 0ceaee69066ce7e0f2c335518a61398c8b8fbafa..03510131e46f1264dba4a55f23da3874a535b1ac 100644 (file)
+// Copyright (C) 2014-2023  CEA, EDF
+//
+// 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
+//
+
 #include <SketchSolver_ConstraintMultiRotation.h>
-#include <SketchSolver_Group.h>
 #include <SketchSolver_Error.h>
+#include <SketchSolver_Manager.h>
 
-#include <SketchPlugin_Arc.h>
-#include <SketchPlugin_MultiRotation.h>
-
-#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_AttributeInteger.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-#include <ModelAPI_ResultConstruction.h>
+#include <PlaneGCSSolver_AttributeBuilder.h>
+#include <PlaneGCSSolver_PointWrapper.h>
+#include <PlaneGCSSolver_ScalarWrapper.h>
+#include <PlaneGCSSolver_UpdateFeature.h>
 
-#include <GeomAPI_Dir2d.h>
-#include <GeomAPI_XY.h>
+#include <SketchPlugin_MultiRotation.h>
 
-#include <math.h>
+#include <ModelAPI_AttributeString.h>
 
-static double squareDistance(
-    StoragePtr theStorage, const Slvs_hEntity& thePoint1, const Slvs_hEntity& thePoint2)
-{
-  Slvs_Entity aPoint1 = theStorage->getEntity(thePoint1);
-  Slvs_Entity aPoint2 = theStorage->getEntity(thePoint2);
-  double x1 = theStorage->getParameter(aPoint1.param[0]).val;
-  double y1 = theStorage->getParameter(aPoint1.param[1]).val;
-  double x2 = theStorage->getParameter(aPoint2.param[0]).val;
-  double y2 = theStorage->getParameter(aPoint2.param[1]).val;
-  return (x1-x2) * (x1-x2) + (y1-y2) * (y1-y2);
-}
+#include <cmath>
 
 void SketchSolver_ConstraintMultiRotation::getAttributes(
-    Slvs_hEntity& theCenter, double& theAngle,
-    std::vector<std::vector<Slvs_hEntity> >& thePoints,
-    std::vector<std::vector<Slvs_hEntity> >& theCircular)
+    EntityWrapperPtr& theCenter, ScalarWrapperPtr& theAngle,
+    bool& theFullValue, bool& theReversed, std::list<EntityWrapperPtr>& theEntities)
 {
-  DataPtr aData = myBaseConstraint->data();
-  theAngle = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
-      aData->attribute(SketchPlugin_MultiRotation::ANGLE_ID()))->value();
-
-  AttributePtr aCenterAttr = aData->attribute(SketchPlugin_MultiRotation::CENTER_ID());
+  AttributePtr anAngleAttr = myBaseConstraint->attribute(SketchPlugin_MultiRotation::ANGLE_ID());
+  PlaneGCSSolver_AttributeBuilder aValueBuilder;
+  theAngle = std::dynamic_pointer_cast<PlaneGCSSolver_ScalarWrapper>(
+      aValueBuilder.createAttribute(anAngleAttr));
+  myStorage->addEntity(anAngleAttr, theAngle);
+
+  AttributeRefAttrPtr aCenterAttr =
+      myBaseConstraint->refattr(SketchPlugin_MultiRotation::CENTER_ID());
   if (!aCenterAttr || !aCenterAttr->isInitialized()) {
     myErrorMsg = SketchSolver_Error::NOT_INITIALIZED();
     return;
   }
-  int aType = SLVS_E_UNKNOWN; // type of created entity
-  Slvs_hEntity anEntityID = myGroup->getAttributeId(aCenterAttr);
-  if (anEntityID == SLVS_E_UNKNOWN)
-    anEntityID = changeEntity(aCenterAttr, aType);
-  theCenter = anEntityID;
 
-  // Lists of objects and number of copies
-  AttributeRefListPtr anInitialRefList = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
-      aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
-  myNumberOfObjects = anInitialRefList->size();
-  myNumberOfCopies = (size_t) aData->integer(SketchPlugin_MultiRotation::NUMBER_OF_COPIES_ID())->value();
-  AttributeRefListPtr aRefList = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
-      myBaseConstraint->attribute(SketchPlugin_Constraint::ENTITY_B()));
-  if (!aRefList) {
-    myErrorMsg = SketchSolver_Error::INCORRECT_ATTRIBUTE();
-    return;
-  }
+  myType = CONSTRAINT_MULTI_ROTATION;
 
-  // Obtain all points of initial features and store them into separate lists
-  // containing their translated copies.
-  // Also all circles and arc collected too, because they will be constrained by equal radii.
-  FeaturePtr aFeature;
-  ResultConstructionPtr aRC;
-  std::vector<Slvs_hEntity> aPoints[2]; // lists of points of features
-  std::vector<Slvs_hEntity> aCircs;     // list of circular objects
-  std::list<ObjectPtr> anObjectList = aRefList->list();
-  std::list<ObjectPtr>::iterator anObjectIter = anObjectList.begin();
-  while (anObjectIter != anObjectList.end()) {
-    aPoints[0].clear();
-    aPoints[1].clear();
-    aCircs.clear();
+  myStorage->update(AttributePtr(aCenterAttr));
+  theCenter = myStorage->entity(AttributePtr(aCenterAttr));
 
-    for (size_t i = 0; i <= myNumberOfCopies && anObjectIter != anObjectList.end(); i++, anObjectIter++) {
-      aFeature = ModelAPI_Feature::feature(*anObjectIter);
-      if (!aFeature)
-        continue;
-      anEntityID = changeEntity(aFeature, aType);
-      Slvs_Entity anEntity = myStorage->getEntity(anEntityID);
-      switch (aType) {
-      case SLVS_E_POINT_IN_2D:
-      case SLVS_E_POINT_IN_3D:
-        aPoints[0].push_back(anEntityID);
-        break;
-      case SLVS_E_LINE_SEGMENT:
-        aPoints[0].push_back(anEntity.point[0]); // start point of line
-        aPoints[1].push_back(anEntity.point[1]); // end point of line
-        break;
-      case SLVS_E_CIRCLE:
-        aPoints[0].push_back(anEntity.point[0]); // center of circle
-        aCircs.push_back(anEntityID);
-        break;
-      case SLVS_E_ARC_OF_CIRCLE:
-        aPoints[0].push_back(anEntity.point[1]); // start point of arc
-        aPoints[1].push_back(anEntity.point[2]); // end point of arc
-        aCircs.push_back(anEntityID);
-        break;
-      default:
-        myErrorMsg = SketchSolver_Error::INCORRECT_ATTRIBUTE();
-        return;
-      }
-    }
+  AttributeStringPtr aMethodTypeAttr =
+      myBaseConstraint->string(SketchPlugin_MultiRotation::ANGLE_TYPE());
+  theFullValue = aMethodTypeAttr->value() != "SingleAngle";
 
-    if (!aPoints[0].empty())
-      thePoints.push_back(aPoints[0]);
-    if (!aPoints[1].empty())
-      thePoints.push_back(aPoints[1]);
-    if (!aCircs.empty())
-      theCircular.push_back(aCircs);
-  }
+  theReversed = myBaseConstraint->boolean(SketchPlugin_MultiRotation::REVERSED_ID())->value();
+
+  getEntities(theEntities);
+
+  // add owner of central point of Multi-Rotation to the list of monitored features
+  FeaturePtr anOwner = ModelAPI_Feature::feature(aCenterAttr->attr()->owner());
+  if (anOwner)
+    myOriginalFeatures.insert(anOwner);
 }
 
 void SketchSolver_ConstraintMultiRotation::process()
 {
   cleanErrorMsg();
-  if (!myBaseConstraint || !myStorage || myGroup == 0) {
-    /// TODO: Put error message here
+  if (!myBaseConstraint || !myStorage) {
+    // Not enough parameters are assigned
     return;
   }
-  if (!mySlvsConstraints.empty()) // some data is changed, update constraint
-    update(myBaseConstraint);
 
-  Slvs_hEntity aCenter;
-  std::vector<std::vector<Slvs_hEntity> > aPointsAndCopies;
-  std::vector<std::vector<Slvs_hEntity> > aCircsAndCopies;
-  getAttributes(aCenter, myAngle, aPointsAndCopies, aCircsAndCopies);
+  EntityWrapperPtr aRotationCenter;
+  std::list<EntityWrapperPtr> aBaseEntities;
+  getAttributes(aRotationCenter, myAngle, myIsFullValue, myIsRevered, aBaseEntities);
   if (!myErrorMsg.empty())
     return;
 
-  myAuxLines.clear();
-
-  // Create lines between neighbor rotated points and make angle between them equal to anAngle.
-  // Also these lines should have equal lengths.
-  Slvs_Constraint aConstraint;
-  myRotationCenter = aCenter;
-  Slvs_Entity aPrevLine;
-  std::vector<std::vector<Slvs_hEntity> >::iterator aCopyIter = aPointsAndCopies.begin();
-  for (; aCopyIter != aPointsAndCopies.end(); aCopyIter++) {
-    size_t aSize = aCopyIter->size();
-    if (aSize <= 1) continue;
-
-    aPrevLine = Slvs_MakeLineSegment(SLVS_E_UNKNOWN, myGroup->getId(),
-          myGroup->getWorkplaneId(), aCenter, (*aCopyIter)[0]);
-    aPrevLine.h = myStorage->addEntity(aPrevLine);
-    std::vector<Slvs_hEntity> anEqualLines(1, aPrevLine.h);
-    for (size_t i = 1; i < aSize; i++) {
-      Slvs_Entity aLine = Slvs_MakeLineSegment(SLVS_E_UNKNOWN, myGroup->getId(),
-          myGroup->getWorkplaneId(), aCenter, (*aCopyIter)[i]);
-      aLine.h = myStorage->addEntity(aLine);
-      // Equal length constraint
-      aConstraint = Slvs_MakeConstraint(SLVS_E_UNKNOWN, myGroup->getId(),
-          SLVS_C_EQUAL_LENGTH_LINES, myGroup->getWorkplaneId(), 0.0,
-          SLVS_E_UNKNOWN, SLVS_E_UNKNOWN, aPrevLine.h, aLine.h);
-      aConstraint.h = myStorage->addConstraint(aConstraint);
-      mySlvsConstraints.push_back(aConstraint.h);
-      // Angle constraint
-      aConstraint = Slvs_MakeConstraint(SLVS_E_UNKNOWN, myGroup->getId(),
-          SLVS_C_ANGLE, myGroup->getWorkplaneId(), fabs(myAngle), SLVS_E_UNKNOWN, SLVS_E_UNKNOWN,
-          aPrevLine.h, aLine.h);
-      if (myAngle < 0.0) // clockwise rotation
-        aConstraint.other = true;
-      aConstraint.h = myStorage->addConstraint(aConstraint);
-      mySlvsConstraints.push_back(aConstraint.h);
-
-      aPrevLine = aLine;
-      anEqualLines.push_back(aPrevLine.h);
-    }
-
-    myAuxLines.push_back(anEqualLines);
-  }
-  // Equal radii constraints
-  for (aCopyIter = aCircsAndCopies.begin(); aCopyIter != aCircsAndCopies.end(); aCopyIter++) {
-    size_t aSize = aCopyIter->size();
-    for (size_t i = 0; i < aSize - 1; i++) {
-      aConstraint = Slvs_MakeConstraint(SLVS_E_UNKNOWN, myGroup->getId(),
-          SLVS_C_EQUAL_RADIUS, myGroup->getWorkplaneId(), 0.0, SLVS_E_UNKNOWN, SLVS_E_UNKNOWN,
-          (*aCopyIter)[i], (*aCopyIter)[i+1]);
-      aConstraint.h = myStorage->addConstraint(aConstraint);
-      mySlvsConstraints.push_back(aConstraint.h);
-    }
-  }
-
-  // Set the rotation center unchanged during constraint recalculation
-  if (!myStorage->isPointFixed(myRotationCenter, aConstraint.h, true)) {
-    aConstraint = Slvs_MakeConstraint(
-        SLVS_E_UNKNOWN, myGroup->getId(), SLVS_C_WHERE_DRAGGED, myGroup->getWorkplaneId(), 0.0,
-        myRotationCenter, SLVS_E_UNKNOWN, SLVS_E_UNKNOWN, SLVS_E_UNKNOWN);
-    aConstraint.h = myStorage->addConstraint(aConstraint);
-    mySlvsConstraints.push_back(aConstraint.h);
-  }
-
+  myAdjusted = false;
   adjustConstraint();
-}
 
-void SketchSolver_ConstraintMultiRotation::update(ConstraintPtr theConstraint)
-{
-  cleanErrorMsg();
-  if (!theConstraint || theConstraint == myBaseConstraint) {
-    AttributeRefListPtr anInitialRefList = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
-        myBaseConstraint->attribute(SketchPlugin_Constraint::ENTITY_A()));
-    AttributeIntegerPtr aNbCopies = myBaseConstraint->integer(SketchPlugin_MultiRotation::NUMBER_OF_COPIES_ID());
-    if (anInitialRefList->size() != myNumberOfObjects || aNbCopies->value() != myNumberOfCopies) {
-      remove(myBaseConstraint);
-      process();
-      return;
-    }
-  }
-
-  // update angle value
-  myAngle = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
-      myBaseConstraint->attribute(SketchPlugin_MultiRotation::ANGLE_ID()))->value();
-
-  SketchSolver_Constraint::update();
+  myStorage->subscribeUpdates(this, PlaneGCSSolver_UpdateFeature::GROUP());
 }
 
-bool SketchSolver_ConstraintMultiRotation::remove(ConstraintPtr theConstraint)
+void SketchSolver_ConstraintMultiRotation::updateLocal()
 {
-  cleanErrorMsg();
-  if (theConstraint && theConstraint != myBaseConstraint)
-    return false;
-  bool isFullyRemoved = true;
-  std::vector<Slvs_hEntity>::iterator aCIter = mySlvsConstraints.begin();
-  for (; aCIter != mySlvsConstraints.end(); aCIter++)
-   isFullyRemoved = myStorage->removeConstraint(*aCIter) && isFullyRemoved;
-  mySlvsConstraints.clear();
-
-  std::map<FeaturePtr, Slvs_hEntity>::iterator aFeatIt = myFeatureMap.begin();
-  for (; aFeatIt != myFeatureMap.end(); aFeatIt++)
-    myStorage->removeEntity(aFeatIt->second);
-  myStorage->removeUnusedEntities();
-
-  std::map<FeaturePtr, Slvs_hEntity> aFeatureMapCopy = myFeatureMap;
-
-  if (isFullyRemoved) {
-    myFeatureMap.clear();
-    myAttributeMap.clear();
-    myValueMap.clear();
-  } else
-    cleanRemovedEntities();
-
-  // Restore initial features
-  std::map<FeaturePtr, Slvs_hEntity>::iterator aFIter = aFeatureMapCopy.begin();
-  for (; aFIter != aFeatureMapCopy.end(); ++aFIter)
-  {
-    if (myFeatureMap.find(aFIter->first) != myFeatureMap.end())
-      continue; // the feature was not removed
-    Slvs_hEntity anEntity = myGroup->getFeatureId(aFIter->first);
-    if (anEntity != SLVS_E_UNKNOWN)
-      myFeatureMap[aFIter->first] = anEntity;
-  }
+  double aValue = myBaseConstraint->real(SketchPlugin_MultiRotation::ANGLE_ID())->value();
+  bool isReversed = myBaseConstraint->boolean(SketchPlugin_MultiRotation::REVERSED_ID())->value();
+  if (fabs(myAngle->value() - aValue) > tolerance || isReversed != myIsRevered)
+    myAdjusted = false;
+  // update angle value
+  myAngle->setValue(aValue);
+  myIsRevered = isReversed;
 
-  return true;
+  // update center
+  DataPtr aData = myBaseConstraint->data();
+  AttributePoint2DPtr aCenterPointAttribute = GeomDataAPI_Point2D::getPoint2D(aData,
+                                           SketchPlugin_MultiRotation::CENTER_ID());
+  bool aCenterPointChanged = aCenterPointAttribute != myCenterPointAttribute;
+  if (aCenterPointChanged)
+    myCenterPointAttribute = aCenterPointAttribute;
+
+  AttributeStringPtr aMethodTypeAttr = aData->string(SketchPlugin_MultiRotation::ANGLE_TYPE());
+  bool aFullValue = aMethodTypeAttr->value() != "SingleAngle";
+  bool isMethodChanged = aFullValue != myIsFullValue;
+  if (isMethodChanged)
+    myIsFullValue = aFullValue;
+
+  if (aCenterPointChanged || isMethodChanged)
+    myAdjusted = false;
 }
 
 void SketchSolver_ConstraintMultiRotation::adjustConstraint()
 {
-  if (abs(myAngle) < tolerance) {
+  if (myAdjusted)
+    return;
+
+  double anAngleValue = myAngle->value();
+  if (fabs(anAngleValue) < tolerance) {
     myStorage->setNeedToResolve(false);
     return;
   }
+  if (myIsRevered)
+    anAngleValue *= -1.0;
 
-  // Check the lengths of auxiliary lines are zero.
-  // If they become zero, remove corresponding Angle constraints.
-  // It they become non-zero (but were zero recently), add Angle constraint.
-  std::vector<Slvs_hConstraint>::iterator aConstr = mySlvsConstraints.begin();
-  std::map<Slvs_hEntity, Slvs_hEntity> anEqualLines;
-  bool isFirstRemoved = false;
-  for (; aConstr != mySlvsConstraints.end();
-       isFirstRemoved ? aConstr = mySlvsConstraints.begin() : ++aConstr) {
-    isFirstRemoved = false;
-    Slvs_Constraint aConstraint = myStorage->getConstraint(*aConstr);
-    if (aConstraint.type == SLVS_C_ANGLE || aConstraint.type == SLVS_C_EQUAL_LENGTH_LINES) {
-      Slvs_Entity aLine = myStorage->getEntity(aConstraint.entityA);
-      // Line length became zero => remove constraint
-      if (squareDistance(myStorage, aLine.point[0], aLine.point[1]) < tolerance * tolerance) {
-        myStorage->removeConstraint(aConstraint.h);
-        isFirstRemoved = aConstr == mySlvsConstraints.begin();
-        std::vector<Slvs_hConstraint>::iterator aTmpIter = aConstr;
-        if (!isFirstRemoved)
-          --aConstr;
-        mySlvsConstraints.erase(aTmpIter);
-      }
-      // Store the lines into the map
-      anEqualLines[aConstraint.entityB] = aConstraint.entityA;
-    }
+  // Obtain coordinates of rotation center
+  AttributeRefAttrPtr aCenterAttr =
+      myBaseConstraint->refattr(SketchPlugin_MultiRotation::CENTER_ID());
+  std::shared_ptr<PlaneGCSSolver_PointWrapper> aRotCenter =
+      std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(
+      myStorage->entity(AttributePtr(aCenterAttr)));
+  if (aRotCenter)
+  {
+    GCSPointPtr aCenterPoint = aRotCenter->point();
+    myCenterCoord[0] = *(aCenterPoint->x);
+    myCenterCoord[1] = *(aCenterPoint->y);
+  }
+  else
+  {
+    AttributePoint2DPtr aCenterPnt =
+        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aCenterAttr->attr());
+    myCenterCoord[0] = aCenterPnt->x();
+    myCenterCoord[1] = aCenterPnt->y();
   }
-  // Create Angle and Equal constraints for non-degenerated lines
-  AuxLinesList::iterator anIt = myAuxLines.begin();
-  for (; anIt != myAuxLines.end(); ++anIt) {
-    if (anEqualLines.find(anIt->back()) != anEqualLines.end())
-      continue;
-
-    std::vector<Slvs_hEntity>::iterator anEqLinesIt = anIt->begin();
-    Slvs_hEntity aPrevLine = (*anEqLinesIt);
-    // Check the length of the line
-    Slvs_Entity aLine = myStorage->getEntity(aPrevLine);
-    if (squareDistance(myStorage, aLine.point[0], aLine.point[1]) < tolerance * tolerance)
-      continue;
-
-    for (++anEqLinesIt; anEqLinesIt != anIt->end(); ++anEqLinesIt) {
-      Slvs_hEntity aLine = (*anEqLinesIt);
-      // Equal length constraint
-      Slvs_Constraint aConstraint = Slvs_MakeConstraint(SLVS_E_UNKNOWN, myGroup->getId(),
-          SLVS_C_EQUAL_LENGTH_LINES, myGroup->getWorkplaneId(), 0.0,
-          SLVS_E_UNKNOWN, SLVS_E_UNKNOWN, aPrevLine, aLine);
-      aConstraint.h = myStorage->addConstraint(aConstraint);
-      mySlvsConstraints.push_back(aConstraint.h);
-      // Angle constraint
-      aConstraint = Slvs_MakeConstraint(SLVS_E_UNKNOWN, myGroup->getId(),
-          SLVS_C_ANGLE, myGroup->getWorkplaneId(), fabs(myAngle), SLVS_E_UNKNOWN, SLVS_E_UNKNOWN,
-          aPrevLine, aLine);
-      if (myAngle < 0.0) // clockwise rotation
-        aConstraint.other = true;
-      aConstraint.h = myStorage->addConstraint(aConstraint);
-      mySlvsConstraints.push_back(aConstraint.h);
 
-      aPrevLine = aLine;
-    }
+  if (myIsFullValue && myNumberOfCopies > 0)
+  {
+    // if the full angle value is equal to 360, then distribute rotated items
+    // to avoid superposition of original feature and last copy
+    if (fabs(anAngleValue - 360.0) < 1.e-7)
+      anAngleValue /= (myNumberOfCopies + 1);
+    else
+      anAngleValue /= myNumberOfCopies;
   }
 
-  // Obtain coordinates of rotation center
-  Slvs_Entity aRotCenter = myStorage->getEntity(myRotationCenter);
-  double aCenterXY[2];
-  for (int i = 0; i < 2; i++)
-    aCenterXY[i] = myStorage->getParameter(aRotCenter.param[i]).val;
+  myRotationVal[0] = sin(anAngleValue * PI / 180.0);
+  myRotationVal[1] = cos(anAngleValue * PI / 180.0);
 
-  double cosA = cos(myAngle * PI / 180.0);
-  double sinA = sin(myAngle * PI / 180.0);
+  SketchSolver_ConstraintMulti::adjustConstraint();
+}
 
-  // Update positions of all points to satisfy angles
-  std::list<Slvs_Constraint> aConstrAngle = myStorage->getConstraintsByType(SLVS_C_ANGLE);
-  std::list<Slvs_Constraint>::iterator anAngIt = aConstrAngle.begin();
-  std::vector<Slvs_hConstraint>::iterator aCIt;
-  Slvs_hConstraint aFixed; // temporary variable
-  double aVec[2]; // coordinates of vector defining a line
-  Slvs_Param aTarget[2]; // parameter to be changed
-  for (; anAngIt != aConstrAngle.end(); anAngIt++) {
-    for (aCIt = mySlvsConstraints.begin(); aCIt != mySlvsConstraints.end(); aCIt++)
-      if (anAngIt->h == *aCIt)
-        break;
-    if (aCIt == mySlvsConstraints.end())
-      continue;
-    Slvs_Entity aLineA = myStorage->getEntity(anAngIt->entityA);
-    Slvs_Entity aLineB = myStorage->getEntity(anAngIt->entityB);
-    if (myStorage->isPointFixed(aLineB.point[1], aFixed))
-      continue;
-    Slvs_Entity aPointA = myStorage->getEntity(aLineA.point[1]);
-    Slvs_Entity aPointB = myStorage->getEntity(aLineB.point[1]);
-    for (int i = 0; i < 2; i++) {
-      aVec[i] = myStorage->getParameter(aPointA.param[i]).val - aCenterXY[i];
-      aTarget[i] = myStorage->getParameter(aPointB.param[i]);
-    }
-    aTarget[0].val = aCenterXY[0] + aVec[0] * cosA - aVec[1] * sinA;
-    aTarget[1].val = aCenterXY[1] + aVec[0] * sinA + aVec[1] * cosA;
-    myStorage->updateParameter(aTarget[0]);
-    myStorage->updateParameter(aTarget[1]);
+void SketchSolver_ConstraintMultiRotation::getRelative(
+    double theAbsX, double theAbsY, double& theRelX, double& theRelY)
+{
+  theRelX = theAbsX - myCenterCoord[0];
+  theRelY = theAbsY - myCenterCoord[1];
+}
 
-    anAngIt->valA = myAngle;
-    myStorage->updateConstraint(*anAngIt);
-  }
+void SketchSolver_ConstraintMultiRotation::getAbsolute(
+    double theRelX, double theRelY, double& theAbsX, double& theAbsY)
+{
+  theAbsX = theRelX + myCenterCoord[0];
+  theAbsY = theRelY + myCenterCoord[1];
+}
 
-  // update positions of centers of arcs for correct radius calculation
-  std::list<Slvs_Constraint> aRadii = myStorage->getConstraintsByType(SLVS_C_EQUAL_RADIUS);
-  std::map<FeaturePtr, Slvs_hEntity>::iterator aFeatIt;
-  for (anAngIt = aRadii.begin(); anAngIt != aRadii.end(); anAngIt++) {
-    int aNbFound = 0; // number of arcs used in translation
-    for (aFeatIt = myFeatureMap.begin(); aFeatIt != myFeatureMap.end(); aFeatIt++)
-      if (aFeatIt->second == anAngIt->entityA || aFeatIt->second == anAngIt->entityB) {
-        if (aFeatIt->first->getKind() == SketchPlugin_Arc::ID())
-          aNbFound++;
-        else
-          break;
-      }
-    if (aNbFound != 2)
-      continue;
-    // two arcs were found, update their centers
-    Slvs_Entity anArcA = myStorage->getEntity(anAngIt->entityA);
-    Slvs_Entity anArcB = myStorage->getEntity(anAngIt->entityB);
-    if (myStorage->isPointFixed(anArcB.point[0], aFixed))
-      continue;
-    Slvs_Entity aCenterA = myStorage->getEntity(anArcA.point[0]);
-    Slvs_Entity aCenterB = myStorage->getEntity(anArcB.point[0]);
-    for (int i = 0; i < 2; i++) {
-      aVec[i] = myStorage->getParameter(aCenterA.param[i]).val - aCenterXY[i];
-      aTarget[i] = myStorage->getParameter(aCenterB.param[i]);
-    }
-    aTarget[0].val = aCenterXY[0] + aVec[0] * cosA - aVec[1] * sinA;
-    aTarget[1].val = aCenterXY[1] + aVec[0] * sinA + aVec[1] * cosA;
-    myStorage->updateParameter(aTarget[0]);
-    myStorage->updateParameter(aTarget[1]);
-  }
+void SketchSolver_ConstraintMultiRotation::transformRelative(double& theX, double& theY)
+{
+  // rotate direction
+  // myRotationVal[0] = sinA, myRotationVal[1] = cosA
+  double aTemp = theX * myRotationVal[1] - theY * myRotationVal[0];
+  theY = theX * myRotationVal[0] + theY * myRotationVal[1];
+  theX = aTemp;
+}
+
+const std::string& SketchSolver_ConstraintMultiRotation::nameNbObjects()
+{
+  return SketchPlugin_MultiRotation::NUMBER_OF_OBJECTS_ID();
 }