Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67186 - in sandbox/geometry/boost/geometry: algorithms algorithms/detail/overlay algorithms/detail/sections extensions/gis/io/wkt multi/algorithms multi/algorithms/detail/sections util
From: barend.gehrels_at_[hidden]
Date: 2010-12-12 10:47:02


Author: barendgehrels
Date: 2010-12-12 10:46:52 EST (Sun, 12 Dec 2010)
New Revision: 67186
URL: http://svn.boost.org/trac/boost/changeset/67186

Log:
Made closeable_view and reversible_view metafunctions, defining itself or a Boost.Range reversed_range or a closing_view
Text files modified:
   sandbox/geometry/boost/geometry/algorithms/area.hpp | 9 ++---
   sandbox/geometry/boost/geometry/algorithms/centroid.hpp | 6 ---
   sandbox/geometry/boost/geometry/algorithms/detail/overlay/copy_segments.hpp | 50 ++++++++++++++++++------------------
   sandbox/geometry/boost/geometry/algorithms/detail/overlay/get_turns.hpp | 12 ++++----
   sandbox/geometry/boost/geometry/algorithms/detail/sections/get_full_section.hpp | 12 ++++----
   sandbox/geometry/boost/geometry/algorithms/detail/sections/sectionalize.hpp | 6 ---
   sandbox/geometry/boost/geometry/algorithms/distance.hpp | 6 ---
   sandbox/geometry/boost/geometry/algorithms/length.hpp | 7 ++--
   sandbox/geometry/boost/geometry/algorithms/perimeter.hpp | 10 +++++--
   sandbox/geometry/boost/geometry/algorithms/within.hpp | 9 ++---
   sandbox/geometry/boost/geometry/extensions/gis/io/wkt/write_wkt.hpp | 9 +++++
   sandbox/geometry/boost/geometry/multi/algorithms/detail/sections/get_full_section.hpp | 7 ++--
   sandbox/geometry/boost/geometry/multi/algorithms/length.hpp | 2
   sandbox/geometry/boost/geometry/util/closeable_view.hpp | 54 +++++++++++++++++++--------------------
   sandbox/geometry/boost/geometry/util/reversible_view.hpp | 37 +++-----------------------
   15 files changed, 102 insertions(+), 134 deletions(-)

Modified: sandbox/geometry/boost/geometry/algorithms/area.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/area.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/area.hpp 2010-12-12 10:46:52 EST (Sun, 12 Dec 2010)
@@ -92,12 +92,11 @@
             return type();
         }
 
- typedef reversible_view<Ring const, Direction> rview_type;
- typedef closeable_view
+ typedef typename reversible_view<Ring const, Direction>::type rview_type;
+ typedef typename closeable_view
             <
- rview_type const,
- Closure == open // close it if it is open
- > view_type;
+ rview_type const, Closure
+ >::type view_type;
         typedef typename boost::range_iterator<view_type const>::type iterator_type;
 
         rview_type rview(ring);

Modified: sandbox/geometry/boost/geometry/algorithms/centroid.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/centroid.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/centroid.hpp 2010-12-12 10:46:52 EST (Sun, 12 Dec 2010)
@@ -157,11 +157,7 @@
     static inline void apply(Ring const& ring,
             Strategy const& strategy, typename Strategy::state_type& state)
     {
- typedef closeable_view
- <
- Ring const,
- Closure == open // close it if it is open
- > view_type;
+ typedef typename closeable_view<Ring const, Closure>::type view_type;
 
         typedef typename boost::range_iterator<view_type const>::type iterator_type;
 

Modified: sandbox/geometry/boost/geometry/algorithms/detail/overlay/copy_segments.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/overlay/copy_segments.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/overlay/copy_segments.hpp 2010-12-12 10:46:52 EST (Sun, 12 Dec 2010)
@@ -42,11 +42,11 @@
 template <typename Ring, typename SegmentIdentifier, typename RangeOut>
 struct copy_segments_ring
 {
- typedef closeable_view
+ typedef typename closeable_view
         <
             Ring const,
- closure<Ring>::value == open
- > view_type;
+ closure<Ring>::value
+ >::type view_type;
 
     static inline void apply(Ring const& ring,
             SegmentIdentifier const& seg_id, int to_index,
@@ -57,7 +57,7 @@
 
         typedef geometry::ever_circling_iterator<iterator> ec_iterator;
 
- // The problem: sometimes we want to from "3" to "2"
+ // The problem: sometimes we want to from "3" to "2"
         // -> end = "3" -> end == begin
         // This is not convenient with iterators.
 
@@ -117,11 +117,11 @@
 };
 
 
-template
+template
 <
- typename Box,
- typename SegmentIdentifier,
- typename RangeOut,
+ typename Box,
+ typename SegmentIdentifier,
+ typename RangeOut,
     order_selector Order
>
 struct copy_segments_box
@@ -151,7 +151,7 @@
         point_index[3] = reverse ? 1 : 3;
         point_index[4] = 0;
 
- // 3: (possibly cyclic) copy to output
+ // 3: (possibly cyclic) copy to output
         // (see comments in ring-version)
         for (int i = 0; i < count; ++i)
         {
@@ -180,7 +180,7 @@
     typename GeometryIn,
     typename SegmentIdentifier,
     typename RangeOut,
- order_selector Order
+ order_selector Order
>
 struct copy_segments
 {
@@ -192,11 +192,11 @@
 };
 
 
-template
+template
 <
- typename Ring,
- typename SegmentIdentifier,
- typename RangeOut,
+ typename Ring,
+ typename SegmentIdentifier,
+ typename RangeOut,
     order_selector Order
>
 struct copy_segments<ring_tag, Ring, SegmentIdentifier, RangeOut, Order>
@@ -207,11 +207,11 @@
 {};
 
 
-template
+template
 <
- typename Polygon,
- typename SegmentIdentifier,
- typename RangeOut,
+ typename Polygon,
+ typename SegmentIdentifier,
+ typename RangeOut,
     order_selector Order
>
 struct copy_segments<polygon_tag, Polygon, SegmentIdentifier, RangeOut, Order>
@@ -222,11 +222,11 @@
 {};
 
 
-template
+template
 <
- typename Box,
- typename SegmentIdentifier,
- typename RangeOut,
+ typename Box,
+ typename SegmentIdentifier,
+ typename RangeOut,
     order_selector Order
>
 struct copy_segments<box_tag, Box, SegmentIdentifier, RangeOut, Order>
@@ -249,9 +249,9 @@
  */
 template
 <
- order_selector Order,
- typename Geometry,
- typename SegmentIdentifier,
+ order_selector Order,
+ typename Geometry,
+ typename SegmentIdentifier,
     typename RangeOut
>
 inline void copy_segments(Geometry const& geometry,

Modified: sandbox/geometry/boost/geometry/algorithms/detail/overlay/get_turns.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/overlay/get_turns.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/overlay/get_turns.hpp 2010-12-12 10:46:52 EST (Sun, 12 Dec 2010)
@@ -90,16 +90,16 @@
>
 class get_turns_in_sections
 {
- typedef closeable_view
+ typedef typename closeable_view
         <
             typename range_type<Geometry1>::type const,
- closure<Geometry1>::value == open
- > view_type1;
- typedef closeable_view
+ closure<Geometry1>::value
+ >::type view_type1;
+ typedef typename closeable_view
         <
             typename range_type<Geometry2>::type const,
- closure<Geometry2>::value == open
- > view_type2;
+ closure<Geometry2>::value
+ >::type view_type2;
 
     typedef typename boost::range_iterator
         <

Modified: sandbox/geometry/boost/geometry/algorithms/detail/sections/get_full_section.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/sections/get_full_section.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/sections/get_full_section.hpp 2010-12-12 10:46:52 EST (Sun, 12 Dec 2010)
@@ -34,11 +34,11 @@
 template <typename Range, typename Section>
 struct full_section_range
 {
- typedef closeable_view
+ typedef typename closeable_view
         <
             Range const,
- closure<Range>::value == open // close it if it is open
- > view_type;
+ closure<Range>::value
+ >::type view_type;
 
     static inline view_type apply(Range const& range, Section const& section)
     {
@@ -51,11 +51,11 @@
 struct full_section_polygon
 {
     typedef typename geometry::ring_type<Polygon>::type ring_type;
- typedef closeable_view
+ typedef typename closeable_view
         <
             ring_type const,
- closure<ring_type>::value == open // close it if it is open
- > view_type;
+ closure<ring_type>::value
+ >::type view_type;
 
     static inline view_type apply(Polygon const& polygon, Section const& section)
     {

Modified: sandbox/geometry/boost/geometry/algorithms/detail/sections/sectionalize.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/sections/sectionalize.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/sections/sectionalize.hpp 2010-12-12 10:46:52 EST (Sun, 12 Dec 2010)
@@ -353,11 +353,7 @@
>
 struct sectionalize_range
 {
- typedef closeable_view
- <
- Range const,
- Closure == open // close it if it is open
- > view_type;
+ typedef typename closeable_view<Range const, Closure>::type view_type;
 
     static inline void apply(Range const& range, Sections& sections,
                 int ring_index = -1, int multi_index = -1)

Modified: sandbox/geometry/boost/geometry/algorithms/distance.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/distance.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/distance.hpp 2010-12-12 10:46:52 EST (Sun, 12 Dec 2010)
@@ -102,11 +102,7 @@
             return zero;
         }
 
- typedef closeable_view
- <
- Range const,
- Closure == open
- > view_type;
+ typedef typename closeable_view<Range const, Closure>::type view_type;
 
         view_type view(range);
 

Modified: sandbox/geometry/boost/geometry/algorithms/length.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/length.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/length.hpp 2010-12-12 10:46:52 EST (Sun, 12 Dec 2010)
@@ -17,6 +17,7 @@
 #include <boost/type_traits.hpp>
 
 #include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/closure.hpp>
 
 #include <boost/geometry/geometries/concepts/check.hpp>
 
@@ -56,7 +57,7 @@
 \note for_each could be used here, now that point_type is changed by boost
     range iterator
 */
-template<typename Range, typename Strategy, bool Close>
+template<typename Range, typename Strategy, closure_selector Closure>
 struct range_length
 {
     typedef typename length_result<Range>::type return_type;
@@ -64,7 +65,7 @@
     static inline return_type apply(
             Range const& range, Strategy const& strategy)
     {
- typedef closeable_view<Range const, Close> view_type;
+ typedef typename closeable_view<Range const, Closure>::type view_type;
         typedef typename boost::range_iterator
             <
                 view_type const
@@ -111,7 +112,7 @@
 
 template <typename Geometry, typename Strategy>
 struct length<linestring_tag, Geometry, Strategy>
- : detail::length::range_length<Geometry, Strategy, false>
+ : detail::length::range_length<Geometry, Strategy, closed>
 {};
 
 

Modified: sandbox/geometry/boost/geometry/algorithms/perimeter.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/perimeter.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/perimeter.hpp 2010-12-12 10:46:52 EST (Sun, 12 Dec 2010)
@@ -38,8 +38,12 @@
 
 template <typename Geometry, typename Strategy>
 struct perimeter<ring_tag, Geometry, Strategy>
- : detail::length::range_length<Geometry, Strategy,
- closure<Geometry>::value == open>
+ : detail::length::range_length
+ <
+ Geometry,
+ Strategy,
+ closure<Geometry>::value
+ >
 {};
 
 template <typename Polygon, typename Strategy>
@@ -53,7 +57,7 @@
                 <
                     typename ring_type<Polygon>::type,
                     Strategy,
- closure<Polygon>::value == open
+ closure<Polygon>::value
>
>
 {};

Modified: sandbox/geometry/boost/geometry/algorithms/within.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/within.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/within.hpp 2010-12-12 10:46:52 EST (Sun, 12 Dec 2010)
@@ -160,12 +160,11 @@
             return -1;
         }
 
- typedef reversible_view<Ring const, Direction> rev_view_type;
- typedef closeable_view
+ typedef typename reversible_view<Ring const, Direction>::type rev_view_type;
+ typedef typename closeable_view
             <
- rev_view_type const,
- Closure == open // close it if it is open
- > cl_view_type;
+ rev_view_type const, Closure
+ >::type cl_view_type;
         typedef typename boost::range_iterator<cl_view_type const>::type iterator_type;
 
         rev_view_type rev_view(ring);

Modified: sandbox/geometry/boost/geometry/extensions/gis/io/wkt/write_wkt.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/extensions/gis/io/wkt/write_wkt.hpp (original)
+++ sandbox/geometry/boost/geometry/extensions/gis/io/wkt/write_wkt.hpp 2010-12-12 10:46:52 EST (Sun, 12 Dec 2010)
@@ -214,7 +214,14 @@
 {
 
 template <typename Tag, typename Geometry>
-struct wkt {};
+struct wkt
+{
+ BOOST_MPL_ASSERT_MSG
+ (
+ false, NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+ , (types<Geometry>)
+ );
+};
 
 
 template <typename Point>

Modified: sandbox/geometry/boost/geometry/multi/algorithms/detail/sections/get_full_section.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/multi/algorithms/detail/sections/get_full_section.hpp (original)
+++ sandbox/geometry/boost/geometry/multi/algorithms/detail/sections/get_full_section.hpp 2010-12-12 10:46:52 EST (Sun, 12 Dec 2010)
@@ -35,11 +35,10 @@
 struct full_section_multi
 {
     typedef typename geometry::ring_type<MultiGeometry>::type ring_type;
- typedef closeable_view
+ typedef typename closeable_view
         <
- ring_type const,
- closure<MultiGeometry>::value == open // close it if it is open
- > view_type;
+ ring_type const, closure<MultiGeometry>::value
+ >::type view_type;
 
     static inline view_type apply(MultiGeometry const& multi,
                 Section const& section)

Modified: sandbox/geometry/boost/geometry/multi/algorithms/length.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/multi/algorithms/length.hpp (original)
+++ sandbox/geometry/boost/geometry/multi/algorithms/length.hpp 2010-12-12 10:46:52 EST (Sun, 12 Dec 2010)
@@ -34,7 +34,7 @@
                 <
                     typename boost::range_value<MultiLinestring>::type,
                     Strategy,
- false
+ closed // no need to close it explicitly
>
>
 {};

Modified: sandbox/geometry/boost/geometry/util/closeable_view.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/util/closeable_view.hpp (original)
+++ sandbox/geometry/boost/geometry/util/closeable_view.hpp 2010-12-12 10:46:52 EST (Sun, 12 Dec 2010)
@@ -11,6 +11,7 @@
 
 #include <boost/range.hpp>
 
+#include <boost/geometry/core/closure.hpp>
 #include <boost/geometry/core/ring_type.hpp>
 #include <boost/geometry/core/tag.hpp>
 #include <boost/geometry/core/tags.hpp>
@@ -20,51 +21,48 @@
 namespace boost { namespace geometry
 {
 
-
-
-template <typename Range, bool Close>
-struct closeable_view {};
-
-
+namespace detail
+{
 
 template <typename Range>
-struct closeable_view<Range, false>
+struct closing_view
 {
- closeable_view(Range& r)
+ explicit closing_view(Range& r)
         : m_range(r)
     {}
 
- typedef typename boost::range_iterator<Range const>::type const_iterator;
- typedef typename boost::range_iterator<Range>::type iterator;
 
- const_iterator begin() const { return boost::begin(m_range); }
- const_iterator end() const { return boost::end(m_range); }
+ typedef closing_iterator<Range> iterator;
+ typedef closing_iterator<Range const> const_iterator;
+
+ inline const_iterator begin() const { return const_iterator(m_range); }
+ inline const_iterator end() const { return const_iterator(m_range, true); }
 
- iterator begin() { return boost::begin(m_range); }
- iterator end() { return boost::end(m_range); }
+ inline iterator begin() { return iterator(m_range); }
+ inline iterator end() { return iterator(m_range, true); }
 private :
     Range& m_range;
 };
 
+}
 
-template <typename Range>
-struct closeable_view<Range, true>
-{
- explicit closeable_view(Range& r)
- : m_range(r)
- {}
 
+template <typename Range, closure_selector Close>
+struct closeable_view {};
 
- typedef closing_iterator<Range> iterator;
- typedef closing_iterator<Range const> const_iterator;
 
- const_iterator begin() const { return const_iterator(m_range); }
- const_iterator end() const { return const_iterator(m_range, true); }
 
- iterator begin() { return iterator(m_range); }
- iterator end() { return iterator(m_range, true); }
-private :
- Range& m_range;
+template <typename Range>
+struct closeable_view<Range, closed>
+{
+ typedef Range type;
+};
+
+
+template <typename Range>
+struct closeable_view<Range, open>
+{
+ typedef detail::closing_view<Range> type;
 };
 
 

Modified: sandbox/geometry/boost/geometry/util/reversible_view.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/util/reversible_view.hpp (original)
+++ sandbox/geometry/boost/geometry/util/reversible_view.hpp 2010-12-12 10:46:52 EST (Sun, 12 Dec 2010)
@@ -10,6 +10,7 @@
 
 
 #include <boost/range.hpp>
+#include <boost/range/adaptor/reversed.hpp>
 
 #include <boost/geometry/core/ring_type.hpp>
 #include <boost/geometry/core/tag.hpp>
@@ -21,52 +22,24 @@
 
 enum iterate_direction { iterate_forward, iterate_reverse };
 
-
+// BSG 13-12-2010, changed into meta-function
 template <typename Range, iterate_direction Direction>
 struct reversible_view {};
 
 
-
 template <typename Range>
 struct reversible_view<Range, iterate_forward>
 {
- explicit reversible_view(Range& r)
- : m_range(r)
- {}
-
- typedef typename boost::range_iterator<Range const>::type const_iterator;
- typedef typename boost::range_iterator<Range>::type iterator;
-
- const_iterator begin() const { return boost::begin(this->m_range); }
- const_iterator end() const { return boost::end(this->m_range); }
-
- iterator begin() { return boost::begin(this->m_range); }
- iterator end() { return boost::end(this->m_range); }
-private :
- Range& m_range;
+ typedef Range type;
 };
 
 
 template <typename Range>
-struct reversible_view<Range, iterate_reverse>
+struct reversible_view<Range, iterate_reverse>
 {
- reversible_view(Range& r)
- : m_range(r)
- {}
-
- typedef typename boost::range_reverse_iterator<Range const>::type const_iterator;
- typedef typename boost::range_reverse_iterator<Range>::type iterator;
-
- const_iterator begin() const { return boost::rbegin(this->m_range); }
- const_iterator end() const { return boost::rend(this->m_range); }
-
- iterator begin() { return boost::rbegin(this->m_range); }
- iterator end() { return boost::rend(this->m_range); }
-private :
- Range& m_range;
+ typedef boost::range_detail::reverse_range<Range> type;
 };
 
-
 }} // namespace boost::geometry
 
 


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