FeaturePtr aCoincidenceFeature = SketchPlugin_ConstraintCoincidence::findCoincidenceFeature
(ModelAPI_Feature::feature(aResult1),
ModelAPI_Feature::feature(aResult2));
- aTangentPoint = SketchPlugin_ConstraintCoincidence::getPoint(aCoincidenceFeature);
+ // get the point not lying on the splitting feature
+ for (int i = 0; i < CONSTRAINT_ATTR_SIZE; ++i) {
+ AttributeRefAttrPtr aRefAttr = aCoincidenceFeature->refattr(ATTRIBUTE(i));
+ if (!aRefAttr || aRefAttr->isObject())
+ continue;
+ AttributePoint2DPtr aPoint =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aRefAttr->attr());
+ if (!aPoint)
+ continue;
+ if (aPoint->owner() != aBaseFeature) {
+ aTangentPoint = aPoint;
+ break;
+ }
+ }
}
if (aTangentPoint.get()) {
FeaturePtr aFeature1 = ModelAPI_Feature::feature(aResult1);
return;
}
+ // manually change type of arc to avoid incorrect self-constrainting of the tangent arc
+ aBaseFeature->string(SketchPlugin_Arc::ARC_TYPE())->setValue(
+ SketchPlugin_Arc::ARC_TYPE_CENTER_START_END());
+
arrangePointsOnArc(aBaseFeature, aStartPointAttrOfBase, anEndPointAttrOfBase,
aFirstPointAttrOfSplit, aSecondPointAttrOfSplit);
#ifdef DEBUG_SPLIT
std::shared_ptr<GeomDataAPI_Point2D>& theFirstPointAttr,
std::shared_ptr<GeomDataAPI_Point2D>& theSecondPointAttr) const
{
+ static const double anAngleTol = 1.e-12;
+
std::shared_ptr<GeomAPI_Pnt2d> aCenter = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
theArc->attribute(SketchPlugin_Arc::CENTER_ID()))->pnt();
bool isReversed = theArc->boolean(SketchPlugin_Arc::INVERSED_ID())->value();
double aFirstPtAngle = aStartDir->angle(aFirstPtDir);
double aSecondPtAngle = aStartDir->angle(aSecondPtDir);
double aPeriod = isReversed ? -2.0 * PI : 2.0 * PI;
- if (isReversed == (aFirstPtAngle > 0.))
+ if (fabs(aFirstPtAngle) > anAngleTol && isReversed == (aFirstPtAngle > 0.))
aFirstPtAngle += aPeriod;
- if (isReversed == (aSecondPtAngle > 0.))
+ if (fabs(aSecondPtAngle) > anAngleTol && isReversed == (aSecondPtAngle > 0.))
aSecondPtAngle += aPeriod;
if (fabs(aFirstPtAngle) > fabs(aSecondPtAngle)) {
bool PlaneGCSSolver_Solver::isTangentTruth(GCS::Constraint* theTangent) const
{
- static const double aTol = 1e-5;
- double aTol2 = aTol *aTol;
-
if (theTangent->getTypeId() == GCS::TangentCircumf) {
+ static const double aTol = 1e-4;
GCS::VEC_pD aParams = theTangent->params();
double dx = *(aParams[2]) - *(aParams[0]);
double dy = *(aParams[3]) - *(aParams[1]);
double aDist2 = dx * dx + dy * dy;
double aRadSum = *(aParams[4]) + *(aParams[5]);
double aRadDiff = *(aParams[4]) - *(aParams[5]);
- aTol2 *= aDist2 > 1.0 ? aDist2 : 1.0;
+ double aTol2 = aTol * aRadSum;
+ aTol2 *= aTol2;
return fabs(aDist2 - aRadSum * aRadSum) <= aTol2 ||
fabs(aDist2 - aRadDiff * aRadDiff) <= aTol2;
}
if (theTangent->getTypeId() == GCS::P2LDistance) {
+ static const double aTol2 = 1e-12;
GCS::VEC_pD aParams = theTangent->params();
double aDist2 = *(aParams[6]) * *(aParams[6]);
// orthogonal line direction