From: azv Date: Mon, 5 Sep 2016 08:46:47 +0000 (+0300) Subject: Fix incorrect splitting arc tangent to a line (issue #1718) X-Git-Tag: V_2.5.0~62 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fc4c6f809d7193a9f35cd3113b706f9c51061a21;p=modules%2Fshaper.git Fix incorrect splitting arc tangent to a line (issue #1718) --- diff --git a/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp b/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp index 6e4e3841b..caf0695aa 100755 --- a/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp @@ -381,7 +381,20 @@ void SketchPlugin_ConstraintSplit::getConstraints(std::set& theFeatu 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(aRefAttr->attr()); + if (!aPoint) + continue; + if (aPoint->owner() != aBaseFeature) { + aTangentPoint = aPoint; + break; + } + } } if (aTangentPoint.get()) { FeaturePtr aFeature1 = ModelAPI_Feature::feature(aResult1); @@ -767,6 +780,10 @@ void SketchPlugin_ConstraintSplit::splitArc(FeaturePtr& theSplitFeature, 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 @@ -951,6 +968,8 @@ void SketchPlugin_ConstraintSplit::arrangePointsOnArc( std::shared_ptr& theFirstPointAttr, std::shared_ptr& theSecondPointAttr) const { + static const double anAngleTol = 1.e-12; + std::shared_ptr aCenter = std::dynamic_pointer_cast( theArc->attribute(SketchPlugin_Arc::CENTER_ID()))->pnt(); bool isReversed = theArc->boolean(SketchPlugin_Arc::INVERSED_ID())->value(); @@ -967,9 +986,9 @@ void SketchPlugin_ConstraintSplit::arrangePointsOnArc( 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)) { diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp index c522bbacc..72736bc43 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp @@ -212,21 +212,21 @@ GCS::SolveStatus PlaneGCSSolver_Solver::solveWithoutTangent() 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