0032842: Modeling Data - a regression in conversion of a face to bspline
authorifv <ifv@opencascade.com>
Sun, 10 Apr 2022 13:56:46 +0000 (16:56 +0300)
committersmoskvin <smoskvin@opencascade.com>
Tue, 12 Apr 2022 17:50:29 +0000 (20:50 +0300)
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
tests/bugs/moddata_3/bug32842 [new file with mode: 0644]

index ec70246..b901da7 100644 (file)
@@ -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 (file)
index 0000000..2dd884d
--- /dev/null
@@ -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