Added boost header
This commit is contained in:
114
test/external/boost/geometry/views/box_view.hpp
vendored
Normal file
114
test/external/boost/geometry/views/box_view.hpp
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
// 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_BOX_VIEW_HPP
|
||||
#define BOOST_GEOMETRY_VIEWS_BOX_VIEW_HPP
|
||||
|
||||
|
||||
#include <boost/range.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
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Makes a box behave like a ring or a range
|
||||
\details Adapts a box to the Boost.Range concept, enabling the user to iterating
|
||||
box corners. The box_view is registered as a Ring Concept
|
||||
\tparam Box \tparam_geometry{Box}
|
||||
\tparam Clockwise If true, walks in clockwise direction, otherwise
|
||||
it walks in counterclockwise direction
|
||||
\ingroup views
|
||||
|
||||
\qbk{before.synopsis,
|
||||
[heading Model of]
|
||||
[link geometry.reference.concepts.concept_ring Ring Concept]
|
||||
}
|
||||
|
||||
\qbk{[include reference/views/box_view.qbk]}
|
||||
*/
|
||||
template <typename Box, bool Clockwise = true>
|
||||
struct box_view
|
||||
: public detail::points_view
|
||||
<
|
||||
typename geometry::point_type<Box>::type,
|
||||
5
|
||||
>
|
||||
{
|
||||
typedef typename geometry::point_type<Box>::type point_type;
|
||||
|
||||
/// Constructor accepting the box to adapt
|
||||
explicit box_view(Box const& box)
|
||||
: detail::points_view<point_type, 5>(copy_policy(box))
|
||||
{}
|
||||
|
||||
private :
|
||||
|
||||
class copy_policy
|
||||
{
|
||||
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 const& m_box;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
|
||||
|
||||
// All views on boxes are handled as rings
|
||||
namespace traits
|
||||
{
|
||||
|
||||
template<typename Box, bool Clockwise>
|
||||
struct tag<box_view<Box, Clockwise> >
|
||||
{
|
||||
typedef ring_tag type;
|
||||
};
|
||||
|
||||
template<typename Box>
|
||||
struct point_order<box_view<Box, false> >
|
||||
{
|
||||
static order_selector const value = counterclockwise;
|
||||
};
|
||||
|
||||
|
||||
template<typename Box>
|
||||
struct point_order<box_view<Box, true> >
|
||||
{
|
||||
static order_selector const value = clockwise;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_VIEWS_BOX_VIEW_HPP
|
||||
100
test/external/boost/geometry/views/closeable_view.hpp
vendored
Normal file
100
test/external/boost/geometry/views/closeable_view.hpp
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
// 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_CLOSEABLE_VIEW_HPP
|
||||
#define BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP
|
||||
|
||||
|
||||
#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>
|
||||
#include <boost/geometry/iterators/closing_iterator.hpp>
|
||||
|
||||
#include <boost/geometry/views/identity_view.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename Range>
|
||||
struct closing_view
|
||||
{
|
||||
// Keep this explicit, important for nested views/ranges
|
||||
explicit inline closing_view(Range& r)
|
||||
: m_range(r)
|
||||
{}
|
||||
|
||||
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); }
|
||||
|
||||
inline iterator begin() { return iterator(m_range); }
|
||||
inline iterator end() { return iterator(m_range, true); }
|
||||
private :
|
||||
Range& m_range;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
/*!
|
||||
\brief View on a range, either closing it or leaving it as it is
|
||||
\details The closeable_view is used internally by the library to handle all rings,
|
||||
either closed or open, the same way. The default method is closed, all
|
||||
algorithms process rings as if they are closed. Therefore, if they are opened,
|
||||
a view is created which closes them.
|
||||
The closeable_view might be used by library users, but its main purpose is
|
||||
internally.
|
||||
\tparam Range Original range
|
||||
\tparam Close Specifies if it the range is closed, if so, nothing will happen.
|
||||
If it is open, it will iterate the first point after the last point.
|
||||
\ingroup views
|
||||
*/
|
||||
template <typename Range, closure_selector Close>
|
||||
struct closeable_view {};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_SPECIALIZATIONS
|
||||
|
||||
template <typename Range>
|
||||
struct closeable_view<Range, closed>
|
||||
{
|
||||
typedef identity_view<Range> type;
|
||||
};
|
||||
|
||||
|
||||
template <typename Range>
|
||||
struct closeable_view<Range, open>
|
||||
{
|
||||
typedef detail::closing_view<Range> type;
|
||||
};
|
||||
|
||||
#endif // DOXYGEN_NO_SPECIALIZATIONS
|
||||
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP
|
||||
141
test/external/boost/geometry/views/detail/points_view.hpp
vendored
Normal file
141
test/external/boost/geometry/views/detail/points_view.hpp
vendored
Normal file
@@ -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
|
||||
93
test/external/boost/geometry/views/detail/range_type.hpp
vendored
Normal file
93
test/external/boost/geometry/views/detail/range_type.hpp
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
// 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_RANGE_TYPE_HPP
|
||||
#define BOOST_GEOMETRY_VIEWS_DETAIL_RANGE_TYPE_HPP
|
||||
|
||||
|
||||
#include <boost/type_traits.hpp>
|
||||
|
||||
#include <boost/geometry/core/ring_type.hpp>
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch
|
||||
{
|
||||
|
||||
|
||||
template <typename GeometryTag, typename Geometry>
|
||||
struct range_type
|
||||
{
|
||||
// Even if it is not recognized, define itself as a type.
|
||||
// This enables calling range_type over any range
|
||||
// (not necessarily a geometry)
|
||||
|
||||
// Furthermore, applicable for ring/linestring
|
||||
typedef Geometry type;
|
||||
};
|
||||
|
||||
|
||||
template <typename Geometry>
|
||||
struct range_type<point_tag, Geometry>
|
||||
{
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
|
||||
template <typename Geometry>
|
||||
struct range_type<polygon_tag, Geometry>
|
||||
{
|
||||
typedef typename ring_type<Geometry>::type type;
|
||||
};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
// Will probably be replaced by the more generic "view_as", therefore in detail
|
||||
namespace detail
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Meta-function defining a type which is a boost-range.
|
||||
\details
|
||||
- For linestrings and rings, it defines the type itself.
|
||||
- For polygons it defines the ring type.
|
||||
- For multi-points, it defines the type itself
|
||||
- For multi-polygons and multi-linestrings, it defines the single-version
|
||||
(so in the end the linestring and ring-type-of-multi-polygon)
|
||||
\ingroup iterators
|
||||
*/
|
||||
template <typename Geometry>
|
||||
struct range_type
|
||||
{
|
||||
typedef typename dispatch::range_type
|
||||
<
|
||||
typename tag<Geometry>::type,
|
||||
Geometry
|
||||
>::type type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_VIEWS_DETAIL_RANGE_TYPE_HPP
|
||||
53
test/external/boost/geometry/views/identity_view.hpp
vendored
Normal file
53
test/external/boost/geometry/views/identity_view.hpp
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
// 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_IDENTITY_VIEW_HPP
|
||||
#define BOOST_GEOMETRY_VIEWS_IDENTITY_VIEW_HPP
|
||||
|
||||
|
||||
#include <boost/range.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief View on a range, not modifying anything
|
||||
\tparam Range original range
|
||||
\ingroup views
|
||||
*/
|
||||
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
|
||||
74
test/external/boost/geometry/views/reversible_view.hpp
vendored
Normal file
74
test/external/boost/geometry/views/reversible_view.hpp
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
// 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_REVERSIBLE_VIEW_HPP
|
||||
#define BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP
|
||||
|
||||
|
||||
#include <boost/version.hpp>
|
||||
#include <boost/range.hpp>
|
||||
#include <boost/range/adaptor/reversed.hpp>
|
||||
|
||||
#include <boost/geometry/core/ring_type.hpp>
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/views/identity_view.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Flag for iterating a reversible_view in forward or reverse direction
|
||||
\ingroup views
|
||||
*/
|
||||
enum iterate_direction { iterate_forward, iterate_reverse };
|
||||
|
||||
/*!
|
||||
\brief View on a range, reversing direction if necessary
|
||||
\tparam Range original range
|
||||
\tparam Direction direction of iteration
|
||||
\ingroup views
|
||||
*/
|
||||
template <typename Range, iterate_direction Direction>
|
||||
struct reversible_view {};
|
||||
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_SPECIALIZATIONS
|
||||
|
||||
template <typename Range>
|
||||
struct reversible_view<Range, iterate_forward>
|
||||
{
|
||||
typedef identity_view<Range> type;
|
||||
};
|
||||
|
||||
|
||||
template <typename Range>
|
||||
struct reversible_view<Range, iterate_reverse>
|
||||
{
|
||||
#if BOOST_VERSION > 104500
|
||||
typedef boost::reversed_range<Range> type;
|
||||
#else
|
||||
// For older versions of Boost
|
||||
typedef boost::range_detail::reverse_range<Range> type;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // DOXYGEN_NO_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP
|
||||
100
test/external/boost/geometry/views/segment_view.hpp
vendored
Normal file
100
test/external/boost/geometry/views/segment_view.hpp
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
// 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_SEGMENT_VIEW_HPP
|
||||
#define BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP
|
||||
|
||||
|
||||
#include <boost/range.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
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Makes a segment behave like a linestring or a range
|
||||
\details Adapts a segment to the Boost.Range concept, enabling the user to
|
||||
iterate the two segment points. The segment_view is registered as a LineString Concept
|
||||
\tparam Segment \tparam_geometry{Segment}
|
||||
\ingroup views
|
||||
|
||||
\qbk{before.synopsis,
|
||||
[heading Model of]
|
||||
[link geometry.reference.concepts.concept_linestring LineString Concept]
|
||||
}
|
||||
|
||||
\qbk{[include reference/views/segment_view.qbk]}
|
||||
|
||||
*/
|
||||
template <typename Segment>
|
||||
struct segment_view
|
||||
: public detail::points_view
|
||||
<
|
||||
typename geometry::point_type<Segment>::type,
|
||||
2
|
||||
>
|
||||
{
|
||||
typedef typename geometry::point_type<Segment>::type point_type;
|
||||
|
||||
/// Constructor accepting the segment to adapt
|
||||
explicit segment_view(Segment const& segment)
|
||||
: detail::points_view<point_type, 2>(copy_policy(segment))
|
||||
{}
|
||||
|
||||
private :
|
||||
|
||||
class copy_policy
|
||||
{
|
||||
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 const& m_segment;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
|
||||
|
||||
// All segment ranges can be handled as linestrings
|
||||
namespace traits
|
||||
{
|
||||
|
||||
template<typename Segment>
|
||||
struct tag<segment_view<Segment> >
|
||||
{
|
||||
typedef linestring_tag type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP
|
||||
Reference in New Issue
Block a user