From: omy Date: Mon, 1 Jun 2015 14:39:42 +0000 (+0300) Subject: 0026278: Canonical recognition from time to time raises exception on the attached... X-Git-Tag: V7_0_0_beta~506 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=283b833c8e2367cd9d98a1c8572553ef0b870f6c;p=occt-copy.git 0026278: Canonical recognition from time to time raises exception on the attached shape 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. --- diff --git a/src/BSplSLib/BSplSLib_Cache.cxx b/src/BSplSLib/BSplSLib_Cache.cxx index dbc8e4198b..bd125aa993 100644 --- a/src/BSplSLib/BSplSLib_Cache.cxx +++ b/src/BSplSLib/BSplSLib_Cache.cxx @@ -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;