summaryrefslogtreecommitdiff
path: root/boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp')
-rw-r--r--boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp33
1 files changed, 9 insertions, 24 deletions
diff --git a/boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp b/boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp
index 20a6d7f..13e0a5a 100644
--- a/boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp
+++ b/boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp
@@ -11,6 +11,7 @@
#include <boost/array.hpp>
+#include <boost/assert.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/range.hpp>
@@ -21,8 +22,7 @@
#include <boost/geometry/algorithms/convert.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/util/range.hpp>
-#include <boost/geometry/views/closeable_view.hpp>
-#include <boost/geometry/views/reversible_view.hpp>
+#include <boost/geometry/views/detail/normalized_view.hpp>
namespace boost { namespace geometry
@@ -37,41 +37,24 @@ namespace detail { namespace copy_segments
template <typename Range, bool Reverse, typename SegmentIdentifier, typename PointOut>
struct copy_segment_point_range
{
- typedef typename closeable_view
- <
- Range const,
- closure<Range>::value
- >::type cview_type;
-
- typedef typename reversible_view
- <
- cview_type const,
- Reverse ? iterate_reverse : iterate_forward
- >::type rview_type;
-
static inline bool apply(Range const& range,
SegmentIdentifier const& seg_id, bool second,
PointOut& point)
{
+ detail::normalized_view<Range const> view(range);
+
+ signed_index_type const n = boost::size(view);
signed_index_type index = seg_id.segment_index;
if (second)
{
index++;
- if (index >= int(boost::size(range)))
+ if (index >= n)
{
index = 0;
}
}
- // Exception?
- if (index >= int(boost::size(range)))
- {
- return false;
- }
-
- cview_type cview(range);
- rview_type view(cview);
-
+ BOOST_ASSERT(index >= 0 && index < n);
geometry::convert(*(boost::begin(view) + index), point);
return true;
@@ -323,6 +306,8 @@ inline bool copy_segment_point(Geometry1 const& geometry1, Geometry2 const& geom
concept::check<Geometry1 const>();
concept::check<Geometry2 const>();
+ BOOST_ASSERT(seg_id.source_index == 0 || seg_id.source_index == 1);
+
if (seg_id.source_index == 0)
{
return dispatch::copy_segment_point