- bool hasDuplicated = myStorage->hasDuplicatedConstraint();
- Slvs_Constraint aNewConstraint = Slvs_MakeConstraint(SLVS_E_UNKNOWN, myGroup->getId(),
- SLVS_C_POINTS_COINCIDENT, myGroup->getWorkplaneId(), 0.0, thePoint1, thePoint2,
- SLVS_E_UNKNOWN, SLVS_E_UNKNOWN);
- Slvs_hConstraint aNewID = myStorage->addConstraint(aNewConstraint);
- if (!hasDuplicated && myStorage->hasDuplicatedConstraint()) {
- // the duplicated constraint appears
- myStorage->removeConstraint(aNewID);
- return SLVS_E_UNKNOWN;
+ AttributePoint2DPtr aPointA, aPointB;
+ FeaturePtr anOwnerA, anOwnerB;
+ FeaturePtr aParentA, aParentB;
+ getPointOwnerAndParent(theConstraint->refattr(SketchPlugin_Constraint::ENTITY_A()),
+ aPointA, anOwnerA, aParentA);
+ getPointOwnerAndParent(theConstraint->refattr(SketchPlugin_Constraint::ENTITY_B()),
+ aPointB, anOwnerB, aParentB);
+
+ AttributePtr anAxisStart, anAxisEnd, aPoint;
+ FeaturePtr aConstruction, anEllipticArc;
+ if (aParentA && aParentA == anOwnerB) {
+ aPoint = aPointB;
+ aConstruction = anOwnerA;
+ anEllipticArc = anOwnerB;
+ }
+ else if (aParentB && aParentB == anOwnerA) {
+ aPoint = aPointA;
+ aConstruction = anOwnerB;
+ anEllipticArc = anOwnerA;
+ }
+
+ if (!anEllipticArc || anEllipticArc->getKind() != SketchPlugin_EllipticArc::ID() ||
+ (aPoint->id() != SketchPlugin_EllipticArc::START_POINT_ID() &&
+ aPoint->id() != SketchPlugin_EllipticArc::END_POINT_ID()))
+ return;
+
+ findDiameterOnEllipse(aConstruction, anEllipticArc, anAxisStart, anAxisEnd);
+
+ if (anAxisStart && anAxisEnd) {
+ theAttributes[0] = theStorage->entity(aPoint);
+ theAttributes[1] = theStorage->entity(anAxisStart);
+ theAttributes[2] = theStorage->entity(anAxisEnd);
+ theType = CONSTRAINT_PT_ON_CURVE;
+ getCoincidentFeatureExtremities(theConstraint, theStorage, theExtremities);