From 3a46f887da9be24b7fe1ac668927b0bb560ca513 Mon Sep 17 00:00:00 2001 From: isn Date: Thu, 22 Sep 2016 14:42:30 +0300 Subject: [PATCH] 0027890: BndLib_Add2dCurve::Add(..) works incorrect on some curves new testcase: extension for 'gbounding' command. now this command allows to pass curve2d as args and works in two modes ('normal' and optimal) --- src/BRepTest/BRepTest_BasicCommands.cxx | 97 +++++++++++++++++++------ 1 file changed, 75 insertions(+), 22 deletions(-) diff --git a/src/BRepTest/BRepTest_BasicCommands.cxx b/src/BRepTest/BRepTest_BasicCommands.cxx index 87424fc459..fca78e69b7 100644 --- a/src/BRepTest/BRepTest_BasicCommands.cxx +++ b/src/BRepTest/BRepTest_BasicCommands.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -486,46 +487,98 @@ static Standard_Integer optbounding(Draw_Interpretor& di,Standard_Integer n,cons #include #include #include +#include +#include static Standard_Integer gbounding(Draw_Interpretor& di,Standard_Integer n,const char** a) { - if (n < 2) + if (n != 2 && n != 3) { - di << "Usage: gbounding surf/curve \n"; + di << "Usage: gbounding surf/curve/curve2d [-o] \n"; + di << "[-o] turn off Optimal mode ('on' by default) \n"; return 1; } - Standard_Real axmin,aymin,azmin,axmax,aymax,azmax; - Bnd_Box B; Handle(Draw_Box) DB; - - if (n == 2) { + else + { + Standard_Boolean IsOptimal = Standard_True; + if (n == 3 && !strcmp(a[2], "-o")) + IsOptimal = Standard_False; + + Standard_Real axmin,aymin,azmin,axmax,aymax,azmax; + Bnd_Box B; + Bnd_Box2d B2d; + Handle(Draw_Box) DB; + Standard_Boolean Is3d = Standard_True; Handle(Geom_Curve) C; Handle(Geom_Surface) S; + Handle_Geom2d_Curve C2d; S = DrawTrSurf::GetSurface(a[1]); - if (S.IsNull()) + if (!S.IsNull()) { - C = DrawTrSurf::GetCurve(a[1]); + //add surf + GeomAdaptor_Surface aGAS(S); + if (IsOptimal) + BndLib_AddSurface::AddOptimal(aGAS, Precision::Confusion(), B); + else + BndLib_AddSurface::Add(aGAS, Precision::Confusion(), B); } - if(!S.IsNull()) + else { - GeomAdaptor_Surface aGAS(S); - BndLib_AddSurface::AddOptimal(aGAS, Precision::Confusion(), B); + C = DrawTrSurf::GetCurve(a[1]); + if (!C.IsNull()) + { + // add cur + GeomAdaptor_Curve aGAC(C); + if (IsOptimal) + BndLib_Add3dCurve::AddOptimal(aGAC, Precision::Confusion(), B); + else + BndLib_Add3dCurve::Add(aGAC, Precision::Confusion(), B); + } + else + { + C2d = DrawTrSurf::GetCurve2d(a[1]); + if (!C2d.IsNull()) + { + //add cur2d + Is3d = Standard_False; + if (IsOptimal) + BndLib_Add2dCurve::AddOptimal(C2d, C2d->FirstParameter(), C2d->LastParameter(), Precision::Confusion(), B2d); + else + BndLib_Add2dCurve::Add(C2d, C2d->FirstParameter(), C2d->LastParameter(), Precision::Confusion(), B2d); + } + else + { + di << "Wrong argument \n"; + return 1; + } + } } - else if(!C.IsNull()) + + if (Is3d) { - GeomAdaptor_Curve aGAC(C); - BndLib_Add3dCurve::AddOptimal(aGAC, Precision::Confusion(), B); + B.Get(axmin,aymin,azmin,axmax,aymax,azmax); + DB = new Draw_Box(gp_Pnt(axmin,aymin,azmin),gp_Pnt(axmax,aymax,azmax),Draw_vert); + dout<