From: jgv Date: Thu, 27 Mar 2014 12:51:39 +0000 (+0400) Subject: 0024633: Incorrect projection of a curve on a surface X-Git-Tag: V6_8_0_beta~459 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=15173a087b3569b7401d499a554d18904d60964e 0024633: Incorrect projection of a curve on a surface Test cases for issue CR24633 --- diff --git a/src/ProjLib/ProjLib_ComputeApproxOnPolarSurface.cxx b/src/ProjLib/ProjLib_ComputeApproxOnPolarSurface.cxx index 013fe7bc46..347fd4aef1 100644 --- a/src/ProjLib/ProjLib_ComputeApproxOnPolarSurface.cxx +++ b/src/ProjLib/ProjLib_ComputeApproxOnPolarSurface.cxx @@ -1057,14 +1057,59 @@ Handle(Adaptor2d_HCurve2d) (pntproj, Surf->Surface(), U0, V0, TolU, TolV) ; if (aLocateExtPS.IsDone()) - if (aLocateExtPS.SquareDistance() < DistTol3d * DistTol3d) { //OCC217 - //if (aLocateExtPS.SquareDistance() < Tol3d * Tol3d) { + { + if (aLocateExtPS.SquareDistance() < DistTol3d * DistTol3d) + { //OCC217 + //if (aLocateExtPS.SquareDistance() < Tol3d * Tol3d) { (aLocateExtPS.Point()).Parameter(U0,V0); U1 = U0 + usens*uperiod; V1 = V0 + vsens*vperiod; Pts2d(i).SetCoord(U1,V1); myProjIsDone = Standard_True; } + else + { + Extrema_ExtPS aGlobalExtr(pntproj, Surf->Surface(), TolU, TolV); + if (aGlobalExtr.IsDone()) + { + Standard_Real LocalMinSqDist = RealLast(); + Standard_Integer imin = 0; + for (Standard_Integer isol = 1; isol <= aGlobalExtr.NbExt(); isol++) + { + Standard_Real aSqDist = aGlobalExtr.SquareDistance(isol); + if (aSqDist < LocalMinSqDist) + { + LocalMinSqDist = aSqDist; + imin = isol; + } + } + if (LocalMinSqDist < DistTol3d * DistTol3d) + { + Standard_Real LocalU, LocalV; + aGlobalExtr.Point(imin).Parameter(LocalU, LocalV); + if (uperiod > 0. && Abs(U0 - LocalU) >= uperiod/2.) + { + if (LocalU > U0) + usens = -1; + else + usens = 1; + } + if (vperiod > 0. && Abs(V0 - LocalV) >= vperiod/2.) + { + if (LocalV > V0) + vsens = -1; + else + vsens = 1; + } + U0 = LocalU; V0 = LocalV; + U1 = U0 + usens*uperiod; + V1 = V0 + vsens*vperiod; + Pts2d(i).SetCoord(U1,V1); + myProjIsDone = Standard_True; + } + } + } + } if(!myProjIsDone && uperiod) { Standard_Real Uinf, Usup, Uaux; Uinf = Surf->Surface().FirstUParameter(); diff --git a/tests/bugs/moddata_3/bug24633_1 b/tests/bugs/moddata_3/bug24633_1 new file mode 100644 index 0000000000..9510b568c9 --- /dev/null +++ b/tests/bugs/moddata_3/bug24633_1 @@ -0,0 +1,27 @@ +puts "============" +puts "OCC24633" +puts "============" +puts "" +####################################################################### +# Incorrect projection of a curve on a surface +####################################################################### + +restore [locate_data_file bug24633_comp_49.brep] a + +explode a +mkcurve c a_1 +mksurface s a_2 +pcurve a_2 + +project prj c s + +set prj_length [lindex [length prj] end] + +set good_length 7.2662499016218058 +checkreal "prj_length" ${prj_length} ${good_length} 0.01 0.01 + +#v2d2 +view 1 -2D- 728 20 400 400 + +2dfit +set only_screen_axo 1 diff --git a/tests/bugs/moddata_3/bug24633_2 b/tests/bugs/moddata_3/bug24633_2 new file mode 100644 index 0000000000..4d2c6bc52f --- /dev/null +++ b/tests/bugs/moddata_3/bug24633_2 @@ -0,0 +1,27 @@ +puts "============" +puts "OCC24633" +puts "============" +puts "" +####################################################################### +# Incorrect projection of a curve on a surface +####################################################################### + +restore [locate_data_file bug24633_comp_50.brep] a + +explode a +mkcurve c a_1 +mksurface s a_2 +pcurve a_2 + +project prj c s + +set prj_length [lindex [length prj] end] + +set good_length 7.2662499016218058 +checkreal "prj_length" ${prj_length} ${good_length} 0.01 0.01 + +#v2d2 +view 1 -2D- 728 20 400 400 + +2dfit +set only_screen_axo 1