#ifndef colors_Color3_Space_H__ #define colors_Color3_Space_H__ #include "../geo/Vectors.h" #include "../math/Matrix.h" #include "../math/utility.h" #include namespace meow { /*! * @brief Base class of color space with 3 channels. * * @author cat_leopard */ template class Color3_Space { protected: Vector3D min_; Vector3D max_; Vector3D val_; /*! * @brief Constructor * * @param [in] min_bound Minimum value of each channels. * @param [in] max_bound Maximum value of each channels. * @param [in] init_value Initial value of each channels. */ Color3_Space(Vector3D const& min_bound, Vector3D const& max_bound, Vector3D const& init_value): min_(min_bound), max_(max_bound), val_(init_value) { } /*! * @brief Copy constructor * * @param [in] b Data to copy from. */ Color3_Space(Color3_Space const& b): min_(b.min_), max_(b.max_), val_(b.val_) { } /*! * @brief Copy method * * We copy the value only, not include \c min_bound and \c max_bound. * * @param [in] b Value to copy from. * @return \c *this */ Color3_Space& copyFrom(Color3_Space const& b) { val_ = b.val_; return *this; } public: //! @brief Destructor virtual ~Color3_Space() { } //! @brief minimum bound of each channels. Vector3D const& minV() const { return min_; } //! @brief maximum bound of each channels. Vector3D const& maxV() const { return max_; } //! @brief value of each channels. Vector3D const& valV() const { return val_; } /*! * @brief Set the value of each channels. * * @param [in] vv new value * @return new value */ Vector3D const& valV(Vector3D const& vv) { val_ = vv; return val(); } //! @brief Get the non-constant reference of each channels. Vector3D& valVGet() { return val_; } /*! * @brief Return the minimum of the \c i -th channel. * * @param [in] id index of the channel. * @return new value */ T const& min(size_t id) const { return minV()(id); } /*! * @brief Return the maximum of the \c i -th channel. * * @param [in] id index of the channel. * @return new value */ T const& max(size_t id) const { return maxV()(id); } /*! * @brief Return the value of the \c i -th channel. * * @param [in] id index of the channel. * @return new value */ T const& val(size_t id) const { return valV()(id); } /*! * @brief Set the value of \c i -th channel. * * @param [in] i index of the channel * @param [in] c new value */ T const& val(size_t i, T const& c) { if (i == 0) val_.x(c); else if (i == 1) val_.y(c); else if (i == 2) val_.z(c); return val(i); } /*! * @brief Get the non-constant reference of value of the \c i -th channel. * * @param [in] id index of the channel */ T& valGet(size_t id) { if (id == 0) return valVGet().xGet(); else if (id == 1) return valVGet().yGet(); else return valVGet().zGet(); } }; } // meow #endif // colors_Color3_Space_H__