From 4c26106f76a508beaceae1b41721814df67d07cd Mon Sep 17 00:00:00 2001 From: gka Date: Thu, 7 Nov 2019 18:09:48 +0300 Subject: [PATCH] 0031140: Draw command "cirtang" raises exception on the parallel curves Exception in the algorithm Geom2dGcc_Circ2dTanOnRadGeo raised because the number of solutions exceeded the size of reserved array for solutions. A check has been added to forbid adding solutions outside of allocated place. The similar protection has been done in other algorithms of this package. --- src/GccAna/GccAna_Circ2dTanOnRad_3.cxx | 8 +- src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cxx | 170 +++++++++--------- src/Geom2dGcc/Geom2dGcc_Circ2d2TanRad.cxx | 22 +-- src/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cxx | 16 +- src/Geom2dGcc/Geom2dGcc_Circ2d3Tan.cxx | 32 ++-- src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cxx | 110 ++++++------ tests/lowalgos/2dgcc/bug31140 | 9 + 7 files changed, 190 insertions(+), 177 deletions(-) create mode 100644 tests/lowalgos/2dgcc/bug31140 diff --git a/src/GccAna/GccAna_Circ2dTanOnRad_3.cxx b/src/GccAna/GccAna_Circ2dTanOnRad_3.cxx index 84bbcced84..bfe6e81ae3 100644 --- a/src/GccAna/GccAna_Circ2dTanOnRad_3.cxx +++ b/src/GccAna/GccAna_Circ2dTanOnRad_3.cxx @@ -97,10 +97,10 @@ GccAna_Circ2dTanOnRad:: else { if (Abs(Radius-R1) < Tol) { if (OnCirc.Distance(center1) < Tol) { - cirsol(NbrSol) = C1; + NbrSol = 1; + cirsol(NbrSol) = C1; // ============== qualifier1(NbrSol) = Qualified1.Qualifier(); - NbrSol = 1; TheSame1(NbrSol) = 1; pntcen3(NbrSol) = center1; parcen3(NbrSol)=ElCLib::Parameter(OnCirc,pntcen3(NbrSol)); @@ -126,10 +126,10 @@ GccAna_Circ2dTanOnRad:: else { if (Abs(Radius-R1) < Tol) { if (OnCirc.Distance(center1) < Tol) { - cirsol(NbrSol) = C1; + NbrSol = 1; + cirsol(NbrSol) = C1; // ============== qualifier1(NbrSol) = Qualified1.Qualifier(); - NbrSol = 1; TheSame1(NbrSol) = 1; pntcen3(NbrSol) = center1; parcen3(NbrSol)=ElCLib::Parameter(OnCirc,pntcen3(NbrSol)); diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cxx b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cxx index 91b5047309..da11146c0f 100644 --- a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cxx +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnGeo.cxx @@ -46,24 +46,26 @@ #include #include +static const Standard_Integer aNbSolMAX = 8; + Geom2dGcc_Circ2d2TanOnGeo:: Geom2dGcc_Circ2d2TanOnGeo (const GccEnt_QualifiedCirc& Qualified1 , const GccEnt_QualifiedCirc& Qualified2 , const Geom2dAdaptor_Curve& OnCurv , const Standard_Real Tolerance ): - cirsol(1,8) , - qualifier1(1,8), - qualifier2(1,8), - TheSame1(1,8) , - TheSame2(1,8) , - pnttg1sol(1,8) , - pnttg2sol(1,8) , - pntcen(1,8) , - par1sol(1,8) , - par2sol(1,8) , - pararg1(1,8) , - pararg2(1,8) , - parcen3(1,8) + cirsol(1, aNbSolMAX) , + qualifier1(1, aNbSolMAX), + qualifier2(1, aNbSolMAX), + TheSame1(1, aNbSolMAX) , + TheSame2(1, aNbSolMAX) , + pnttg1sol(1, aNbSolMAX) , + pnttg2sol(1, aNbSolMAX) , + pntcen(1, aNbSolMAX) , + par1sol(1, aNbSolMAX) , + par2sol(1, aNbSolMAX) , + pararg1(1, aNbSolMAX) , + pararg2(1, aNbSolMAX) , + parcen3(1, aNbSolMAX) { WellDone = Standard_False; Standard_Real thefirst = -100000.; @@ -200,7 +202,7 @@ Geom2dGcc_Circ2d2TanOnGeo (const GccEnt_QualifiedCirc& Qualified1 , } } if (nnsol > 0) { - for (Standard_Integer k = 1 ; k <= nnsol ; k++) { + for (Standard_Integer k = 1 ; k <= nnsol && NbrSol < aNbSolMAX; k++) { NbrSol++; cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius(k)); // ========================================================== @@ -276,19 +278,19 @@ Geom2dGcc_Circ2d2TanOnGeo (const GccEnt_QualifiedCirc& Qualified1 , const GccEnt_QualifiedLin& Qualified2 , const Geom2dAdaptor_Curve& OnCurv , const Standard_Real Tolerance ): -cirsol(1,8) , -qualifier1(1,8), -qualifier2(1,8), -TheSame1(1,8) , -TheSame2(1,8) , -pnttg1sol(1,8) , -pnttg2sol(1,8) , -pntcen(1,8) , -par1sol(1,8) , -par2sol(1,8) , -pararg1(1,8) , -pararg2(1,8) , -parcen3(1,8) +cirsol(1, aNbSolMAX) , +qualifier1(1, aNbSolMAX), +qualifier2(1, aNbSolMAX), +TheSame1(1, aNbSolMAX) , +TheSame2(1, aNbSolMAX) , +pnttg1sol(1, aNbSolMAX) , +pnttg2sol(1, aNbSolMAX) , +pntcen(1, aNbSolMAX) , +par1sol(1, aNbSolMAX) , +par2sol(1, aNbSolMAX) , +pararg1(1, aNbSolMAX) , +pararg2(1, aNbSolMAX) , +parcen3(1, aNbSolMAX) { WellDone = Standard_False; @@ -353,7 +355,7 @@ parcen3(1,8) } if (Intp.IsDone()) { if (!Intp.IsEmpty()) { - for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) { + for (Standard_Integer j = 1 ; j <= Intp.NbPoints() && NbrSol < aNbSolMAX; j++) { gp_Pnt2d Center(Intp.Point(j).Value()); Standard_Real dist1 = Center.Distance(center1); // Standard_Integer nbsol = 1; @@ -454,19 +456,19 @@ Geom2dGcc_Circ2d2TanOnGeo (const GccEnt_QualifiedLin& Qualified1 , const GccEnt_QualifiedLin& Qualified2 , const Geom2dAdaptor_Curve& OnCurv , const Standard_Real Tolerance ): -cirsol(1,8) , -qualifier1(1,8), -qualifier2(1,8), -TheSame1(1,8) , -TheSame2(1,8) , -pnttg1sol(1,8) , -pnttg2sol(1,8) , -pntcen(1,8) , -par1sol(1,8) , -par2sol(1,8) , -pararg1(1,8) , -pararg2(1,8) , -parcen3(1,8) +cirsol(1, aNbSolMAX) , +qualifier1(1, aNbSolMAX), +qualifier2(1, aNbSolMAX), +TheSame1(1, aNbSolMAX) , +TheSame2(1, aNbSolMAX) , +pnttg1sol(1, aNbSolMAX) , +pnttg2sol(1, aNbSolMAX) , +pntcen(1, aNbSolMAX) , +par1sol(1, aNbSolMAX) , +par2sol(1, aNbSolMAX) , +pararg1(1, aNbSolMAX) , +pararg2(1, aNbSolMAX) , +parcen3(1, aNbSolMAX) { WellDone = Standard_False; @@ -510,7 +512,7 @@ parcen3(1,8) Intp.Perform(Bis.ThisSolution(i),D1,C2,D2,Tol1,Tol2); if (Intp.IsDone()) { if ((!Intp.IsEmpty())) { - for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) { + for (Standard_Integer j = 1 ; j <= Intp.NbPoints() && NbrSol < aNbSolMAX; j++) { gp_Pnt2d Center(Intp.Point(j).Value()); Standard_Real dist1 = L1.Distance(Center); Standard_Real dist2 = L2.Distance(Center); @@ -609,19 +611,19 @@ Geom2dGcc_Circ2d2TanOnGeo (const GccEnt_QualifiedCirc& Qualified1 , const gp_Pnt2d& Point2 , const Geom2dAdaptor_Curve& OnCurv , const Standard_Real Tolerance ): -cirsol(1,8) , -qualifier1(1,8), -qualifier2(1,8), -TheSame1(1,8) , -TheSame2(1,8) , -pnttg1sol(1,8) , -pnttg2sol(1,8) , -pntcen(1,8) , -par1sol(1,8) , -par2sol(1,8) , -pararg1(1,8) , -pararg2(1,8) , -parcen3(1,8) +cirsol(1, aNbSolMAX) , +qualifier1(1, aNbSolMAX), +qualifier2(1, aNbSolMAX), +TheSame1(1, aNbSolMAX) , +TheSame2(1, aNbSolMAX) , +pnttg1sol(1, aNbSolMAX) , +pnttg2sol(1, aNbSolMAX) , +pntcen(1, aNbSolMAX) , +par1sol(1, aNbSolMAX) , +par2sol(1, aNbSolMAX) , +pararg1(1, aNbSolMAX) , +pararg2(1, aNbSolMAX) , +parcen3(1, aNbSolMAX) { WellDone = Standard_False; @@ -697,7 +699,7 @@ parcen3(1,8) } if (Intp.IsDone()) { if ((!Intp.IsEmpty())) { - for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) { + for (Standard_Integer j = 1 ; j <= Intp.NbPoints() && NbrSol < aNbSolMAX; j++) { gp_Pnt2d Center(Intp.Point(j).Value()); Radius = Center.Distance(Point2); Standard_Real dist1 = center1.Distance(Center); @@ -771,19 +773,19 @@ Geom2dGcc_Circ2d2TanOnGeo (const GccEnt_QualifiedLin& Qualified1 , const gp_Pnt2d& Point2 , const Geom2dAdaptor_Curve& OnCurv , const Standard_Real Tolerance ): -cirsol(1,8) , -qualifier1(1,8), -qualifier2(1,8), -TheSame1(1,8) , -TheSame2(1,8) , -pnttg1sol(1,8) , -pnttg2sol(1,8) , -pntcen(1,8) , -par1sol(1,8) , -par2sol(1,8) , -pararg1(1,8) , -pararg2(1,8) , -parcen3(1,8) +cirsol(1, aNbSolMAX) , +qualifier1(1, aNbSolMAX), +qualifier2(1, aNbSolMAX), +TheSame1(1, aNbSolMAX) , +TheSame2(1, aNbSolMAX) , +pnttg1sol(1, aNbSolMAX) , +pnttg2sol(1, aNbSolMAX) , +pntcen(1, aNbSolMAX) , +par1sol(1, aNbSolMAX) , +par2sol(1, aNbSolMAX) , +pararg1(1, aNbSolMAX) , +pararg2(1, aNbSolMAX) , +parcen3(1, aNbSolMAX) { WellDone = Standard_False; @@ -839,7 +841,7 @@ parcen3(1,8) } if (Intp.IsDone()) { if ((!Intp.IsEmpty())) { - for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) { + for (Standard_Integer j = 1 ; j <= Intp.NbPoints() && NbrSol < aNbSolMAX; j++) { gp_Pnt2d Center(Intp.Point(j).Value()); Standard_Real Radius = L1.Distance(Center); // Standard_Integer nbsol = 1; @@ -908,19 +910,19 @@ Geom2dGcc_Circ2d2TanOnGeo (const gp_Pnt2d& Point1 , const gp_Pnt2d& Point2 , const Geom2dAdaptor_Curve& OnCurv , const Standard_Real Tolerance ): -cirsol(1,8) , -qualifier1(1,8), -qualifier2(1,8), -TheSame1(1,8) , -TheSame2(1,8) , -pnttg1sol(1,8) , -pnttg2sol(1,8) , -pntcen(1,8) , -par1sol(1,8) , -par2sol(1,8) , -pararg1(1,8) , -pararg2(1,8) , -parcen3(1,8) +cirsol(1, aNbSolMAX) , +qualifier1(1, aNbSolMAX), +qualifier2(1, aNbSolMAX), +TheSame1(1, aNbSolMAX) , +TheSame2(1, aNbSolMAX) , +pnttg1sol(1, aNbSolMAX) , +pnttg2sol(1, aNbSolMAX) , +pntcen(1, aNbSolMAX) , +par1sol(1, aNbSolMAX) , +par2sol(1, aNbSolMAX) , +pararg1(1, aNbSolMAX) , +pararg2(1, aNbSolMAX) , +parcen3(1, aNbSolMAX) { WellDone = Standard_False; @@ -947,7 +949,7 @@ parcen3(1,8) Intp.Perform(Bis.ThisSolution(),D1,Cu2,D2,Tol1,Tol2); if (Intp.IsDone()) { if ((!Intp.IsEmpty())) { - for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) { + for (Standard_Integer j = 1 ; j <= Intp.NbPoints() && NbrSol < aNbSolMAX; j++) { gp_Pnt2d Center(Intp.Point(j).Value()); Standard_Real Radius = Point2.Distance(Center); NbrSol++; diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRad.cxx b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRad.cxx index f0d174f744..243d696a07 100644 --- a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRad.cxx +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRad.cxx @@ -262,17 +262,17 @@ Geom2dGcc_Circ2d2TanRad:: const Handle(Geom2d_Point)& Point , const Standard_Real Radius , const Standard_Real Tolerance ): - cirsol(1,8) , - qualifier1(1,8), - qualifier2(1,8), - TheSame1(1,8) , - TheSame2(1,8) , - pnttg1sol(1,8), - pnttg2sol(1,8), - par1sol(1,8) , - par2sol(1,8) , - pararg1(1,8) , - pararg2(1,8) + cirsol(1,aNbSolMAX) , + qualifier1(1,aNbSolMAX), + qualifier2(1,aNbSolMAX), + TheSame1(1,aNbSolMAX) , + TheSame2(1,aNbSolMAX) , + pnttg1sol(1,aNbSolMAX), + pnttg2sol(1,aNbSolMAX), + par1sol(1,aNbSolMAX) , + par2sol(1,aNbSolMAX) , + pararg1(1,aNbSolMAX) , + pararg2(1,aNbSolMAX) { if (Radius < 0.) { throw Standard_NegativeValue(); } else { diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cxx b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cxx index 2160dba82a..2c3caa0bb4 100644 --- a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cxx +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanRadGeo.cxx @@ -181,7 +181,7 @@ pararg2(1,aNbSolMAX) gp_Pnt2d Point(L1.Location().XY()+cote1(jcote1)*Dir.XY()); gp_Lin2d Line(Point,L1.Direction()); // ligne avec deport. IntRes2d_Domain D1; - for (Standard_Integer jcote2 = 1 ; jcote2 <= nbrcote2 ; jcote2++) { + for (Standard_Integer jcote2 = 1; jcote2 <= nbrcote2 && NbrSol < aNbSolMAX; jcote2++) { Handle(Geom2dAdaptor_HCurve) HCu2 = new Geom2dAdaptor_HCurve(Cu2); Adaptor2d_OffsetCurve C2(HCu2,cote2(jcote2)); firstparam = Max(C2.FirstParameter(),thefirst); @@ -191,7 +191,7 @@ pararg2(1,aNbSolMAX) Geom2dInt_TheIntConicCurveOfGInter Intp(Line,D1,C2,D2,Tol,Tol); if (Intp.IsDone()) { if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { + for (Standard_Integer i = 1; i <= Intp.NbPoints() && NbrSol < aNbSolMAX; i++) { NbrSol++; gp_Pnt2d Center(Intp.Point(i).Value()); cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); @@ -360,7 +360,7 @@ pararg2(1,aNbSolMAX) } Standard_Real R1 = C1.Radius(); Geom2dInt_TheIntConicCurveOfGInter Intp; - for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { + for (Standard_Integer jcote1 = 1; jcote1 <= nbrcote1 && NbrSol < aNbSolMAX; jcote1++) { gp_Circ2d Circ(C1.XAxis(),R1+cote1(jcote1)); IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol, ElCLib::Value(2.*M_PI,Circ),2.*M_PI,Tol); @@ -375,7 +375,7 @@ pararg2(1,aNbSolMAX) Intp.Perform(Circ,D1,C2,D2,Tol,Tol); if (Intp.IsDone()) { if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { + for (Standard_Integer i = 1; i <= Intp.NbPoints() && NbrSol < aNbSolMAX; i++) { NbrSol++; gp_Pnt2d Center(Intp.Point(i).Value()); cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); @@ -497,7 +497,7 @@ pararg2(1,aNbSolMAX) ElCLib::Value(M_PI+M_PI,Circ),M_PI+M_PI,Tol); D1.SetEquivalentParameters(0.,M_PI+M_PI); Geom2dInt_TheIntConicCurveOfGInter Intp; - for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { + for (Standard_Integer jcote1 = 1; jcote1 <= nbrcote1 && NbrSol < aNbSolMAX; jcote1++) { Handle(Geom2dAdaptor_HCurve) HCu1 = new Geom2dAdaptor_HCurve(Cu1); Adaptor2d_OffsetCurve Cu2(HCu1,cote1(jcote1)); firstparam = Max(Cu2.FirstParameter(),thefirst); @@ -507,7 +507,7 @@ pararg2(1,aNbSolMAX) Intp.Perform(Circ,D1,Cu2,D2,Tol,Tol); if (Intp.IsDone()) { if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { + for (Standard_Integer i = 1; i <= Intp.NbPoints() && NbrSol < aNbSolMAX; i++) { NbrSol++; gp_Pnt2d Center(Intp.Point(i).Value()); cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); @@ -839,7 +839,7 @@ pararg2(1,aNbSolMAX) IntRes2d_Domain D2C1(C1.Value(firstparam),firstparam,Tol, C1.Value(lastparam),lastparam,Tol); #endif - for (Standard_Integer jcote2 = 1 ; jcote2 <= nbrcote2 ; jcote2++) { + for (Standard_Integer jcote2 = 1; jcote2 <= nbrcote2 && NbrSol < aNbSolMAX; jcote2++) { Handle(Geom2dAdaptor_HCurve) HCu2 = new Geom2dAdaptor_HCurve(Cu2); Adaptor2d_OffsetCurve C2(HCu2,cote2(jcote2)); #ifdef OCCT_DEBUG @@ -853,7 +853,7 @@ pararg2(1,aNbSolMAX) if (!Intp.IsEmpty()) { const Standard_Real aSQApproxTol = Precision::Approximation() * Precision::Approximation(); - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) + for (Standard_Integer i = 1; i <= Intp.NbPoints() && NbrSol < aNbSolMAX; i++) { Standard_Real aU0 = Intp.Point(i).ParamOnFirst(); Standard_Real aV0 = Intp.Point(i).ParamOnSecond(); diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d3Tan.cxx b/src/Geom2dGcc/Geom2dGcc_Circ2d3Tan.cxx index 792b3326a8..7301427491 100644 --- a/src/Geom2dGcc/Geom2dGcc_Circ2d3Tan.cxx +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d3Tan.cxx @@ -248,22 +248,22 @@ Geom2dGcc_Circ2d3Tan:: const Standard_Real Tolerance , const Standard_Real Param1 , const Standard_Real Param2 ): - cirsol(1,16) , - qualifier1(1,16), - qualifier2(1,16), - qualifier3(1,16), - TheSame1(1,16) , - TheSame2(1,16) , - TheSame3(1,16) , - pnttg1sol(1,16), - pnttg2sol(1,16), - pnttg3sol(1,16), - par1sol(1,16) , - par2sol(1,16) , - par3sol(1,16) , - pararg1(1,16) , - pararg2(1,16) , - pararg3(1,16) + cirsol(1,20) , + qualifier1(1,20), + qualifier2(1,20), + qualifier3(1,20), + TheSame1(1,20) , + TheSame2(1,20) , + TheSame3(1,20) , + pnttg1sol(1,20), + pnttg2sol(1,20), + pnttg3sol(1,20), + par1sol(1,20) , + par2sol(1,20) , + par3sol(1,20) , + pararg1(1,20) , + pararg2(1,20) , + pararg3(1,20) { Geom2dAdaptor_Curve C1 = Qualified1.Qualified(); Geom2dAdaptor_Curve C2 = Qualified2.Qualified(); diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cxx b/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cxx index da9b436452..892c06a964 100644 --- a/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cxx +++ b/src/Geom2dGcc/Geom2dGcc_Circ2dTanOnRadGeo.cxx @@ -44,6 +44,8 @@ #include #include +static const Standard_Integer aNbSolMAX = 8; + //========================================================================= // Cercle tangent : a un cercle Qualified1 (C1). + // centre : sur une droite OnLine. + @@ -70,14 +72,14 @@ Geom2dGcc_Circ2dTanOnRadGeo (const Geom2dGcc_QCurve& Qualified1, // Initialisation des champs. + //========================================================================= -cirsol(1,8) , -qualifier1(1,8) , -TheSame1(1,8) , -pnttg1sol(1,8) , -pntcen3(1,8) , -par1sol(1,8) , -pararg1(1,8) , -parcen3(1,8) +cirsol(1,aNbSolMAX) , +qualifier1(1,aNbSolMAX) , +TheSame1(1,aNbSolMAX) , +pnttg1sol(1,aNbSolMAX) , +pntcen3(1,aNbSolMAX) , +par1sol(1,aNbSolMAX) , +pararg1(1,aNbSolMAX) , +parcen3(1,aNbSolMAX) { //========================================================================= @@ -131,7 +133,7 @@ parcen3(1,8) Intp.Perform(OnLine,D1,C2,D2,Tol,Tol); if (Intp.IsDone()) { if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { + for (Standard_Integer i = 1 ; i <= Intp.NbPoints() && NbrSol < aNbSolMAX; i++) { NbrSol++; gp_Pnt2d Center(Intp.Point(i).Value()); cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); @@ -179,14 +181,14 @@ Geom2dGcc_Circ2dTanOnRadGeo (const Geom2dGcc_QCurve& Qualified1, // Initialisation des champs. + //========================================================================= -cirsol(1,8) , -qualifier1(1,8) , -TheSame1(1,8) , -pnttg1sol(1,8) , -pntcen3(1,8) , -par1sol(1,8) , -pararg1(1,8) , -parcen3(1,8) +cirsol(1,aNbSolMAX) , +qualifier1(1,aNbSolMAX) , +TheSame1(1,aNbSolMAX) , +pnttg1sol(1,aNbSolMAX) , +pntcen3(1,aNbSolMAX) , +par1sol(1,aNbSolMAX) , +pararg1(1,aNbSolMAX) , +parcen3(1,aNbSolMAX) { //========================================================================= @@ -244,7 +246,7 @@ parcen3(1,8) Intp.Perform(OnCirc,D1,C2,D2,Tol,Tol); if (Intp.IsDone()) { if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { + for (Standard_Integer i = 1 ; i <= Intp.NbPoints() && NbrSol < aNbSolMAX; i++) { NbrSol++; gp_Pnt2d Center(Intp.Point(i).Value()); cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); @@ -292,14 +294,14 @@ Geom2dGcc_Circ2dTanOnRadGeo (const GccEnt_QualifiedCirc& Qualified1, // Initialisation des champs. + //========================================================================= -cirsol(1,8) , -qualifier1(1,8) , -TheSame1(1,8) , -pnttg1sol(1,8) , -pntcen3(1,8) , -par1sol(1,8) , -pararg1(1,8) , -parcen3(1,8) +cirsol(1,aNbSolMAX) , +qualifier1(1,aNbSolMAX) , +TheSame1(1,aNbSolMAX) , +pnttg1sol(1,aNbSolMAX) , +pntcen3(1,aNbSolMAX) , +par1sol(1,aNbSolMAX) , +pararg1(1,aNbSolMAX) , +parcen3(1,aNbSolMAX) { //========================================================================= @@ -358,7 +360,7 @@ parcen3(1,8) Intp.Perform(Circ,D1,OnCurv,D2,Tol,Tol); if (Intp.IsDone()) { if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { + for (Standard_Integer i = 1 ; i <= Intp.NbPoints() && NbrSol < aNbSolMAX; i++) { NbrSol++; gp_Pnt2d Center(Intp.Point(i).Value()); cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); @@ -416,14 +418,14 @@ Geom2dGcc_Circ2dTanOnRadGeo (const GccEnt_QualifiedLin& Qualified1, // Initialisation des champs. + //========================================================================= -cirsol(1,8) , -qualifier1(1,8) , -TheSame1(1,8) , -pnttg1sol(1,8) , -pntcen3(1,8) , -par1sol(1,8) , -pararg1(1,8) , -parcen3(1,8) +cirsol(1,aNbSolMAX) , +qualifier1(1,aNbSolMAX) , +TheSame1(1,aNbSolMAX) , +pnttg1sol(1,aNbSolMAX) , +pntcen3(1,aNbSolMAX) , +par1sol(1,aNbSolMAX) , +pararg1(1,aNbSolMAX) , +parcen3(1,aNbSolMAX) { //========================================================================= @@ -482,7 +484,7 @@ parcen3(1,8) Intp.Perform(Line,D1,OnCurv,D2,Tol,Tol); if (Intp.IsDone()) { if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { + for (Standard_Integer i = 1 ; i <= Intp.NbPoints() && NbrSol < aNbSolMAX; i++) { NbrSol++; gp_Pnt2d Center(Intp.Point(i).Value()); cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); @@ -537,14 +539,14 @@ Geom2dGcc_Circ2dTanOnRadGeo (const Geom2dGcc_QCurve& Qualified1, // Initialisation des champs. + //========================================================================= -cirsol(1,8) , -qualifier1(1,8) , -TheSame1(1,8) , -pnttg1sol(1,8) , -pntcen3(1,8) , -par1sol(1,8) , -pararg1(1,8) , -parcen3(1,8) +cirsol(1,aNbSolMAX) , +qualifier1(1,aNbSolMAX) , +TheSame1(1,aNbSolMAX) , +pnttg1sol(1,aNbSolMAX) , +pntcen3(1,aNbSolMAX) , +par1sol(1,aNbSolMAX) , +pararg1(1,aNbSolMAX) , +parcen3(1,aNbSolMAX) { //========================================================================= @@ -605,7 +607,7 @@ parcen3(1,8) Intp.Perform(C1,D1,C2,D2,Tol,Tol); if (Intp.IsDone()) { if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { + for (Standard_Integer i = 1 ; i <= Intp.NbPoints() && NbrSol < aNbSolMAX; i++) { NbrSol++; gp_Pnt2d Center(Intp.Point(i).Value()); cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); @@ -653,14 +655,14 @@ Geom2dGcc_Circ2dTanOnRadGeo (const gp_Pnt2d& Point1 , // Initialisation des champs. + //========================================================================= -cirsol(1,8) , -qualifier1(1,8) , -TheSame1(1,8) , -pnttg1sol(1,8) , -pntcen3(1,8) , -par1sol(1,8) , -pararg1(1,8) , -parcen3(1,8) +cirsol(1,aNbSolMAX) , +qualifier1(1,aNbSolMAX) , +TheSame1(1,aNbSolMAX) , +pnttg1sol(1,aNbSolMAX) , +pntcen3(1,aNbSolMAX) , +par1sol(1,aNbSolMAX) , +pararg1(1,aNbSolMAX) , +parcen3(1,aNbSolMAX) { //========================================================================= @@ -692,7 +694,7 @@ parcen3(1,8) Geom2dInt_TheIntConicCurveOfGInter Intp(Circ,D1,OnCurv,D2,Tol,Tol); if (Intp.IsDone()) { if (!Intp.IsEmpty()) { - for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { + for (Standard_Integer i = 1 ; i <= Intp.NbPoints() && NbrSol < aNbSolMAX; i++) { NbrSol++; gp_Pnt2d Center(Intp.Point(i).Value()); cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); diff --git a/tests/lowalgos/2dgcc/bug31140 b/tests/lowalgos/2dgcc/bug31140 new file mode 100644 index 0000000000..5c2d8435e4 --- /dev/null +++ b/tests/lowalgos/2dgcc/bug31140 @@ -0,0 +1,9 @@ +puts "=======================" +puts "0031140: Draw command cirtang raises ex-ception on the parallel curves" +puts "=======================" + +restore [locate_data_file bug31140_edge1.brep] e1 +restore [locate_data_file bug31140_edge2.brep] e2 +mk2dcurve c1 e1 +mk2dcurve c2 e2 +cirtang res -c c1 -c c2 -r .1 -- 2.20.1