0029712: Extrema algorithm raises exception
[occt.git] / src / Extrema / Extrema_GenExtPC.gxx
index f3d26aa..bf63909 100644 (file)
@@ -205,9 +205,13 @@ Standard_Integer Extrema_GenExtPC::NbExt () const {
 //purpose  : 
 //=======================================================================
 
-Standard_Real Extrema_GenExtPC::SquareDistance (const Standard_Integer N) const {
+Standard_Real Extrema_GenExtPC::SquareDistance (const Standard_Integer N) const
+{
+  if ((N < 1) || (N > NbExt()))
+  {
+    throw Standard_OutOfRange();
+  }
 
-  if (!IsDone()) { throw StdFail_NotDone(); }
   return myF.SquareDistance(N);
 }
 
@@ -219,7 +223,11 @@ Standard_Real Extrema_GenExtPC::SquareDistance (const Standard_Integer N) const
 
 Standard_Boolean Extrema_GenExtPC::IsMin (const Standard_Integer N) const {
 
-  if (!IsDone()) { throw StdFail_NotDone(); }
+  if ((N < 1) || (N > NbExt()))
+  {
+    throw Standard_OutOfRange();
+  }
+
   return myF.IsMin(N);
 }
 
@@ -231,7 +239,11 @@ Standard_Boolean Extrema_GenExtPC::IsMin (const Standard_Integer N) const {
 
 const POnC & Extrema_GenExtPC::Point (const Standard_Integer N) const 
 {
-  if (!IsDone()) { throw StdFail_NotDone(); }
+  if ((N < 1) || (N > NbExt()))
+  {
+    throw Standard_OutOfRange();
+  }
+
   return myF.Point(N);
 }
 //=============================================================================