From: sbh Date: Wed, 1 Apr 2015 10:13:23 +0000 (+0300) Subject: Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0 X-Git-Tag: V_1.1.0~66^2~2^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ce9008bdda3fa14d6fa6c61360541249ccf43ce0;p=modules%2Fshaper.git Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0 --- ce9008bdda3fa14d6fa6c61360541249ccf43ce0 diff --cc src/SketchSolver/SketchSolver_ConstraintGroup.cpp index a3f083faf,49437e464..f54067afa --- a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp @@@ -806,16 -808,51 +808,51 @@@ bool SketchSolver_ConstraintGroup::chan for (aBaseIter = aBaseList.begin(); aBaseIter != aBaseList.end(); aBaseIter++) { aRC = std::dynamic_pointer_cast(*aBaseIter); aBaseFeature = aRC ? aRC->document()->feature(aRC) : - std::dynamic_pointer_cast(*aBaseIter); + std::dynamic_pointer_cast(*aBaseIter); if (!aBaseFeature) continue; std::list aPoints = aBaseFeature->data()->attributes(GeomDataAPI_Point2D::typeId()); - std::list::iterator anIt = aPoints.begin(); - for ( ; anIt != aPoints.end(); anIt++) { + if (aBaseFeature->getKind() != SketchPlugin_Arc::ID()) { + std::list::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::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 >::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::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); + } } } }