0026278: Canonical recognition from time to time raises exception on the attached...
authoromy <omy@opencascade.com>
Mon, 1 Jun 2015 14:39:42 +0000 (17:39 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 10 Jun 2015 07:42:24 +0000 (10:42 +0300)
Corrected array boundaries to avoid Standard_OutOfRange exception in BSplSLib and BSplSLib_Cache on the given shapes.
Code formatting has been corrected for ShapeFix_Edge.

src/BSplSLib/BSplSLib_Cache.cxx

index dbc8e41..bd125aa 100644 (file)
@@ -148,8 +148,20 @@ void BSplSLib_Cache::BuildCache(const Standard_Real&           theParameterU,
                             thePeriodicU, mySpanIndex[0], aNewParamU);
   BSplCLib::LocateParameter(theDegreeV, theFlatKnotsV, BSplCLib::NoMults(), aNewParamV, 
                             thePeriodicV, mySpanIndex[1], aNewParamV);
+
+  // Protection against Out of Range exception.
+  if (mySpanIndex[0] >= theFlatKnotsU.Length()) {
+    mySpanIndex[0] = theFlatKnotsU.Length() - 1;
+  }
+
   mySpanLength[0] = (theFlatKnotsU.Value(mySpanIndex[0] + 1) - theFlatKnotsU.Value(mySpanIndex[0])) * 0.5;
   mySpanStart[0]  = theFlatKnotsU.Value(mySpanIndex[0]) + mySpanLength[0];
+
+  // Protection against Out of Range exception.
+  if (mySpanIndex[1] >= theFlatKnotsV.Length()) {
+    mySpanIndex[1] = theFlatKnotsV.Length() - 1;
+  }
+
   mySpanLength[1] = (theFlatKnotsV.Value(mySpanIndex[1] + 1) - theFlatKnotsV.Value(mySpanIndex[1])) * 0.5;
   mySpanStart[1]  = theFlatKnotsV.Value(mySpanIndex[1]) + mySpanLength[1];
   mySpanIndexMax[0] = theFlatKnotsU.Length() - 1 - theDegreeU;