0023341: Wrong result done by 2D classifier algorithm for a point and a face.
[occt.git] / src / IntCurve / IntCurve_IntConicConic_1.cxx
index 6f8beea..600994d 100755 (executable)
@@ -436,7 +436,6 @@ void LineCircleGeometricIntersection(const gp_Lin2d& Line,
     Standard_Real dAlpha1;
     //---------------------------------------------------------------
     //-- Line coupe le cercle Circle+ (=C(x1,y1,R1+Tol))
-    //modified by NIZNHY-PKV Thu May 12 12:25:17 2011f
     b2Sol=Standard_False;
     if (R>dO1O2+TolTang) {
       Standard_Real aX2, aTol2;
@@ -449,7 +448,6 @@ void LineCircleGeometricIntersection(const gp_Lin2d& Line,
     }
     if(dO1O2 > RmTol && !b2Sol) { 
     //if(dO1O2 > RmTol) { 
-    //modified by NIZNHY-PKV Thu May 12 12:25:20 2011t
       Standard_Real dx=dO1O2;
       Standard_Real dy=0.0;     //(RpTol*RpTol-dx*dx); //Patch !!!
       dy=(dy>=0.0)? Sqrt(dy) : 0.0;
@@ -1023,26 +1021,33 @@ static inline void getDomainParametrs(const IntRes2d_Domain& theDomain,
 }
 
 
+//=======================================================================
+//function : computeIntPoint
+//purpose  : 
+//=======================================================================
 static Standard_Boolean computeIntPoint(const IntRes2d_Domain& theCurDomain,
-                                                         const IntRes2d_Domain& theDomainOther,
-                                                         const gp_Lin2d& theCurLin,
-                                                         const gp_Lin2d& theOtherLin,   
-                                                         Standard_Real theCosT1T2,
-                                                         Standard_Real theParCur, Standard_Real theParOther,
-                                                         Standard_Real& theResInf, Standard_Real& theResSup,
-                                                         Standard_Integer theNum,
-                                                         IntRes2d_TypeTrans theCurTrans,    
-                                                         IntRes2d_IntersectionPoint& theNewPoint)
+                                       const IntRes2d_Domain& theDomainOther,
+                                       const gp_Lin2d& theCurLin,
+                                       const gp_Lin2d& theOtherLin,   
+                                       Standard_Real theCosT1T2,
+                                       Standard_Real theParCur, Standard_Real theParOther,
+                                       Standard_Real& theResInf, Standard_Real& theResSup,
+                                       Standard_Integer theNum,
+                                       IntRes2d_TypeTrans theCurTrans,    
+                                       IntRes2d_IntersectionPoint& theNewPoint)
 {
   if(fabs(theResSup-theParCur) > fabs(theResInf-theParCur))
     theResSup = theResInf;
 
   Standard_Real aRes2 = theParOther + (theResSup - theParCur) * theCosT1T2;
 
-  Standard_Real aFirst2, aLast2, aTol1, aTol2;
-  getDomainParametrs(theDomainOther,aFirst2, aLast2, aTol1, aTol2);
-  if( aRes2  < aFirst2 - aTol1 || aRes2  > aLast2 + aTol2 ) 
-         return Standard_False;
+  Standard_Real aFirst2, aLast2, aTol21, aTol22, aTol11, aTol12 ;
+  
+  getDomainParametrs(theDomainOther,aFirst2, aLast2, aTol21, aTol22);
+  
+  if( aRes2  < aFirst2 - aTol21 || aRes2  > aLast2 + aTol22 ) {
+    return Standard_False;
+  }
        
   //------ compute parameters of intersection point --
   IntRes2d_Transition aT1,aT2;
@@ -1069,7 +1074,7 @@ static Standard_Boolean computeIntPoint(const IntRes2d_Domain& theCurDomain,
   Standard_Real aResU2 = theParOther;
 
   Standard_Real aFirst1, aLast1;
-  getDomainParametrs(theCurDomain,aFirst1, aLast1, aTol1, aTol2);
+  getDomainParametrs(theCurDomain,aFirst1, aLast1, aTol11, aTol12);
   
   Standard_Boolean isInside1 = (theParCur >= aFirst1 && theParCur <= aLast1);
   Standard_Boolean isInside2 = (theParOther >= aFirst2 && theParOther <= aLast2);
@@ -1093,6 +1098,13 @@ static Standard_Boolean computeIntPoint(const IntRes2d_Domain& theCurDomain,
     }
     else 
     {
+      //PKVf
+      // check that parameters are within range on both curves
+      if ( theParCur < aFirst1-aTol11 || theParCur > aLast1+aTol12 ||
+           theParOther < aFirst2-aTol21 || theParOther > aLast2+aTol22) {
+        return Standard_False;
+      }
+      //PKVt
       aResU1 = theResSup;
       aResU2= aRes2;
     }