Salome HOME
Issue #3279: Incorrect result of 1D-Fillet with boundary value of radius
[modules/shaper.git] / src / GeomAlgoImpl / GEOMImpl_Fillet1d.cxx
index b9aef213c74f7e97bd693df1757067e6d5338494..3f3c2d74e33848d391e1e66702bb97fc60ac44ae 100644 (file)
@@ -578,7 +578,7 @@ TopoDS_Edge GEOMImpl_Fillet1d::Result(const gp_Pnt& thePoint,
   aTargetPoint2d.SetCoord(aX, aY);
 
   // choose the nearest circle
-  Standard_Real aDistance, aP;
+  Standard_Real aDistance = Precision::Infinite();
   GEOMImpl_Fillet1dPoint *aNearest;
   Standard_Integer a;
   TColStd_ListIteratorOfListOfReal anIter(myResultParams);
@@ -589,7 +589,7 @@ TopoDS_Edge GEOMImpl_Fillet1d::Result(const gp_Pnt& thePoint,
     fillPoint(aPoint);
     if (!aPoint->HasSolution(myRadius))
       continue;
-    aP = fabs(aPoint->GetCenter().Distance(aTargetPoint2d) - myRadius);
+    Standard_Real aP = fabs(aPoint->GetCenter().Distance(aTargetPoint2d) - myRadius);
     if (!aNearest || aP < aDistance)
     {
       aNearest = aPoint;
@@ -664,6 +664,10 @@ TopoDS_Edge GEOMImpl_Fillet1d::Result(const gp_Pnt& thePoint,
       else
         theEdge1 = aDivider1.Edge();
   }
+  else {
+    // error: filleted edge becomes degenerated
+    aResult = TopoDS_Edge();
+  }
 
   aCurve = BRep_Tool::Curve(myEdge2, aStart, anEnd);
   aCurve->D1(aNearest->GetParam2(), aPoint2, aDir);
@@ -682,6 +686,10 @@ TopoDS_Edge GEOMImpl_Fillet1d::Result(const gp_Pnt& thePoint,
       else
         theEdge2 = aDivider2.Edge();
   }
+  else {
+    // error: filleted edge becomes degenerated
+    aResult = TopoDS_Edge();
+  }
 
   delete aNearest;
   return aResult;
@@ -715,7 +723,7 @@ Standard_Boolean GEOMImpl_Fillet1dPoint::ComputeDifference(GEOMImpl_Fillet1dPoin
 {
   Standard_Integer a;
   Standard_Boolean aDiffsSet = (myD.Length() != 0);
-  Standard_Real aDX = thePoint->GetParam() - myParam, aDY;
+  Standard_Real aDX = thePoint->GetParam() - myParam, aDY = 0.0;
   if (thePoint->myV.Length() == myV.Length())
   { // absolutely the same points
     for(a = 1; a <= myV.Length(); a++)