]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix incorrect splitting arc tangent to a line (issue #1718)
authorazv <azv@opencascade.com>
Mon, 5 Sep 2016 08:46:47 +0000 (11:46 +0300)
committerazv <azv@opencascade.com>
Mon, 5 Sep 2016 08:46:47 +0000 (11:46 +0300)
src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp

index 6e4e3841be16e1147f50e9b64d2a4fd2fd38363c..caf0695aab46324c85d7836773dfc621573e604c 100755 (executable)
@@ -381,7 +381,20 @@ void SketchPlugin_ConstraintSplit::getConstraints(std::set<FeaturePtr>& 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<GeomDataAPI_Point2D>(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<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();
@@ -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)) {
index c522bbacc212b47074aabfa1062bf9813ccc3ee6..72736bc4317dbf4324df8f3b3c2c9223ea6434b6 100644 (file)
@@ -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