]> OCCT Git - occt.git/commitdiff
Modeling - Periodic BSpline curve bounding
authordpasukhi <dpasukhi@opencascade.com>
Fri, 11 Apr 2025 15:56:17 +0000 (16:56 +0100)
committerdpasukhi <dpasukhi@opencascade.com>
Fri, 11 Apr 2025 15:56:17 +0000 (16:56 +0100)
Enhance periodic curve handling in BndLib_Add3dCurve::Add method

src/ModelingData/TKGeomBase/BndLib/BndLib_Add3dCurve.cxx

index 5508a13268ac9715fea6553a047f9952402c315c..549061ca552b3f8fccaf4b111df05dcbb6f2ec82 100644 (file)
@@ -215,12 +215,32 @@ 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;