]> OCCT Git - occt.git/commitdiff
Modeling - Periodic BSpline curve bounding #493
authorPasukhin Dmitry <dpasukhi@opencascade.com>
Fri, 11 Apr 2025 21:08:02 +0000 (22:08 +0100)
committerdpasukhi <dpasukhi@opencascade.com>
Mon, 19 May 2025 21:19:51 +0000 (22:19 +0100)
Enhance periodic curve handling in BndLib_Add3dCurve::Add method.
Checks the periodic BSpline on 3 directions of period for tolerance upgrade.

src/BndLib/BndLib_Add3dCurve.cxx
tests/bugs/modalg_6/bug27079_3

index 5508a13268ac9715fea6553a047f9952402c315c..efa7ff74ffeb4e9a6d37086939d8cae06e4c40fd 100644 (file)
@@ -215,12 +215,33 @@ void BndLib_Add3dCurve::Add(const Adaptor3d_Curve& C,
             u2 = Bsaux->LastParameter();
           //  modified by NIZHNY-EAP Fri Dec  3 14:29:18 1999 ___END___
         }
-        const Standard_Real anU2Periodic =
-          Bsaux->IsPeriodic() ? (u2 - (Bsaux->LastParameter() - Bsaux->FirstParameter())) : u2;
         Standard_Real aSegmentTol = 2. * Precision::PConfusion();
-        if (Abs((anU2Periodic - u1) < aSegmentTol))
+
+        // For periodic curves, check if parameters are close in either direction
+        if (Bsaux->IsPeriodic())
+        {
+          const Standard_Real aPeriod = Bsaux->LastParameter() - Bsaux->FirstParameter();
+
+          // Check direct distance between parameters
+          const Standard_Real aDirectDiff = Abs(u2 - u1);
+
+          // Check distances across period boundary (in both directions)
+          const Standard_Real aCrossPeriodDiff1 = Abs(u2 - aPeriod - u1);
+          const Standard_Real aCrossPeriodDiff2 = Abs(u1 - aPeriod - u2);
+
+          // Find the minimum difference (closest approach)
+          const Standard_Real aMinDiff =
+            Min(aDirectDiff, Min(aCrossPeriodDiff1, aCrossPeriodDiff2));
+
+          if (aMinDiff < aSegmentTol)
+          {
+            aSegmentTol = aMinDiff * 0.01;
+          }
+        }
+        // For non-periodic curves, just check direct parameter difference
+        else if (Abs(u2 - u1) < aSegmentTol)
         {
-          aSegmentTol = Abs(anU2Periodic - u1) * 0.01;
+          aSegmentTol = Abs(u2 - u1) * 0.01;
         }
         Bsaux->Segment(u1, u2, aSegmentTol);
         Bs = Bsaux;
index 8162441ce415e744f26c90f285f1ad7e4edad810..db7200a31d4434ea1552fc3d6300bfc469474fbf 100644 (file)
@@ -20,6 +20,6 @@ bop f1 f2
 bopsection result
 
 checkprops result -l 13.7747
-checknbshapes result -vertex 3 -edge 2
+checknbshapes result -vertex 4 -edge 3
 
 checkview -screenshot -2d -path ${imagedir}/${test_image}.png