From: ifv Date: Thu, 11 Sep 2014 08:33:38 +0000 (+0400) Subject: 0024886: BRepOffsetAPI_NormalProjection failure X-Git-Tag: V6_8_0_beta~119 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=6e0fd076ae86f2412b3f19e9636e4462062c4dcc 0024886: BRepOffsetAPI_NormalProjection failure Test case for issue CR24886 --- diff --git a/src/ProjLib/ProjLib_CompProjectedCurve.cxx b/src/ProjLib/ProjLib_CompProjectedCurve.cxx index 0b2a375472..ba4f5e50c9 100644 --- a/src/ProjLib/ProjLib_CompProjectedCurve.cxx +++ b/src/ProjLib/ProjLib_CompProjectedCurve.cxx @@ -41,16 +41,16 @@ Standard_EXPORT Standard_Integer init_point_count, dicho_bound_count; static void InitChron(OSD_Chronometer& ch) { - ch.Reset(); - ch.Start(); + ch.Reset(); + ch.Start(); } static void ResultChron( OSD_Chronometer & ch, Standard_Real & time) { - Standard_Real tch ; - ch.Stop(); - ch.Show(tch); - time=time +tch; + Standard_Real tch ; + ch.Stop(); + ch.Show(tch); + time=time +tch; } #endif @@ -61,11 +61,11 @@ static void ResultChron( OSD_Chronometer & ch, Standard_Real & time) //======================================================================= static void d1(const Standard_Real t, - const Standard_Real u, - const Standard_Real v, - gp_Vec2d& V, - const Handle(Adaptor3d_HCurve)& Curve, - const Handle(Adaptor3d_HSurface)& Surface) + const Standard_Real u, + const Standard_Real v, + gp_Vec2d& V, + const Handle(Adaptor3d_HCurve)& Curve, + const Handle(Adaptor3d_HSurface)& Surface) { gp_Pnt S, C; gp_Vec DS1_u, DS1_v, DS2_u, DS2_uv, DS2_v, DC1_t; @@ -75,15 +75,15 @@ static void d1(const Standard_Real t, gp_Vec2d dE_dt(-DC1_t*DS1_u, -DC1_t*DS1_v); gp_XY dE_du(DS1_u*DS1_u + Ort*DS2_u, - DS1_u*DS1_v + Ort*DS2_uv); + DS1_u*DS1_v + Ort*DS2_uv); gp_XY dE_dv(DS1_v*DS1_u + Ort*DS2_uv, - DS1_v*DS1_v + Ort*DS2_v); + DS1_v*DS1_v + Ort*DS2_v); Standard_Real det = dE_du.X()*dE_dv.Y() - dE_du.Y()*dE_dv.X(); if (fabs(det) < gp::Resolution()) Standard_ConstructionError::Raise(); - + gp_Mat2d M(gp_XY(dE_dv.Y()/det, -dE_du.Y()/det), - gp_XY(-dE_dv.X()/det, dE_du.X()/det)); + gp_XY(-dE_dv.X()/det, dE_du.X()/det)); V = - gp_Vec2d(gp_Vec2d(M.Row(1))*dE_dt, gp_Vec2d(M.Row(2))*dE_dt); } @@ -93,33 +93,33 @@ static void d1(const Standard_Real t, //purpose : computes second derivative of the projected curve //======================================================================= - static void d2(const Standard_Real t, - const Standard_Real u, - const Standard_Real v, - gp_Vec2d& V1, gp_Vec2d& V2, - const Handle(Adaptor3d_HCurve)& Curve, - const Handle(Adaptor3d_HSurface)& Surface) +static void d2(const Standard_Real t, + const Standard_Real u, + const Standard_Real v, + gp_Vec2d& V1, gp_Vec2d& V2, + const Handle(Adaptor3d_HCurve)& Curve, + const Handle(Adaptor3d_HSurface)& Surface) { gp_Pnt S, C; gp_Vec DS1_u, DS1_v, DS2_u, DS2_uv, DS2_v, - DS3_u, DS3_v, DS3_uuv, DS3_uvv, - DC1_t, DC2_t; + DS3_u, DS3_v, DS3_uuv, DS3_uvv, + DC1_t, DC2_t; Surface->D3(u, v, S, DS1_u, DS1_v, DS2_u, DS2_v, DS2_uv, - DS3_u, DS3_v, DS3_uuv, DS3_uvv); + DS3_u, DS3_v, DS3_uuv, DS3_uvv); Curve->D2(t, C, DC1_t, DC2_t); gp_Vec Ort(C, S); gp_Vec2d dE_dt(-DC1_t*DS1_u, -DC1_t*DS1_v); gp_XY dE_du(DS1_u*DS1_u + Ort*DS2_u, - DS1_u*DS1_v + Ort*DS2_uv); + DS1_u*DS1_v + Ort*DS2_uv); gp_XY dE_dv(DS1_v*DS1_u + Ort*DS2_uv, - DS1_v*DS1_v + Ort*DS2_v); + DS1_v*DS1_v + Ort*DS2_v); Standard_Real det = dE_du.X()*dE_dv.Y() - dE_du.Y()*dE_dv.X(); if (fabs(det) < gp::Resolution()) Standard_ConstructionError::Raise(); gp_Mat2d M(gp_XY(dE_dv.Y()/det, -dE_du.Y()/det), - gp_XY(-dE_dv.X()/det, dE_du.X()/det)); + gp_XY(-dE_dv.X()/det, dE_du.X()/det)); // First derivative V1 = - gp_Vec2d(gp_Vec2d(M.Row(1))*dE_dt, gp_Vec2d(M.Row(2))*dE_dt); @@ -131,9 +131,9 @@ static void d1(const Standard_Real t, // Computation of 2*(d2E/dtdX)(dX/dt) = S2 gp_Vec2d d2E1_dtdX(-DC1_t*DS2_u, - -DC1_t*DS2_uv); + -DC1_t*DS2_uv); gp_Vec2d d2E2_dtdX(-DC1_t*DS2_uv, - -DC1_t*DS2_v); + -DC1_t*DS2_v); gp_Vec2d S2 = 2*gp_Vec2d(d2E1_dtdX*V1, d2E2_dtdX*V1); // Computation of (d2E/dX2)*(dX/dt)2 = S3 @@ -141,22 +141,22 @@ static void d1(const Standard_Real t, // Row11 = (d2E1/du2, d2E1/dudv) Standard_Real tmp; gp_Vec2d Row11(3*DS1_u*DS2_u + Ort*DS3_u, - tmp = 2*DS1_u*DS2_uv + - DS1_v*DS2_u + Ort*DS3_uuv); + tmp = 2*DS1_u*DS2_uv + + DS1_v*DS2_u + Ort*DS3_uuv); // Row12 = (d2E1/dudv, d2E1/dv2) gp_Vec2d Row12(tmp, DS2_v*DS1_u + 2*DS1_v*DS2_uv + - Ort*DS3_uvv); + Ort*DS3_uvv); // Row21 = (d2E2/du2, d2E2/dudv) gp_Vec2d Row21(DS2_u*DS1_v + 2*DS1_u*DS2_uv + Ort*DS3_uuv, - tmp = 2*DS2_uv*DS1_v + DS1_u*DS2_v + Ort*DS3_uvv); + tmp = 2*DS2_uv*DS1_v + DS1_u*DS2_v + Ort*DS3_uvv); // Row22 = (d2E2/duv, d2E2/dvdv) gp_Vec2d Row22(tmp, 3*DS1_v*DS2_v + Ort*DS3_v); gp_Vec2d S3(V1*gp_Vec2d(Row11*V1, Row12*V1), - V1*gp_Vec2d(Row21*V1, Row22*V1)); + V1*gp_Vec2d(Row21*V1, Row22*V1)); gp_Vec2d Sum = d2E_dt + S2 + S3; @@ -169,11 +169,11 @@ static void d1(const Standard_Real t, #if 0 static void d1CurvOnSurf(const Standard_Real t, - const Standard_Real u, - const Standard_Real v, - gp_Vec& V, - const Handle(Adaptor3d_HCurve)& Curve, - const Handle(Adaptor3d_HSurface)& Surface) + const Standard_Real u, + const Standard_Real v, + gp_Vec& V, + const Handle(Adaptor3d_HCurve)& Curve, + const Handle(Adaptor3d_HSurface)& Surface) { gp_Pnt S, C; gp_Vec2d V2d; @@ -184,15 +184,15 @@ static void d1CurvOnSurf(const Standard_Real t, gp_Vec2d dE_dt(-DC1_t*DS1_u, -DC1_t*DS1_v); gp_XY dE_du(DS1_u*DS1_u + Ort*DS2_u, - DS1_u*DS1_v + Ort*DS2_uv); + DS1_u*DS1_v + Ort*DS2_uv); gp_XY dE_dv(DS1_v*DS1_u + Ort*DS2_uv, - DS1_v*DS1_v + Ort*DS2_v); + DS1_v*DS1_v + Ort*DS2_v); Standard_Real det = dE_du.X()*dE_dv.Y() - dE_du.Y()*dE_dv.X(); if (fabs(det) < gp::Resolution()) Standard_ConstructionError::Raise(); - + gp_Mat2d M(gp_XY(dE_dv.Y()/det, -dE_du.Y()/det), - gp_XY(-dE_dv.X()/det, dE_du.X()/det)); + gp_XY(-dE_dv.X()/det, dE_du.X()/det)); V2d = - gp_Vec2d(gp_Vec2d(M.Row(1))*dE_dt, gp_Vec2d(M.Row(2))*dE_dt); @@ -206,34 +206,34 @@ static void d1CurvOnSurf(const Standard_Real t, //purpose : computes second derivative of the 3D projected curve //======================================================================= - static void d2CurvOnSurf(const Standard_Real t, - const Standard_Real u, - const Standard_Real v, - gp_Vec& V1 , gp_Vec& V2 , - const Handle(Adaptor3d_HCurve)& Curve, - const Handle(Adaptor3d_HSurface)& Surface) +static void d2CurvOnSurf(const Standard_Real t, + const Standard_Real u, + const Standard_Real v, + gp_Vec& V1 , gp_Vec& V2 , + const Handle(Adaptor3d_HCurve)& Curve, + const Handle(Adaptor3d_HSurface)& Surface) { gp_Pnt S, C; gp_Vec2d V12d,V22d; gp_Vec DS1_u, DS1_v, DS2_u, DS2_uv, DS2_v, - DS3_u, DS3_v, DS3_uuv, DS3_uvv, - DC1_t, DC2_t; + DS3_u, DS3_v, DS3_uuv, DS3_uvv, + DC1_t, DC2_t; Surface->D3(u, v, S, DS1_u, DS1_v, DS2_u, DS2_v, DS2_uv, - DS3_u, DS3_v, DS3_uuv, DS3_uvv); + DS3_u, DS3_v, DS3_uuv, DS3_uvv); Curve->D2(t, C, DC1_t, DC2_t); gp_Vec Ort(C, S); gp_Vec2d dE_dt(-DC1_t*DS1_u, -DC1_t*DS1_v); gp_XY dE_du(DS1_u*DS1_u + Ort*DS2_u, - DS1_u*DS1_v + Ort*DS2_uv); + DS1_u*DS1_v + Ort*DS2_uv); gp_XY dE_dv(DS1_v*DS1_u + Ort*DS2_uv, - DS1_v*DS1_v + Ort*DS2_v); + DS1_v*DS1_v + Ort*DS2_v); Standard_Real det = dE_du.X()*dE_dv.Y() - dE_du.Y()*dE_dv.X(); if (fabs(det) < gp::Resolution()) Standard_ConstructionError::Raise(); gp_Mat2d M(gp_XY(dE_dv.Y()/det, -dE_du.Y()/det), - gp_XY(-dE_dv.X()/det, dE_du.X()/det)); + gp_XY(-dE_dv.X()/det, dE_du.X()/det)); // First derivative V12d = - gp_Vec2d(gp_Vec2d(M.Row(1))*dE_dt, gp_Vec2d(M.Row(2))*dE_dt); @@ -245,9 +245,9 @@ static void d1CurvOnSurf(const Standard_Real t, // Computation of 2*(d2E/dtdX)(dX/dt) = S2 gp_Vec2d d2E1_dtdX(-DC1_t*DS2_u, - -DC1_t*DS2_uv); + -DC1_t*DS2_uv); gp_Vec2d d2E2_dtdX(-DC1_t*DS2_uv, - -DC1_t*DS2_v); + -DC1_t*DS2_v); gp_Vec2d S2 = 2*gp_Vec2d(d2E1_dtdX*V12d, d2E2_dtdX*V12d); // Computation of (d2E/dX2)*(dX/dt)2 = S3 @@ -255,22 +255,22 @@ static void d1CurvOnSurf(const Standard_Real t, // Row11 = (d2E1/du2, d2E1/dudv) Standard_Real tmp; gp_Vec2d Row11(3*DS1_u*DS2_u + Ort*DS3_u, - tmp = 2*DS1_u*DS2_uv + - DS1_v*DS2_u + Ort*DS3_uuv); + tmp = 2*DS1_u*DS2_uv + + DS1_v*DS2_u + Ort*DS3_uuv); // Row12 = (d2E1/dudv, d2E1/dv2) gp_Vec2d Row12(tmp, DS2_v*DS1_u + 2*DS1_v*DS2_uv + - Ort*DS3_uvv); + Ort*DS3_uvv); // Row21 = (d2E2/du2, d2E2/dudv) gp_Vec2d Row21(DS2_u*DS1_v + 2*DS1_u*DS2_uv + Ort*DS3_uuv, - tmp = 2*DS2_uv*DS1_v + DS1_u*DS2_v + Ort*DS3_uvv); + tmp = 2*DS2_uv*DS1_v + DS1_u*DS2_v + Ort*DS3_uvv); // Row22 = (d2E2/duv, d2E2/dvdv) gp_Vec2d Row22(tmp, 3*DS1_v*DS2_v + Ort*DS3_v); gp_Vec2d S3(V12d*gp_Vec2d(Row11*V12d, Row12*V12d), - V12d*gp_Vec2d(Row21*V12d, Row22*V12d)); + V12d*gp_Vec2d(Row21*V12d, Row22*V12d)); gp_Vec2d Sum = d2E_dt + S2 + S3; @@ -278,10 +278,10 @@ static void d1CurvOnSurf(const Standard_Real t, V1 = DS1_u * V12d.X() + DS1_v * V12d.Y(); V2 = DS2_u * V12d.X() *V12d.X() - + DS1_u * V22d.X() - + 2 * DS2_uv * V12d.X() *V12d.Y() - + DS2_v * V12d.Y() * V12d.Y() - + DS1_v * V22d.Y(); + + DS1_u * V22d.X() + + 2 * DS2_uv * V12d.X() *V12d.Y() + + DS2_v * V12d.Y() * V12d.Y() + + DS1_v * V22d.Y(); } //======================================================================= @@ -290,12 +290,12 @@ static void d1CurvOnSurf(const Standard_Real t, //======================================================================= static Standard_Boolean ExactBound(gp_Pnt& Sol, - const Standard_Real NotSol, - const Standard_Real Tol, - const Standard_Real TolU, - const Standard_Real TolV, - const Handle(Adaptor3d_HCurve)& Curve, - const Handle(Adaptor3d_HSurface)& Surface) + const Standard_Real NotSol, + const Standard_Real Tol, + const Standard_Real TolU, + const Standard_Real TolV, + const Handle(Adaptor3d_HCurve)& Curve, + const Handle(Adaptor3d_HSurface)& Surface) { Standard_Real U0, V0, t, t1, t2, FirstU, LastU, FirstV, LastV; gp_Pnt2d POnS; @@ -329,13 +329,13 @@ static Standard_Boolean ExactBound(gp_Pnt& Sol, else { RU1 = gp_Pnt2d(U0, V0). - Distance(gp_Pnt2d(FirstU, V0 + (FirstU - U0)*D2d.Y()/D2d.X())); + Distance(gp_Pnt2d(FirstU, V0 + (FirstU - U0)*D2d.Y()/D2d.X())); RU2 = gp_Pnt2d(U0, V0). - Distance(gp_Pnt2d(LastU, V0 + (LastU - U0)*D2d.Y()/D2d.X())); + Distance(gp_Pnt2d(LastU, V0 + (LastU - U0)*D2d.Y()/D2d.X())); RV1 = gp_Pnt2d(U0, V0). - Distance(gp_Pnt2d(U0 + (FirstV - V0)*D2d.X()/D2d.Y(), FirstV)); + Distance(gp_Pnt2d(U0 + (FirstV - V0)*D2d.X()/D2d.Y(), FirstV)); RV2 = gp_Pnt2d(U0, V0). - Distance(gp_Pnt2d(U0 + (LastV - V0)*D2d.X()/D2d.Y(), LastV)); + Distance(gp_Pnt2d(U0 + (LastV - V0)*D2d.X()/D2d.Y(), LastV)); } TColgp_SequenceOfPnt Seq; Seq.Append(gp_Pnt(FirstU, RU1, 2)); @@ -347,50 +347,50 @@ static Standard_Boolean ExactBound(gp_Pnt& Sol, for(j = 1; j <= 4-i; j++) if(Seq(j).Y() < Seq(j+1).Y()) { - gp_Pnt swp; - swp = Seq.Value(j+1); - Seq.ChangeValue(j+1) = Seq.Value(j); - Seq.ChangeValue(j) = swp; + gp_Pnt swp; + swp = Seq.Value(j+1); + Seq.ChangeValue(j+1) = Seq.Value(j); + Seq.ChangeValue(j) = swp; } - t = Sol.X(); - t1 = Min(Sol.X(), NotSol); - t2 = Max(Sol.X(), NotSol); + t = Sol.X(); + t1 = Min(Sol.X(), NotSol); + t2 = Max(Sol.X(), NotSol); - Standard_Boolean isDone = Standard_False; - while (!Seq.IsEmpty()) - { - gp_Pnt P; - P = Seq.Last(); - Seq.Remove(Seq.Length()); - ProjLib_PrjResolve aPrjPS(Curve->Curve(), - Surface->Surface(), - Standard_Integer(P.Z())); - if(Standard_Integer(P.Z()) == 2) - { - aPrjPS.Perform(t, P.X(), V0, gp_Pnt2d(Tol, TolV), - gp_Pnt2d(t1, Surface->FirstVParameter()), - gp_Pnt2d(t2, Surface->LastVParameter()), FuncTol); - if(!aPrjPS.IsDone()) continue; - POnS = aPrjPS.Solution(); - Sol = gp_Pnt(POnS.X(), P.X(), POnS.Y()); - isDone = Standard_True; - break; - } - else - { - aPrjPS.Perform(t, U0, P.X(), gp_Pnt2d(Tol, TolU), - gp_Pnt2d(t1, Surface->FirstUParameter()), - gp_Pnt2d(t2, Surface->LastUParameter()), FuncTol); - if(!aPrjPS.IsDone()) continue; - POnS = aPrjPS.Solution(); - Sol = gp_Pnt(POnS.X(), POnS.Y(), P.X()); - isDone = Standard_True; - break; - } - } + Standard_Boolean isDone = Standard_False; + while (!Seq.IsEmpty()) + { + gp_Pnt P; + P = Seq.Last(); + Seq.Remove(Seq.Length()); + ProjLib_PrjResolve aPrjPS(Curve->Curve(), + Surface->Surface(), + Standard_Integer(P.Z())); + if(Standard_Integer(P.Z()) == 2) + { + aPrjPS.Perform(t, P.X(), V0, gp_Pnt2d(Tol, TolV), + gp_Pnt2d(t1, Surface->FirstVParameter()), + gp_Pnt2d(t2, Surface->LastVParameter()), FuncTol); + if(!aPrjPS.IsDone()) continue; + POnS = aPrjPS.Solution(); + Sol = gp_Pnt(POnS.X(), P.X(), POnS.Y()); + isDone = Standard_True; + break; + } + else + { + aPrjPS.Perform(t, U0, P.X(), gp_Pnt2d(Tol, TolU), + gp_Pnt2d(t1, Surface->FirstUParameter()), + gp_Pnt2d(t2, Surface->LastUParameter()), FuncTol); + if(!aPrjPS.IsDone()) continue; + POnS = aPrjPS.Solution(); + Sol = gp_Pnt(POnS.X(), POnS.Y(), P.X()); + isDone = Standard_True; + break; + } + } - return isDone; + return isDone; } //======================================================================= @@ -399,12 +399,12 @@ static Standard_Boolean ExactBound(gp_Pnt& Sol, //======================================================================= static void DichExactBound(gp_Pnt& Sol, - const Standard_Real NotSol, - const Standard_Real Tol, - const Standard_Real TolU, - const Standard_Real TolV, - const Handle(Adaptor3d_HCurve)& Curve, - const Handle(Adaptor3d_HSurface)& Surface) + const Standard_Real NotSol, + const Standard_Real Tol, + const Standard_Real TolU, + const Standard_Real TolV, + const Handle(Adaptor3d_HCurve)& Curve, + const Handle(Adaptor3d_HSurface)& Surface) { #ifdef __OCC_DEBUG_CHRONO InitChron(chr_dicho_bound); @@ -421,9 +421,9 @@ static void DichExactBound(gp_Pnt& Sol, { t = (Sol.X() + aNotSol)/2; aPrjPS.Perform(t, U0, V0, gp_Pnt2d(TolU, TolV), - gp_Pnt2d(Surface->FirstUParameter(),Surface->FirstVParameter()), - gp_Pnt2d(Surface->LastUParameter(),Surface->LastVParameter()), - FuncTol, Standard_True); + gp_Pnt2d(Surface->FirstUParameter(),Surface->FirstVParameter()), + gp_Pnt2d(Surface->LastUParameter(),Surface->LastVParameter()), + FuncTol, Standard_True); if (aPrjPS.IsDone()) { @@ -435,8 +435,8 @@ static void DichExactBound(gp_Pnt& Sol, else aNotSol = t; } #ifdef __OCC_DEBUG_CHRONO - ResultChron(chr_dicho_bound,t_dicho_bound); - dicho_bound_count++; + ResultChron(chr_dicho_bound,t_dicho_bound); + dicho_bound_count++; #endif } @@ -446,48 +446,48 @@ static void DichExactBound(gp_Pnt& Sol, //======================================================================= static Standard_Boolean InitialPoint(const gp_Pnt& Point, - const Standard_Real t, - const Handle(Adaptor3d_HCurve)& C, - const Handle(Adaptor3d_HSurface)& S, - const Standard_Real TolU, - const Standard_Real TolV, - Standard_Real& U, - Standard_Real& V) + const Standard_Real t, + const Handle(Adaptor3d_HCurve)& C, + const Handle(Adaptor3d_HSurface)& S, + const Standard_Real TolU, + const Standard_Real TolV, + Standard_Real& U, + Standard_Real& V) { - ProjLib_PrjResolve aPrjPS(C->Curve(), S->Surface(), 1); - Standard_Real ParU,ParV; - Extrema_ExtPS aExtPS; - aExtPS.Initialize(S->Surface(), S->FirstUParameter(), - S->LastUParameter(), S->FirstVParameter(), - S->LastVParameter(), TolU, TolV); + ProjLib_PrjResolve aPrjPS(C->Curve(), S->Surface(), 1); + Standard_Real ParU,ParV; + Extrema_ExtPS aExtPS; + aExtPS.Initialize(S->Surface(), S->FirstUParameter(), + S->LastUParameter(), S->FirstVParameter(), + S->LastVParameter(), TolU, TolV); - aExtPS.Perform(Point); - Standard_Integer argmin = 0; - if (aExtPS.IsDone() && aExtPS.NbExt()) + aExtPS.Perform(Point); + Standard_Integer argmin = 0; + if (aExtPS.IsDone() && aExtPS.NbExt()) + { + Standard_Integer i, Nend; + // Search for the nearest solution which is also a normal projection + Nend = aExtPS.NbExt(); + for(i = 1; i <= Nend; i++) { - Standard_Integer i, Nend; - // Search for the nearest solution which is also a normal projection - Nend = aExtPS.NbExt(); - for(i = 1; i <= Nend; i++) - { - Extrema_POnSurf POnS = aExtPS.Point(i); - POnS.Parameter(ParU, ParV); - aPrjPS.Perform(t, ParU, ParV, gp_Pnt2d(TolU, TolV), - gp_Pnt2d(S->FirstUParameter(), S->FirstVParameter()), - gp_Pnt2d(S->LastUParameter(), S->LastVParameter()), - FuncTol, Standard_True); - if(aPrjPS.IsDone() ) - if (argmin == 0 || aExtPS.SquareDistance(i) < aExtPS.SquareDistance(argmin)) argmin = i; - } - } - if( argmin == 0 ) return Standard_False; - else - { - Extrema_POnSurf POnS = aExtPS.Point(argmin); - POnS.Parameter(U, V); - return Standard_True; + Extrema_POnSurf POnS = aExtPS.Point(i); + POnS.Parameter(ParU, ParV); + aPrjPS.Perform(t, ParU, ParV, gp_Pnt2d(TolU, TolV), + gp_Pnt2d(S->FirstUParameter(), S->FirstVParameter()), + gp_Pnt2d(S->LastUParameter(), S->LastVParameter()), + FuncTol, Standard_True); + if(aPrjPS.IsDone() ) + if (argmin == 0 || aExtPS.SquareDistance(i) < aExtPS.SquareDistance(argmin)) argmin = i; } + } + if( argmin == 0 ) return Standard_False; + else + { + Extrema_POnSurf POnS = aExtPS.Point(argmin); + POnS.Parameter(U, V); + return Standard_True; + } } //======================================================================= @@ -495,7 +495,7 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point, //purpose : //======================================================================= - ProjLib_CompProjectedCurve::ProjLib_CompProjectedCurve() +ProjLib_CompProjectedCurve::ProjLib_CompProjectedCurve() { } @@ -504,13 +504,13 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point, //purpose : //======================================================================= - ProjLib_CompProjectedCurve::ProjLib_CompProjectedCurve( - const Handle(Adaptor3d_HSurface)& S, - const Handle(Adaptor3d_HCurve)& C, - const Standard_Real TolU, - const Standard_Real TolV) - : mySurface(S), myCurve(C), myNbCurves(0), myTolU(TolU), myTolV(TolV), - myMaxDist(-1) +ProjLib_CompProjectedCurve::ProjLib_CompProjectedCurve( + const Handle(Adaptor3d_HSurface)& S, + const Handle(Adaptor3d_HCurve)& C, + const Standard_Real TolU, + const Standard_Real TolV) + : mySurface(S), myCurve(C), myNbCurves(0), myTolU(TolU), myTolV(TolV), + myMaxDist(-1) { mySequence = new ProjLib_HSequenceOfHSequenceOfPnt(); Init(); @@ -521,14 +521,14 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point, //purpose : //======================================================================= - ProjLib_CompProjectedCurve::ProjLib_CompProjectedCurve( - const Handle(Adaptor3d_HSurface)& S, - const Handle(Adaptor3d_HCurve)& C, - const Standard_Real TolU, - const Standard_Real TolV, - const Standard_Real MaxDist) - : mySurface(S), myCurve(C), myNbCurves(0), myTolU(TolU), myTolV(TolV), - myMaxDist(MaxDist) +ProjLib_CompProjectedCurve::ProjLib_CompProjectedCurve( + const Handle(Adaptor3d_HSurface)& S, + const Handle(Adaptor3d_HCurve)& C, + const Standard_Real TolU, + const Standard_Real TolV, + const Standard_Real MaxDist) + : mySurface(S), myCurve(C), myNbCurves(0), myTolU(TolU), myTolV(TolV), + myMaxDist(MaxDist) { mySequence = new ProjLib_HSequenceOfHSequenceOfPnt(); Init(); @@ -539,7 +539,7 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point, //purpose : //======================================================================= - void ProjLib_CompProjectedCurve::Init() +void ProjLib_CompProjectedCurve::Init() { myTabInt.Nullify(); @@ -551,33 +551,33 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point, //Method Extrema_ExtCS gives wrong result(ex. sphere and segment orthogonal to it) Standard_Real TolC = Precision::Confusion(), TolS = Precision::Confusion(); Extrema_ExtCS CExt(myCurve->Curve(), - mySurface->Surface(), - TolC, - TolS); + mySurface->Surface(), + TolC, + TolS); if (CExt.IsDone() && CExt.NbExt()) { - // Search for the minimum solution - Nend = CExt.NbExt(); - if(myMaxDist > 0) - { - Standard_Real min_val2; - min_val2 = CExt.SquareDistance(1); - for(i = 2; i <= Nend; i++) - if (CExt.SquareDistance(i) < min_val2) min_val2 = CExt.SquareDistance(i); - if(min_val2 > myMaxDist * myMaxDist) return; - } - } - // end of new part + // Search for the minimum solution + Nend = CExt.NbExt(); + if(myMaxDist > 0) + { + Standard_Real min_val2; + min_val2 = CExt.SquareDistance(1); + for(i = 2; i <= Nend; i++) + if (CExt.SquareDistance(i) < min_val2) min_val2 = CExt.SquareDistance(i); + if(min_val2 > myMaxDist * myMaxDist) return; + } + } + // end of new part Standard_Real FirstU, LastU, Step, DecStep, SearchStep, WalkStep, t; - + FirstU = myCurve->FirstParameter(); LastU = myCurve->LastParameter(); const Standard_Real MinStep = 0.01*(LastU - FirstU), - MaxStep = 0.1*(LastU - FirstU); + MaxStep = 0.1*(LastU - FirstU); SearchStep = 10*MinStep; Step = SearchStep; - + //Initialization of aPrjPS Standard_Real Uinf = mySurface->FirstUParameter(); Standard_Real Usup = mySurface->LastUParameter(); @@ -590,8 +590,8 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point, Standard_Boolean new_part; Standard_Real prevDeb=0.; Standard_Boolean SameDeb=Standard_False; - - + + gp_Pnt Triple, prevTriple; //Basic loop @@ -613,120 +613,120 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point, // Search an initpoint in the list of Extrema Curve-Surface if(Nend != 0 && !CExt.IsParallel()) { - for (i=1;i<=Nend;i++) - { - Extrema_POnCurv P1; - Extrema_POnSurf P2; - CExt.Points(i,P1,P2); - ParT=P1.Parameter(); - P2.Parameter(ParU, ParV); - - aPrjPS.Perform(ParT, ParU, ParV, gp_Pnt2d(myTolU, myTolV), - gp_Pnt2d(mySurface->FirstUParameter(),mySurface->FirstVParameter()), - gp_Pnt2d(mySurface->LastUParameter(), mySurface->LastVParameter()), - FuncTol, Standard_True); - if ( aPrjPS.IsDone() && P1.Parameter() > Max(FirstU,t-Step+Precision::PConfusion()) - && P1.Parameter() <= t) - { - t=ParT; - U=ParU; - V=ParV; - CPoint=P1.Value(); - initpoint = Standard_True; - break; - } - } + for (i=1;i<=Nend;i++) + { + Extrema_POnCurv P1; + Extrema_POnSurf P2; + CExt.Points(i,P1,P2); + ParT=P1.Parameter(); + P2.Parameter(ParU, ParV); + + aPrjPS.Perform(ParT, ParU, ParV, gp_Pnt2d(myTolU, myTolV), + gp_Pnt2d(mySurface->FirstUParameter(),mySurface->FirstVParameter()), + gp_Pnt2d(mySurface->LastUParameter(), mySurface->LastVParameter()), + FuncTol, Standard_True); + if ( aPrjPS.IsDone() && P1.Parameter() > Max(FirstU,t-Step+Precision::PConfusion()) + && P1.Parameter() <= t) + { + t=ParT; + U=ParU; + V=ParV; + CPoint=P1.Value(); + initpoint = Standard_True; + break; + } + } } if (!initpoint) { - myCurve->D0(t,CPoint); + myCurve->D0(t,CPoint); #ifdef __OCC_DEBUG_CHRONO - InitChron(chr_init_point); + InitChron(chr_init_point); #endif - initpoint=InitialPoint(CPoint, t,myCurve,mySurface, myTolU, myTolV, U, V); + initpoint=InitialPoint(CPoint, t,myCurve,mySurface, myTolU, myTolV, U, V); #ifdef __OCC_DEBUG_CHRONO - ResultChron(chr_init_point,t_init_point); - init_point_count++; + ResultChron(chr_init_point,t_init_point); + init_point_count++; #endif - } + } if(initpoint) { // When U or V lie on surface joint in some cases we cannot use them // as initial point for aPrjPS, so we switch them - gp_Vec2d D; - - if((Abs(U - Uinf) < mySurface->UResolution(Precision::PConfusion())) && - mySurface->IsUPeriodic()) + gp_Vec2d D; + + if((Abs(U - Uinf) < mySurface->UResolution(Precision::PConfusion())) && + mySurface->IsUPeriodic()) { - d1(t, U, V, D, myCurve, mySurface); - if (D.X() < 0) U = Usup; - } - else if((Abs(U - Usup) < mySurface->UResolution(Precision::PConfusion())) && - mySurface->IsUPeriodic()) - { - d1(t, U, V, D, myCurve, mySurface); - if (D.X() > 0) U = Uinf; - } + d1(t, U, V, D, myCurve, mySurface); + if (D.X() < 0) U = Usup; + } + else if((Abs(U - Usup) < mySurface->UResolution(Precision::PConfusion())) && + mySurface->IsUPeriodic()) + { + d1(t, U, V, D, myCurve, mySurface); + if (D.X() > 0) U = Uinf; + } - if((Abs(V - Vinf) < mySurface->VResolution(Precision::PConfusion())) && - mySurface->IsVPeriodic()) + if((Abs(V - Vinf) < mySurface->VResolution(Precision::PConfusion())) && + mySurface->IsVPeriodic()) { - d1(t, U, V, D, myCurve, mySurface); - if (D.Y() < 0) V = Vsup; - } - else if((Abs(V - Vsup) <= mySurface->VResolution(Precision::PConfusion())) && - mySurface->IsVPeriodic()) + d1(t, U, V, D, myCurve, mySurface); + if (D.Y() < 0) V = Vsup; + } + else if((Abs(V - Vsup) <= mySurface->VResolution(Precision::PConfusion())) && + mySurface->IsVPeriodic()) { - d1(t, U, V, D, myCurve, mySurface); - if (D.Y() > 0) V = Vinf; - } + d1(t, U, V, D, myCurve, mySurface); + if (D.Y() > 0) V = Vinf; + } - if (myMaxDist > 0) + if (myMaxDist > 0) { // Here we are going to stop if the distance between projection and // corresponding curve point is greater than myMaxDist - gp_Pnt POnS; - Standard_Real d; - mySurface->D0(U, V, POnS); - d = CPoint.Distance(POnS); - if (d > myMaxDist) + gp_Pnt POnS; + Standard_Real d; + mySurface->D0(U, V, POnS); + d = CPoint.Distance(POnS); + if (d > myMaxDist) { - mySequence->Clear(); - myNbCurves = 0; - return; - } + mySequence->Clear(); + myNbCurves = 0; + return; + } } - Triple = gp_Pnt(t, U, V); - if (t != FirstU) + Triple = gp_Pnt(t, U, V); + if (t != FirstU) { - //Search for exact boundary point - Tol = Min(myTolU, myTolV); - gp_Vec2d D; - d1(Triple.X(), Triple.Y(), Triple.Z(), D, myCurve, mySurface); - Tol /= Max(Abs(D.X()), Abs(D.Y())); - - if(!ExactBound(Triple, t - Step, Tol, - myTolU, myTolV, myCurve, mySurface)) + //Search for exact boundary point + Tol = Min(myTolU, myTolV); + gp_Vec2d D; + d1(Triple.X(), Triple.Y(), Triple.Z(), D, myCurve, mySurface); + Tol /= Max(Abs(D.X()), Abs(D.Y())); + + if(!ExactBound(Triple, t - Step, Tol, + myTolU, myTolV, myCurve, mySurface)) { #if DEB - cout<<"There is a problem with ExactBound computation"<LastU) - { - Step =Step+LastU-t; - t=LastU; - } + if(t>LastU) + { + Step =Step+LastU-t; + t=LastU; + } } } if (!new_part) break; @@ -749,7 +749,7 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point, MagnD2 = D2.Magnitude(); if(MagnD2 < Precision::Confusion()) WalkStep = MaxStep; else WalkStep = Min(MaxStep, Max(MinStep, 0.1*MagnD1/MagnD2)); - + Step = WalkStep; DecStep = Step;; @@ -765,93 +765,93 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point, V0 = Triple.Z(); aPrjPS.Perform(t, U0, V0, gp_Pnt2d(myTolU, myTolV), - gp_Pnt2d(mySurface->FirstUParameter(),mySurface->FirstVParameter()), - gp_Pnt2d(mySurface->LastUParameter(), mySurface->LastVParameter()), - FuncTol, Standard_True); + gp_Pnt2d(mySurface->FirstUParameter(),mySurface->FirstVParameter()), + gp_Pnt2d(mySurface->LastUParameter(), mySurface->LastVParameter()), + FuncTol, Standard_True); if(!aPrjPS.IsDone()) { if (DecStep <= MinStep) { - //Search for exact boundary point - Tol = Min(myTolU, myTolV); - gp_Vec2d D; - d1(Triple.X(), Triple.Y(), Triple.Z(), D, myCurve, mySurface); - Tol /= Max(Abs(D.X()), Abs(D.Y())); - - if(!ExactBound(Triple, t, Tol, myTolU, myTolV, - myCurve, mySurface)) - { + //Search for exact boundary point + Tol = Min(myTolU, myTolV); + gp_Vec2d D; + d1(Triple.X(), Triple.Y(), Triple.Z(), D, myCurve, mySurface); + Tol /= Max(Abs(D.X()), Abs(D.Y())); + + if(!ExactBound(Triple, t, Tol, myTolU, myTolV, + myCurve, mySurface)) + { #if DEB - cout<<"There is a problem with ExactBound computation"<Value(myNbCurves)->Value(mySequence->Value(myNbCurves)->Length()).X()) > 1.e-10) - mySequence->Value(myNbCurves)->Append(Triple); - if((LastU - Triple.X()) < Tol) {t = LastU + 1; break;}//return; - - Step = SearchStep; - t = Triple.X() + Step; - if (t > (LastU-MinStep/2) ) - { - Step =Step+LastU-t; - t = LastU; - } - DecStep=Step; - new_part = Standard_False; - } + DichExactBound(Triple, t, Tol, myTolU, myTolV, + myCurve, mySurface); + } + + if((Triple.X() - mySequence->Value(myNbCurves)->Value(mySequence->Value(myNbCurves)->Length()).X()) > 1.e-10) + mySequence->Value(myNbCurves)->Append(Triple); + if((LastU - Triple.X()) < Tol) {t = LastU + 1; break;}//return; + + Step = SearchStep; + t = Triple.X() + Step; + if (t > (LastU-MinStep/2) ) + { + Step =Step+LastU-t; + t = LastU; + } + DecStep=Step; + new_part = Standard_False; + } else { - // decrease step - DecStep=DecStep / 2.; - Step = Max (MinStep , DecStep); - t = Triple .X() + Step; - if (t > (LastU-MinStep/4) ) - { - Step =Step+LastU-t; - t = LastU; - } + // decrease step + DecStep=DecStep / 2.; + Step = Max (MinStep , DecStep); + t = Triple .X() + Step; + if (t > (LastU-MinStep/4) ) + { + Step =Step+LastU-t; + t = LastU; + } } } // Go further else { - prevTriple = Triple; - Triple = gp_Pnt(t, aPrjPS.Solution().X(), aPrjPS.Solution().Y()); - - if((Triple.X() - mySequence->Value(myNbCurves)->Value(mySequence->Value(myNbCurves)->Length()).X()) > 1.e-10) - mySequence->Value(myNbCurves)->Append(Triple); - if (t == LastU) {t = LastU + 1; break;}//return; - - //Computation of WalkStep - d2CurvOnSurf(Triple.X(), Triple.Y(), Triple.Z(), D1, D2, myCurve, mySurface); - MagnD1 = D1.Magnitude(); - MagnD2 = D2.Magnitude(); - if(MagnD2 < Precision::Confusion() ) WalkStep = MaxStep; - else WalkStep = Min(MaxStep, Max(MinStep, 0.1*MagnD1/MagnD2)); - - Step = WalkStep; - t += Step; - if (t > (LastU-MinStep/2) ) - { - Step =Step+LastU-t; - t = LastU; - } - DecStep=Step; + prevTriple = Triple; + Triple = gp_Pnt(t, aPrjPS.Solution().X(), aPrjPS.Solution().Y()); + + if((Triple.X() - mySequence->Value(myNbCurves)->Value(mySequence->Value(myNbCurves)->Length()).X()) > 1.e-10) + mySequence->Value(myNbCurves)->Append(Triple); + if (t == LastU) {t = LastU + 1; break;}//return; + + //Computation of WalkStep + d2CurvOnSurf(Triple.X(), Triple.Y(), Triple.Z(), D1, D2, myCurve, mySurface); + MagnD1 = D1.Magnitude(); + MagnD2 = D2.Magnitude(); + if(MagnD2 < Precision::Confusion() ) WalkStep = MaxStep; + else WalkStep = Min(MaxStep, Max(MinStep, 0.1*MagnD1/MagnD2)); + + Step = WalkStep; + t += Step; + if (t > (LastU-MinStep/2) ) + { + Step =Step+LastU-t; + t = LastU; + } + DecStep=Step; } } } // Sequence postproceeding Standard_Integer j; -// 1. Removing poor parts + // 1. Removing poor parts Standard_Integer NbPart=myNbCurves; Standard_Integer ipart=1; for(i = 1; i <= NbPart; i++) { -// Standard_Integer NbPoints = mySequence->Value(i)->Length(); + // Standard_Integer NbPoints = mySequence->Value(i)->Length(); if(mySequence->Value(ipart)->Length() < 2) { mySequence->Remove(ipart); myNbCurves--; @@ -861,15 +861,15 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point, if(myNbCurves == 0) return; -// 2. Removing common parts of bounds + // 2. Removing common parts of bounds for(i = 1; i < myNbCurves; i++) { if(mySequence->Value(i)->Value(mySequence->Value(i)->Length()).X() >= - mySequence->Value(i+1)->Value(1).X()) + mySequence->Value(i+1)->Value(1).X()) mySequence->ChangeValue(i+1)->ChangeValue(1).SetX(mySequence->Value(i)->Value(mySequence->Value(i)->Length()).X() + 1.e-12); } -// 3. Computation of the maximum distance from each part of curve to surface + // 3. Computation of the maximum distance from each part of curve to surface myMaxDistance = new TColStd_HArray1OfReal(1, myNbCurves); myMaxDistance->Init(0); @@ -883,91 +883,91 @@ static Standard_Boolean InitialPoint(const gp_Pnt& Point, mySurface->D0(Triple.Y(), Triple.Z(), POnS); Distance = POnC.Distance(POnS); if (myMaxDistance->Value(i) < Distance) - myMaxDistance->ChangeValue(i) = Distance; + myMaxDistance->ChangeValue(i) = Distance; } -// 4. Check the projection to be a single point + // 4. Check the projection to be a single point - gp_Pnt2d Pmoy, Pcurr, P; - Standard_Real AveU, AveV; - mySnglPnts = new TColStd_HArray1OfBoolean(1, myNbCurves); - for(i = 1; i <= myNbCurves; i++) mySnglPnts->SetValue(i, Standard_True); + gp_Pnt2d Pmoy, Pcurr, P; + Standard_Real AveU, AveV; + mySnglPnts = new TColStd_HArray1OfBoolean(1, myNbCurves); + for(i = 1; i <= myNbCurves; i++) mySnglPnts->SetValue(i, Standard_True); - for(i = 1; i <= myNbCurves; i++) - { - //compute an average U and V + for(i = 1; i <= myNbCurves; i++) + { + //compute an average U and V - for(j = 1, AveU = 0., AveV = 0.; j <= mySequence->Value(i)->Length(); j++) - { - AveU += mySequence->Value(i)->Value(j).Y(); - AveV += mySequence->Value(i)->Value(j).Z(); - } - AveU /= mySequence->Value(i)->Length(); - AveV /= mySequence->Value(i)->Length(); + for(j = 1, AveU = 0., AveV = 0.; j <= mySequence->Value(i)->Length(); j++) + { + AveU += mySequence->Value(i)->Value(j).Y(); + AveV += mySequence->Value(i)->Value(j).Z(); + } + AveU /= mySequence->Value(i)->Length(); + AveV /= mySequence->Value(i)->Length(); - Pmoy.SetCoord(AveU,AveV); - for(j = 1; j <= mySequence->Value(i)->Length(); j++) - { - Pcurr = - gp_Pnt2d(mySequence->Value(i)->Value(j).Y(), mySequence->Value(i)->Value(j).Z()); - if (Pcurr.Distance(Pmoy) > ((myTolU < myTolV) ? myTolV : myTolU)) + Pmoy.SetCoord(AveU,AveV); + for(j = 1; j <= mySequence->Value(i)->Length(); j++) + { + Pcurr = + gp_Pnt2d(mySequence->Value(i)->Value(j).Y(), mySequence->Value(i)->Value(j).Z()); + if (Pcurr.Distance(Pmoy) > ((myTolU < myTolV) ? myTolV : myTolU)) { - mySnglPnts->SetValue(i, Standard_False); - break; - } + mySnglPnts->SetValue(i, Standard_False); + break; + } + } } - } - -// 5. Check the projection to be an isoparametric curve of the surface - myUIso = new TColStd_HArray1OfBoolean(1, myNbCurves); - for(i = 1; i <= myNbCurves; i++) myUIso->SetValue(i, Standard_True); + // 5. Check the projection to be an isoparametric curve of the surface - myVIso = new TColStd_HArray1OfBoolean(1, myNbCurves); - for(i = 1; i <= myNbCurves; i++) myVIso->SetValue(i, Standard_True); + myUIso = new TColStd_HArray1OfBoolean(1, myNbCurves); + for(i = 1; i <= myNbCurves; i++) myUIso->SetValue(i, Standard_True); - for(i = 1; i <= myNbCurves; i++) { - if (IsSinglePnt(i, P)|| mySequence->Value(i)->Length() <=2) { - myUIso->SetValue(i, Standard_False); - myVIso->SetValue(i, Standard_False); - continue; - } + myVIso = new TColStd_HArray1OfBoolean(1, myNbCurves); + for(i = 1; i <= myNbCurves; i++) myVIso->SetValue(i, Standard_True); -// new test for isoparametrics + for(i = 1; i <= myNbCurves; i++) { + if (IsSinglePnt(i, P)|| mySequence->Value(i)->Length() <=2) { + myUIso->SetValue(i, Standard_False); + myVIso->SetValue(i, Standard_False); + continue; + } - if ( mySequence->Value(i)->Length() > 2) { - //compute an average U and V + // new test for isoparametrics - for(j = 1, AveU = 0., AveV = 0.; j <= mySequence->Value(i)->Length(); j++) { - AveU += mySequence->Value(i)->Value(j).Y(); - AveV += mySequence->Value(i)->Value(j).Z(); - } - AveU /= mySequence->Value(i)->Length(); - AveV /= mySequence->Value(i)->Length(); + if ( mySequence->Value(i)->Length() > 2) { + //compute an average U and V - // is i-part U-isoparametric ? - for(j = 1; j <= mySequence->Value(i)->Length(); j++) - { - if(Abs(mySequence->Value(i)->Value(j).Y() - AveU) > myTolU) - { - myUIso->SetValue(i, Standard_False); - break; - } - } + for(j = 1, AveU = 0., AveV = 0.; j <= mySequence->Value(i)->Length(); j++) { + AveU += mySequence->Value(i)->Value(j).Y(); + AveV += mySequence->Value(i)->Value(j).Z(); + } + AveU /= mySequence->Value(i)->Length(); + AveV /= mySequence->Value(i)->Length(); - // is i-part V-isoparametric ? - for(j = 1; j <= mySequence->Value(i)->Length(); j++) - { - if(Abs(mySequence->Value(i)->Value(j).Z() - AveV) > myTolV) - { - myVIso->SetValue(i, Standard_False); - break; + // is i-part U-isoparametric ? + for(j = 1; j <= mySequence->Value(i)->Length(); j++) + { + if(Abs(mySequence->Value(i)->Value(j).Y() - AveU) > myTolU) + { + myUIso->SetValue(i, Standard_False); + break; + } + } + + // is i-part V-isoparametric ? + for(j = 1; j <= mySequence->Value(i)->Length(); j++) + { + if(Abs(mySequence->Value(i)->Value(j).Z() - AveV) > myTolV) + { + myVIso->SetValue(i, Standard_False); + break; + } + } + // } } -// - } - } } //======================================================================= //function : Load @@ -994,7 +994,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) //purpose : //======================================================================= - const Handle(Adaptor3d_HSurface)& ProjLib_CompProjectedCurve::GetSurface() const +const Handle(Adaptor3d_HSurface)& ProjLib_CompProjectedCurve::GetSurface() const { return mySurface; } @@ -1005,7 +1005,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) //purpose : //======================================================================= - const Handle(Adaptor3d_HCurve)& ProjLib_CompProjectedCurve::GetCurve() const +const Handle(Adaptor3d_HCurve)& ProjLib_CompProjectedCurve::GetCurve() const { return myCurve; } @@ -1015,8 +1015,8 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) //purpose : //======================================================================= - void ProjLib_CompProjectedCurve::GetTolerance(Standard_Real& TolU, - Standard_Real& TolV) const +void ProjLib_CompProjectedCurve::GetTolerance(Standard_Real& TolU, + Standard_Real& TolV) const { TolU = myTolU; TolV = myTolV; @@ -1027,7 +1027,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) //purpose : //======================================================================= - Standard_Integer ProjLib_CompProjectedCurve::NbCurves() const +Standard_Integer ProjLib_CompProjectedCurve::NbCurves() const { return myNbCurves; } @@ -1036,9 +1036,9 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) //purpose : //======================================================================= - void ProjLib_CompProjectedCurve::Bounds(const Standard_Integer Index, - Standard_Real& Udeb, - Standard_Real& Ufin) const +void ProjLib_CompProjectedCurve::Bounds(const Standard_Integer Index, + Standard_Real& Udeb, + Standard_Real& Ufin) const { if(Index < 1 || Index > myNbCurves) Standard_NoSuchObject::Raise(); Udeb = mySequence->Value(Index)->Value(1).X(); @@ -1049,7 +1049,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) //purpose : //======================================================================= - Standard_Boolean ProjLib_CompProjectedCurve::IsSinglePnt(const Standard_Integer Index, gp_Pnt2d& P) const +Standard_Boolean ProjLib_CompProjectedCurve::IsSinglePnt(const Standard_Integer Index, gp_Pnt2d& P) const { if(Index < 1 || Index > myNbCurves) Standard_NoSuchObject::Raise(); P = gp_Pnt2d(mySequence->Value(Index)->Value(1).Y(), mySequence->Value(Index)->Value(1).Z()); @@ -1061,7 +1061,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) //purpose : //======================================================================= - Standard_Boolean ProjLib_CompProjectedCurve::IsUIso(const Standard_Integer Index, Standard_Real& U) const +Standard_Boolean ProjLib_CompProjectedCurve::IsUIso(const Standard_Integer Index, Standard_Real& U) const { if(Index < 1 || Index > myNbCurves) Standard_NoSuchObject::Raise(); U = mySequence->Value(Index)->Value(1).Y(); @@ -1072,7 +1072,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) //purpose : //======================================================================= - Standard_Boolean ProjLib_CompProjectedCurve::IsVIso(const Standard_Integer Index, Standard_Real& V) const +Standard_Boolean ProjLib_CompProjectedCurve::IsVIso(const Standard_Integer Index, Standard_Real& V) const { if(Index < 1 || Index > myNbCurves) Standard_NoSuchObject::Raise(); V = mySequence->Value(Index)->Value(1).Z(); @@ -1083,7 +1083,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) //purpose : //======================================================================= - gp_Pnt2d ProjLib_CompProjectedCurve::Value(const Standard_Real t) const +gp_Pnt2d ProjLib_CompProjectedCurve::Value(const Standard_Real t) const { gp_Pnt2d P; D0(t, P); @@ -1094,7 +1094,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) //purpose : //======================================================================= - void ProjLib_CompProjectedCurve::D0(const Standard_Real U,gp_Pnt2d& P) const +void ProjLib_CompProjectedCurve::D0(const Standard_Real U,gp_Pnt2d& P) const { Standard_Integer i, j; Standard_Real Udeb, Ufin; @@ -1117,10 +1117,10 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) for(j = 1; j < End; j++) if ((U >= mySequence->Value(i)->Value(j).X()) && (U <= mySequence->Value(i)->Value(j + 1).X())) break; -// U0 = mySequence->Value(i)->Value(j).Y(); -// V0 = mySequence->Value(i)->Value(j).Z(); + // U0 = mySequence->Value(i)->Value(j).Y(); + // V0 = mySequence->Value(i)->Value(j).Z(); -// Cubic Interpolation + // Cubic Interpolation if(mySequence->Value(i)->Length() < 4 || (Abs(U-mySequence->Value(i)->Value(j).X()) <= Precision::PConfusion()) ) { @@ -1128,7 +1128,7 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) V0 = mySequence->Value(i)->Value(j).Z(); } else if (Abs(U-mySequence->Value(i)->Value(j+1).X()) - <= Precision::PConfusion()) + <= Precision::PConfusion()) { U0 = mySequence->Value(i)->Value(j+1).Y(); V0 = mySequence->Value(i)->Value(j+1).Z(); @@ -1137,36 +1137,36 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) { if (j == 1) j = 2; if (j > mySequence->Value(i)->Length() - 2) - j = mySequence->Value(i)->Length() - 2; - + j = mySequence->Value(i)->Length() - 2; + gp_Vec2d I1, I2, I3, I21, I22, I31, Y1, Y2, Y3, Y4, Res; Standard_Real X1, X2, X3, X4; - + X1 = mySequence->Value(i)->Value(j - 1).X(); X2 = mySequence->Value(i)->Value(j).X(); X3 = mySequence->Value(i)->Value(j + 1).X(); X4 = mySequence->Value(i)->Value(j + 2).X(); - + Y1 = gp_Vec2d(mySequence->Value(i)->Value(j - 1).Y(), - mySequence->Value(i)->Value(j - 1).Z()); + mySequence->Value(i)->Value(j - 1).Z()); Y2 = gp_Vec2d(mySequence->Value(i)->Value(j).Y(), - mySequence->Value(i)->Value(j).Z()); + mySequence->Value(i)->Value(j).Z()); Y3 = gp_Vec2d(mySequence->Value(i)->Value(j + 1).Y(), - mySequence->Value(i)->Value(j + 1).Z()); + mySequence->Value(i)->Value(j + 1).Z()); Y4 = gp_Vec2d(mySequence->Value(i)->Value(j + 2).Y(), - mySequence->Value(i)->Value(j + 2).Z()); - + mySequence->Value(i)->Value(j + 2).Z()); + I1 = (Y1 - Y2)/(X1 - X2); I2 = (Y2 - Y3)/(X2 - X3); I3 = (Y3 - Y4)/(X3 - X4); - + I21 = (I1 - I2)/(X1 - X3); I22 = (I2 - I3)/(X2 - X4); - + I31 = (I21 - I22)/(X1 - X4); - + Res = Y1 + (U - X1)*(I1 + (U - X2)*(I21 + (U - X3)*I31)); - + U0 = Res.X(); V0 = Res.Y(); @@ -1180,8 +1180,8 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) ProjLib_PrjResolve aPrjPS(myCurve->Curve(), mySurface->Surface(), 1); aPrjPS.Perform(U, U0, V0, gp_Pnt2d(myTolU, myTolV), - gp_Pnt2d(mySurface->FirstUParameter(), mySurface->FirstVParameter()), - gp_Pnt2d(mySurface->LastUParameter(), mySurface->LastVParameter())); + gp_Pnt2d(mySurface->FirstUParameter(), mySurface->FirstVParameter()), + gp_Pnt2d(mySurface->LastUParameter(), mySurface->LastVParameter())); P = aPrjPS.Solution(); } @@ -1190,9 +1190,9 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) //purpose : //======================================================================= - void ProjLib_CompProjectedCurve::D1(const Standard_Real t, - gp_Pnt2d& P, - gp_Vec2d& V) const +void ProjLib_CompProjectedCurve::D1(const Standard_Real t, + gp_Pnt2d& P, + gp_Vec2d& V) const { Standard_Real u, v; D0(t, P); @@ -1205,10 +1205,10 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) //purpose : //======================================================================= - void ProjLib_CompProjectedCurve::D2(const Standard_Real t, - gp_Pnt2d& P, - gp_Vec2d& V1, - gp_Vec2d& V2) const +void ProjLib_CompProjectedCurve::D2(const Standard_Real t, + gp_Pnt2d& P, + gp_Vec2d& V1, + gp_Vec2d& V2) const { Standard_Real u, v; D0(t, P); @@ -1222,25 +1222,25 @@ void ProjLib_CompProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) //======================================================================= gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t, - const Standard_Integer N) const + const Standard_Integer N) const { if (N < 1 ) Standard_OutOfRange::Raise("ProjLib_CompProjectedCurve : N must be greater than 0"); else if (N ==1) { - gp_Pnt2d P; - gp_Vec2d V; - D1(t,P,V); - return V; - } + gp_Pnt2d P; + gp_Vec2d V; + D1(t,P,V); + return V; + } else if ( N==2) { - gp_Pnt2d P; - gp_Vec2d V1,V2; - D2(t,P,V1,V2); - return V2; + gp_Pnt2d P; + gp_Vec2d V1,V2; + D2(t,P,V1,V2); + return V2; } else if (N > 2 ) - Standard_NotImplemented::Raise("ProjLib_CompProjectedCurve::DN"); + Standard_NotImplemented::Raise("ProjLib_CompProjectedCurve::DN"); return gp_Vec2d(); } @@ -1249,7 +1249,7 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t, //purpose : //======================================================================= - const Handle(ProjLib_HSequenceOfHSequenceOfPnt)& ProjLib_CompProjectedCurve::GetSequence() const +const Handle(ProjLib_HSequenceOfHSequenceOfPnt)& ProjLib_CompProjectedCurve::GetSequence() const { return mySequence; } @@ -1258,7 +1258,7 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t, //purpose : //======================================================================= - Standard_Real ProjLib_CompProjectedCurve::FirstParameter() const +Standard_Real ProjLib_CompProjectedCurve::FirstParameter() const { return myCurve->FirstParameter(); } @@ -1268,7 +1268,7 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t, //purpose : //======================================================================= - Standard_Real ProjLib_CompProjectedCurve::LastParameter() const +Standard_Real ProjLib_CompProjectedCurve::LastParameter() const { return myCurve->LastParameter(); } @@ -1278,7 +1278,7 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t, //purpose : //======================================================================= - Standard_Real ProjLib_CompProjectedCurve::MaxDistance(const Standard_Integer Index) const +Standard_Real ProjLib_CompProjectedCurve::MaxDistance(const Standard_Integer Index) const { if(Index < 1 || Index > myNbCurves) Standard_NoSuchObject::Raise(); return myMaxDistance->Value(Index); @@ -1289,7 +1289,7 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t, //purpose : //======================================================================= - Standard_Integer ProjLib_CompProjectedCurve::NbIntervals(const GeomAbs_Shape S) const +Standard_Integer ProjLib_CompProjectedCurve::NbIntervals(const GeomAbs_Shape S) const { const_cast(this)->myTabInt.Nullify(); BuildIntervals(S); @@ -1301,7 +1301,7 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t, //purpose : //======================================================================= - void ProjLib_CompProjectedCurve::Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) const +void ProjLib_CompProjectedCurve::Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) const { if (myTabInt.IsNull()) BuildIntervals (S); T = myTabInt->Array1(); @@ -1312,7 +1312,7 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t, //purpose : //======================================================================= - void ProjLib_CompProjectedCurve::BuildIntervals(const GeomAbs_Shape S) const +void ProjLib_CompProjectedCurve::BuildIntervals(const GeomAbs_Shape S) const { GeomAbs_Shape SforS = GeomAbs_CN; switch(S) { @@ -1350,9 +1350,9 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t, Standard_Real Tl, Tr, Ul, Ur, Vl, Vr, Tol; Handle(TColStd_HArray1OfReal) BArr = NULL, - CArr = NULL, - UArr = NULL, - VArr = NULL; + CArr = NULL, + UArr = NULL, + VArr = NULL; // proccessing projection bounds BArr = new TColStd_HArray1OfReal(1, 2*myNbCurves); @@ -1370,42 +1370,46 @@ gp_Vec2d ProjLib_CompProjectedCurve::DN(const Standard_Real t, TColStd_SequenceOfReal TUdisc; for(k = 2; k <= NbIntSurU; k++) { -// cout<<"CutPntsU("<