diff --git a/src/ProjLib/ProjLib_CompProjectedCurve.cxx b/src/ProjLib/ProjLib_CompProjectedCurve.cxx index c1b7a9cfa2..37083ed7a6 100644 --- a/src/ProjLib/ProjLib_CompProjectedCurve.cxx +++ b/src/ProjLib/ProjLib_CompProjectedCurve.cxx @@ -767,7 +767,7 @@ void ProjLib_CompProjectedCurve::Init() t = Triple.X() + Step; if (t > LastU) t = LastU; - + Standard_Real prevStep = Step; Standard_Real U0, V0; gp_Pnt2d aLowBorder(mySurface->FirstUParameter(),mySurface->FirstVParameter()); gp_Pnt2d aUppBorder(mySurface->LastUParameter(), mySurface->LastVParameter()); @@ -776,8 +776,8 @@ void ProjLib_CompProjectedCurve::Init() while (t <= LastU && new_part) { - U0 = Triple.Y() + (Triple.Y() - prevTriple.Y()); - V0 = Triple.Z() + (Triple.Z() - prevTriple.Z()); + U0 = Triple.Y() + (Step / prevStep) * (Triple.Y() - prevTriple.Y()); + V0 = Triple.Z() + (Step / prevStep) * (Triple.Z() - prevTriple.Z()); // adjust U0 to be in [mySurface->FirstUParameter(),mySurface->LastUParameter()] U0 = Min(Max(U0, aLowBorder.X()), aUppBorder.X()); // adjust V0 to be in [mySurface->FirstVParameter(),mySurface->LastVParameter()] @@ -837,9 +837,27 @@ void ProjLib_CompProjectedCurve::Init() // Go further else { - prevTriple = Triple; + prevTriple = Triple; + prevStep = Step; Triple = gp_Pnt(t, aPrjPS.Solution().X(), aPrjPS.Solution().Y()); + if (mySurface->GetType() == GeomAbs_SurfaceOfRevolution && + (Abs (Triple.Z() - mySurface->FirstVParameter()) < Precision::Confusion() || + Abs (Triple.Z() - mySurface->LastVParameter() ) < Precision::Confusion() )) + { + // Go out from possible attraktor. + + Standard_Real U,V; + InitialPoint(myCurve->Value(t), t, myCurve, mySurface, myTolU, myTolV, U, V); + if (Abs (Abs(U - Triple.Y()) - mySurface->UPeriod()) < Precision::Confusion()) + { + // Handle period jump. + U = Triple.Y(); + } + Triple.SetY(U); + Triple.SetZ(V); + } + 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; @@ -854,7 +872,7 @@ void ProjLib_CompProjectedCurve::Init() Step = WalkStep; t += Step; if (t > (LastU-MinStep/2) ) - { + { Step =Step+LastU-t; t = LastU; } diff --git a/src/ProjLib/ProjLib_ProjectedCurve.cxx b/src/ProjLib/ProjLib_ProjectedCurve.cxx index f1cfe27176..934ca7ad78 100644 --- a/src/ProjLib/ProjLib_ProjectedCurve.cxx +++ b/src/ProjLib/ProjLib_ProjectedCurve.cxx @@ -332,6 +332,7 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) Standard_Real LastPar = C->LastParameter(); GeomAbs_SurfaceType SType = mySurface->GetType(); GeomAbs_CurveType CType = myCurve->GetType(); + Standard_Boolean isAnalyticalSurf = Standard_True; switch (SType) { @@ -384,6 +385,7 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) case GeomAbs_BezierSurface: case GeomAbs_BSplineSurface: { + isAnalyticalSurf = Standard_False; Standard_Boolean IsTrimmed[2] = {Standard_False, Standard_False}; Standard_Integer SingularCase[2]; Standard_Real f, l, dt; @@ -431,34 +433,38 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) Handle(Geom2d_BSplineCurve) aRes = polar.BSpline(); - if(IsTrimmed[0] || IsTrimmed[1]) + if (!aRes.IsNull()) { - if(IsTrimmed[0]) + if( (IsTrimmed[0] || IsTrimmed[1])) { - //Add segment before start of curve - f = myCurve->FirstParameter(); - ExtendC2d(aRes, f, -dt, U1, U2, V1, V2, 0, SingularCase[0]); + if(IsTrimmed[0]) + { + //Add segment before start of curve + f = myCurve->FirstParameter(); + ExtendC2d(aRes, f, -dt, U1, U2, V1, V2, 0, SingularCase[0]); + } + if(IsTrimmed[1]) + { + //Add segment after end of curve + l = myCurve->LastParameter(); + ExtendC2d(aRes, l, dt, U1, U2, V1, V2, 1, SingularCase[1]); + } + Handle(Geom2d_Curve) NewCurve2d; + GeomLib::SameRange(Precision::PConfusion(), aRes, + aRes->FirstParameter(), aRes->LastParameter(), + FirstPar, LastPar, NewCurve2d); + aRes = Handle(Geom2d_BSplineCurve)::DownCast(NewCurve2d); } - if(IsTrimmed[1]) - { - //Add segment after end of curve - l = myCurve->LastParameter(); - ExtendC2d(aRes, l, dt, U1, U2, V1, V2, 1, SingularCase[1]); - } - Handle(Geom2d_Curve) NewCurve2d; - GeomLib::SameRange(Precision::PConfusion(), aRes, - aRes->FirstParameter(), aRes->LastParameter(), - FirstPar, LastPar, NewCurve2d); - aRes = Handle(Geom2d_BSplineCurve)::DownCast(NewCurve2d); + myResult.SetBSpline(aRes); + myResult.Done(); + myResult.SetType(GeomAbs_BSplineCurve); } - myResult.SetBSpline(aRes); - myResult.Done(); - myResult.SetType(GeomAbs_BSplineCurve); } break; default: { + isAnalyticalSurf = Standard_False; Standard_Boolean IsTrimmed[2] = {Standard_False, Standard_False}; Standard_Real Vsingular[2] = {0.0 , 0.0}; //for surfaces of revolution Standard_Real f = 0.0, l = 0.0, dt = 0.0; @@ -546,39 +552,44 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) Handle(Geom2d_BSplineCurve) aRes = appr.Curve2d(); - if(IsTrimmed[0] || IsTrimmed[1]) + if (!aRes.IsNull()) { - // Treatment only for surface of revolution - Standard_Real u1, u2, v1, v2; - u1 = mySurface->FirstUParameter(); - u2 = mySurface->LastUParameter(); - v1 = mySurface->FirstVParameter(); - v2 = mySurface->LastVParameter(); + if(IsTrimmed[0] || IsTrimmed[1]) + { + // Treatment only for surface of revolution + Standard_Real u1, u2, v1, v2; + u1 = mySurface->FirstUParameter(); + u2 = mySurface->LastUParameter(); + v1 = mySurface->FirstVParameter(); + v2 = mySurface->LastVParameter(); - if(IsTrimmed[0]) - { - //Add segment before start of curve - ExtendC2d(aRes, f, -dt, u1, u2, Vsingular[0], v2, 0, 3); + if(IsTrimmed[0]) + { + //Add segment before start of curve + ExtendC2d(aRes, f, -dt, u1, u2, Vsingular[0], v2, 0, 3); + } + if(IsTrimmed[1]) + { + //Add segment after end of curve + ExtendC2d(aRes, l, dt, u1, u2, v1, Vsingular[1], 1, 4); + } + Handle(Geom2d_Curve) NewCurve2d; + GeomLib::SameRange(Precision::PConfusion(), aRes, + aRes->FirstParameter(), aRes->LastParameter(), + FirstPar, LastPar, NewCurve2d); + aRes = Handle(Geom2d_BSplineCurve)::DownCast(NewCurve2d); } - if(IsTrimmed[1]) - { - //Add segment after end of curve - ExtendC2d(aRes, l, dt, u1, u2, v1, Vsingular[1], 1, 4); - } - Handle(Geom2d_Curve) NewCurve2d; - GeomLib::SameRange(Precision::PConfusion(), aRes, - aRes->FirstParameter(), aRes->LastParameter(), - FirstPar, LastPar, NewCurve2d); - aRes = Handle(Geom2d_BSplineCurve)::DownCast(NewCurve2d); + + myResult.SetBSpline(aRes); + myResult.Done(); + myResult.SetType(GeomAbs_BSplineCurve); } - - myResult.SetBSpline(aRes); - myResult.Done(); - myResult.SetType(GeomAbs_BSplineCurve); } } - if ( !myResult.IsDone()) + + if ( !myResult.IsDone() && isAnalyticalSurf) { + // Use advanced analytical projector if base analytical projection failed. ProjLib_ComputeApprox Comp( myCurve, mySurface, myTolerance); myResult.Done(); @@ -602,8 +613,7 @@ void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C) } myTolerance = Comp.Tolerance(); } - - else + else if (myResult.IsDone()) { // On remet arbitrairement la tol atteinte a une valeur // petite en attendant mieux. dub lbo 11/03/97 diff --git a/src/ProjLib/ProjLib_Projector.cxx b/src/ProjLib/ProjLib_Projector.cxx index 11c1a68fa7..1c9556e065 100644 --- a/src/ProjLib/ProjLib_Projector.cxx +++ b/src/ProjLib/ProjLib_Projector.cxx @@ -29,6 +29,8 @@ ProjLib_Projector::ProjLib_Projector() { + isDone = Standard_False; + myType = GeomAbs_BSplineCurve; } diff --git a/tests/bugs/moddata_2/bug469 b/tests/bugs/moddata_2/bug469 index dd00b42bde..5e44d4eb3f 100755 --- a/tests/bugs/moddata_2/bug469 +++ b/tests/bugs/moddata_2/bug469 @@ -1,7 +1,9 @@ #puts "TODO OCC12345 ALL: An exception was caught" #puts "TODO OCC12345 ALL: \\*\\* Exception \\*\\*.*" -puts "TODO OCC12345 ALL: TEST INCOMPLETE" -puts "TODO OCC12345 ALL: xception" +#puts "TODO OCC12345 ALL: TEST INCOMPLETE" +#puts "TODO OCC12345 ALL: xception" +puts "TODO OCC25892 ALL: Faulty shapes in variables" +puts "TODO OCC25892 ALL: The square of result shape is" puts "========================" puts " OCC469 " diff --git a/tests/bugs/moddata_3/bug25892_01 b/tests/bugs/moddata_3/bug25892_01 new file mode 100644 index 0000000000..08af3bc620 --- /dev/null +++ b/tests/bugs/moddata_3/bug25892_01 @@ -0,0 +1,20 @@ +puts "============" +puts "OCC25892" +puts "============" +puts "" +####################################################################### +# Wrong result obtained by projection algorithm. +####################################################################### + +restore [locate_data_file bug25892_c001] c +restore [locate_data_file bug25892_f001] f + +mksurface s f + +catch {project cx c s} + +#v2d2 +view 1 -2D- 728 20 400 400 + +2dfit +set only_screen_axo 1 diff --git a/tests/bugs/moddata_3/bug25892_02 b/tests/bugs/moddata_3/bug25892_02 new file mode 100644 index 0000000000..707f876512 --- /dev/null +++ b/tests/bugs/moddata_3/bug25892_02 @@ -0,0 +1,20 @@ +puts "============" +puts "OCC25892" +puts "============" +puts "" +####################################################################### +# Wrong result obtained by projection algorithm. +####################################################################### + +restore [locate_data_file bug25892_c002] c +restore [locate_data_file bug25892_f002] f + +mksurface s f + +catch {project cx c s} + +#v2d2 +view 1 -2D- 728 20 400 400 + +2dfit +set only_screen_axo 1 diff --git a/tests/bugs/moddata_3/bug25892_03 b/tests/bugs/moddata_3/bug25892_03 new file mode 100644 index 0000000000..3de819b8d2 --- /dev/null +++ b/tests/bugs/moddata_3/bug25892_03 @@ -0,0 +1,18 @@ +puts "============" +puts "OCC25892" +puts "============" +puts "" +####################################################################### +# Wrong result obtained by projection algorithm. +####################################################################### + +restore [locate_data_file bug25892_c003] c +restore [locate_data_file bug25892_s003] s + +project cx c s + +#v2d2 +view 1 -2D- 728 20 400 400 + +2dfit +set only_screen_axo 1 diff --git a/tests/bugs/moddata_3/bug25892_04 b/tests/bugs/moddata_3/bug25892_04 new file mode 100644 index 0000000000..fe863c4168 --- /dev/null +++ b/tests/bugs/moddata_3/bug25892_04 @@ -0,0 +1,18 @@ +puts "============" +puts "OCC25892" +puts "============" +puts "" +####################################################################### +# Wrong result obtained by projection algorithm. +####################################################################### + +restore [locate_data_file bug25892_c004] c +restore [locate_data_file bug25892_s004] s + +project cx c s + +#v2d2 +view 1 -2D- 728 20 400 400 + +2dfit +set only_screen_axo 1 diff --git a/tests/bugs/moddata_3/bug25892_05 b/tests/bugs/moddata_3/bug25892_05 new file mode 100644 index 0000000000..f721d2d891 --- /dev/null +++ b/tests/bugs/moddata_3/bug25892_05 @@ -0,0 +1,18 @@ +puts "============" +puts "OCC25892" +puts "============" +puts "" +####################################################################### +# Wrong result obtained by projection algorithm. +####################################################################### + +restore [locate_data_file bug25892_c005] c +restore [locate_data_file bug25892_s005] s + +project cx c s + +#v2d2 +view 1 -2D- 728 20 400 400 + +2dfit +set only_screen_axo 1 diff --git a/tests/bugs/moddata_3/bug25892_06 b/tests/bugs/moddata_3/bug25892_06 new file mode 100644 index 0000000000..442d6edb6f --- /dev/null +++ b/tests/bugs/moddata_3/bug25892_06 @@ -0,0 +1,18 @@ +puts "============" +puts "OCC25892" +puts "============" +puts "" +####################################################################### +# Wrong result obtained by projection algorithm. +####################################################################### + +restore [locate_data_file bug25892_c006] c +restore [locate_data_file bug25892_s006] s + +project cx c s + +#v2d2 +view 1 -2D- 728 20 400 400 + +2dfit +set only_screen_axo 1 diff --git a/tests/bugs/moddata_3/bug25892_07 b/tests/bugs/moddata_3/bug25892_07 new file mode 100644 index 0000000000..84e8afb1ae --- /dev/null +++ b/tests/bugs/moddata_3/bug25892_07 @@ -0,0 +1,18 @@ +puts "============" +puts "OCC25892" +puts "============" +puts "" +####################################################################### +# Wrong result obtained by projection algorithm. +####################################################################### + +restore [locate_data_file bug25892_c007] c +restore [locate_data_file bug25892_s007] s + +project cx c s + +#v2d2 +view 1 -2D- 728 20 400 400 + +2dfit +set only_screen_axo 1 diff --git a/tests/bugs/moddata_3/bug25892_08 b/tests/bugs/moddata_3/bug25892_08 new file mode 100644 index 0000000000..8780644556 --- /dev/null +++ b/tests/bugs/moddata_3/bug25892_08 @@ -0,0 +1,18 @@ +puts "============" +puts "OCC25892" +puts "============" +puts "" +####################################################################### +# Wrong result obtained by projection algorithm. +####################################################################### + +restore [locate_data_file bug25892_c008] c +restore [locate_data_file bug25892_s008] s + +project cx c s + +#v2d2 +view 1 -2D- 728 20 400 400 + +2dfit +set only_screen_axo 1 diff --git a/tests/bugs/moddata_3/bug25892_09 b/tests/bugs/moddata_3/bug25892_09 new file mode 100644 index 0000000000..e44f2945a0 --- /dev/null +++ b/tests/bugs/moddata_3/bug25892_09 @@ -0,0 +1,18 @@ +puts "============" +puts "OCC25892" +puts "============" +puts "" +####################################################################### +# Wrong result obtained by projection algorithm. +####################################################################### + +restore [locate_data_file bug25892_c009] c +restore [locate_data_file bug25892_s009] s + +project cx c s + +#v2d2 +view 1 -2D- 728 20 400 400 + +2dfit +set only_screen_axo 1 diff --git a/tests/bugs/moddata_3/bug25892_10 b/tests/bugs/moddata_3/bug25892_10 new file mode 100644 index 0000000000..50a2855459 --- /dev/null +++ b/tests/bugs/moddata_3/bug25892_10 @@ -0,0 +1,18 @@ +puts "============" +puts "OCC25892" +puts "============" +puts "" +####################################################################### +# Wrong result obtained by projection algorithm. +####################################################################### + +restore [locate_data_file bug25892_c010] c +restore [locate_data_file bug25892_s010] s + +project cx c s + +#v2d2 +view 1 -2D- 728 20 400 400 + +2dfit +set only_screen_axo 1 diff --git a/tests/bugs/moddata_3/bug25892_11 b/tests/bugs/moddata_3/bug25892_11 new file mode 100644 index 0000000000..63547352ef --- /dev/null +++ b/tests/bugs/moddata_3/bug25892_11 @@ -0,0 +1,18 @@ +puts "============" +puts "OCC25892" +puts "============" +puts "" +####################################################################### +# Wrong result obtained by projection algorithm. +####################################################################### + +restore [locate_data_file bug25892_c011] c +restore [locate_data_file bug25892_s011] s + +project cx c s + +#v2d2 +view 1 -2D- 728 20 400 400 + +2dfit +set only_screen_axo 1 diff --git a/tests/bugs/moddata_3/bug25892_12 b/tests/bugs/moddata_3/bug25892_12 new file mode 100644 index 0000000000..6edf2f3c91 --- /dev/null +++ b/tests/bugs/moddata_3/bug25892_12 @@ -0,0 +1,18 @@ +puts "============" +puts "OCC25892" +puts "============" +puts "" +####################################################################### +# Wrong result obtained by projection algorithm. +####################################################################### + +restore [locate_data_file bug25892_c012] c +restore [locate_data_file bug25892_s012] s + +project cx c s + +#v2d2 +view 1 -2D- 728 20 400 400 + +2dfit +set only_screen_axo 1 diff --git a/tests/bugs/moddata_3/bug25892_13 b/tests/bugs/moddata_3/bug25892_13 new file mode 100644 index 0000000000..09ad7c79e0 --- /dev/null +++ b/tests/bugs/moddata_3/bug25892_13 @@ -0,0 +1,18 @@ +puts "============" +puts "OCC25892" +puts "============" +puts "" +####################################################################### +# Wrong result obtained by projection algorithm. +####################################################################### + +restore [locate_data_file bug25892_c013] c +restore [locate_data_file bug25892_s013] s + +project cx c s + +#v2d2 +view 1 -2D- 728 20 400 400 + +2dfit +set only_screen_axo 1 diff --git a/tests/bugs/moddata_3/bug25892_14 b/tests/bugs/moddata_3/bug25892_14 new file mode 100644 index 0000000000..8f4d3d595d --- /dev/null +++ b/tests/bugs/moddata_3/bug25892_14 @@ -0,0 +1,18 @@ +puts "============" +puts "OCC25892" +puts "============" +puts "" +####################################################################### +# Wrong result obtained by projection algorithm. +####################################################################### + +restore [locate_data_file bug25892_c014] c +restore [locate_data_file bug25892_s014] s + +project cx c s + +#v2d2 +view 1 -2D- 728 20 400 400 + +2dfit +set only_screen_axo 1