Salome HOME
protect IndexToShape() from Standard_OutOfRange exception
authoreap <eap@opencascade.com>
Mon, 15 Feb 2010 07:11:44 +0000 (07:11 +0000)
committereap <eap@opencascade.com>
Mon, 15 Feb 2010 07:11:44 +0000 (07:11 +0000)
src/SMESHDS/SMESHDS_Mesh.cxx

index 34118b82907afab02291f4d9651c74a35fa22e27..c4479f35bc73ff1ecfd6393020e580085c02ac55 100644 (file)
 #include "SMDS_SpacePosition.hxx"
 #include "SMESHDS_GroupOnGeom.hxx"
 
-#include <TopExp_Explorer.hxx>
+#include <Standard_ErrorHandler.hxx>
+#include <Standard_OutOfRange.hxx>
 #include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
 #include <TopoDS_Iterator.hxx>
 
 #include "utilities.h"
@@ -1235,7 +1237,15 @@ int SMESHDS_Mesh::AddCompoundSubmesh(const TopoDS_Shape& S,
 //=======================================================================
 const TopoDS_Shape& SMESHDS_Mesh::IndexToShape(int ShapeIndex) const
 {
-        return myIndexToShape.FindKey(ShapeIndex);
+  try
+  {
+    return myIndexToShape.FindKey(ShapeIndex);
+  }
+  catch ( Standard_OutOfRange )
+  {
+  }
+  static TopoDS_Shape nullShape;
+  return nullShape;
 }
 
 //=======================================================================