|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r71861 - in trunk: boost/geometry/views libs/geometry/test/views
From: barend.gehrels_at_[hidden]
Date: 2011-05-10 13:26:00
Author: barendgehrels
Date: 2011-05-10 13:26:00 EDT (Tue, 10 May 2011)
New Revision: 71861
URL: http://svn.boost.org/trac/boost/changeset/71861
Log:
Fixed box_view copy, added order traits function and corresponding unit test
Text files modified:
trunk/boost/geometry/views/box_view.hpp | 27 +++++++++++++++++++++------
trunk/boost/geometry/views/segment_view.hpp | 14 ++++++++------
trunk/libs/geometry/test/views/box_view.cpp | 23 ++++++++++++++---------
3 files changed, 43 insertions(+), 21 deletions(-)
Modified: trunk/boost/geometry/views/box_view.hpp
==============================================================================
--- trunk/boost/geometry/views/box_view.hpp (original)
+++ trunk/boost/geometry/views/box_view.hpp 2011-05-10 13:26:00 EDT (Tue, 10 May 2011)
@@ -72,7 +72,7 @@
points[4] = points[0];
}
private :
- Box m_box;
+ Box const& m_box;
};
};
@@ -83,11 +83,26 @@
// 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, 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
Modified: trunk/boost/geometry/views/segment_view.hpp
==============================================================================
--- trunk/boost/geometry/views/segment_view.hpp (original)
+++ trunk/boost/geometry/views/segment_view.hpp 2011-05-10 13:26:00 EDT (Tue, 10 May 2011)
@@ -71,7 +71,7 @@
geometry::detail::assign_point_from_index<1>(m_segment, points[1]);
}
private :
- Segment m_segment;
+ Segment const& m_segment;
};
};
@@ -82,11 +82,13 @@
// All segment ranges can be handled as linestrings
namespace traits
{
- template<typename Segment>
- struct tag<segment_view<Segment> >
- {
- typedef linestring_tag type;
- };
+
+template<typename Segment>
+struct tag<segment_view<Segment> >
+{
+ typedef linestring_tag type;
+};
+
}
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
Modified: trunk/libs/geometry/test/views/box_view.cpp
==============================================================================
--- trunk/libs/geometry/test/views/box_view.cpp (original)
+++ trunk/libs/geometry/test/views/box_view.cpp 2011-05-10 13:26:00 EDT (Tue, 10 May 2011)
@@ -22,18 +22,19 @@
template <typename Box, bool Reverse>
-void test_geometry(std::string const& wkt, std::string const& expected)
+void test_geometry(std::string const& wkt, std::string const& expected,
+ bg::order_selector expected_order)
{
Box box;
bg::read_wkt(wkt, box);
- typedef bg::box_view<Box, Reverse> range_type;
- range_type range(box);
+ typedef bg::box_view<Box, Reverse> view_type;
+ view_type range(box);
{
std::ostringstream out;
- for (typename boost::range_iterator<range_type>::type it = boost::begin(range);
+ for (typename boost::range_iterator<view_type>::type it = boost::begin(range);
it != boost::end(range); ++it)
{
out << " " << bg::get<0>(*it) << bg::get<1>(*it);
@@ -43,7 +44,7 @@
{
// Check forward/backward behaviour
- typename boost::range_iterator<range_type>::type it = boost::begin(range);
+ typename boost::range_iterator<view_type>::type it = boost::begin(range);
it++;
it--;
// Not verified further, same as segment
@@ -56,16 +57,20 @@
}
// Check Boost.Range concept
- BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<range_type>) );
+ BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<view_type>) );
+
+ // Check order
+ bg::order_selector order = bg::point_order<view_type>::value;
+ BOOST_CHECK_EQUAL(order, expected_order);
}
template <typename P>
void test_all()
{
- test_geometry<bg::model::box<P>, true> ("polygon((1 1,2 2))", " 11 12 22 21 11");
- test_geometry<bg::model::box<P>, false>("polygon((1 1,2 2))", " 11 21 22 12 11");
- test_geometry<bg::model::box<P>, true> ("polygon((3 3,5 5))", " 33 35 55 53 33");
+ test_geometry<bg::model::box<P>, true> ("polygon((1 1,2 2))", " 11 12 22 21 11", bg::clockwise);
+ test_geometry<bg::model::box<P>, false>("polygon((1 1,2 2))", " 11 21 22 12 11", bg::counterclockwise);
+ test_geometry<bg::model::box<P>, true> ("polygon((3 3,5 5))", " 33 35 55 53 33", bg::clockwise);
}
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