From: aml Date: Thu, 5 Mar 2015 11:56:28 +0000 (+0300) Subject: 0025861: Wrong result obtained by projection algorithm. X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FCR680-SALOME-PATCH;p=occt-copy.git 0025861: Wrong result obtained by projection algorithm. Handling of trimmed analytical surfaces added in extrema PS. New draw-command and test case for issue CR25861 Correction of test case for issue CR25861 --- diff --git a/src/Extrema/Extrema_ExtPS.cxx b/src/Extrema/Extrema_ExtPS.cxx index e845275210..37926ae1c6 100644 --- a/src/Extrema/Extrema_ExtPS.cxx +++ b/src/Extrema/Extrema_ExtPS.cxx @@ -110,10 +110,22 @@ void Extrema_ExtPS::TreatSolution (const Extrema_POnSurf& PS, Standard_Real U, V; PS.Parameter(U, V); if (myS->IsUPeriodic()) { - U = ElCLib::InPeriod(U, myuinf, myuinf+myS->UPeriod()); + U = ElCLib::InPeriod(U, myuinf, myuinf + myS->UPeriod()); + + // Handle trimmed surfaces. + if (U > myusup + mytolu) + U -= myS->UPeriod(); + if (U < myuinf - mytolu) + U += myS->UPeriod(); } if (myS->IsVPeriodic()) { - V = ElCLib::InPeriod(V, myvinf, myvinf+myS->VPeriod()); + V = ElCLib::InPeriod(V, myvinf, myvinf + myS->VPeriod()); + + // Handle trimmed surfaces. + if (V > myvsup + mytolv) + V -= myS->VPeriod(); + if (V < myvinf - mytolv) + V += myS->VPeriod(); } if ((myuinf-U) <= mytolu && (U-myusup) <= mytolu && (myvinf-V) <= mytolv && (V-myvsup) <= mytolv) { diff --git a/src/QABugs/QABugs_19.cxx b/src/QABugs/QABugs_19.cxx index 62008a795d..d42a7db696 100755 --- a/src/QABugs/QABugs_19.cxx +++ b/src/QABugs/QABugs_19.cxx @@ -3126,6 +3126,57 @@ static Standard_Integer OCC25446 (Draw_Interpretor& theDI, return 0; } +#include +#include + +//======================================================================= +//function : xprojponf +//purpose : +//======================================================================= +Standard_Integer xprojponf (Draw_Interpretor& di, + Standard_Integer n, + const char** a) +{ + if (n!=3) { + di<<" use xprojponf p f \n"; + return 0; + } + // + gp_Pnt aP, aPS; + TopoDS_Shape aS; + TopoDS_Face aF; + Handle(IntTools_Context) aCtx; + // + DrawTrSurf::GetPoint(a[1], aP); + aS=DBRep::Get(a[2]); + // + if (aS.IsNull()) { + di<<" null shape is not allowed\n"; + return 0; + } + // + if (aS.ShapeType()!=TopAbs_FACE) { + di << a[2] << " not a face\n"; + return 0; + } + // + aCtx=new IntTools_Context; + // + aF=TopoDS::Face(aS); + GeomAPI_ProjectPointOnSurf& aPPS=aCtx->ProjPS(aF); + // + aPPS.Perform(aP); + if (!aPPS.IsDone()) { + di<<" projection failed\n"; + return 0; + } + // + aPS=aPPS.NearestPoint(); + di<< " point px " << aPS.X() << " " << aPS.Y() << " " << aPS.Z() << "\n"; + // + return 0; +} + void QABugs::Commands_19(Draw_Interpretor& theCommands) { const char *group = "QABugs"; @@ -3187,5 +3238,6 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) { theCommands.Add ("OCC25348", "OCC25348", __FILE__, OCC25348, group); theCommands.Add ("OCC25413", "OCC25413 shape", __FILE__, OCC25413, group); theCommands.Add ("OCC25446", "OCC25446 res b1 b2 op", __FILE__, OCC25446, group); + theCommands.Add ("xprojponf", "xprojponf p f", __FILE__, xprojponf, group); return; } diff --git a/tests/bugs/moddata_3/bug25861 b/tests/bugs/moddata_3/bug25861 new file mode 100644 index 0000000000..a09e56703a --- /dev/null +++ b/tests/bugs/moddata_3/bug25861 @@ -0,0 +1,34 @@ +puts "================" +puts "OCC25861" +puts "================" +puts "" +####################################################################### +# Wrong result obtained by projection algorithm. +####################################################################### + +pload QAcommands + +restore [locate_data_file bug25861_f3.brep] f3 + +point p 6.9184976310066668 -24.127668568051799 8.6427835999999978 + +set info [xprojponf p f3] + +if { [regexp {point px +([-0-9.+eE]+) +([-0-9.+eE]+) +([-0-9.+eE]+)} ${info} string x2 y2 z2] != 1 } { + puts "Error: Wrong result obtained by projection algorithm" +} else { + puts "OK: Good result obtained by projection algorithm" + + vertex v1 p + vertex v2 ${x2} ${y2} ${z2} + + set CMP_TOL 1.0e-7 + distmini res v1 v2 + set distmin [dval res_val] + if { [expr abs(${distmin})] > ${CMP_TOL} } { + puts "Error: Wrong projection point" + } else { + puts "OK: Good projection point" + } + +}