Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65213 - sandbox/geometry/boost/geometry/geometries
From: barend.gehrels_at_[hidden]
Date: 2010-09-03 06:24:42


Author: barendgehrels
Date: 2010-09-03 06:24:41 EDT (Fri, 03 Sep 2010)
New Revision: 65213
URL: http://svn.boost.org/trac/boost/changeset/65213

Log:
Added model::segment (preparing model namespace)
Text files modified:
   sandbox/geometry/boost/geometry/geometries/point.hpp | 3
   sandbox/geometry/boost/geometry/geometries/segment.hpp | 89 ++++++++++++++++++++++++++++++++++++++++
   2 files changed, 90 insertions(+), 2 deletions(-)

Modified: sandbox/geometry/boost/geometry/geometries/point.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/geometries/point.hpp (original)
+++ sandbox/geometry/boost/geometry/geometries/point.hpp 2010-09-03 06:24:41 EDT (Fri, 03 Sep 2010)
@@ -26,8 +26,7 @@
 /*!
 \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
 

Modified: sandbox/geometry/boost/geometry/geometries/segment.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/geometries/segment.hpp (original)
+++ sandbox/geometry/boost/geometry/geometries/segment.hpp 2010-09-03 06:24:41 EDT (Fri, 03 Sep 2010)
@@ -58,6 +58,45 @@
     {}
 };
 
+
+// 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<P&>
+*/
+template<typename Point>
+struct segment : public std::pair<Point, Point>
+{
+ 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 @@
     }
 };
 
+
+template <typename Point>
+struct tag<model::segment<Point> >
+{
+ typedef segment_tag type;
+};
+
+template <typename Point>
+struct point_type<model::segment<Point> >
+{
+ typedef Point type;
+};
+
+template <typename Point, std::size_t Dimension>
+struct indexed_access<model::segment<Point>, 0, Dimension>
+{
+ typedef model::segment<Point> segment_type;
+ typedef typename geometry::coordinate_type<segment_type>::type coordinate_type;
+
+ static inline coordinate_type get(segment_type const& s)
+ {
+ return geometry::get<Dimension>(s.first);
+ }
+
+ static inline void set(segment_type& s, coordinate_type const& value)
+ {
+ geometry::set<Dimension>(s.first, value);
+ }
+};
+
+
+template <typename Point, std::size_t Dimension>
+struct indexed_access<model::segment<Point>, 1, Dimension>
+{
+ typedef model::segment<Point> segment_type;
+ typedef typename geometry::coordinate_type<segment_type>::type coordinate_type;
+
+ static inline coordinate_type get(segment_type const& s)
+ {
+ return geometry::get<Dimension>(s.second);
+ }
+
+ static inline void set(segment_type& s, coordinate_type const& value)
+ {
+ geometry::set<Dimension>(s.second, value);
+ }
+};
+
+
+
 } // namespace traits
 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk