From 342ed98c32de6a4ba38fe4aab69bacc5be599a57 Mon Sep 17 00:00:00 2001 From: ifv Date: Fri, 24 Sep 2021 16:24:34 +0300 Subject: [PATCH] 0032557: Modeling Data - Use of BRepBuilderAPI_NurbsConvert create 2d p-curves with errors BRepTools/BRepTools_NurbsConvertModification.cxx - Checking domain of 2dCurves if surfaces are periodic is improved tests/bugs/moddata_3/bug32557 - test case added --- .../BRepTools_NurbsConvertModification.cxx | 18 +++++++++++++++--- tests/bugs/mesh/bug30008_2 | 2 +- tests/bugs/moddata_3/bug32557 | 10 ++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 tests/bugs/moddata_3/bug32557 diff --git a/src/BRepTools/BRepTools_NurbsConvertModification.cxx b/src/BRepTools/BRepTools_NurbsConvertModification.cxx index bd05b0378c..67565185c9 100644 --- a/src/BRepTools/BRepTools_NurbsConvertModification.cxx +++ b/src/BRepTools/BRepTools_NurbsConvertModification.cxx @@ -493,11 +493,23 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d { //Surface is periodic, checking curve2d domain //Old domain - gp_Pnt2d aPf = C2d->Value(f2d); + Standard_Real aMinDist = Precision::Infinite(); + if (S->IsUPeriodic()) + { + aMinDist = Min(0.5 * S->UPeriod(), aMinDist); + } + if (S->IsVPeriodic()) + { + aMinDist = Min(0.5 * S->VPeriod(), aMinDist); + } + aMinDist *= aMinDist; + //Old domain + Standard_Real t = 0.5 * (f2d + l2d); + gp_Pnt2d aPf = C2d->Value(t); //New domain - gp_Pnt2d aNewPf = Curve2d->Value(f2d); + gp_Pnt2d aNewPf = Curve2d->Value(t); gp_Vec2d aT(aNewPf, aPf); - if (aT.SquareMagnitude() > Precision::SquarePConfusion()) + if (aT.SquareMagnitude() > aMinDist) { Curve2d = Handle(Geom2d_Curve)::DownCast(Curve2d->Translated(aT)); } diff --git a/tests/bugs/mesh/bug30008_2 b/tests/bugs/mesh/bug30008_2 index 7a57ceff91..ffffa6b9d8 100644 --- a/tests/bugs/mesh/bug30008_2 +++ b/tests/bugs/mesh/bug30008_2 @@ -19,7 +19,7 @@ nurbsconvert result result incmesh result 0.15 -a 20 tricheck result -checktrinfo result -tri 191 -nod 146 -defl 0.052300780129031083 -tol_abs_defl 1.0e-6 +checktrinfo result -tri 193 -nod 147 -defl 0.052300780129031083 -tol_abs_defl 1.0e-6 vinit diff --git a/tests/bugs/moddata_3/bug32557 b/tests/bugs/moddata_3/bug32557 new file mode 100644 index 0000000000..374a129033 --- /dev/null +++ b/tests/bugs/moddata_3/bug32557 @@ -0,0 +1,10 @@ +puts "===========================================================" +puts "0032557: Modeling Data - Use of BRepBuilderAPI_NurbsConvert create 2d p-curves with gaps" +puts "===========================================================" +puts "" + +restore [locate_data_file bug32557.brep] f + +nurbsconvert bf f +checkmaxtol bf -ref 1.1e-7 +