From 63199bfe5d7ec26405d5091c18179e33477a3277 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Fri, 3 Sep 2010 10:24:41 +0000 Subject: [PATCH] Added model::segment (preparing model namespace) [SVN r65213] --- include/boost/geometry/geometries/point.hpp | 3 +- include/boost/geometry/geometries/segment.hpp | 89 +++++++++++++++++++ 2 files changed, 90 insertions(+), 2 deletions(-) diff --git a/include/boost/geometry/geometries/point.hpp b/include/boost/geometry/geometries/point.hpp index 89a1114f1..61e22c27a 100644 --- a/include/boost/geometry/geometries/point.hpp +++ b/include/boost/geometry/geometries/point.hpp @@ -26,8 +26,7 @@ namespace boost { namespace geometry /*! \brief Basic point class, having coordinates defined in a neutral way \ingroup geometries - -\tparam CoordinateType \template_numerical +\tparam CoordinateType \tparam_numeric \tparam DimensionCount number of coordinates, usually 2 or 3 \tparam CoordinateSystem coordinate system, for example cs::cartesian diff --git a/include/boost/geometry/geometries/segment.hpp b/include/boost/geometry/geometries/segment.hpp index 8ea09315a..97465e3d4 100644 --- a/include/boost/geometry/geometries/segment.hpp +++ b/include/boost/geometry/geometries/segment.hpp @@ -58,6 +58,45 @@ public: {} }; + +// Namespace model +// Anticipates for all geometries, which will be moved to namespace "model": + +/* +Bruno: +However maybe an even better name +would be "model", since those geometries model the concepts GGL +defines. It would state more clearly that those shapes are not mere +shapes but are also examples of models for our concepts. + +Barend: +I agree that model is a better name. Very good. +So that is the new proposal :-) +*/ + +namespace model +{ + +/*! +\brief segment: segment owning two points +\note Might be merged with "segment", while "segment" be used as segment +*/ +template +struct segment : public std::pair +{ + inline segment() + {} + + inline segment(Point const& p1, Point const& p2) + { + this->first = p1; + this->second = p2; + } +}; + +} // namespace model + + // Traits specializations for segment above #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS namespace traits @@ -110,6 +149,56 @@ struct indexed_access, 1, Dimension> } }; + +template +struct tag > +{ + typedef segment_tag type; +}; + +template +struct point_type > +{ + typedef Point type; +}; + +template +struct indexed_access, 0, Dimension> +{ + typedef model::segment segment_type; + typedef typename geometry::coordinate_type::type coordinate_type; + + static inline coordinate_type get(segment_type const& s) + { + return geometry::get(s.first); + } + + static inline void set(segment_type& s, coordinate_type const& value) + { + geometry::set(s.first, value); + } +}; + + +template +struct indexed_access, 1, Dimension> +{ + typedef model::segment segment_type; + typedef typename geometry::coordinate_type::type coordinate_type; + + static inline coordinate_type get(segment_type const& s) + { + return geometry::get(s.second); + } + + static inline void set(segment_type& s, coordinate_type const& value) + { + geometry::set(s.second, value); + } +}; + + + } // namespace traits #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS