From ceff3c21781d62ba5040a3e5a927bc13933d1098 Mon Sep 17 00:00:00 2001 From: Domenico Tiziani Date: Wed, 26 Oct 2016 15:57:40 +0200 Subject: [PATCH] Added component scale getter --- include/GModelSpatialComposite.hpp | 1 + src/model/GModelSpatialComposite.cpp | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 0 deletions(-) diff --git a/include/GModelSpatialComposite.hpp b/include/GModelSpatialComposite.hpp index f96f61a..ebbfbe0 100644 --- a/include/GModelSpatialComposite.hpp +++ b/include/GModelSpatialComposite.hpp @@ -82,6 +82,7 @@ public: double scale = 1.); const GModelSpatial* component(const int& index) const; const GModelSpatial* component(const std::string& name) const; + double component_scale(const int& index) const; protected: diff --git a/src/model/GModelSpatialComposite.cpp b/src/model/GModelSpatialComposite.cpp index db79aa4..226b0d4 100644 --- a/src/model/GModelSpatialComposite.cpp +++ b/src/model/GModelSpatialComposite.cpp @@ -594,6 +594,29 @@ const GModelSpatial* GModelSpatialComposite::component(const std::string& name) return m_components[index]; } +/***********************************************************************//** + * @brief Returns scale of spatial component + * + * @param[in] index Index of spatial component [0,...,components()-1]. + * @return Scale. + * + * @exception GException::out_of_range + * Index is out of range. + * + * Returns the scale of a spatial component to the composite model + ***************************************************************************/ +double GModelSpatialComposite::component_scale(const int& index) const +{ + // Check if index is in validity range + if (index < 0 || index >= m_components.size()) { + throw GException::out_of_range(G_COMPONENT_INDEX, "Component Index", + index, m_components.size()); + } + + // Return spatial component + return m_component_scales[index]; +} + /***********************************************************************//** * @brief Print composite spatial model information -- libgit2 0.21.4