0023158: ApproxInt_PrmPrmSvSurfaces raises FPE (division by zero) signal
authorvsr <vsr@opencascade.com>
Thu, 17 May 2012 06:24:01 +0000 (10:24 +0400)
committervsr <vsr@opencascade.com>
Fri, 25 May 2012 11:08:50 +0000 (15:08 +0400)
Prevent division by zero in ApproxInt_PrmPrmSvSurfaces::Compute

src/ApproxInt/ApproxInt_PrmPrmSvSurfaces.gxx

index 028e52d..785069b 100755 (executable)
@@ -24,6 +24,7 @@
 
 #include <TColStd_Array1OfReal.hxx>
 #include <math_FunctionSetRoot.hxx>
 
 #include <TColStd_Array1OfReal.hxx>
 #include <math_FunctionSetRoot.hxx>
+#include <Precision.hxx>
 
 #define Debug(expr)  cout<<" expr :"<<expr;
 #define MySurf1 MyIntersectionOn2S.Function().AuxillarSurface1()
 
 #define Debug(expr)  cout<<" expr :"<<expr;
 #define MySurf1 MyIntersectionOn2S.Function().AuxillarSurface1()
@@ -173,6 +174,11 @@ Standard_Boolean ApproxInt_PrmPrmSvSurfaces::Compute( Standard_Real& u1
   TgTU = Tg.Dot(TU);
   TgTV = Tg.Dot(TV);
   DIS  = TUTU * TVTV - TUTV * TUTV;
   TgTU = Tg.Dot(TU);
   TgTV = Tg.Dot(TV);
   DIS  = TUTU * TVTV - TUTV * TUTV;
+  if(fabs(DIS)<Precision::Angular()) { 
+    MyIsTangent=Standard_False;
+    MyHasBeenComputed = MyHasBeenComputedbis = Standard_False;
+    return(Standard_False); 
+  }
   
   DeltaU = (TgTU * TVTV - TgTV * TUTV ) / DIS ; 
   DeltaV = (TgTV * TUTU - TgTU * TUTV ) / DIS ;
   
   DeltaU = (TgTU * TVTV - TgTV * TUTV ) / DIS ; 
   DeltaV = (TgTV * TUTU - TgTU * TUTV ) / DIS ;
@@ -190,6 +196,11 @@ Standard_Boolean ApproxInt_PrmPrmSvSurfaces::Compute( Standard_Real& u1
   TgTU = Tg.Dot(TU);
   TgTV = Tg.Dot(TV);
   DIS  = TUTU * TVTV - TUTV * TUTV;
   TgTU = Tg.Dot(TU);
   TgTV = Tg.Dot(TV);
   DIS  = TUTU * TVTV - TUTV * TUTV;
+  if(fabs(DIS)<Precision::Angular()) { 
+    MyIsTangent=Standard_False;
+    MyHasBeenComputed = MyHasBeenComputedbis = Standard_False;
+    return(Standard_False); 
+  }
 
   DeltaU = (TgTU * TVTV - TgTV * TUTV ) / DIS ; 
   DeltaV = (TgTV * TUTU - TgTU * TUTV ) / DIS ;
 
   DeltaU = (TgTU * TVTV - TgTV * TUTV ) / DIS ; 
   DeltaV = (TgTV * TUTU - TgTU * TUTV ) / DIS ;