0028076: Test bugs moddata_2 bug469 fails when FPE are enabled
authornbv <nbv@opencascade.com>
Wed, 9 Nov 2016 08:22:12 +0000 (11:22 +0300)
committerapn <apn@opencascade.com>
Thu, 17 Nov 2016 11:47:38 +0000 (14:47 +0300)
The reason of FPE exception has been eliminated.

src/ApproxInt/ApproxInt_KnotTools.cxx

index 7d7a77d..b8bf254 100644 (file)
@@ -57,17 +57,33 @@ static Standard_Real EvalCurv(const Standard_Real dim,
       mp += p*p;
     }
   }
-  //mp *= 2.; //P(j,i) = -P(i,j);
-  mp = Sqrt(mp);
   //
   Standard_Real q = 0.;
   for(i = 0; i < dim; ++i)
   {
     q += V1[i]*V1[i];
   }
-  q = Sqrt(q);
+
+  if (q < 1 / Precision::Infinite())
+  {
+    // Indeed, if q is small then we can
+    // obtain equivocation of "0/0" type.
+    // In this case, local curvature can be
+    // not equal to 0 or Infinity.
+    // However, it is good solution to insert
+    // knot in the place with such singularity.
+    // Therefore, we need imitation of curvature
+    // jumping. Return of Precision::Infinite() is
+    // enough for it.
+
+    return Precision::Infinite();
+  }
+
+  q = Min(q, Precision::Infinite());
+  q *= q*q;
+
   //
-  Standard_Real curv = mp / (q*q*q);
+  Standard_Real curv = Sqrt(mp / q);
 
   return curv;
 }