From 3736bf59c05a33ebc6cc74cf028efcdb2edcbbda Mon Sep 17 00:00:00 2001
From: Dmitrij Naumov <dmitrij@naumov.de>
Date: Tue, 24 Feb 2015 13:25:44 +0000
Subject: [PATCH] [MeL] Replace throw with assert in getNodeID, getElementID.

---
 MeshLib/MeshSubset.h | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/MeshLib/MeshSubset.h b/MeshLib/MeshSubset.h
index b5fbee28c61..c586e186e62 100644
--- a/MeshLib/MeshSubset.h
+++ b/MeshLib/MeshSubset.h
@@ -13,6 +13,7 @@
 #ifndef MESHSUBSET_H_
 #define MESHSUBSET_H_
 
+#include <cassert>
 #include <vector>
 
 #include "Mesh.h"
@@ -65,13 +66,10 @@ public:
 
     /// Returns the global node id Node::getID() of i-th node in the mesh
     /// subset.
-    /// Throws std::out_of_range exception if there are no nodes available.
+    /// \pre The _nodes must be a valid pointer to a vector of size > i.
     std::size_t getNodeID(std::size_t const i) const
     {
-        if (!_nodes)
-            throw std::out_of_range(
-                "In MeshSubset::getNodeID(): no nodes or nodes are empty.");
-
+        assert(_nodes && i < _nodes->size());
         return (*_nodes)[i]->getID();
     }
 
@@ -83,13 +81,10 @@ public:
 
     /// Returns the global element id Element::getID() of i-th element in the
     /// mesh subset.
-    /// Throws std::out_of_range exception if there are no nodes available.
+    /// \pre The _eles must be a valid pointer to a vector of size > i.
     std::size_t getElementID(std::size_t const i) const
     {
-        if (!_eles)
-            throw std::out_of_range(
-                "In MeshSubset::getElementID(): no elements or elements are empty.");
-
+        assert(_eles && i < _eles->size());
         return (*_eles)[i]->getID();
     }
 
-- 
GitLab