#include <PlaneGCSSolver_Tools.h>
#include <PlaneGCSSolver_UpdateCoincidence.h>
+#include <SketchPlugin_Arc.h>
+#include <SketchPlugin_Line.h>
+
+static void getCoincidentFeatureExtremities(const ConstraintPtr& theConstraint,
+ const StoragePtr& theStorage,
+ EntityWrapperPtr theExtremities[2])
+{
+ for (int i = 0; i < CONSTRAINT_ATTR_SIZE; ++i) {
+ AttributeRefAttrPtr aRefAttr = theConstraint->refattr(SketchPlugin_Constraint::ATTRIBUTE(i));
+ if (!aRefAttr || !aRefAttr->isObject())
+ continue;
+
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
+ if (!aFeature)
+ continue;
+
+ if (aFeature->getKind() == SketchPlugin_Line::ID()) {
+ theExtremities[0] = theStorage->entity(aFeature->attribute(SketchPlugin_Line::START_ID()));
+ theExtremities[1] = theStorage->entity(aFeature->attribute(SketchPlugin_Line::END_ID()));
+ } else if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
+ theExtremities[0] = theStorage->entity(aFeature->attribute(SketchPlugin_Arc::START_ID()));
+ theExtremities[1] = theStorage->entity(aFeature->attribute(SketchPlugin_Arc::END_ID()));
+ }
+ }
+}
+
+
void SketchSolver_ConstraintCoincidence::process()
{
cleanErrorMsg();
myType = CONSTRAINT_PT_ON_CIRCLE;
else
myErrorMsg = SketchSolver_Error::INCORRECT_ATTRIBUTE();
+
+ // obtain extremity points of the coincident feature for further checking of multi-coincidence
+ getCoincidentFeatureExtremities(myBaseConstraint, myStorage, myFeatureExtremities);
} else
myErrorMsg = SketchSolver_Error::INCORRECT_ATTRIBUTE();
}
PlaneGCSSolver_UpdateCoincidence* anUpdater =
static_cast<PlaneGCSSolver_UpdateCoincidence*>(theUpdater);
bool isAccepted = anUpdater->checkCoincidence(myAttributes.front(), myAttributes.back());
+
+ // additionally check the point is coincident to extremity of coincident feature
+ if (myFeatureExtremities[0] && myFeatureExtremities[1]) {
+ EntityWrapperPtr aPoint =
+ myAttributes.front()->type() == ENTITY_POINT ? myAttributes.front() : myAttributes.back();
+
+ for (int i = 0; i < 2; ++i)
+ isAccepted = isAccepted && !anUpdater->isPointOnEntity(aPoint, myFeatureExtremities[i]);
+ }
+
if (isAccepted) {
if (!myInSolver) {
myInSolver = true;