-void SketchSolver_ConstraintMulti::adjustConstraint()
-{
- double aRelCoord[2] = {0.0, 0.0}; // relative coordinates of point
- double anAbsCoord[2] = {0.0, 0.0}; // absolute coordinates of point
-
- std::list<Slvs_Constraint> aCoincident = myStorage->getConstraintsByType(SLVS_C_POINTS_COINCIDENT);
- std::list<Slvs_Constraint>::const_iterator aCoIt;
-
- // Update positions of all points to satisfy angles
- std::vector< std::vector<Slvs_hEntity> >::const_iterator aPointsIter = myPointsAndCopies.begin();
- std::vector<Slvs_hEntity>::const_iterator aCopyIter;
- for (; aPointsIter != myPointsAndCopies.end(); ++aPointsIter) {
- aCopyIter = aPointsIter->begin();
- const Slvs_Entity& anInitial = myStorage->getEntity(*aCopyIter);
- for (int i = 0; i < 2; i++)
- anAbsCoord[i] = myStorage->getParameter(anInitial.param[i]).val;
- getRelative(anAbsCoord[0], anAbsCoord[1], aRelCoord[0], aRelCoord[1]);
-
- // if the point is coincident with another one which is temporary fixed (moved by user),
- // we will update its position correspondingly
- Slvs_hConstraint aFixed;
- for (aCoIt = aCoincident.begin(); aCoIt != aCoincident.end(); ++aCoIt) {
- if ((aCoIt->ptA == anInitial.h && myInitialPoints.find(aCoIt->ptB) != myInitialPoints.end()) ||
- (aCoIt->ptB == anInitial.h && myInitialPoints.find(aCoIt->ptA) != myInitialPoints.end())) {
- Slvs_hEntity anOtherId = aCoIt->ptA == anInitial.h ? aCoIt->ptB : aCoIt->ptA;
- if (!myStorage->isTemporary(aFixed) &&
- myPointsJustUpdated.find(anOtherId) == myPointsJustUpdated.end())
- continue; // nothing to change
-
- const Slvs_Entity& anOtherPnt = myStorage->getEntity(anOtherId);
- for (int i = 0; i < 2; i++) {
- Slvs_Param anInitParam = myStorage->getParameter(anInitial.param[i]);
- const Slvs_Param& anOtherParam = myStorage->getParameter(anOtherPnt.param[i]);
- anInitParam.val = anOtherParam.val;
- myStorage->updateParameter(anInitParam);
- anAbsCoord[i] = anOtherParam.val;
- }
- getRelative(anAbsCoord[0], anAbsCoord[1], aRelCoord[0], aRelCoord[1]);
- }
+ std::list<ObjectPtr> anObjectList = aRefList->list();
+ std::list<ObjectPtr>::iterator anObjIt = anObjectList.begin();
+ while (anObjIt != anObjectList.end()) {
+ anOriginal = ModelAPI_Feature::feature(*anObjIt++);
+ if (!anOriginal)
+ continue;
+
+ // Fill lists of coordinates of points composing a feature
+ std::list<double> aX, aY;
+ double aXCoord, aYCoord;
+ std::list<AttributePtr> aPoints =
+ anOriginal->data()->attributes(GeomDataAPI_Point2D::typeId());
+ std::list<AttributePtr>::iterator aPtIt = aPoints.begin();
+ for (; aPtIt != aPoints.end(); ++aPtIt) {
+ AttributePoint2DPtr aPoint2D = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*aPtIt);
+ if (aPoint2D->isInitialized()) {
+ aXCoord = aPoint2D->x();
+ aYCoord = aPoint2D->y();
+ getRelative(aXCoord, aYCoord, aXCoord, aYCoord);
+ } else
+ aXCoord = aYCoord = 0;
+
+ aX.push_back(aXCoord);
+ aY.push_back(aYCoord);