0031402: Modeling Data - Geom_BSplineSurface::Segment() produces wrong result
[occt.git] / src / Geom / Geom_BSplineSurface.cxx
index 262b3d7..5316b0c 100644 (file)
@@ -619,9 +619,11 @@ void Geom_BSplineSurface::segment(const Standard_Real U1,
   Standard_Integer ToU2 = uknots->Upper();
   BSplCLib::LocateParameter(udeg, uknots->Array1(), umults->Array1(),
                             NewU1, uperiodic, FromU1, ToU2, index1U, U);
+  if (Abs(uknots->Value(index1U + 1) - U) <= EpsU)
+    index1U++;
   BSplCLib::LocateParameter(udeg, uknots->Array1(), umults->Array1(),
                             NewU1 + deltaU, uperiodic, FromU1, ToU2, index2U, U);
-  if (Abs(uknots->Value(index2U + 1) - U) <= EpsU)
+  if (Abs(uknots->Value(index2U + 1) - U) <= EpsU || index2U == index1U)
     index2U++;
 
   Standard_Integer nbuknots = index2U - index1U + 1;
@@ -659,9 +661,11 @@ void Geom_BSplineSurface::segment(const Standard_Real U1,
   Standard_Integer ToV2 = vknots->Upper();
   BSplCLib::LocateParameter(vdeg, vknots->Array1(), vmults->Array1(),
                             NewV1, vperiodic, FromV1, ToV2, index1V, V);
+  if (Abs(vknots->Value(index1V + 1) - V) <= EpsV)
+    index1V++;
   BSplCLib::LocateParameter(vdeg, vknots->Array1(), vmults->Array1(),
                             NewV1 + deltaV, vperiodic, FromV1, ToV2, index2V, V);
-  if (Abs(vknots->Value(index2V + 1) - V) <= EpsV)
+  if (Abs(vknots->Value(index2V + 1) - V) <= EpsV || index2V == index1V)
     index2V++;
 
   Standard_Integer nbvknots = index2V - index1V + 1;