0028375: Regressions after enabling floating point signals handling in DRAW
authormsv <msv@opencascade.com>
Wed, 25 Jan 2017 15:12:18 +0000 (18:12 +0300)
committerapn <apn@opencascade.com>
Thu, 2 Feb 2017 13:06:42 +0000 (16:06 +0300)
In Bisector_BisecCC.cxx avoid division by zero when the variable N1P2P1==0.
In Bisector_BisecPC.cxx avoid creation of gp_Dir2d with zero components.

src/Bisector/Bisector_BisecCC.cxx
src/Bisector/Bisector_BisecPC.cxx

index c8d9f12..71b380b 100644 (file)
@@ -684,12 +684,13 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real  U,
     gp_Vec2d P2P1(P1.X() - P2.X(),P1.Y() - P2.Y());
     Standard_Real SquareP2P1 = P2P1.SquareMagnitude();
     Standard_Real N1P2P1     = N1.Dot(P2P1);
+    const Standard_Real anEps = Epsilon(1);
 
     if (P1.IsEqual(P2,Precision::Confusion())) {
       PBis = P1 ;
       Dist = 0.0;
     }
-    else if (N1P2P1*sign1 < 0) {
+    else if (N1P2P1*sign1 < anEps) {
       Valid = Standard_False;
     }
     else {     
index b577d8a..8abf8d9 100644 (file)
@@ -328,26 +328,35 @@ void Bisector_BisecPC::Extension(const Standard_Real    U,
                                       gp_Vec2d&        V2,
                                       gp_Vec2d&        V3 ) const
 {
-  gp_Dir2d      DirExt;
   Standard_Real dU;
 
+  V1.SetCoord(0., 0.);
+  V2.SetCoord(0., 0.);
+  V3.SetCoord(0., 0.);
   if      ( U < startIntervals.Value(bisInterval)) {
-    dU = U - startIntervals.Value(bisInterval);
-    DirExt.SetCoord(pointStartBis.X() - point.X(),
-                   pointStartBis.Y() - point.Y());
-    P.SetCoord(pointStartBis.X() + dU*DirExt.X(),
-              pointStartBis.Y() + dU*DirExt.Y());
+    if (pointStartBis.IsEqual(point, Precision::PConfusion()))
+      P = pointStartBis;
+    else {
+      dU = U - startIntervals.Value(bisInterval);
+      gp_Dir2d DirExt(pointStartBis.X() - point.X(),
+                      pointStartBis.Y() - point.Y());
+      P.SetCoord(pointStartBis.X() + dU*DirExt.X(),
+                 pointStartBis.Y() + dU*DirExt.Y());
+      V1.SetCoord(DirExt.X(), DirExt.Y());
+    }
   }
   else if ( U > endIntervals.Value(bisInterval)) { 
-    dU =  U - endIntervals.Value(bisInterval);
-    DirExt.SetCoord(point.X() - pointEndBis.X(),
-                   point.Y() - pointEndBis.Y()); 
-    P.SetCoord(pointEndBis.X() + dU*DirExt.X(),
-              pointEndBis.Y() + dU*DirExt.Y());
+    if (pointEndBis.IsEqual(point, Precision::PConfusion()))
+      P = pointEndBis;
+    else {
+      dU =  U - endIntervals.Value(bisInterval);
+      gp_Dir2d DirExt(point.X() - pointEndBis.X(),
+                      point.Y() - pointEndBis.Y()); 
+      P.SetCoord(pointEndBis.X() + dU*DirExt.X(),
+                 pointEndBis.Y() + dU*DirExt.Y());
+      V1.SetCoord(DirExt.X(), DirExt.Y());
+    }
   }
-  V1.SetCoord(DirExt.X(),DirExt.Y());
-  V2.SetCoord(0.        ,0.        );
-  V3.SetCoord(0.        ,0.        );
 }