(*aCIt)->rescale();
}
+bool PlaneGCSSolver_Builder::isArcArcTangencyInternal(
+ EntityWrapperPtr theArc1, EntityWrapperPtr theArc2) const
+{
+ std::shared_ptr<GCS::Circle> aCirc1 = std::dynamic_pointer_cast<GCS::Circle>(
+ GCS_ENTITY_WRAPPER(theArc1)->entity());
+ std::shared_ptr<GCS::Circle> aCirc2 = std::dynamic_pointer_cast<GCS::Circle>(
+ GCS_ENTITY_WRAPPER(theArc2)->entity());
+
+ if (!aCirc1 || !aCirc2)
+ return false;
+
+ double aDX = *(aCirc1->center.x) - *(aCirc2->center.x);
+ double aDY = *(aCirc1->center.y) - *(aCirc2->center.y);
+ double aDist = sqrt(aDX * aDX + aDY * aDY);
+
+ return (aDist < *(aCirc1->rad) || aDist < *(aCirc2->rad));
+}
+
return aNbCoinc == 1;
}
+/// \brief Check if two connected arcs have centers
+/// in same direction relatively to connection point
+static bool isInternalTangency(EntityWrapperPtr theEntity1, EntityWrapperPtr theEntity2)
+{
+ BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
+ return aBuilder->isArcArcTangencyInternal(theEntity1, theEntity2);
+}
+
void SketchSolver_ConstraintTangent::getAttributes(
double& theValue,
else if (aNbCircles == 1)
myType = CONSTRAINT_TANGENT_CIRCLE_LINE;
}
- else if (aNbArcs == 2)
+ else if (aNbArcs == 2) {
myType = CONSTRAINT_TANGENT_ARC_ARC;
+ isArcArcInternal = isInternalTangency(theAttributes[2], theAttributes[3]);
+ }
else {
myErrorMsg = SketchSolver_Error::INCORRECT_ATTRIBUTE();
return;
void SketchSolver_ConstraintTangent::adjustConstraint()
{
- if (myType != CONSTRAINT_TANGENT_CIRCLE_LINE)
- return;
-
- ConstraintWrapperPtr aConstraint = myStorage->constraint(myBaseConstraint).front();
- AttributePtr aCircleCenter = aConstraint->entities().front()->baseAttribute();
- if (!aCircleCenter)
- return;
- FeaturePtr aCircle = ModelAPI_Feature::feature(aCircleCenter->owner());
- AttributeDoublePtr aRadius = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
- aCircle->attribute(SketchPlugin_Circle::RADIUS_ID()));
-
- if (fabs(aRadius->value()) == fabs(aConstraint->value()))
- return;
-
- aConstraint->setValue(aRadius->value());
-
- // Adjust the sign of constraint value
- BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
- aBuilder->adjustConstraint(aConstraint);
- myStorage->addConstraint(myBaseConstraint, aConstraint);
+ if (myType == CONSTRAINT_TANGENT_CIRCLE_LINE) {
+ ConstraintWrapperPtr aConstraint = myStorage->constraint(myBaseConstraint).front();
+ AttributePtr aCircleCenter = aConstraint->entities().front()->baseAttribute();
+ if (!aCircleCenter)
+ return;
+ FeaturePtr aCircle = ModelAPI_Feature::feature(aCircleCenter->owner());
+ AttributeDoublePtr aRadius = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+ aCircle->attribute(SketchPlugin_Circle::RADIUS_ID()));
+
+ if (fabs(aRadius->value()) == fabs(aConstraint->value()))
+ return;
+
+ aConstraint->setValue(aRadius->value());
+
+ // Adjust the sign of constraint value
+ BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
+ aBuilder->adjustConstraint(aConstraint);
+ myStorage->addConstraint(myBaseConstraint, aConstraint);
+ }
+ else if (myType == CONSTRAINT_TANGENT_ARC_ARC) {
+ ConstraintWrapperPtr aConstraint = myStorage->constraint(myBaseConstraint).front();
+ if (isArcArcInternal != isInternalTangency(
+ aConstraint->entities().front(), aConstraint->entities().back())) {
+ // fully rebuld constraint, because it is unable to access attributes of PlaneGCS constraint
+ remove();
+ process();
+ }
+ }
}