From fc41d3b1c01a8d483f92a92e66d048adbcba09b5 Mon Sep 17 00:00:00 2001 From: ifv Date: Sun, 10 Apr 2022 16:56:46 +0300 Subject: [PATCH] 0032842: Modeling Data - a regression in conversion of a face to bspline GeomConvert/GeomConvert_1.cxx - forbid using CheckAndSegment if trim is out of base period when converting trimmed torus tests/bugs/moddata_3/bug32842 - test case added --- src/GeomConvert/GeomConvert_1.cxx | 10 ++++++++-- tests/bugs/moddata_3/bug32842 | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 tests/bugs/moddata_3/bug32842 diff --git a/src/GeomConvert/GeomConvert_1.cxx b/src/GeomConvert/GeomConvert_1.cxx index ec702460b2..b901da74df 100644 --- a/src/GeomConvert/GeomConvert_1.cxx +++ b/src/GeomConvert/GeomConvert_1.cxx @@ -477,7 +477,13 @@ Handle(Geom_BSplineSurface) GeomConvert::SurfaceToBSplineSurface Handle(Geom_ToroidalSurface)::DownCast(Surf); gp_Torus Tr = TheElSurf->Torus(); - if (isUClosed) { + // + // if isUClosed = true and U trim does not coinside with first period of torus, + // method CheckAndSegment shifts position of U seam boundary of surface. + // probably bug? So, for this case we must build not periodic surface. + Standard_Boolean isUFirstPeriod = !(UFirst < 0. || ULast > 2.*M_PI); + Standard_Boolean isVFirstPeriod = !(VFirst < 0. || VLast > 2.*M_PI); + if (isUClosed && isUFirstPeriod) { Convert_TorusToBSplineSurface Convert (Tr, VFirst, VLast, Standard_False); TheSurface = BSplineSurfaceBuilder (Convert); @@ -487,7 +493,7 @@ Handle(Geom_BSplineSurface) GeomConvert::SurfaceToBSplineSurface TheSurface->CheckAndSegment(UFirst, ULast, VFirst, VLast); } } - else if (Strim->IsVClosed()) { + else if (Strim->IsVClosed() && isVFirstPeriod) { Convert_TorusToBSplineSurface Convert (Tr, UFirst, ULast); TheSurface = BSplineSurfaceBuilder (Convert); Standard_Integer aNbK = TheSurface->NbVKnots(); diff --git a/tests/bugs/moddata_3/bug32842 b/tests/bugs/moddata_3/bug32842 new file mode 100644 index 0000000000..2dd884d377 --- /dev/null +++ b/tests/bugs/moddata_3/bug32842 @@ -0,0 +1,17 @@ +puts "===========================================================" +puts "0032842: Modeling Data - a regression in conversion of a face to bspline" +puts "===========================================================" +puts "" + +restore [locate_data_file bug32842.brep] s +nurbsconvert bs s +explode bs e +pcurve pc2 bs_2 bs +bounds pc2 t1 t2 +2dcvalue pc2 t1 x1 y1 +2dcvalue pc2 t2 x2 y2 +mksurface surf bs +bounds surf u1 u2 v1 v2 + +checkreal "U21" [dval (u2-x1)] 0 1.e-7 1.e-7 +checkreal "U22" [dval (u2-x2)] 0 1.e-7 1.e-7