diff --git a/src/BOPInt/BOPInt_Context.cxx b/src/BOPInt/BOPInt_Context.cxx index 1db39055c5..109ad6ba8e 100644 --- a/src/BOPInt/BOPInt_Context.cxx +++ b/src/BOPInt/BOPInt_Context.cxx @@ -215,7 +215,9 @@ // pProjPS=(GeomAPI_ProjectPointOnSurf*)myAllocator->Allocate(sizeof(GeomAPI_ProjectPointOnSurf)); new (pProjPS) GeomAPI_ProjectPointOnSurf(); - pProjPS->Init(aS ,Umin, Usup, Vmin, Vsup, anEpsT); + pProjPS->Init(aS ,Umin, Usup, Vmin, Vsup, anEpsT, Extrema_ExtAlgo_Tree); + Extrema_ExtPS& anExtAlgo = const_cast(pProjPS->Extrema()); + anExtAlgo.SetFlag(Extrema_ExtFlag_MIN); // anAdr=(Standard_Address)pProjPS; myProjPSMap.Bind(aF, anAdr); diff --git a/src/TestTopOpe/TestTopOpe_CORCommands.cxx b/src/TestTopOpe/TestTopOpe_CORCommands.cxx index 8f02967132..694ea0330a 100755 --- a/src/TestTopOpe/TestTopOpe_CORCommands.cxx +++ b/src/TestTopOpe/TestTopOpe_CORCommands.cxx @@ -73,6 +73,9 @@ #include #include +#include +#include + #ifdef DRAW #include #endif @@ -671,16 +674,57 @@ static Standard_Integer pntonc2d(Draw_Interpretor& di, Standard_Integer n, const static Standard_Integer projponf(Draw_Interpretor& di, Standard_Integer n, const char** a) { - if (n < 3) return 1; + if (n < 3) { + di << "projponf f pnt [extrema flag: -min/-max/-minmax] [extrema algo: -g(grad)/-t(tree)]\n"; + return 1; + } + // TopoDS_Shape aLocalShape = DBRep::Get(a[1]); TopoDS_Face f = TopoDS::Face(aLocalShape); -// TopoDS_Face f = TopoDS::Face(DBRep::Get(a[1])); - if (f.IsNull()) {di<<"null shape"<<"\n";return 1;} - gp_Pnt p; DrawTrSurf::GetPoint(a[2], p); - Standard_Real dist=0.; gp_Pnt2d uv; Standard_Boolean ok = FUN_tool_projPonF(p,f,uv,dist); - if (!ok) {di<<"projection failed"<<"\n"; return 1;} - gp_Pnt pproj; ok = FUN_tool_value(uv,f,pproj); - if (!ok) {di<<"projection failed"<<"\n"; return 1;} + // + if (f.IsNull()) { + di<<"null shape"<<"\n"; + return 1; + } + // + Standard_Real dist=0.; + Standard_Boolean ok; + gp_Pnt2d uv; + gp_Pnt p, pproj; + Extrema_ExtAlgo aExtAlgo = Extrema_ExtAlgo_Grad; + Extrema_ExtFlag aExtFlag = Extrema_ExtFlag_MINMAX; + // + DrawTrSurf::GetPoint(a[2], p); + // + if (n > 3) { + const char* key1 = a[3]; + const char* key2 = (n > 4) ? a[4] : NULL; + if (key1) { + if (!strcasecmp(key1,"-min")) { + aExtFlag = Extrema_ExtFlag_MIN; + } else if (!strcasecmp(key1,"-max")) { + aExtFlag = Extrema_ExtFlag_MAX; + } else { + aExtAlgo = (!strcasecmp(key1,"-t")) ? Extrema_ExtAlgo_Tree : aExtAlgo; + } + } + if (key2) { + aExtAlgo = (!strcasecmp(key2,"-t")) ? Extrema_ExtAlgo_Tree : aExtAlgo; + } + } + ok = FUN_tool_projPonF(p, f, uv, dist, aExtFlag, aExtAlgo); + // + if (!ok) { + di<<"projection failed"<<"\n"; + return 1; + } + // + ok = FUN_tool_value(uv,f,pproj); + if (!ok) { + di<<"projection failed"<<"\n"; + return 1; + } + // di<<"proj dist = "<Bounds(UMin, UMax, VMin, VMax); + PonS.Init(S, UMin, UMax, VMin, VMax, aExtAlgo); + Extrema_ExtPS& anExtAlgo = const_cast(PonS.Extrema()); + anExtAlgo.SetFlag(aExtFlag); + // + PonS.Perform(P); + // if (!PonS.Extrema().IsDone()) return Standard_False; if (PonS.NbPoints() == 0) return Standard_False; dist = PonS.LowerDistance(); @@ -272,10 +283,12 @@ Standard_EXPORT Standard_Boolean FUN_tool_projPonboundedF(const gp_Pnt& P,const // ---------------------------------------------------------------------- Standard_EXPORT Standard_Boolean FUN_tool_projPonF(const gp_Pnt& P,const TopoDS_Face& F, - gp_Pnt2d& UV,Standard_Real& dist) + gp_Pnt2d& UV,Standard_Real& dist, + const Extrema_ExtFlag aExtFlag, + const Extrema_ExtAlgo aExtAlgo) { dist = 1.; Handle(Geom_Surface) S = BRep_Tool::Surface(F); - Standard_Boolean ok = FUN_tool_projPonS(P,S,UV,dist); + Standard_Boolean ok = FUN_tool_projPonS(P,S,UV,dist, aExtFlag, aExtAlgo); return ok; } diff --git a/src/TopOpeBRepTool/TopOpeBRepTool_PROJECT.hxx b/src/TopOpeBRepTool/TopOpeBRepTool_PROJECT.hxx index 04d62b909c..daa63e9a05 100755 --- a/src/TopOpeBRepTool/TopOpeBRepTool_PROJECT.hxx +++ b/src/TopOpeBRepTool/TopOpeBRepTool_PROJECT.hxx @@ -31,6 +31,8 @@ #include #include #include +#include +#include // ---------------------------------------------------------------------- // project point

on geometries (curve ,surface ) @@ -44,7 +46,9 @@ Standard_EXPORT Standard_Boolean FUN_tool_projPonC(const gp_Pnt& P,const BRepAda Standard_EXPORT Standard_Boolean FUN_tool_projPonC2D(const gp_Pnt& P,const Standard_Real tole,const BRepAdaptor_Curve2d& BAC2D,const Standard_Real pmin,const Standard_Real pmax,Standard_Real& param,Standard_Real& dist); Standard_EXPORT Standard_Boolean FUN_tool_projPonC2D(const gp_Pnt& P,const BRepAdaptor_Curve2d& BAC2D,const Standard_Real pmin,const Standard_Real pmax,Standard_Real& param,Standard_Real& dist); Standard_EXPORT Standard_Boolean FUN_tool_projPonC2D(const gp_Pnt& P,const BRepAdaptor_Curve2d& BAC2D,Standard_Real& param,Standard_Real& dist); -Standard_EXPORT Standard_Boolean FUN_tool_projPonS(const gp_Pnt& P,const Handle(Geom_Surface)& S,gp_Pnt2d& UV,Standard_Real& dist); +Standard_EXPORT Standard_Boolean FUN_tool_projPonS(const gp_Pnt& P,const Handle(Geom_Surface)& S,gp_Pnt2d& UV,Standard_Real& dist, + const Extrema_ExtFlag aExtFlag=Extrema_ExtFlag_MINMAX, + const Extrema_ExtAlgo aExtAlgo=Extrema_ExtAlgo_Grad); // ---------------------------------------------------------------------- // project point

on topologies (edge ,face ) @@ -52,6 +56,8 @@ Standard_EXPORT Standard_Boolean FUN_tool_projPonS(const gp_Pnt& P,const Handle( Standard_EXPORT Standard_Boolean FUN_tool_projPonE(const gp_Pnt& P,const Standard_Real tole,const TopoDS_Edge& E,Standard_Real& param,Standard_Real& dist); Standard_EXPORT Standard_Boolean FUN_tool_projPonE(const gp_Pnt& P,const TopoDS_Edge& E,Standard_Real& param,Standard_Real& dist); Standard_EXPORT Standard_Boolean FUN_tool_projPonboundedF(const gp_Pnt& P,const TopoDS_Face& F,gp_Pnt2d& UV,Standard_Real& dist); -Standard_EXPORT Standard_Boolean FUN_tool_projPonF(const gp_Pnt& P,const TopoDS_Face& F,gp_Pnt2d& UV,Standard_Real& dist); +Standard_EXPORT Standard_Boolean FUN_tool_projPonF(const gp_Pnt& P,const TopoDS_Face& F,gp_Pnt2d& UV,Standard_Real& dist, + const Extrema_ExtFlag aExtFlag=Extrema_ExtFlag_MINMAX, + const Extrema_ExtAlgo aExtAlgo=Extrema_ExtAlgo_Grad); #endif diff --git a/tests/bugs/modalg_5/bug23906 b/tests/bugs/modalg_5/bug23906 new file mode 100755 index 0000000000..2e6c980b5a --- /dev/null +++ b/tests/bugs/modalg_5/bug23906 @@ -0,0 +1,34 @@ +puts "============" +puts "OCC23906" +puts "============" +puts "" +############################### +## Performance of the projection algorithm in some cases became lower after integration of the fix for the bug 0022610 +############################### + +restore [locate_data_file bug23906_f.brep] f + +point p 3.5527136788005e-015 100 100 + +dchrono h reset +dchrono h start + +projponf f p -min -t + +dchrono h stop +set q2 [dchrono h show] + +regexp {CPU user time: ([-0-9.+eE]+) seconds} $q2 full z +puts "$z" +if { [string compare $tcl_platform(platform) "windows"] == 0 } { + puts "OS = Windows NT" + set max_time 0.2 +} else { + puts "OS = Linux" + set max_time 0.1 +} +if { $z > ${max_time} } { + puts "Elapsed time is more then ${max_time} seconds - Faulty" +} else { + puts "Elapsed time is less then ${max_time} seconds - OK" +}