Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71794 - in trunk/boost/geometry: . algorithms/detail/overlay extensions/gis/io/shapelib extensions/io/svg iterators ranges views views/detail
From: barend.gehrels_at_[hidden]
Date: 2011-05-07 18:11:21


Author: barendgehrels
Date: 2011-05-07 18:11:19 EDT (Sat, 07 May 2011)
New Revision: 71794
URL: http://svn.boost.org/trac/boost/changeset/71794

Log:
Moved box_range/segment_range to views, renamed to box_view/segment_view, removed corresponding iterators (now nested class), created detail::points_view of which other two are derived
Added:
   trunk/boost/geometry/views/box_view.hpp
      - copied, changed from r71709, /trunk/boost/geometry/ranges/box_range.hpp
   trunk/boost/geometry/views/detail/
   trunk/boost/geometry/views/detail/points_view.hpp (contents, props changed)
   trunk/boost/geometry/views/segment_view.hpp
      - copied, changed from r71709, /trunk/boost/geometry/ranges/segment_range.hpp
Removed:
   trunk/boost/geometry/iterators/box_iterator.hpp
   trunk/boost/geometry/iterators/segment_range_iterator.hpp
   trunk/boost/geometry/ranges/box_range.hpp
   trunk/boost/geometry/ranges/segment_range.hpp
Text files modified:
   trunk/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp | 5 +-
   trunk/boost/geometry/extensions/gis/io/shapelib/shp_create_object.hpp | 8 ++--
   trunk/boost/geometry/extensions/io/svg/svg_mapper.hpp | 8 ++--
   trunk/boost/geometry/geometry.hpp | 7 ++-
   trunk/boost/geometry/views/box_view.hpp | 66 +++++++++++++++++++++++----------------
   trunk/boost/geometry/views/closeable_view.hpp | 2
   trunk/boost/geometry/views/identity_view.hpp | 2
   trunk/boost/geometry/views/reversible_view.hpp | 4 +-
   trunk/boost/geometry/views/segment_view.hpp | 61 +++++++++++++++++++++---------------
   9 files changed, 93 insertions(+), 70 deletions(-)

Modified: trunk/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp (original)
+++ trunk/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp 2011-05-07 18:11:19 EDT (Sat, 07 May 2011)
@@ -26,7 +26,7 @@
 #include <boost/geometry/algorithms/detail/overlay/get_intersection_points.hpp>
 #include <boost/geometry/algorithms/detail/overlay/overlay.hpp>
 #include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>
-#include <boost/geometry/ranges/segment_range.hpp>
+#include <boost/geometry/views/segment_view.hpp>
 
 
 namespace boost { namespace geometry
@@ -286,8 +286,7 @@
     static inline OutputIterator apply(Segment const& segment,
             Box const& box, OutputIterator out, Strategy const& strategy)
     {
- typedef geometry::segment_range<Segment> range_type;
- range_type range(segment);
+ geometry::segment_view<Segment> range(segment);
 
         typedef typename point_type<GeometryOut>::type point_type;
         strategy::intersection::liang_barsky<Box, point_type> lb_strategy;

Modified: trunk/boost/geometry/extensions/gis/io/shapelib/shp_create_object.hpp
==============================================================================
--- trunk/boost/geometry/extensions/gis/io/shapelib/shp_create_object.hpp (original)
+++ trunk/boost/geometry/extensions/gis/io/shapelib/shp_create_object.hpp 2011-05-07 18:11:19 EDT (Sat, 07 May 2011)
@@ -20,8 +20,8 @@
 #include <boost/geometry/core/ring_type.hpp>
 #include <boost/geometry/algorithms/num_interior_rings.hpp>
 #include <boost/geometry/algorithms/num_points.hpp>
-#include <boost/geometry/ranges/box_range.hpp>
-#include <boost/geometry/ranges/segment_range.hpp>
+#include <boost/geometry/views/box_view.hpp>
+#include <boost/geometry/views/segment_view.hpp>
 
 
 // Should be somewhere in your include path
@@ -189,7 +189,7 @@
     : detail::shp_create_object::shape_create_adapted_range
         <
             Box,
- box_range<Box>,
+ box_view<Box>,
             SHPT_POLYGON
>
 {};
@@ -199,7 +199,7 @@
     : detail::shp_create_object::shape_create_adapted_range
         <
             Segment,
- segment_range<Segment>,
+ segment_view<Segment>,
             SHPT_ARC
>
 {};

Modified: trunk/boost/geometry/extensions/io/svg/svg_mapper.hpp
==============================================================================
--- trunk/boost/geometry/extensions/io/svg/svg_mapper.hpp (original)
+++ trunk/boost/geometry/extensions/io/svg/svg_mapper.hpp 2011-05-07 18:11:19 EDT (Sat, 07 May 2011)
@@ -35,7 +35,7 @@
 #include <boost/geometry/algorithms/num_points.hpp>
 #include <boost/geometry/strategies/transform.hpp>
 #include <boost/geometry/strategies/transform/map_transformer.hpp>
-#include <boost/geometry/ranges/segment_range.hpp>
+#include <boost/geometry/views/segment_view.hpp>
 
 #include <boost/geometry/geometries/box.hpp>
 #include <boost/geometry/geometries/linestring.hpp>
@@ -122,11 +122,11 @@
                     std::string const& style, int size,
                     Segment const& segment, TransformStrategy const& strategy)
     {
- typedef segment_range<Segment> range_type;
- range_type range(segment);
+ typedef segment_view<Segment> view_type;
+ view_type range(segment);
         svg_map_range
             <
- range_type,
+ view_type,
                 model::linestring<model::d2::point_xy<int> >
>::apply(stream, style, size, range, strategy);
     }

Modified: trunk/boost/geometry/geometry.hpp
==============================================================================
--- trunk/boost/geometry/geometry.hpp (original)
+++ trunk/boost/geometry/geometry.hpp 2011-05-07 18:11:19 EDT (Sat, 07 May 2011)
@@ -55,6 +55,7 @@
 #include <boost/geometry/algorithms/num_geometries.hpp>
 #include <boost/geometry/algorithms/num_interior_rings.hpp>
 #include <boost/geometry/algorithms/num_points.hpp>
+#include <boost/geometry/algorithms/overlaps.hpp>
 #include <boost/geometry/algorithms/perimeter.hpp>
 #include <boost/geometry/algorithms/reverse.hpp>
 #include <boost/geometry/algorithms/simplify.hpp>
@@ -76,9 +77,6 @@
 // if you don't (e.g. area=0 of a multipolygon)
 #include <boost/geometry/multi/multi.hpp>
 
-#include <boost/geometry/ranges/box_range.hpp>
-#include <boost/geometry/ranges/segment_range.hpp>
-
 // check includes all concepts
 #include <boost/geometry/geometries/concepts/check.hpp>
 
@@ -88,6 +86,9 @@
 #include <boost/geometry/util/select_coordinate_type.hpp>
 #include <boost/geometry/util/write_dsv.hpp>
 
+#include <boost/geometry/views/box_view.hpp>
+#include <boost/geometry/views/segment_view.hpp>
+
 #include <boost/geometry/domains/gis/io/wkt/wkt.hpp>
 
 

Deleted: trunk/boost/geometry/iterators/box_iterator.hpp
==============================================================================
--- trunk/boost/geometry/iterators/box_iterator.hpp 2011-05-07 18:11:19 EDT (Sat, 07 May 2011)
+++ (empty file)
@@ -1,126 +0,0 @@
-// Boost.Geometry (aka GGL, Generic Geometry Library)
-
-// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
-// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
-// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
-
-// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
-// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
-
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_GEOMETRY_BOX_ITERATOR_HPP
-#define BOOST_GEOMETRY_BOX_ITERATOR_HPP
-
-#include <boost/iterator.hpp>
-#include <boost/iterator/iterator_facade.hpp>
-#include <boost/iterator/iterator_categories.hpp>
-
-#include <boost/geometry/core/point_type.hpp>
-#include <boost/geometry/algorithms/assign.hpp>
-
-
-namespace boost { namespace geometry
-{
-
-/*!
- \brief Iterator which adapts a box (four points + closing) as iterator
- \tparam Box box type on which this iterator is based on
- \note It is always const. We cannot dereference something non-const
- (at least not without doing tricks as returning assignables)
- \ingroup iterators
-*/
-template <typename Box>
-struct box_iterator
- : public boost::iterator_facade
- <
- box_iterator<Box>,
- typename point_type<Box>::type const,
- boost::random_access_traversal_tag
- >
-{
- // Default constructor is required to check concept of Range
- inline box_iterator()
- : m_index(-1)
- , m_box_address(NULL)
- {
- }
-
- explicit inline box_iterator(Box const& box)
- : m_index(0)
- , m_box_address(&box)
- {
- init(box);
- }
-
- // Constructor to indicate the end of a box
- explicit inline box_iterator(Box const& box, bool)
- : m_index(5)
- , m_box_address(&box)
- {
- init(box);
- }
-
- // Operator= is required to check concept of Range
- inline box_iterator<Box>& operator=(box_iterator<Box> const& source)
- {
- m_index = source.m_index;
- m_box_address = source.m_box_address;
- return *this;
- }
-
- typedef std::ptrdiff_t difference_type;
-
-private:
- friend class boost::iterator_core_access;
- typedef typename point_type<Box>::type point_type;
-
- inline point_type const& dereference() const
- {
- if (m_index >= 0 && m_index <= 3)
- {
- return m_points[m_index];
- }
- // If it index is 4, or other, return first point
- return m_points[0];
- }
-
- inline bool equal(box_iterator<Box> const& other) const
- {
- return m_box_address == this->m_box_address
- && other.m_index == this->m_index;
- }
-
- inline void increment()
- {
- m_index++;
- }
-
- inline void decrement()
- {
- m_index--;
- }
-
- inline difference_type distance_to(box_iterator<Box> const& other) const
- {
- return other.m_index - this->m_index;
- }
-
- inline void init(Box const& box)
- {
- detail::assign_box_corners_oriented<false>(box, m_points);
- }
-
- // Copy points here - box might define them otherwise
- point_type m_points[4];
- int m_index;
- Box const* m_box_address;
-};
-
-
-}} // namespace boost::geometry
-
-
-#endif // BOOST_GEOMETRY_BOX_ITERATOR_HPP

Deleted: trunk/boost/geometry/iterators/segment_range_iterator.hpp
==============================================================================
--- trunk/boost/geometry/iterators/segment_range_iterator.hpp 2011-05-07 18:11:19 EDT (Sat, 07 May 2011)
+++ (empty file)
@@ -1,133 +0,0 @@
-// Boost.Geometry (aka GGL, Generic Geometry Library)
-
-// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
-// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
-// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
-
-// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
-// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
-
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_GEOMETRY_SEGMENT_RANGE_ITERATOR_HPP
-#define BOOST_GEOMETRY_SEGMENT_RANGE_ITERATOR_HPP
-
-#include <boost/assert.hpp>
-
-#include <boost/iterator.hpp>
-#include <boost/iterator/iterator_facade.hpp>
-#include <boost/iterator/iterator_categories.hpp>
-
-#include <boost/geometry/core/point_type.hpp>
-#include <boost/geometry/algorithms/assign.hpp>
-
-
-namespace boost { namespace geometry
-{
-
-/*!
- \brief Iterator which adapts a segment (two points) as iterator
- \tparam Segment segment type on which this iterator is based on
- \note It is always const. We cannot dereference something non-const
- (at least not without doing tricks as returning assignables)
- \ingroup iterators
-*/
-template <typename Segment>
-struct segment_range_iterator
- : public boost::iterator_facade
- <
- segment_range_iterator<Segment>,
- typename point_type<Segment>::type const,
- boost::random_access_traversal_tag
- >
-{
- // Default constructor is required to check concept of Range
- // (used in checking linestring/ring concepts)
- inline segment_range_iterator()
- : m_index(-1)
- , m_segment_address(NULL)
- {
- }
-
- explicit inline segment_range_iterator(Segment const& segment)
- : m_index(0)
- , m_segment_address(&segment)
- {
- init(segment);
- }
-
- // Constructor to indicate the end of a segment
- explicit inline segment_range_iterator(Segment const& segment, bool)
- : m_index(2)
- , m_segment_address(&segment)
- {
- init(segment);
- }
-
- // Operator= is required to check concept of Range
- inline segment_range_iterator<Segment>& operator=(segment_range_iterator<Segment> const& source)
- {
- m_index = source.m_index;
- m_segment_address = source.m_segment_address;
- return *this;
- }
-
- typedef std::ptrdiff_t difference_type;
-
-private:
- friend class boost::iterator_core_access;
- typedef typename point_type<Segment>::type point_type;
-
- inline point_type const& dereference() const
- {
- if (m_index >= 0 && m_index <= 1)
- {
- return m_points[m_index];
- }
-
- BOOST_ASSERT(!"Should not occur"); // Probably throw here.
- return m_points[0];
- }
-
- inline bool equal(segment_range_iterator<Segment> const& other) const
- {
- return m_segment_address == this->m_segment_address
- && other.m_index == this->m_index;
- }
-
- inline void increment()
- {
- m_index++;
- }
-
- inline void decrement()
- {
- m_index--;
- }
-
- inline difference_type distance_to(segment_range_iterator<Segment> const& other) const
- {
- return other.m_index - this->m_index;
- }
-
- inline void init(Segment const& segment)
- {
- geometry::detail::assign_point_from_index<0>(segment, m_points[0]);
- geometry::detail::assign_point_from_index<1>(segment, m_points[1]);
- }
-
- // We HAVE TO copy the points, because a segment does not need
- // to consist of two points,
- // and we are expected to return a point here
- point_type m_points[2];
- int m_index;
- Segment const* m_segment_address;
-};
-
-
-}} // namespace boost::geometry
-
-
-#endif // BOOST_GEOMETRY_SEGMENT_RANGE_ITERATOR_HPP

Deleted: trunk/boost/geometry/ranges/box_range.hpp
==============================================================================
--- trunk/boost/geometry/ranges/box_range.hpp 2011-05-07 18:11:19 EDT (Sat, 07 May 2011)
+++ (empty file)
@@ -1,75 +0,0 @@
-// Boost.Geometry (aka GGL, Generic Geometry Library)
-
-// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
-// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
-// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
-
-// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
-// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
-
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_GEOMETRY_RANGES_BOX_RANGE_HPP
-#define BOOST_GEOMETRY_RANGES_BOX_RANGE_HPP
-
-
-#include <boost/range.hpp>
-
-#include <boost/geometry/iterators/box_iterator.hpp>
-
-
-namespace boost { namespace geometry
-{
-
-
-/*!
-\brief Range, walking over the four points of a box
-\tparam Box box type
-\ingroup ranges
-*/
-template <typename Box>
-class box_range
-{
-public :
- typedef box_iterator<Box const> const_iterator;
- typedef box_iterator<Box const> iterator; // must be defined
-
- explicit box_range(Box const& box)
- : m_begin(const_iterator(box))
- , m_end(const_iterator(box, true))
- {
- }
-
- const_iterator begin() const { return m_begin; }
- const_iterator end() const { return m_end; }
-
- // It may not be used non-const, so comment this:
- //iterator begin() { return m_begin; }
- //iterator end() { return m_end; }
-
-private :
- const_iterator m_begin, m_end;
-};
-
-
-#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
-
-// All box ranges can be handled as rings
-namespace traits
-{
- template<typename Box>
- struct tag<box_range<Box> >
- {
- typedef ring_tag type;
- };
-}
-
-#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
-
-
-}} // namespace boost::geometry
-
-
-#endif // BOOST_GEOMETRY_RANGES_BOX_RANGE_HPP

Deleted: trunk/boost/geometry/ranges/segment_range.hpp
==============================================================================
--- trunk/boost/geometry/ranges/segment_range.hpp 2011-05-07 18:11:19 EDT (Sat, 07 May 2011)
+++ (empty file)
@@ -1,76 +0,0 @@
-// Boost.Geometry (aka GGL, Generic Geometry Library)
-
-// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
-// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
-// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
-
-// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
-// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
-
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_GEOMETRY_RANGES_SEGMENT_RANGE_HPP
-#define BOOST_GEOMETRY_RANGES_SEGMENT_RANGE_HPP
-
-
-#include <boost/range.hpp>
-
-#include <boost/geometry/iterators/segment_range_iterator.hpp>
-
-
-namespace boost { namespace geometry
-{
-
-
-/*!
-\brief Range, walking over the two points of a segment
-\tparam Segment segment type
-\ingroup ranges
-*/
-template <typename Segment>
-class segment_range
-{
-public :
- typedef segment_range_iterator<Segment const> const_iterator;
- typedef segment_range_iterator<Segment const> iterator; // must be defined
-
- explicit segment_range(Segment const& segment)
- : m_begin(const_iterator(segment))
- , m_end(const_iterator(segment, true))
- {
- }
-
- const_iterator begin() const { return m_begin; }
- const_iterator end() const { return m_end; }
-
- // It may not be used non-const, so comment this:
- //iterator begin() { return m_begin; }
- //iterator end() { return m_end; }
-
-private :
- const_iterator m_begin, m_end;
-};
-
-
-#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
-
-// All segment ranges can be handled as linestrings
-namespace traits
-{
- template<typename Segment>
- struct tag<segment_range<Segment> >
- {
- typedef linestring_tag type;
- };
-}
-
-#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
-
-
-
-}} // namespace boost::geometry
-
-
-#endif // BOOST_GEOMETRY_RANGES_SEGMENT_RANGE_HPP

Copied: trunk/boost/geometry/views/box_view.hpp (from r71709, /trunk/boost/geometry/ranges/box_range.hpp)
==============================================================================
--- /trunk/boost/geometry/ranges/box_range.hpp (original)
+++ trunk/boost/geometry/views/box_view.hpp 2011-05-07 18:11:19 EDT (Sat, 07 May 2011)
@@ -11,13 +11,15 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#ifndef BOOST_GEOMETRY_RANGES_BOX_RANGE_HPP
-#define BOOST_GEOMETRY_RANGES_BOX_RANGE_HPP
+#ifndef BOOST_GEOMETRY_VIEWS_BOX_VIEW_HPP
+#define BOOST_GEOMETRY_VIEWS_BOX_VIEW_HPP
 
 
 #include <boost/range.hpp>
 
-#include <boost/geometry/iterators/box_iterator.hpp>
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/views/detail/points_view.hpp>
+#include <boost/geometry/algorithms/assign.hpp>
 
 
 namespace boost { namespace geometry
@@ -27,40 +29,50 @@
 /*!
 \brief Range, walking over the four points of a box
 \tparam Box box type
-\ingroup ranges
+\ingroup views
 */
-template <typename Box>
-class box_range
+template <typename Box, bool Clockwise = true>
+struct box_view
+ : public detail::points_view
+ <
+ typename geometry::point_type<Box>::type,
+ 5
+ >
 {
-public :
- typedef box_iterator<Box const> const_iterator;
- typedef box_iterator<Box const> iterator; // must be defined
-
- explicit box_range(Box const& box)
- : m_begin(const_iterator(box))
- , m_end(const_iterator(box, true))
+ typedef typename geometry::point_type<Box>::type point_type;
+
+ explicit box_view(Box const& box)
+ : detail::points_view<point_type, 5>(copy_policy(box))
+ {}
+
+private :
+
+ class copy_policy
     {
- }
-
- const_iterator begin() const { return m_begin; }
- const_iterator end() const { return m_end; }
-
- // It may not be used non-const, so comment this:
- //iterator begin() { return m_begin; }
- //iterator end() { return m_end; }
+ public :
+ inline copy_policy(Box const& box)
+ : m_box(box)
+ {}
+
+ inline void apply(point_type* points) const
+ {
+ detail::assign_box_corners_oriented<!Clockwise>(m_box, points);
+ points[4] = points[0];
+ }
+ private :
+ Box m_box;
+ };
 
-private :
- const_iterator m_begin, m_end;
 };
 
 
 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
 
-// All box ranges can be handled as rings
+// All views on boxes are handled as rings
 namespace traits
 {
- template<typename Box>
- struct tag<box_range<Box> >
+ template<typename Box, bool Clockwise>
+ struct tag<box_view<Box, Clockwise> >
     {
         typedef ring_tag type;
     };
@@ -72,4 +84,4 @@
 }} // namespace boost::geometry
 
 
-#endif // BOOST_GEOMETRY_RANGES_BOX_RANGE_HPP
+#endif // BOOST_GEOMETRY_VIEWS_BOX_VIEW_HPP

Modified: trunk/boost/geometry/views/closeable_view.hpp
==============================================================================
--- trunk/boost/geometry/views/closeable_view.hpp (original)
+++ trunk/boost/geometry/views/closeable_view.hpp 2011-05-07 18:11:19 EDT (Sat, 07 May 2011)
@@ -63,7 +63,7 @@
 \brief View on a range, either closing or not closing
 \tparam Range original range
 \tparam Close specifying if it should be closed or not
-\ingroup ranges
+\ingroup views
 */
 template <typename Range, closure_selector Close>
 struct closeable_view {};

Added: trunk/boost/geometry/views/detail/points_view.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/geometry/views/detail/points_view.hpp 2011-05-07 18:11:19 EDT (Sat, 07 May 2011)
@@ -0,0 +1,141 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_VIEWS_DETAIL_POINTS_VIEW_HPP
+#define BOOST_GEOMETRY_VIEWS_DETAIL_POINTS_VIEW_HPP
+
+
+#include <boost/range.hpp>
+#include <boost/iterator.hpp>
+#include <boost/iterator/iterator_facade.hpp>
+#include <boost/iterator/iterator_categories.hpp>
+
+#include <boost/geometry/core/exception.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace detail
+{
+
+// Adapts pointer, on points, to a Boost.Range
+template <typename Point, int MaxSize>
+class points_view
+{
+ // Iterates over a series of points (indicated by pointer
+ // to have it lightweight). Probably there is already an
+ // equivalent of this within Boost. If so, TODO: use that one.
+ // This used to be "box_iterator" and "segment_iterator".
+ struct points_iterator
+ : public boost::iterator_facade
+ <
+ points_iterator,
+ Point const,
+ boost::random_access_traversal_tag
+ >
+ {
+ // Constructor: Begin iterator
+ inline points_iterator(Point const* p)
+ : m_points(p)
+ , m_index(0)
+ {}
+
+ // Constructor: End iterator
+ inline points_iterator(Point const* p, bool)
+ : m_points(p)
+ , m_index(MaxSize)
+ {}
+
+ // Constructor: default (for Range Concept checking).
+ inline points_iterator()
+ : m_points(NULL)
+ , m_index(MaxSize)
+ {}
+
+ typedef std::ptrdiff_t difference_type;
+
+ private:
+ friend class boost::iterator_core_access;
+
+ inline Point const& dereference() const
+ {
+ if (m_index >= 0 && m_index < MaxSize)
+ {
+ return m_points[m_index];
+ }
+
+ // If it index larger (or smaller) return first point
+ // (assuming initialized)
+ return m_points[0];
+ }
+
+ inline bool equal(points_iterator const& other) const
+ {
+ return other.m_index == this->m_index;
+ }
+
+ inline void increment()
+ {
+ m_index++;
+ }
+
+ inline void decrement()
+ {
+ m_index--;
+ }
+
+ inline difference_type distance_to(points_iterator const& other) const
+ {
+ return other.m_index - this->m_index;
+ }
+
+ inline void advance(difference_type n)
+ {
+ m_index += n;
+ }
+
+ Point const* m_points;
+ int m_index;
+ };
+
+public :
+
+ typedef points_iterator const_iterator;
+ typedef points_iterator iterator; // must be defined
+
+ const_iterator begin() const { return const_iterator(m_points); }
+ const_iterator end() const { return const_iterator(m_points, true); }
+
+ // It may NOT be used non-const, so commented:
+ //iterator begin() { return m_begin; }
+ //iterator end() { return m_end; }
+
+protected :
+
+ template <typename CopyPolicy>
+ explicit points_view(CopyPolicy const& copy)
+ {
+ copy.apply(m_points);
+ }
+
+private :
+ // Copy points here - box might define them otherwise
+ Point m_points[MaxSize];
+};
+
+}
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_VIEWS_DETAIL_POINTS_VIEW_HPP

Modified: trunk/boost/geometry/views/identity_view.hpp
==============================================================================
--- trunk/boost/geometry/views/identity_view.hpp (original)
+++ trunk/boost/geometry/views/identity_view.hpp 2011-05-07 18:11:19 EDT (Sat, 07 May 2011)
@@ -25,7 +25,7 @@
 /*!
 \brief View on a range, not modifying anything
 \tparam Range original range
-\ingroup ranges
+\ingroup views
 */
 template <typename Range>
 struct identity_view

Modified: trunk/boost/geometry/views/reversible_view.hpp
==============================================================================
--- trunk/boost/geometry/views/reversible_view.hpp (original)
+++ trunk/boost/geometry/views/reversible_view.hpp 2011-05-07 18:11:19 EDT (Sat, 07 May 2011)
@@ -30,7 +30,7 @@
 
 /*!
 \brief Flag for iterating a reversible_view in forward or reverse direction
-\ingroup ranges
+\ingroup views
 */
 enum iterate_direction { iterate_forward, iterate_reverse };
 
@@ -38,7 +38,7 @@
 \brief View on a range, reversing direction if necessary
 \tparam Range original range
 \tparam Direction direction of iteration
-\ingroup ranges
+\ingroup views
 */
 template <typename Range, iterate_direction Direction>
 struct reversible_view {};

Copied: trunk/boost/geometry/views/segment_view.hpp (from r71709, /trunk/boost/geometry/ranges/segment_range.hpp)
==============================================================================
--- /trunk/boost/geometry/ranges/segment_range.hpp (original)
+++ trunk/boost/geometry/views/segment_view.hpp 2011-05-07 18:11:19 EDT (Sat, 07 May 2011)
@@ -11,13 +11,15 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#ifndef BOOST_GEOMETRY_RANGES_SEGMENT_RANGE_HPP
-#define BOOST_GEOMETRY_RANGES_SEGMENT_RANGE_HPP
+#ifndef BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP
+#define BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP
 
 
 #include <boost/range.hpp>
 
-#include <boost/geometry/iterators/segment_range_iterator.hpp>
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/views/detail/points_view.hpp>
+#include <boost/geometry/algorithms/assign.hpp>
 
 
 namespace boost { namespace geometry
@@ -27,30 +29,40 @@
 /*!
 \brief Range, walking over the two points of a segment
 \tparam Segment segment type
-\ingroup ranges
+\ingroup views
 */
 template <typename Segment>
-class segment_range
+struct segment_view
+ : public detail::points_view
+ <
+ typename geometry::point_type<Segment>::type,
+ 2
+ >
 {
-public :
- typedef segment_range_iterator<Segment const> const_iterator;
- typedef segment_range_iterator<Segment const> iterator; // must be defined
-
- explicit segment_range(Segment const& segment)
- : m_begin(const_iterator(segment))
- , m_end(const_iterator(segment, true))
+ typedef typename geometry::point_type<Segment>::type point_type;
+
+ explicit segment_view(Segment const& segment)
+ : detail::points_view<point_type, 2>(copy_policy(segment))
+ {}
+
+private :
+
+ class copy_policy
     {
- }
-
- const_iterator begin() const { return m_begin; }
- const_iterator end() const { return m_end; }
-
- // It may not be used non-const, so comment this:
- //iterator begin() { return m_begin; }
- //iterator end() { return m_end; }
+ public :
+ inline copy_policy(Segment const& segment)
+ : m_segment(segment)
+ {}
+
+ inline void apply(point_type* points) const
+ {
+ geometry::detail::assign_point_from_index<0>(m_segment, points[0]);
+ geometry::detail::assign_point_from_index<1>(m_segment, points[1]);
+ }
+ private :
+ Segment m_segment;
+ };
 
-private :
- const_iterator m_begin, m_end;
 };
 
 
@@ -60,7 +72,7 @@
 namespace traits
 {
     template<typename Segment>
- struct tag<segment_range<Segment> >
+ struct tag<segment_view<Segment> >
     {
         typedef linestring_tag type;
     };
@@ -69,8 +81,7 @@
 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
 
 
-
 }} // namespace boost::geometry
 
 
-#endif // BOOST_GEOMETRY_RANGES_SEGMENT_RANGE_HPP
+#endif // BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP


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