clip_linestring: renamed linestring to range (for support segments)

added distance checks
added mpl assertions
added intersection segment/box
renamed "segment_iterator" to "segment_returning_iterator" to be able to reuse that name later on


[SVN r64505]
This commit is contained in:
Barend Gehrels 2010-07-31 18:41:31 +00:00
parent 80531061b6
commit 9cd71226df
22 changed files with 933 additions and 52 deletions

View File

@ -24,7 +24,7 @@
#include <boost/geometry/algorithms/distance.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/iterators/segment_iterator.hpp>
#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>
@ -247,7 +247,7 @@ struct centroid_linestring
typedef typename point_type<Linestring>::type point_type;
typedef typename boost::range_iterator<Linestring const>::type point_iterator_type;
typedef segment_iterator<point_iterator_type, point_type> segment_iterator;
typedef segment_returning_iterator<point_iterator_type, point_type> segment_iterator;
double length = double();
std::pair<double, double> average_sum;
@ -366,8 +366,8 @@ template <typename Ring, typename Point, typename Strategy>
struct centroid<ring_tag, Ring, Point, Strategy>
: detail::centroid::centroid_ring
<
Ring,
Point,
Ring,
Point,
geometry::closure<Ring>::value,
Strategy
>

View File

@ -157,14 +157,14 @@ template
<
typename OutputLinestring,
typename OutputIterator,
typename Linestring,
typename Range,
typename Box,
typename Strategy
>
OutputIterator clip_linestring_with_box(Box const& b, Linestring const& linestring,
OutputIterator clip_range_with_box(Box const& b, Range const& range,
OutputIterator out, Strategy const& strategy)
{
if (boost::begin(linestring) == boost::end(linestring))
if (boost::begin(range) == boost::end(range))
{
return out;
}
@ -173,11 +173,11 @@ OutputIterator clip_linestring_with_box(Box const& b, Linestring const& linestri
OutputLinestring line_out;
typedef typename boost::range_iterator<Linestring const>::type iterator_type;
iterator_type vertex = boost::begin(linestring);
typedef typename boost::range_iterator<Range const>::type iterator_type;
iterator_type vertex = boost::begin(range);
for(iterator_type previous = vertex++;
vertex != boost::end(linestring);
previous = vertex++)
vertex != boost::end(range);
++previous, ++vertex)
{
point_type p1, p2;
copy_coordinates(*previous, p1);

View File

@ -20,6 +20,7 @@
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/algorithms/detail/overlay/clip_linestring.hpp>
#include <boost/geometry/algorithms/detail/overlay/assemble.hpp>
#include <boost/geometry/views/segment_range.hpp>
@ -87,15 +88,15 @@ namespace dispatch
template
<
typename Tag1, typename Tag2, typename Tag3,
typename G1, typename G2,
typename TagIn1, typename TagIn2, typename TagOut,
typename Geometry1, typename Geometry2,
typename OutputIterator,
typename GeometryOut,
typename Strategy
>
struct intersection_inserter
: detail::overlay::overlay
<G1, G2, OutputIterator, GeometryOut, -1, Strategy>
<Geometry1, Geometry2, OutputIterator, GeometryOut, -1, Strategy>
{};
@ -162,11 +163,38 @@ struct intersection_inserter
{
typedef typename point_type<GeometryOut>::type point_type;
strategy::intersection::liang_barsky<Box, point_type> lb_strategy;
return detail::intersection::clip_linestring_with_box
return detail::intersection::clip_range_with_box
<GeometryOut>(box, linestring, out, lb_strategy);
}
};
template
<
typename Segment, typename Box,
typename OutputIterator, typename GeometryOut,
typename Strategy
>
struct intersection_inserter
<
segment_tag, box_tag, linestring_tag,
Segment, Box,
OutputIterator, GeometryOut,
Strategy
>
{
static inline OutputIterator apply(Segment const& segment,
Box const& box, OutputIterator out, Strategy const& strategy)
{
typedef boost::geometry::segment_range<Segment> range_type;
range_type range(segment);
typedef typename point_type<GeometryOut>::type point_type;
strategy::intersection::liang_barsky<Box, point_type> lb_strategy;
return detail::intersection::clip_range_with_box
<GeometryOut>(box, range, out, lb_strategy);
}
};
template
<

View File

@ -12,10 +12,11 @@
#include <vector>
#include <boost/scoped_ptr.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/noncopyable.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
@ -24,8 +25,8 @@
#include <boost/geometry/algorithms/transform.hpp>
#include <boost/geometry/algorithms/num_points.hpp>
#include <boost/geometry/strategies/transform.hpp>
#include <boost/geometry/strategies/transform/map_transformer.hpp>
#include <boost/geometry/views/segment_range.hpp>
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/geometries/linestring.hpp>
@ -51,6 +52,11 @@ namespace dispatch
template <typename GeometryTag, bool IsMulti, typename Geometry>
struct svg_map
{
BOOST_MPL_ASSERT_MSG
(
false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
, (Geometry)
);
};
@ -98,6 +104,23 @@ struct svg_map_range
}
};
template <typename Segment>
struct svg_map<boost::geometry::segment_tag, false, Segment>
{
template <typename TransformStrategy>
static inline void apply(std::ostream& stream,
std::string const& style, int size,
Segment const& segment, TransformStrategy const& strategy)
{
typedef boost::geometry::segment_range<Segment> range_type;
range_type range(segment);
svg_map_range
<
range_type,
boost::geometry::linestring<boost::geometry::point_xy<int> >
>::apply(stream, style, size, range, strategy);
}
};
template <typename Ring>
@ -237,6 +260,18 @@ public :
void map(Geometry const& geometry, std::string const& style,
int size = -1)
{
BOOST_MPL_ASSERT_MSG
(
( boost::is_same
<
Point,
typename boost::geometry::point_type<Geometry>::type
>::value )
, POINT_TYPES_ARE_NOT_SAME_FOR_MAPPER_AND_MAP
, (types<Point, typename boost::geometry::point_type<Geometry>::type>)
);
init_matrix();
svg_map(m_stream, style, size, geometry, *m_matrix);
}

View File

@ -13,6 +13,7 @@
#include <string>
#include <boost/config.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/range.hpp>
@ -192,7 +193,14 @@ template <typename Char, typename Traits>
static inline void apply(std::basic_ostream<Char, Traits>& os, G const& geometry)
*/
template <typename GeometryTag, typename Geometry>
struct svg {};
struct svg
{
BOOST_MPL_ASSERT_MSG
(
false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
, (Geometry)
);
};
template <typename Point>
struct svg<point_tag, Point> : detail::svg::svg_point<Point> {};

View File

@ -102,7 +102,9 @@ class ConstLinestring
typedef typename point_type<Geometry>::type point_type;
BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point_type>) );
BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
//BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
// Relaxed the concept.
BOOST_CONCEPT_ASSERT( (boost::ForwardRangeConcept<Geometry>) );
public :

View File

@ -0,0 +1,111 @@
// 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_SEGMENT_RANGE_ITERATOR_HPP
#define BOOST_GEOMETRY_SEGMENT_RANGE_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 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::bidirectional_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);
}
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];
}
// Should not occur. Probably throw here.
// TODO decide
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 void init(Segment const& segment)
{
assign_point_from_index<0>(segment, m_points[0]);
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* const m_segment_address;
};
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_SEGMENT_RANGE_ITERATOR_HPP

View File

@ -7,8 +7,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_ITERATORS_SEGMENT_ITERATOR_HPP
#define BOOST_GEOMETRY_ITERATORS_SEGMENT_ITERATOR_HPP
#ifndef BOOST_GEOMETRY_ITERATORS_SEGMENT_RETURNING_ITERATOR_HPP
#define BOOST_GEOMETRY_ITERATORS_SEGMENT_RETURNING_ITERATOR_HPP
// TODO: This is very experimental version of input iterator
// reading collection of points as segments - proof of concept.
@ -30,7 +30,7 @@ namespace boost { namespace geometry
{
template <typename Base, typename Point>
struct segment_iterator
struct segment_returning_iterator
{
typedef Base base_type;
typedef Point point_type;
@ -42,7 +42,7 @@ struct segment_iterator
typedef segment_type* pointer;
typedef segment_type& reference;
explicit segment_iterator(Base const& end)
explicit segment_returning_iterator(Base const& end)
: m_segment(p1 , p2)
, m_prev(end)
, m_it(end)
@ -50,7 +50,7 @@ struct segment_iterator
{
}
segment_iterator(Base const& it, Base const& end)
segment_returning_iterator(Base const& it, Base const& end)
: m_segment(p1 , p2)
, m_prev(it)
, m_it(it)
@ -78,16 +78,16 @@ struct segment_iterator
return &(operator*());
}
segment_iterator& operator++()
segment_returning_iterator& operator++()
{
++m_prev;
++m_it;
return *this;
}
segment_iterator operator++(int)
segment_returning_iterator operator++(int)
{
segment_iterator it(*this);
segment_returning_iterator it(*this);
++(*this);
return it;
}
@ -106,32 +106,32 @@ private:
};
template <typename Base, typename Point>
bool operator==(segment_iterator<Base, Point> const& lhs,
segment_iterator<Base, Point> const& rhs)
bool operator==(segment_returning_iterator<Base, Point> const& lhs,
segment_returning_iterator<Base, Point> const& rhs)
{
return (lhs.base() == rhs.base());
}
template <typename Base, typename Point>
bool operator!=(segment_iterator<Base, Point> const& lhs,
segment_iterator<Base, Point> const& rhs)
bool operator!=(segment_returning_iterator<Base, Point> const& lhs,
segment_returning_iterator<Base, Point> const& rhs)
{
return (lhs.base() != rhs.base());
}
template <typename C>
segment_iterator
inline segment_returning_iterator
<
typename C::iterator,
typename C::value_type
>
make_segment_iterator(C& c)
make_segment_returning_iterator(C& c)
{
typedef typename C::iterator base_iterator;
typedef typename C::value_type point_type;
return segment_iterator<base_iterator, point_type>(c.begin(), c.end());
return segment_returning_iterator<base_iterator, point_type>(c.begin(), c.end());
}
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ITERATORS_SEGMENT_ITERATOR_HPP
#endif // BOOST_GEOMETRY_ITERATORS_SEGMENT_RETURNING_ITERATOR_HPP

View File

@ -0,0 +1,61 @@
// 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_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
{
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;
};
// All box ranges can be handled as linestrings
namespace traits
{
template<typename Box>
struct tag<box_range<Box> >
{
typedef ring_tag type;
};
}
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_RANGES_BOX_RANGE_HPP

View File

@ -0,0 +1,61 @@
// 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_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
{
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;
};
// All segment ranges can be handled as linestrings
namespace traits
{
template<typename Segment>
struct tag<segment_range<Segment> >
{
typedef linestring_tag type;
};
}
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_RANGES_SEGMENT_RANGE_HPP

View File

@ -179,17 +179,34 @@ void test_all()
test_geometry<P, bg::linestring<P> >("POINT(3 1)", "LINESTRING(1 1,4 4)", sqrt(2.0));
test_geometry<bg::linestring<P>, P>("LINESTRING(1 1,4 4)", "POINT(1 3)", sqrt(2.0));
// Rings
test_geometry<P, bg::linear_ring<P> >("POINT(1 3)", "POLYGON((1 1,4 4,5 0,1 1))", sqrt(2.0));
test_geometry<P, bg::linear_ring<P> >("POINT(3 1)", "POLYGON((1 1,4 4,5 0,1 1))", 0.0);
// other way round
test_geometry<bg::linear_ring<P>, P>("POLYGON((1 1,4 4,5 0,1 1))", "POINT(3 1)", 0.0);
// open ring
test_geometry<P, bg::linear_ring<P, std::vector, true, false> >("POINT(1 3)", "POLYGON((4 4,5 0,1 1))", sqrt(2.0));
// This one COMPILES but should THROW - because boost::array is not variably sized
//test_geometry<P, boost::array<P, 2> >("POINT(3 1)", "LINESTRING(1 1,4 4)", sqrt(2.0));
// Polygons
test_geometry<P, bg::polygon<P> >("POINT(1 3)", "POLYGON((1 1,4 4,5 0,1 1))", sqrt(2.0));
test_geometry<P, bg::polygon<P> >("POINT(3 1)", "POLYGON((1 1,4 4,5 0,1 1))", 0.0);
// other way round
test_geometry<bg::polygon<P>, P>("POLYGON((1 1,4 4,5 0,1 1))", "POINT(3 1)", 0.0);
// open polygon
test_geometry<P, bg::polygon<P, std::vector, std::vector, true, false> >("POINT(1 3)", "POLYGON((4 4,5 0,1 1))", sqrt(2.0));
// Polygons with holes
std::string donut = "POLYGON ((0 0,1 9,8 1,0 0),(1 1,4 1,1 4,1 1))";
test_geometry<P, bg::polygon<P> >("POINT(2 2)", donut, 0.5 * sqrt(2.0));
test_geometry<P, bg::polygon<P> >("POINT(3 3)", donut, 0.0);
// other way round
test_geometry<bg::polygon<P>, P>(donut, "POINT(2 2)", 0.5 * sqrt(2.0));
// open
test_geometry<P, bg::polygon<P, std::vector, std::vector, true, false> >("POINT(2 2)", "POLYGON ((0 0,1 9,8 1),(1 1,4 1,1 4))", 0.5 * sqrt(2.0));
// DOES NOT COMPILE - cannot do read_wkt (because boost::array is not variably sized)
// test_geometry<P, boost::array<P, 2> >("POINT(3 1)", "LINESTRING(1 1,4 4)", sqrt(2.0));
test_geometry<P, test::wrapped_boost_array<P, 2> >("POINT(3 1)", "LINESTRING(1 1,4 4)", sqrt(2.0));
}

View File

@ -17,6 +17,7 @@
#include <test_common/test_point.hpp>
#include <test_common/with_pointer.hpp>
#include <test_geometries/custom_segment.hpp>
@ -26,6 +27,7 @@ void test_all()
typedef boost::geometry::linestring<P> linestring;
typedef boost::geometry::polygon<P> polygon;
typedef boost::geometry::box<P> box;
typedef test::custom_segment_of<P> segment;
std::string clip = "box(2 2,8 8)";
@ -38,6 +40,10 @@ void test_all()
test_one<linestring, linestring, box>("llb", "LINESTRING(0 0,10 10)", clip, 1, 2, sqrt(2.0 * 6.0 * 6.0));
test_one<linestring, box, linestring>("lbl", clip, "LINESTRING(0 0,10 10)", 1, 2, sqrt(2.0 * 6.0 * 6.0));
// Box/segment
test_one<linestring, segment, box>("lsb", "LINESTRING(0 0,10 10)", clip, 1, 2, sqrt(2.0 * 6.0 * 6.0));
test_one<linestring, box, segment>("lbs", clip, "LINESTRING(0 0,10 10)", 1, 2, sqrt(2.0 * 6.0 * 6.0));
// Completely inside
test_one<linestring, linestring, box>("llbi", "LINESTRING(3 3,7 7)", clip, 1, 2, sqrt(2.0 * 4.0 * 4.0));

View File

@ -8,8 +8,10 @@
test-suite ggl-iterators
:
[ run box_iterator.cpp ]
[ run circular_iterator.cpp ]
[ run closing_iterator.cpp ]
[ run ever_circling_iterator.cpp ]
[ run segment_iterator.cpp ]
[ run segment_returning_iterator.cpp ]
[ run segment_range_iterator.cpp ]
;

View File

@ -2,6 +2,18 @@ Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ever_circling_closeable_reversible_iterator", "ever_circling_closeable_reversible_iterator.vcproj", "{8EC8E503-BCB9-4A58-AC33-D61B3B0C2EAF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ever_circling_iterator", "ever_circling_iterator.vcproj", "{73F8C969-FA1E-4D9D-81F9-35B1206F0C14}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "circular_iterator", "circular_iterator.vcproj", "{46571A34-B68D-4854-90C0-56D29EE63FFE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "closing_iterator", "closing_iterator.vcproj", "{04C31A2D-BE88-4FDB-AFFE-EFDFFA9D9C39}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "segment_range_iterator", "segment_range_iterator.vcproj", "{887E64C9-6786-44E2-AE09-B02B855486DE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "box_iterator", "box_iterator.vcproj", "{CD4B14B2-ED74-4111-B8BF-093FA3930A5C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "segment_returning_iterator", "segment_returning_iterator.vcproj", "{A38B1CA8-5194-4FAD-B85E-55697BEECCB7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -12,6 +24,30 @@ Global
{8EC8E503-BCB9-4A58-AC33-D61B3B0C2EAF}.Debug|Win32.Build.0 = Debug|Win32
{8EC8E503-BCB9-4A58-AC33-D61B3B0C2EAF}.Release|Win32.ActiveCfg = Release|Win32
{8EC8E503-BCB9-4A58-AC33-D61B3B0C2EAF}.Release|Win32.Build.0 = Release|Win32
{73F8C969-FA1E-4D9D-81F9-35B1206F0C14}.Debug|Win32.ActiveCfg = Debug|Win32
{73F8C969-FA1E-4D9D-81F9-35B1206F0C14}.Debug|Win32.Build.0 = Debug|Win32
{73F8C969-FA1E-4D9D-81F9-35B1206F0C14}.Release|Win32.ActiveCfg = Release|Win32
{73F8C969-FA1E-4D9D-81F9-35B1206F0C14}.Release|Win32.Build.0 = Release|Win32
{46571A34-B68D-4854-90C0-56D29EE63FFE}.Debug|Win32.ActiveCfg = Debug|Win32
{46571A34-B68D-4854-90C0-56D29EE63FFE}.Debug|Win32.Build.0 = Debug|Win32
{46571A34-B68D-4854-90C0-56D29EE63FFE}.Release|Win32.ActiveCfg = Release|Win32
{46571A34-B68D-4854-90C0-56D29EE63FFE}.Release|Win32.Build.0 = Release|Win32
{04C31A2D-BE88-4FDB-AFFE-EFDFFA9D9C39}.Debug|Win32.ActiveCfg = Debug|Win32
{04C31A2D-BE88-4FDB-AFFE-EFDFFA9D9C39}.Debug|Win32.Build.0 = Debug|Win32
{04C31A2D-BE88-4FDB-AFFE-EFDFFA9D9C39}.Release|Win32.ActiveCfg = Release|Win32
{04C31A2D-BE88-4FDB-AFFE-EFDFFA9D9C39}.Release|Win32.Build.0 = Release|Win32
{887E64C9-6786-44E2-AE09-B02B855486DE}.Debug|Win32.ActiveCfg = Debug|Win32
{887E64C9-6786-44E2-AE09-B02B855486DE}.Debug|Win32.Build.0 = Debug|Win32
{887E64C9-6786-44E2-AE09-B02B855486DE}.Release|Win32.ActiveCfg = Release|Win32
{887E64C9-6786-44E2-AE09-B02B855486DE}.Release|Win32.Build.0 = Release|Win32
{CD4B14B2-ED74-4111-B8BF-093FA3930A5C}.Debug|Win32.ActiveCfg = Debug|Win32
{CD4B14B2-ED74-4111-B8BF-093FA3930A5C}.Debug|Win32.Build.0 = Debug|Win32
{CD4B14B2-ED74-4111-B8BF-093FA3930A5C}.Release|Win32.ActiveCfg = Release|Win32
{CD4B14B2-ED74-4111-B8BF-093FA3930A5C}.Release|Win32.Build.0 = Release|Win32
{A38B1CA8-5194-4FAD-B85E-55697BEECCB7}.Debug|Win32.ActiveCfg = Debug|Win32
{A38B1CA8-5194-4FAD-B85E-55697BEECCB7}.Debug|Win32.Build.0 = Debug|Win32
{A38B1CA8-5194-4FAD-B85E-55697BEECCB7}.Release|Win32.ActiveCfg = Release|Win32
{A38B1CA8-5194-4FAD-B85E-55697BEECCB7}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,52 @@
// Boost.Geometry (aka GGL, Generic Segment 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)
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <geometry_test_common.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/geometries/cartesian2d.hpp>
#include <boost/geometry/iterators/segment_range_iterator.hpp>
#include <boost/geometry/extensions/gis/io/wkt/read_wkt.hpp>
#include <test_geometries/custom_segment.hpp>
template <typename Segment>
void test_geometry(std::string const& wkt, std::string const& expected)
{
Segment segment;
boost::geometry::read_wkt(wkt, segment);
std::ostringstream out;
boost::geometry::segment_range_iterator<Segment> it(segment), end(segment, true);
for ( ; it != end; ++it)
{
out << " " << boost::geometry::get<0>(*it) << boost::geometry::get<1>(*it);
}
BOOST_CHECK_EQUAL(out.str(), expected);
}
template <typename P>
void test_all()
{
test_geometry<test::custom_segment>("linestring(1 1,2 2)", " 11 22");
test_geometry<test::custom_segment>("linestring(4 4,3 3)", " 44 33");
}
int test_main(int, char* [])
{
test_all<boost::geometry::point_2d>();
return 0;
}

View File

@ -0,0 +1,176 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="segment_range_iterator"
ProjectGUID="{887E64C9-6786-44E2-AE09-B02B855486DE}"
RootNamespace="segment_range_iterator"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\segment_range_iterator"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../..;.."
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
ExceptionHandling="2"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
DebugInformationFormat="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\segment_range_iterator"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../..;.."
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
ExceptionHandling="2"
UsePrecompiledHeader="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\segment_range_iterator.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -19,7 +19,7 @@
#include <boost/geometry/geometries/cartesian2d.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/segment.hpp>
#include <boost/geometry/iterators/segment_iterator.hpp>
#include <boost/geometry/iterators/segment_returning_iterator.hpp>
#include <boost/geometry/extensions/gis/io/wkt/read_wkt.hpp>
template <typename C>
@ -28,8 +28,8 @@ void test_linestring(std::string const& wkt, std::string const& expected)
typedef C point_list;
typedef typename C::value_type point;
typedef typename C::iterator base_iterator;
typedef boost::geometry::segment_iterator<base_iterator, point> segment_iterator;
typedef typename segment_iterator::value_type segment;
typedef boost::geometry::segment_returning_iterator<base_iterator, point> segment_returning_iterator;
typedef typename segment_returning_iterator::value_type segment;
typedef boost::geometry::linestring<point> linestring;
linestring g;
@ -39,8 +39,8 @@ void test_linestring(std::string const& wkt, std::string const& expected)
std::copy(g.begin(), g.end(), std::back_insert_iterator<point_list>(v));
BOOST_CHECK_EQUAL(g.size(), v.size());
segment_iterator it(v.begin(), v.end());
segment_iterator end(v.end());
segment_returning_iterator it(v.begin(), v.end());
segment_returning_iterator end(v.end());
std::ostringstream oss;
while (it != end)

View File

@ -2,9 +2,9 @@
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="segment_iterator"
Name="segment_returning_iterator"
ProjectGUID="{A38B1CA8-5194-4FAD-B85E-55697BEECCB7}"
RootNamespace="segment_iterator"
RootNamespace="segment_returning_iterator"
Keyword="Win32Proj"
>
<Platforms>
@ -18,7 +18,7 @@
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\segment_iterator"
IntermediateDirectory="$(ConfigurationName)\segment_returning_iterator"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
@ -92,7 +92,7 @@
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\segment_iterator"
IntermediateDirectory="$(ConfigurationName)\segment_returning_iterator"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
@ -167,7 +167,7 @@
</References>
<Files>
<File
RelativePath=".\segment_iterator.cpp"
RelativePath=".\segment_returning_iterator.cpp"
>
</File>
</Files>

13
test/ranges/Jamfile.v2 Normal file
View File

@ -0,0 +1,13 @@
# test/iterators/Jamfile.v2
#
# Copyright (c) 2010 Barend Gehrels
#
# 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)
test-suite boost-geometry-ranges
:
[ run segment_range.cpp ]
[ run box_range.cpp ]
;

25
test/ranges/ranges.sln Normal file
View File

@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "segment_range", "segment_range.vcproj", "{B49AC3E2-3497-465B-88C2-BCADA4B4ADAF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "box_range", "box_range.vcproj", "{34A1F53A-DA46-41E6-9E26-740D22D662DC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B49AC3E2-3497-465B-88C2-BCADA4B4ADAF}.Debug|Win32.ActiveCfg = Debug|Win32
{B49AC3E2-3497-465B-88C2-BCADA4B4ADAF}.Debug|Win32.Build.0 = Debug|Win32
{B49AC3E2-3497-465B-88C2-BCADA4B4ADAF}.Release|Win32.ActiveCfg = Release|Win32
{B49AC3E2-3497-465B-88C2-BCADA4B4ADAF}.Release|Win32.Build.0 = Release|Win32
{34A1F53A-DA46-41E6-9E26-740D22D662DC}.Debug|Win32.ActiveCfg = Debug|Win32
{34A1F53A-DA46-41E6-9E26-740D22D662DC}.Debug|Win32.Build.0 = Debug|Win32
{34A1F53A-DA46-41E6-9E26-740D22D662DC}.Release|Win32.ActiveCfg = Release|Win32
{34A1F53A-DA46-41E6-9E26-740D22D662DC}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,70 @@
// Boost.Geometry (aka GGL, Generic Geometry Library) test file
//
// 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)
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <geometry_test_common.hpp>
#include <boost/geometry/geometries/cartesian2d.hpp>
#include <boost/geometry/ranges/segment_range.hpp>
#include <boost/geometry/extensions/gis/io/wkt/read_wkt.hpp>
#include <test_geometries/custom_segment.hpp>
template <typename Segment>
void test_geometry(std::string const& wkt, std::string const& expected)
{
namespace bg = boost::geometry;
Segment segment;
bg::read_wkt(wkt, segment);
typedef bg::segment_range<Segment> range_type;
range_type range(segment);
{
std::ostringstream out;
for (typename boost::range_iterator<range_type>::type it = boost::begin(range);
it != boost::end(range); ++it)
{
out << " " << boost::geometry::get<0>(*it) << boost::geometry::get<1>(*it);
}
BOOST_CHECK_EQUAL(out.str(), expected);
}
{
// Check forward/backward behaviour
std::ostringstream out;
typename boost::range_iterator<range_type>::type it = boost::begin(range);
it++;
it--;
out << " " << boost::geometry::get<0>(*it) << boost::geometry::get<1>(*it);
typename boost::range_iterator<range_type>::type it2 = boost::end(range);
it2--;
out << " " << boost::geometry::get<0>(*it2) << boost::geometry::get<1>(*it2);
BOOST_CHECK_EQUAL(out.str(), expected);
}
}
template <typename P>
void test_all()
{
test_geometry<test::custom_segment>("linestring(1 1,2 2)", " 11 22");
test_geometry<test::custom_segment>("linestring(4 4,3 3)", " 44 33");
}
int test_main(int, char* [])
{
test_all<boost::geometry::point_2d>();
return 0;
}

View File

@ -0,0 +1,178 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="segment_range"
ProjectGUID="{B49AC3E2-3497-465B-88C2-BCADA4B4ADAF}"
RootNamespace="segment_range"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\segment_range"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../..;.."
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
ExceptionHandling="2"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\segment_range"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../..;.."
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
ExceptionHandling="2"
UsePrecompiledHeader="0"
WarningLevel="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\segment_range.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>