Moved closeable_view,reversible_view to views

Added identity_view to avoid copies
Renamed get_full_section.hpp to range_by_section.hpp
Added (temporary?) reference to ring/linestring types in ring_return_type...


[SVN r67309]
This commit is contained in:
Barend Gehrels
2010-12-18 21:39:33 +00:00
parent 306b1ddbdc
commit a352ce1a8a
19 changed files with 85 additions and 43 deletions

View File

@@ -33,8 +33,8 @@
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/util/order_as_direction.hpp>
#include <boost/geometry/util/closeable_view.hpp>
#include <boost/geometry/util/reversible_view.hpp>
#include <boost/geometry/views/closeable_view.hpp>
#include <boost/geometry/views/reversible_view.hpp>
namespace boost { namespace geometry

View File

@@ -28,7 +28,7 @@
#include <boost/geometry/iterators/segment_returning_iterator.hpp>
#include <boost/geometry/strategies/centroid.hpp>
#include <boost/geometry/strategies/concepts/centroid_concept.hpp>
#include <boost/geometry/util/closeable_view.hpp>
#include <boost/geometry/views/closeable_view.hpp>
#include <boost/geometry/util/copy.hpp>
#include <boost/geometry/util/for_each_coordinate.hpp>

View File

@@ -25,8 +25,8 @@
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/iterators/ever_circling_iterator.hpp>
#include <boost/geometry/iterators/range_type.hpp>
#include <boost/geometry/util/closeable_view.hpp>
#include <boost/geometry/util/reversible_view.hpp>
#include <boost/geometry/views/closeable_view.hpp>
#include <boost/geometry/views/reversible_view.hpp>
namespace boost { namespace geometry

View File

@@ -30,8 +30,8 @@
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/util/closeable_view.hpp>
#include <boost/geometry/util/reversible_view.hpp>
#include <boost/geometry/views/closeable_view.hpp>
#include <boost/geometry/views/reversible_view.hpp>
#include <boost/geometry/geometries/box.hpp>
@@ -48,7 +48,7 @@
#include <boost/geometry/algorithms/detail/overlay/segment_identifier.hpp>
#include <boost/geometry/algorithms/detail/sections/get_full_section.hpp>
#include <boost/geometry/algorithms/detail/sections/range_by_section.hpp>
#include <boost/geometry/algorithms/combine.hpp>
#include <boost/geometry/algorithms/distance.hpp>
@@ -106,12 +106,12 @@ class get_turns_in_sections
typedef typename reversible_view
<
cview_type1 const,
cview_type1 const,
Reverse1 ? iterate_reverse : iterate_forward
>::type view_type1;
typedef typename reversible_view
<
cview_type2 const,
cview_type2 const,
Reverse2 ? iterate_reverse : iterate_forward
>::type view_type2;

View File

@@ -5,10 +5,9 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_GET_FULL_SECTION_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_GET_FULL_SECTION_HPP
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_RANGE_BY_SECTION_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_RANGE_BY_SECTION_HPP
// TODO rename to "range_by_section"
#include <boost/mpl/assert.hpp>
#include <boost/range.hpp>
@@ -109,7 +108,7 @@ struct range_by_section<polygon_tag, Polygon, Section>
\param section structure with section
*/
template <typename Geometry, typename Section>
inline typename ring_return_type<Geometry const>::type
inline typename ring_return_type<Geometry const>::type
range_by_section(Geometry const& geometry, Section const& section)
{
concept::check<Geometry const>();
@@ -125,4 +124,4 @@ inline typename ring_return_type<Geometry const>::type
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_GET_FULL_SECTION_HPP
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_RANGE_BY_SECTION_HPP

View File

@@ -26,8 +26,8 @@
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/util/closeable_view.hpp>
#include <boost/geometry/util/reversible_view.hpp>
#include <boost/geometry/views/closeable_view.hpp>
#include <boost/geometry/views/reversible_view.hpp>
#include <boost/geometry/geometries/segment.hpp>
@@ -357,7 +357,7 @@ struct sectionalize_range
typedef typename closeable_view<Range const, Closure>::type cview_type;
typedef typename reversible_view
<
cview_type const,
cview_type const,
Reverse ? iterate_reverse : iterate_forward
>::type view_type;
@@ -540,7 +540,7 @@ struct sectionalize<box_tag, Box, Reverse, Sections, DimensionCount, MaxCount>
template
<
typename LineString,
typename LineString,
typename Sections,
std::size_t DimensionCount,
std::size_t MaxCount

View File

@@ -31,7 +31,7 @@
#include <boost/geometry/algorithms/assign.hpp>
#include <boost/geometry/algorithms/within.hpp>
#include <boost/geometry/util/closeable_view.hpp>
#include <boost/geometry/views/closeable_view.hpp>
#include <boost/geometry/util/math.hpp>

View File

@@ -23,7 +23,7 @@
#include <boost/geometry/algorithms/assign.hpp>
#include <boost/geometry/algorithms/detail/calculate_null.hpp>
#include <boost/geometry/util/closeable_view.hpp>
#include <boost/geometry/views/closeable_view.hpp>
#include <boost/geometry/strategies/distance.hpp>
#include <boost/geometry/strategies/length_result.hpp>

View File

@@ -39,7 +39,7 @@ struct range_count
static inline std::size_t apply(Range const& range, bool add_for_open)
{
std::size_t n = boost::size(range);
if (add_for_open)
if (add_for_open && n > 0)
{
closure_selector const s = geometry::closure<Range>::value;

View File

@@ -29,8 +29,8 @@
#include <boost/geometry/strategies/within.hpp>
#include <boost/geometry/strategies/concepts/within_concept.hpp>
#include <boost/geometry/util/order_as_direction.hpp>
#include <boost/geometry/util/closeable_view.hpp>
#include <boost/geometry/util/reversible_view.hpp>
#include <boost/geometry/views/closeable_view.hpp>
#include <boost/geometry/views/reversible_view.hpp>
namespace boost { namespace geometry

View File

@@ -90,14 +90,14 @@ struct ring_return_type
template <typename LineString>
struct ring_return_type<linestring_tag, LineString>
{
typedef LineString type;
typedef LineString& type;
};
template <typename Ring>
struct ring_return_type<ring_tag, Ring>
{
typedef Ring type;
typedef Ring& type;
};

View File

@@ -15,7 +15,7 @@
#include <boost/geometry/multi/algorithms/distance.hpp>
#include <boost/geometry/multi/iterators/range_type.hpp>
#include <boost/geometry/multi/algorithms/detail/sections/get_full_section.hpp>
#include <boost/geometry/multi/algorithms/detail/sections/range_by_section.hpp>
#include <boost/geometry/multi/algorithms/detail/sections/sectionalize.hpp>

View File

@@ -5,8 +5,8 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_SECTIONS_GET_FULL_SECTION_HPP
#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_SECTIONS_GET_FULL_SECTION_HPP
#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_SECTIONS_RANGE_BY_SECTION_HPP
#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_SECTIONS_RANGE_BY_SECTION_HPP
#include <boost/assert.hpp>
@@ -14,7 +14,7 @@
#include <boost/geometry/multi/core/tags.hpp>
#include <boost/geometry/multi/core/ring_type.hpp>
#include <boost/geometry/algorithms/detail/sections/get_full_section.hpp>
#include <boost/geometry/algorithms/detail/sections/range_by_section.hpp>
namespace boost { namespace geometry
@@ -81,4 +81,4 @@ struct range_by_section<multi_polygon_tag, MultiPolygon, Section>
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_SECTIONS_GET_FULL_SECTION_HPP
#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_SECTIONS_RANGE_BY_SECTION_HPP

View File

@@ -20,7 +20,7 @@
#include <boost/geometry/multi/algorithms/detail/overlay/copy_segments.hpp>
#include <boost/geometry/multi/algorithms/detail/overlay/copy_segment_point.hpp>
#include <boost/geometry/multi/algorithms/detail/overlay/add_to_containment.hpp>
#include <boost/geometry/multi/algorithms/detail/sections/get_full_section.hpp>
#include <boost/geometry/multi/algorithms/detail/sections/range_by_section.hpp>
#include <boost/geometry/multi/algorithms/detail/sections/sectionalize.hpp>

View File

@@ -20,7 +20,7 @@
#include <boost/geometry/multi/algorithms/detail/overlay/copy_segments.hpp>
#include <boost/geometry/multi/algorithms/detail/overlay/copy_segment_point.hpp>
#include <boost/geometry/multi/algorithms/detail/overlay/add_to_containment.hpp>
#include <boost/geometry/multi/algorithms/detail/sections/get_full_section.hpp>
#include <boost/geometry/multi/algorithms/detail/sections/range_by_section.hpp>
#include <boost/geometry/multi/algorithms/detail/sections/sectionalize.hpp>
namespace boost { namespace geometry

View File

@@ -10,7 +10,6 @@
#define BOOST_GEOMETRY_UTIL_ORDER_AS_DIRECTION_HPP
#include <boost/geometry/core/point_order.hpp>
#include <boost/geometry/util/reversible_view.hpp>
namespace boost { namespace geometry

View File

@@ -5,8 +5,8 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_UTIL_CLOSEABLE_VIEW_HPP
#define BOOST_GEOMETRY_UTIL_CLOSEABLE_VIEW_HPP
#ifndef BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP
#define BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP
#include <boost/range.hpp>
@@ -17,6 +17,7 @@
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/iterators/closing_iterator.hpp>
#include <boost/geometry/views/identity_view.hpp>
namespace boost { namespace geometry
{
@@ -56,7 +57,7 @@ struct closeable_view {};
template <typename Range>
struct closeable_view<Range, closed>
{
typedef Range type;
typedef identity_view<Range> type;
};
@@ -70,4 +71,4 @@ struct closeable_view<Range, open>
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_UTIL_CLOSEABLE_VIEW_HPP
#endif // BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP

View File

@@ -0,0 +1,42 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright Barend Gehrels 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_IDENTITY_VIEW_HPP
#define BOOST_GEOMETRY_VIEWS_IDENTITY_VIEW_HPP
#include <boost/range.hpp>
namespace boost { namespace geometry
{
template <typename Range>
struct identity_view
{
typedef typename boost::range_iterator<Range const>::type const_iterator;
typedef typename boost::range_iterator<Range>::type iterator;
explicit inline identity_view(Range& r)
: m_range(r)
{}
inline const_iterator begin() const { return boost::begin(m_range); }
inline const_iterator end() const { return boost::end(m_range); }
inline iterator begin() { return boost::begin(m_range); }
inline iterator end() { return boost::end(m_range); }
private :
Range& m_range;
};
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_VIEWS_IDENTITY_VIEW_HPP

View File

@@ -5,8 +5,8 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_UTIL_REVERSIBLE_VIEW_HPP
#define BOOST_GEOMETRY_UTIL_REVERSIBLE_VIEW_HPP
#ifndef BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP
#define BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP
#include <boost/range.hpp>
@@ -16,6 +16,7 @@
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/views/identity_view.hpp>
namespace boost { namespace geometry
{
@@ -30,12 +31,12 @@ struct reversible_view {};
template <typename Range>
struct reversible_view<Range, iterate_forward>
{
typedef Range type;
typedef identity_view<Range> type;
};
template <typename Range>
struct reversible_view<Range, iterate_reverse>
struct reversible_view<Range, iterate_reverse>
{
typedef boost::range_detail::reverse_range<Range> type;
};
@@ -43,4 +44,4 @@ struct reversible_view<Range, iterate_reverse>
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_UTIL_REVERSIBLE_VIEW_HPP
#endif // BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP