]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
authorsbh <sergey.belash@opencascade.com>
Wed, 1 Apr 2015 10:13:23 +0000 (13:13 +0300)
committersbh <sergey.belash@opencascade.com>
Wed, 1 Apr 2015 10:13:23 +0000 (13:13 +0300)
1  2 
src/SketchSolver/SketchSolver_ConstraintGroup.cpp

index a3f083faf190c5ea113a901543db95c8b48b7ac4,49437e464f62542e834d443e3fee74ec5e001600..f54067afa647d3c20c62e7a9d85a5bff5a328ade
@@@ -806,16 -808,51 +808,51 @@@ bool SketchSolver_ConstraintGroup::chan
      for (aBaseIter = aBaseList.begin(); aBaseIter != aBaseList.end(); aBaseIter++) {
        aRC = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aBaseIter);
        aBaseFeature = aRC ? aRC->document()->feature(aRC) :
 -          std::dynamic_pointer_cast<SketchPlugin_Feature>(*aBaseIter);
 +          std::dynamic_pointer_cast<ModelAPI_Feature>(*aBaseIter);
        if (!aBaseFeature) continue;
        std::list<AttributePtr> aPoints = aBaseFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
-       std::list<AttributePtr>::iterator anIt = aPoints.begin();
-       for ( ; anIt != aPoints.end(); anIt++) {
+       if (aBaseFeature->getKind() != SketchPlugin_Arc::ID()) {
+         std::list<AttributePtr>::iterator anIt = aPoints.begin();
+         for ( ; anIt != aPoints.end(); anIt++) {
+           addTemporaryConstraintWhereDragged(*anIt);
+         }
+       } else {
          // Arcs are fixed by center and start points only (to avoid solving errors in SolveSpace)
-         if (aBaseFeature->getKind() == SketchPlugin_Arc::ID() &&
-             (*anIt)->id() == SketchPlugin_Arc::END_ID())
-           continue;
-         addTemporaryConstraintWhereDragged(*anIt);
+         AttributePtr aCenterAttr = aBaseFeature->attribute(SketchPlugin_Arc::CENTER_ID());
+         std::map<AttributePtr, Slvs_hEntity>::iterator aFound = myEntityAttrMap.find(aCenterAttr);
+         Slvs_hEntity anArcPoints[3] = {aFound->second, 0, 0};
+         AttributePtr aStartAttr = aBaseFeature->attribute(SketchPlugin_Arc::START_ID());
+         aFound = myEntityAttrMap.find(aStartAttr);
+         anArcPoints[1] = aFound->second;
+         AttributePtr aEndAttr = aBaseFeature->attribute(SketchPlugin_Arc::END_ID());
+         aFound = myEntityAttrMap.find(aEndAttr);
+         anArcPoints[2] = aFound->second;
+         bool isFixed[3] = {false, false, false};
+         int aNbFixed = 0; // number of already fixed points on the arc
+         for (int i = 0; i < 3; i++) {
+           std::vector<std::set<Slvs_hEntity> >::iterator aCoPtIter = myCoincidentPoints.begin();
+           for (; aCoPtIter != myCoincidentPoints.end() && !isFixed[i]; aCoPtIter++) {
+             if (aCoPtIter->find(anArcPoints[i]) == aCoPtIter->end())
+               continue;  // the entity was not found in current set
+             // Find one of already created SLVS_C_WHERE_DRAGGED constraints in current set of coincident points
+             std::vector<Slvs_Constraint>::iterator aConstrIter = myConstraints.begin();
+             for (; aConstrIter != myConstraints.end(); aConstrIter++)
+               if (aConstrIter->type == SLVS_C_WHERE_DRAGGED && 
+                   aCoPtIter->find(aConstrIter->ptA) != aCoPtIter->end()) {
+                 isFixed[i] = true;
+                 aNbFixed++;
+                 break;  // the SLVS_C_WHERE_DRAGGED constraint already exists
+               }
+           }
+         }
+         if (aNbFixed < 2) { // append constraints
+           if (!isFixed[0])
+             addTemporaryConstraintWhereDragged(aCenterAttr);
+           if (!isFixed[1] && (isFixed[0] || aNbFixed == 0))
+             addTemporaryConstraintWhereDragged(aStartAttr);
+         }
        }
      }
    }