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);
+ }
}
}
}