0027357: Geom2dGcc_Circ2d2TanOn: check status of sub-algorithms to avoid exceptions
authorisn <isn@opencascade.com>
Fri, 17 Jun 2016 11:50:50 +0000 (14:50 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 30 Jun 2016 10:49:20 +0000 (13:49 +0300)
Additional checks for underlying algorithms have been added

test case

get rid of the warning

src/Geom2dGcc/Geom2dGcc_Circ2d2TanOn.cxx
src/QABugs/QABugs_20.cxx
tests/bugs/modalg_6/bug27357 [new file with mode: 0644]

index bb963b7..6d1370b 100644 (file)
@@ -87,11 +87,14 @@ Geom2dGcc_Circ2d2TanOn::
                               GccEnt_QualifiedCirc(c2,Qualified2.Qualifier()),
                                        CCon->Circ2d(),Tolerance);
            WellDone = CircAna.IsDone();
-           NbrSol = CircAna.NbSolutions();
-           for(Standard_Integer i=1; i<=NbrSol; i++) {
-             CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
-           }
-           Results(CircAna);
+            if (WellDone)
+            {
+              NbrSol = CircAna.NbSolutions();
+              for(Standard_Integer i=1; i<=NbrSol; i++) {
+                CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
+              }
+              Results(CircAna);
+            }
          }
          else {
            Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con);
@@ -99,11 +102,14 @@ Geom2dGcc_Circ2d2TanOn::
                               GccEnt_QualifiedCirc(c2,Qualified2.Qualifier()),
                                        LLon->Lin2d(),Tolerance);
            WellDone = CircAna.IsDone();
-           NbrSol = CircAna.NbSolutions();
-           for(Standard_Integer i=1; i<=NbrSol; i++) {
-             CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
-           }
-           Results(CircAna);
+            if (WellDone)
+            {
+              NbrSol = CircAna.NbSolutions();
+              for(Standard_Integer i=1; i<=NbrSol; i++) {
+                CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
+              }
+              Results(CircAna);
+            }
          }
        }
        else {
@@ -115,11 +121,14 @@ Geom2dGcc_Circ2d2TanOn::
                               GccEnt_QualifiedLin(l2,Qualified2.Qualifier()),
                                        CCon->Circ2d(),Tolerance);
            WellDone = CircAna.IsDone();
-           NbrSol = CircAna.NbSolutions();
-           for(Standard_Integer i=1; i<=NbrSol; i++) {
-             CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
-           }
-           Results(CircAna);
+            if (WellDone)
+            {
+              NbrSol = CircAna.NbSolutions();
+              for(Standard_Integer i=1; i<=NbrSol; i++) {
+                CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
+              }
+              Results(CircAna);
+            }
          }
          else {
            Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con);
@@ -127,11 +136,14 @@ Geom2dGcc_Circ2d2TanOn::
                               GccEnt_QualifiedLin(l2,Qualified2.Qualifier()),
                                        LLon->Lin2d(),Tolerance);
            WellDone = CircAna.IsDone();
-           NbrSol = CircAna.NbSolutions();
-           for(Standard_Integer i=1; i<=NbrSol; i++) {
-             CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
-           }
-           Results(CircAna);
+            if (WellDone)
+            {
+              NbrSol = CircAna.NbSolutions();
+              for(Standard_Integer i=1; i<=NbrSol; i++) {
+                CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
+              }
+              Results(CircAna);
+            }
          }
        }
       }
@@ -149,12 +161,15 @@ Geom2dGcc_Circ2d2TanOn::
                                                       Qualified2.Qualifier()),
                                        Ql1,CCon->Circ2d(),Tolerance);
            WellDone = CircAna.IsDone();
-           NbrSol = CircAna.NbSolutions();
-           for(Standard_Integer i=1; i<=NbrSol; i++) {
-             CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
-           }
-           Results(CircAna);
-           Invert = Standard_True;
+            if (WellDone)
+            {
+              NbrSol = CircAna.NbSolutions();
+              for(Standard_Integer i=1; i<=NbrSol; i++) {
+                CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
+              }
+              Results(CircAna);
+              Invert = Standard_True;
+            }
          }
          else {
            Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con);
@@ -162,12 +177,15 @@ Geom2dGcc_Circ2d2TanOn::
                                                       Qualified2.Qualifier()),
                                        Ql1,LLon->Lin2d(),Tolerance);
            WellDone = CircAna.IsDone();
-           NbrSol = CircAna.NbSolutions();
-           for(Standard_Integer i=1; i<=NbrSol; i++) {
-             CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
-           }
-           Results(CircAna);
-           Invert = Standard_True;
+            if (WellDone)
+            {
+              NbrSol = CircAna.NbSolutions();
+              for(Standard_Integer i=1; i<=NbrSol; i++) {
+                CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
+              }
+              Results(CircAna);
+              Invert = Standard_True;
+            }
          }
        }
        else {
@@ -179,11 +197,14 @@ Geom2dGcc_Circ2d2TanOn::
                               GccEnt_QualifiedLin(l2,Qualified2.Qualifier()),
                                        CCon->Circ2d(),Tolerance);
            WellDone = CircAna.IsDone();
-           NbrSol = CircAna.NbSolutions();
-           for(Standard_Integer i=1; i<=NbrSol; i++) {
-             CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
-           }
-           Results(CircAna);
+            if (WellDone)
+            {
+              NbrSol = CircAna.NbSolutions();
+              for(Standard_Integer i=1; i<=NbrSol; i++) {
+                CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
+              }
+              Results(CircAna);
+            }
          }
          else {
            Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con);
@@ -191,11 +212,14 @@ Geom2dGcc_Circ2d2TanOn::
                               GccEnt_QualifiedLin(l2,Qualified2.Qualifier()),
                                        LLon->Lin2d(),Tolerance);
            WellDone = CircAna.IsDone();
-           NbrSol = CircAna.NbSolutions();
-           for(Standard_Integer i=1; i<=NbrSol; i++) {
-             CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
-           }
-           Results(CircAna);
+            if (WellDone)
+            {
+              NbrSol = CircAna.NbSolutions();
+              for(Standard_Integer i=1; i<=NbrSol; i++) {
+                CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
+              }
+              Results(CircAna);
+            }
          }
        }
       }
@@ -218,11 +242,14 @@ Geom2dGcc_Circ2d2TanOn::
            GccEnt_QualifiedCirc(c2,Qualified2.Qualifier());
          Geom2dGcc_Circ2d2TanOnGeo CircGeo(Qc1,Qc2,OnCurve,Tolerance);
          WellDone = CircGeo.IsDone();
-         NbrSol = CircGeo.NbSolutions();
-         for(Standard_Integer i=1; i<=NbrSol; i++) {
-           CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i));
-         }
-         Results(CircGeo);
+          if (WellDone)
+          {
+            NbrSol = CircGeo.NbSolutions();
+            for(Standard_Integer i=1; i<=NbrSol; i++) {
+              CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i));
+            }
+            Results(CircGeo);
+          }
        }
        else {
          Handle(Geom2d_Line) LL2 = Handle(Geom2d_Line)::DownCast(CC2);
@@ -231,11 +258,14 @@ Geom2dGcc_Circ2d2TanOn::
            GccEnt_QualifiedLin(l2,Qualified2.Qualifier());
          Geom2dGcc_Circ2d2TanOnGeo CircGeo(Qc1,Ql2,OnCurve,Tolerance);
          WellDone = CircGeo.IsDone();
-         NbrSol = CircGeo.NbSolutions();
-         for(Standard_Integer i=1; i<=NbrSol; i++) {
-           CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i));
-         }
-         Results(CircGeo);
+          if (WellDone)
+          {
+            NbrSol = CircGeo.NbSolutions();
+            for(Standard_Integer i=1; i<=NbrSol; i++) {
+              CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i));
+            }
+            Results(CircGeo);
+          }
        }
       }
       else {
@@ -250,12 +280,15 @@ Geom2dGcc_Circ2d2TanOn::
            GccEnt_QualifiedCirc(c2,Qualified2.Qualifier());
          Geom2dGcc_Circ2d2TanOnGeo CircGeo(Qc2,Ql1,OnCurve,Tolerance);
          WellDone = CircGeo.IsDone();
-         NbrSol = CircGeo.NbSolutions();
-         for(Standard_Integer i=1; i<=NbrSol; i++) {
-           CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i));
-         }
-         Results(CircGeo);
-         Invert = Standard_True;
+          if (WellDone)
+          {
+            NbrSol = CircGeo.NbSolutions();
+            for(Standard_Integer i=1; i<=NbrSol; i++) {
+              CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i));
+            }
+            Results(CircGeo);
+            Invert = Standard_True;
+          }
        }
        else {
          Handle(Geom2d_Line) LL2 = Handle(Geom2d_Line)::DownCast(CC2);
@@ -264,11 +297,14 @@ Geom2dGcc_Circ2d2TanOn::
            GccEnt_QualifiedLin(l2,Qualified2.Qualifier());
          Geom2dGcc_Circ2d2TanOnGeo CircGeo(Ql1,Ql2,OnCurve,Tolerance);
          WellDone = CircGeo.IsDone();
-         NbrSol = CircGeo.NbSolutions();
-         for(Standard_Integer i=1; i<=NbrSol; i++) {
-           CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i));
-         }
-         Results(CircGeo);
+          if (WellDone)
+          {
+            NbrSol = CircGeo.NbSolutions();
+            for(Standard_Integer i=1; i<=NbrSol; i++) {
+              CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i));
+            }
+            Results(CircGeo);
+          }
        }
       }
     }
@@ -282,43 +318,52 @@ Geom2dGcc_Circ2d2TanOn::
        Geom2dGcc_Circ2d2TanOnIter Circ(Qc1,Qc2,CCon->Circ2d(),
                                   Param1,Param2,ParamOn,Tolerance);
        WellDone = Circ.IsDone();
-       NbrSol = 1;
-       cirsol(1)   = Circ.ThisSolution();
-       if (Circ.IsTheSame1()) { TheSame1(1) = 1; }
-       else {TheSame1(1) = 0; }
-       if (Circ.IsTheSame2()) { TheSame2(1) = 1; }
-       else {TheSame2(1) = 0; }
-       Circ.Tangency1(par1sol(1),pararg1(1),pnttg1sol(1));
-       Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1));
+        if (WellDone)
+        {
+          NbrSol = 1;
+          cirsol(1)   = Circ.ThisSolution();
+          if (Circ.IsTheSame1()) { TheSame1(1) = 1; }
+          else {TheSame1(1) = 0; }
+          if (Circ.IsTheSame2()) { TheSame2(1) = 1; }
+          else {TheSame2(1) = 0; }
+          Circ.Tangency1(par1sol(1),pararg1(1),pnttg1sol(1));
+          Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1));
+        }
       }
       else {
        Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con);
        Geom2dGcc_Circ2d2TanOnIter Circ(Qc1,Qc2,LLon->Lin2d(),
                                       Param1,Param2,ParamOn,Tolerance);
        WellDone = Circ.IsDone();
-       NbrSol = 1;
-       cirsol(1)   = Circ.ThisSolution();
-       if (Circ.IsTheSame1()) { TheSame1(1) = 1; }
-       else {TheSame1(1) = 0; }
-       if (Circ.IsTheSame2()) { TheSame2(1) = 1; }
-       else {TheSame2(1) = 0; }
-       Circ.WhichQualifier(qualifier1(1),qualifier2(1));
-       Circ.Tangency1(par1sol(1),pararg1(1),pnttg1sol(1));
-       Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1));
+        if (WellDone)
+        {
+          NbrSol = 1;
+          cirsol(1)   = Circ.ThisSolution();
+          if (Circ.IsTheSame1()) { TheSame1(1) = 1; }
+          else {TheSame1(1) = 0; }
+          if (Circ.IsTheSame2()) { TheSame2(1) = 1; }
+          else {TheSame2(1) = 0; }
+          Circ.WhichQualifier(qualifier1(1),qualifier2(1));
+          Circ.Tangency1(par1sol(1),pararg1(1),pnttg1sol(1));
+          Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1));
+        }
       }
     }
     Geom2dGcc_Circ2d2TanOnIter Circ(Qc1,Qc2,OnCurve,
                                   Param1,Param2,ParamOn,Tolerance);
     WellDone = Circ.IsDone();
-    NbrSol = 1;
-    cirsol(1)   = Circ.ThisSolution();
-    if (Circ.IsTheSame1()) { TheSame1(1) = 1; }
-    else {TheSame1(1) = 0; }
-    if (Circ.IsTheSame2()) { TheSame2(1) = 1; }
-    else {TheSame2(1) = 0; }
-    Circ.WhichQualifier(qualifier1(1),qualifier2(1));
-    Circ.Tangency1(par1sol(1),pararg1(1),pnttg1sol(1));
-    Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1));
+    if (WellDone)
+    {
+      NbrSol = 1;
+      cirsol(1)   = Circ.ThisSolution();
+      if (Circ.IsTheSame1()) { TheSame1(1) = 1; }
+      else {TheSame1(1) = 0; }
+      if (Circ.IsTheSame2()) { TheSame2(1) = 1; }
+      else {TheSame2(1) = 0; }
+      Circ.WhichQualifier(qualifier1(1),qualifier2(1));
+      Circ.Tangency1(par1sol(1),pararg1(1),pnttg1sol(1));
+      Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1));
+    }
   }
 }
 
@@ -366,21 +411,27 @@ Geom2dGcc_Circ2d2TanOn::
          Handle(Geom2d_Circle) CCon = Handle(Geom2d_Circle)::DownCast(Con);
          GccAna_Circ2d2TanOn CircAna(Qc1,pnt,CCon->Circ2d(),Tolerance);
          WellDone = CircAna.IsDone();
-         NbrSol = CircAna.NbSolutions();
-         for(Standard_Integer i=1; i<=NbrSol; i++) {
-           CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
-         }
-         Results(CircAna);
+          if (WellDone)
+          {
+            NbrSol = CircAna.NbSolutions();
+            for(Standard_Integer i=1; i<=NbrSol; i++) {
+              CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
+            }
+            Results(CircAna);
+          }
        }
        else if (Type3 == GeomAbs_Line) {
          Handle(Geom2d_Line) CCon = Handle(Geom2d_Line)::DownCast(Con);
          GccAna_Circ2d2TanOn CircAna(Qc1,pnt,CCon->Lin2d(),Tolerance);
          WellDone = CircAna.IsDone();
-         NbrSol = CircAna.NbSolutions();
-         for(Standard_Integer i=1; i<=NbrSol; i++) {
-           CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
-         }
-         Results(CircAna);
+          if (WellDone)
+          {
+            NbrSol = CircAna.NbSolutions();
+            for(Standard_Integer i=1; i<=NbrSol; i++) {
+              CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
+            }
+            Results(CircAna);
+          }
        }
       }
       else {
@@ -391,21 +442,27 @@ Geom2dGcc_Circ2d2TanOn::
          Handle(Geom2d_Circle) CCon = Handle(Geom2d_Circle)::DownCast(Con);
          GccAna_Circ2d2TanOn CircAna(Ql1,pnt,CCon->Circ2d(),Tolerance);
          WellDone = CircAna.IsDone();
-         NbrSol = CircAna.NbSolutions();
-         for(Standard_Integer i=1; i<=NbrSol; i++) {
-           CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
-         }
-         Results(CircAna);
+          if (WellDone)
+          {
+            NbrSol = CircAna.NbSolutions();
+            for(Standard_Integer i=1; i<=NbrSol; i++) {
+              CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
+            }
+            Results(CircAna);
+          }
        }
        else if (Type3 == GeomAbs_Line) {
          Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con);
          GccAna_Circ2d2TanOn CircAna(Ql1,pnt,LLon->Lin2d(),Tolerance);
          WellDone = CircAna.IsDone();
-         NbrSol = CircAna.NbSolutions();
-         for(Standard_Integer i=1; i<=NbrSol; i++) {
-           CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
-         }
-         Results(CircAna);
+          if (WellDone)
+          {
+            NbrSol = CircAna.NbSolutions();
+            for(Standard_Integer i=1; i<=NbrSol; i++) {
+              CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
+            }
+            Results(CircAna);
+          }
        }
       }
     }
@@ -420,11 +477,14 @@ Geom2dGcc_Circ2d2TanOn::
        GccEnt_QualifiedCirc Qc1(c1,Qualified1.Qualifier());
        Geom2dGcc_Circ2d2TanOnGeo CircGeo(Qc1,Point->Pnt2d(),OnCurve,Tolerance);
        WellDone = CircGeo.IsDone();
-       NbrSol = CircGeo.NbSolutions();
-       for(Standard_Integer i=1; i<=NbrSol; i++) {
-         CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i));
-       }
-       Results(CircGeo);
+        if (WellDone)
+        {
+          NbrSol = CircGeo.NbSolutions();
+          for(Standard_Integer i=1; i<=NbrSol; i++) {
+            CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i));
+          }
+          Results(CircGeo);
+        }
       }
       else {
        Handle(Geom2d_Line) LLL1 = Handle(Geom2d_Line)::DownCast(CC1);
@@ -432,11 +492,14 @@ Geom2dGcc_Circ2d2TanOn::
        GccEnt_QualifiedLin Ql1(l1,Qualified1.Qualifier());
        Geom2dGcc_Circ2d2TanOnGeo CircGeo(Ql1,Point->Pnt2d(),OnCurve,Tolerance);
        WellDone = CircGeo.IsDone();
-       NbrSol = CircGeo.NbSolutions();
-       for(Standard_Integer i=1; i<=NbrSol; i++) {
-         CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i));
-       }
-       Results(CircGeo);
+        if (WellDone)
+        {
+          NbrSol = CircGeo.NbSolutions();
+          for(Standard_Integer i=1; i<=NbrSol; i++) {
+            CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i));
+          }
+          Results(CircGeo);
+        }
       }
     }
   }                                   
@@ -448,41 +511,50 @@ Geom2dGcc_Circ2d2TanOn::
        Geom2dGcc_Circ2d2TanOnIter Circ(Qc1,Point->Pnt2d(),CCon->Circ2d(),
                                   Param1,ParamOn,Tolerance);
        WellDone = Circ.IsDone();
-       NbrSol = 1;
-       cirsol(1)   = Circ.ThisSolution();
-       if (Circ.IsTheSame1()) { TheSame1(1) = 1; }
-       else {TheSame1(1) = 0; }
-       Circ.WhichQualifier(qualifier1(1),qualifier2(1));
-       Circ.Tangency1(par1sol(1),pararg1(1),pnttg1sol(1));
-       Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1));
+        if (WellDone)
+        {
+          NbrSol = 1;
+          cirsol(1)   = Circ.ThisSolution();
+          if (Circ.IsTheSame1()) { TheSame1(1) = 1; }
+          else {TheSame1(1) = 0; }
+          Circ.WhichQualifier(qualifier1(1),qualifier2(1));
+          Circ.Tangency1(par1sol(1),pararg1(1),pnttg1sol(1));
+          Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1));
+        }
       }
       else {
        Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con);
        Geom2dGcc_Circ2d2TanOnIter Circ(Qc1,Point->Pnt2d(),LLon->Lin2d(),
                                       Param1,ParamOn,Tolerance);
        WellDone = Circ.IsDone();
-       NbrSol = 1;
-       cirsol(1)   = Circ.ThisSolution();
-       if (Circ.IsTheSame1()) { TheSame1(1) = 1; }
-       else {TheSame1(1) = 0; }
-       Circ.WhichQualifier(qualifier1(1),qualifier2(1));
-       Circ.Tangency1(par1sol(1),pararg1(1),pnttg1sol(1));
-       Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1));
+        if (WellDone)
+        {
+          NbrSol = 1;
+          cirsol(1)   = Circ.ThisSolution();
+          if (Circ.IsTheSame1()) { TheSame1(1) = 1; }
+          else {TheSame1(1) = 0; }
+          Circ.WhichQualifier(qualifier1(1),qualifier2(1));
+          Circ.Tangency1(par1sol(1),pararg1(1),pnttg1sol(1));
+          Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1));
+        }
       }
     }
     else {
       Geom2dGcc_Circ2d2TanOnIter Circ(Qc1,Point->Pnt2d(),OnCurve,
                                 Param1,ParamOn,Tolerance);
       WellDone = Circ.IsDone();
-      NbrSol = 1;
-      cirsol(1)   = Circ.ThisSolution();
-      if (Circ.IsTheSame1()) { TheSame1(1) = 1; }
-      else {TheSame1(1) = 0; }
-      if (Circ.IsTheSame2()) { TheSame2(1) = 1; }
-      else {TheSame2(1) = 0; }
-      Circ.WhichQualifier(qualifier1(1),qualifier2(1));
-      Circ.Tangency1(par1sol(1),pararg1(1),pnttg1sol(1));
-      Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1));
+      if (WellDone)
+      {
+        NbrSol = 1;
+        cirsol(1)   = Circ.ThisSolution();
+        if (Circ.IsTheSame1()) { TheSame1(1) = 1; }
+        else {TheSame1(1) = 0; }
+        if (Circ.IsTheSame2()) { TheSame2(1) = 1; }
+        else {TheSame2(1) = 0; }
+        Circ.WhichQualifier(qualifier1(1),qualifier2(1));
+        Circ.Tangency1(par1sol(1),pararg1(1),pnttg1sol(1));
+        Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1));
+      }
     }
   }
 }
@@ -523,21 +595,27 @@ Geom2dGcc_Circ2d2TanOn::
       Handle(Geom2d_Circle) CCon = Handle(Geom2d_Circle)::DownCast(Con);
       GccAna_Circ2d2TanOn CircAna(pnt1,pnt2,CCon->Circ2d(),Tolerance);
       WellDone = CircAna.IsDone();
-      NbrSol = CircAna.NbSolutions();
-      for(Standard_Integer i=1; i<=NbrSol; i++) {
-       CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
+      if (WellDone)
+      {
+        NbrSol = CircAna.NbSolutions();
+        for(Standard_Integer i=1; i<=NbrSol; i++) {
+          CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
+        }
+        Results(CircAna);
       }
-      Results(CircAna);
     }
     else {
       Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con);
       GccAna_Circ2d2TanOn CircAna(pnt1,pnt2,LLon->Lin2d(),Tolerance);
       WellDone = CircAna.IsDone();
-      NbrSol = CircAna.NbSolutions();
-      for(Standard_Integer i=1; i<=NbrSol; i++) {
-       CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
+      if (WellDone)
+      {
+        NbrSol = CircAna.NbSolutions();
+        for(Standard_Integer i=1; i<=NbrSol; i++) {
+          CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i));
+        }
+        Results(CircAna);
       }
-      Results(CircAna);
     }
   }
 
@@ -549,11 +627,14 @@ Geom2dGcc_Circ2d2TanOn::
     Geom2dGcc_Circ2d2TanOnGeo CircGeo(Point1->Pnt2d(),Point2->Pnt2d(),
                                     OnCurve,Tolerance);
     WellDone = CircGeo.IsDone();
-    NbrSol = CircGeo.NbSolutions();
-    for(Standard_Integer i=1; i<=NbrSol; i++) {
-      CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i));
+    if (WellDone)
+    {
+      NbrSol = CircGeo.NbSolutions();
+      for(Standard_Integer i=1; i<=NbrSol; i++) {
+        CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i));
+      }
+      Results(CircGeo);
     }
-    Results(CircGeo);
   }
 }
 
index 011ca26..bf4fba6 100644 (file)
@@ -1975,6 +1975,57 @@ static Standard_Integer OCC26747_3(Draw_Interpretor& theDI,
   return 0;
 }
 
+#include "Geom2d_BezierCurve.hxx"
+#include "Geom2dGcc_QualifiedCurve.hxx"
+#include "Geom2dAdaptor_Curve.hxx"
+#include "Geom2dAPI_ProjectPointOnCurve.hxx"
+#include "Geom2dGcc_Circ2d2TanOn.hxx"
+//=======================================================================
+//function : OCC27357
+//purpose :
+//=======================================================================
+static Standard_Integer OCC27357(Draw_Interpretor& theDI,
+                                 Standard_Integer,
+                                 const char **)
+{
+  TColgp_Array1OfPnt2d aPoles(1,3);
+  aPoles.SetValue(1, gp_Pnt2d(0.,0.));
+  aPoles.SetValue(2, gp_Pnt2d(0.,1.));
+  aPoles.SetValue(3, gp_Pnt2d(6.,0.));
+
+  Handle(Geom2d_BezierCurve) aCurve1 = new Geom2d_BezierCurve(aPoles);
+  aPoles.SetValue(2, gp_Pnt2d(0.,1.5));
+  Handle(Geom2d_BezierCurve) aCurve2 = new Geom2d_BezierCurve(aPoles);
+  NCollection_List<Standard_Integer> aDuumyList;
+  int nP = 100;
+  for(int i = 0 ; i < nP ; i++){
+    Standard_Real u = i / (nP-1.);
+    gp_Pnt2d aP1;
+    gp_Vec2d aTangent;
+    aCurve1->D1(u,aP1,aTangent);
+    gp_Vec2d aNormal(-aTangent.Y(),aTangent.X());
+    Handle(Geom2d_Line) normalLine=new Geom2d_Line(aP1, gp_Dir2d(aNormal));
+    Geom2dGcc_QualifiedCurve qualifiedC1(Geom2dAdaptor_Curve(aCurve1),GccEnt_unqualified);
+    Geom2dGcc_QualifiedCurve qualifiedC2(Geom2dAdaptor_Curve(aCurve2),GccEnt_unqualified);
+
+    try
+    {
+      Geom2dAPI_ProjectPointOnCurve projPc1(aP1, aCurve1);
+      double g1 = projPc1.LowerDistanceParameter();
+      Geom2dAPI_ProjectPointOnCurve projPc3(aP1, normalLine);
+      double g3 = projPc3.LowerDistanceParameter();
+      Geom2dGcc_Circ2d2TanOn aCircleBuilder(qualifiedC1,qualifiedC2,
+        Geom2dAdaptor_Curve(normalLine),1e-9,g1,g1,g3);
+      aDuumyList.Append(aCircleBuilder.NbSolutions());
+    }
+    catch(Standard_Failure)
+    {
+      theDI << "Exception was caught\n";
+    }
+  }
+  return 0;
+}
+
 void QABugs::Commands_20(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
@@ -1990,6 +2041,6 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
   theCommands.Add ("OCC26747_1", "OCC26747_1 result", __FILE__, OCC26747_1, group);
   theCommands.Add ("OCC26747_2", "OCC26747_2 result", __FILE__, OCC26747_2, group);
   theCommands.Add ("OCC26747_3", "OCC26747_3 result", __FILE__, OCC26747_3, group);
-
+  theCommands.Add ("OCC27357", "OCC27357", __FILE__, OCC27357, group);
   return;
 }
diff --git a/tests/bugs/modalg_6/bug27357 b/tests/bugs/modalg_6/bug27357
new file mode 100644 (file)
index 0000000..583b089
--- /dev/null
@@ -0,0 +1,16 @@
+puts "========"
+puts "OCC27357"
+puts "========"
+puts ""
+#################################################################
+# Geom2dGcc_Circ2d2TanOn: check status of sub-algorithms to avoid exceptions
+#################################################################
+
+pload QAcommands
+
+set info [OCC27357]
+if { [regexp "Exception" $info] != 0 } {
+    puts "Error : Exception was caught"
+} else {
+    puts "OK"
+}