From 74411f73aa02e220b8844f0f9370122decb9e37e Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <dmitri.naumov@ufz.de> Date: Thu, 5 Feb 2015 14:58:34 +0100 Subject: [PATCH] [MeL] MeshSubset::getElementID(). --- MeshLib/MeshSubset.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/MeshLib/MeshSubset.h b/MeshLib/MeshSubset.h index 6af8e35bdce..63f4b7b7800 100644 --- a/MeshLib/MeshSubset.h +++ b/MeshLib/MeshSubset.h @@ -81,6 +81,18 @@ public: return (_eles==nullptr) ? 0 : _eles->size(); } + /// 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. + 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."); + + return (*_eles)[i]->getID(); + } + std::vector<Element*>::const_iterator elementsBegin() const { return _msh.getElements().cbegin(); -- GitLab