From fdd983ce72fa32cfb302f6bf3bffb422c4e9c7fe Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Fri, 13 Jun 2014 21:30:53 +0200 Subject: [PATCH] [buffer] Changes in (folder)locations of strategies, and moved buffer_side_selector and piece_type used by strategies. --- .../detail/buffer/buffer_inserter.hpp | 30 +++++++++---------- .../detail/buffer/buffer_policies.hpp | 4 +-- .../buffer/buffered_piece_collection.hpp | 20 ++++++------- .../buffered_piece_collection_with_mapper.hpp | 2 +- .../detail/buffer/buffered_ring.hpp | 2 +- .../detail/buffer/turn_in_piece_visitor.hpp | 3 +- .../agnostic/buffer_distance_asymmetric.hpp | 8 ++--- .../agnostic/buffer_distance_symmetric.hpp | 8 ++--- .../strategies/agnostic/buffer_end_skip.hpp | 8 ++--- .../strategies/agnostic/buffer_side.hpp | 27 ----------------- .../strategies/{agnostic => }/buffer.hpp | 28 ++++++++++++----- .../buffer_end_flat.hpp | 2 +- .../buffer_end_round.hpp | 2 +- .../buffer_join_miter.hpp | 2 +- .../buffer_join_round.hpp | 14 +++++---- .../buffer_join_round_by_divide.hpp | 14 +++++---- .../boost/geometry/strategies/strategies.hpp | 9 ++++++ test/algorithms/buffer/test_buffer.hpp | 10 +------ 18 files changed, 93 insertions(+), 100 deletions(-) delete mode 100644 include/boost/geometry/strategies/agnostic/buffer_side.hpp rename include/boost/geometry/strategies/{agnostic => }/buffer.hpp (67%) rename include/boost/geometry/strategies/{agnostic => cartesian}/buffer_end_flat.hpp (97%) rename include/boost/geometry/strategies/{agnostic => cartesian}/buffer_end_round.hpp (98%) rename include/boost/geometry/strategies/{agnostic => cartesian}/buffer_join_miter.hpp (97%) rename include/boost/geometry/strategies/{agnostic => cartesian}/buffer_join_round.hpp (95%) rename include/boost/geometry/strategies/{agnostic => cartesian}/buffer_join_round_by_divide.hpp (95%) diff --git a/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp b/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp index 7b757b8a1..532bc3a5c 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include @@ -54,7 +54,7 @@ struct buffer_range typename DistanceStrategy > static inline void generate_side(Point const& ip1, Point const& ip2, - buffer_side_selector side, + strategy::buffer::buffer_side_selector side, DistanceStrategy const& distance, output_point_type& p1, output_point_type& p2) { @@ -93,7 +93,7 @@ struct buffer_range > static inline void iterate(Collection& collection, Iterator begin, Iterator end, - buffer_side_selector side, + strategy::buffer::buffer_side_selector side, DistanceStrategy const& distance, JoinStrategy const& join_strategy, EndStrategy const& end_strategy, @@ -142,10 +142,10 @@ struct buffer_range } if (! range_out.empty()) { - collection.add_piece(buffered_join, *prev, range_out); + collection.add_piece(strategy::buffer::buffered_join, *prev, range_out); range_out.clear(); } - collection.add_piece(buffered_segment, *prev, *it, p1, p2); + collection.add_piece(strategy::buffer::buffered_segment, *prev, *it, p1, p2); previous_p1 = p1; previous_p2 = p2; @@ -170,7 +170,7 @@ struct buffer_range range_out); if (! range_out.empty()) { - collection.add_piece(buffered_join, *begin, range_out); + collection.add_piece(strategy::buffer::buffered_join, *begin, range_out); } } @@ -184,9 +184,9 @@ struct buffer_range // TODO fix this (approach) for one-side buffer (1.5 - -1.0) output_point_type rp1, rp2; generate_side(ultimate_point, penultimate_point, - side == buffer_side_left - ? buffer_side_right - : buffer_side_left, + side == strategy::buffer::buffer_side_left + ? strategy::buffer::buffer_side_right + : strategy::buffer::buffer_side_left, distance, rp2, rp1); std::vector range_out; @@ -269,10 +269,10 @@ struct buffer_point //RingOutput range_out; generate_points(point, - distance.apply(point, point, buffer_side_left), + distance.apply(point, point, strategy::buffer::buffer_side_left), range_out); - collection.add_piece(buffered_circle, range_out, false); + collection.add_piece(strategy::buffer::buffered_circle, range_out, false); //std::cout << std::setprecision(20); //std::cout << geometry::wkt(range_out) << std::endl; @@ -355,13 +355,13 @@ struct buffer_inserter // It might be that this will be changed later. // TODO: decide this. base::iterate(collection, boost::rbegin(ring), boost::rend(ring), - buffer_side_right, + strategy::buffer::buffer_side_right, distance, join_strategy, end_strategy); } else { base::iterate(collection, boost::begin(ring), boost::end(ring), - buffer_side_left, + strategy::buffer::buffer_side_left, distance, join_strategy, end_strategy); } } @@ -397,11 +397,11 @@ struct buffer_inserter { collection.start_new_ring(); base::iterate(collection, boost::begin(linestring), boost::end(linestring), - buffer_side_left, + strategy::buffer::buffer_side_left, distance, join_strategy, end_strategy); base::iterate(collection, boost::rbegin(linestring), boost::rend(linestring), - buffer_side_right, + strategy::buffer::buffer_side_right, distance, join_strategy, end_strategy, true); } diff --git a/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp b/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp index 34ce05d38..1bb4b0c05 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp @@ -18,12 +18,10 @@ #include #include -#include - #include #include - +#include namespace boost { namespace geometry diff --git a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp index ff4a8bc03..312e15b8d 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include @@ -161,7 +161,7 @@ struct buffered_piece_collection struct piece { - piece_type type; + strategy::buffer::piece_type type; int index; // The next two members form together a complete clockwise ring @@ -636,7 +636,7 @@ struct buffered_piece_collection //------------------------------------------------------------------------- - inline piece& add_piece(piece_type type, bool decrease_segment_index_by_one) + inline piece& add_piece(strategy::buffer::piece_type type, bool decrease_segment_index_by_one) { piece pc; pc.type = type; @@ -650,15 +650,15 @@ struct buffered_piece_collection return m_pieces.back(); } - inline void add_piece(piece_type type, point_type const& p1, point_type const& p2, + inline void add_piece(strategy::buffer::piece_type type, point_type const& p1, point_type const& p2, point_type const& b1, point_type const& b2) { // If the last type was a join, the segment_id of next segment should be decreased by one. bool const last_type_join = ! m_pieces.empty() && m_pieces.back().first_seg_id.multi_index == current_segment_id.multi_index && ( - m_pieces.back().type == buffered_join - || m_pieces.back().type == buffered_round_end + m_pieces.back().type == strategy::buffer::buffered_join + || m_pieces.back().type == strategy::buffer::buffered_round_end ); piece& pc = add_piece(type, last_type_join); @@ -679,7 +679,7 @@ struct buffered_piece_collection } template - inline piece& add_piece(piece_type type, Range const& range, bool decrease_segment_index_by_one) + inline piece& add_piece(strategy::buffer::piece_type type, Range const& range, bool decrease_segment_index_by_one) { piece& pc = add_piece(type, decrease_segment_index_by_one); @@ -709,7 +709,7 @@ struct buffered_piece_collection } template - inline void add_piece(piece_type type, point_type const& p, Range const& range) + inline void add_piece(strategy::buffer::piece_type type, point_type const& p, Range const& range) { piece& pc = add_piece(type, range, true); @@ -724,8 +724,8 @@ struct buffered_piece_collection template inline void add_endcap(EndcapStrategy const& strategy, Range const& range, point_type const& end_point) { - piece_type pt = strategy.get_piece_type(); - if (pt == buffered_flat_end) + strategy::buffer::piece_type pt = strategy.get_piece_type(); + if (pt == strategy::buffer::buffered_flat_end) { // It is flat, should just be added, without helper segments add_piece(pt, range, true); diff --git a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection_with_mapper.hpp b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection_with_mapper.hpp index 1e70d669d..aca32367e 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection_with_mapper.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection_with_mapper.hpp @@ -192,7 +192,7 @@ struct buffered_piece_collection_with_mapper if (pieces && ! corner.empty()) { - if (it->type == buffered_segment) + if (it->type == strategy::buffer::buffered_segment) { if(boost::is_same::value || boost::is_same::value) { diff --git a/include/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp b/include/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp index 9efc08c46..03ec598c9 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include diff --git a/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp b/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp index 1953744df..057c63624 100644 --- a/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp @@ -16,6 +16,7 @@ #include #include #include +#include namespace boost { namespace geometry { @@ -119,7 +120,7 @@ public: return; } - if (piece.type == buffered_flat_end) + if (piece.type == strategy::buffer::buffered_flat_end) { // Turns cannot be inside a flat end (though they can be on border) return; diff --git a/include/boost/geometry/strategies/agnostic/buffer_distance_asymmetric.hpp b/include/boost/geometry/strategies/agnostic/buffer_distance_asymmetric.hpp index c88fa1127..204a97324 100644 --- a/include/boost/geometry/strategies/agnostic/buffer_distance_asymmetric.hpp +++ b/include/boost/geometry/strategies/agnostic/buffer_distance_asymmetric.hpp @@ -6,10 +6,10 @@ // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_DISTANCE_ASYMMETRIC_HPP -#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_DISTANCE_ASYMMETRIC_HPP +#ifndef BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_ASYMMETRIC_HPP +#define BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_ASYMMETRIC_HPP -#include +#include namespace boost { namespace geometry @@ -58,4 +58,4 @@ private : }} // namespace boost::geometry -#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_DISTANCE_ASYMMETRIC_HPP +#endif // BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_ASYMMETRIC_HPP diff --git a/include/boost/geometry/strategies/agnostic/buffer_distance_symmetric.hpp b/include/boost/geometry/strategies/agnostic/buffer_distance_symmetric.hpp index 5100728e6..8a830e3a5 100644 --- a/include/boost/geometry/strategies/agnostic/buffer_distance_symmetric.hpp +++ b/include/boost/geometry/strategies/agnostic/buffer_distance_symmetric.hpp @@ -6,10 +6,10 @@ // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_DISTANCE_SYMMETRIC_HPP -#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_DISTANCE_SYMMETRIC_HPP +#ifndef BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_SYMMETRIC_HPP +#define BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_SYMMETRIC_HPP -#include +#include namespace boost { namespace geometry @@ -54,4 +54,4 @@ private : }} // namespace boost::geometry -#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_DISTANCE_SYMMETRIC_HPP +#endif // BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_SYMMETRIC_HPP diff --git a/include/boost/geometry/strategies/agnostic/buffer_end_skip.hpp b/include/boost/geometry/strategies/agnostic/buffer_end_skip.hpp index dd6fdbfe4..798980194 100644 --- a/include/boost/geometry/strategies/agnostic/buffer_end_skip.hpp +++ b/include/boost/geometry/strategies/agnostic/buffer_end_skip.hpp @@ -6,10 +6,10 @@ // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_END_SKIP_HPP -#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_END_SKIP_HPP +#ifndef BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_END_SKIP_HPP +#define BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_END_SKIP_HPP -#include +#include namespace boost { namespace geometry @@ -51,4 +51,4 @@ public : }} // namespace boost::geometry -#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_END_SKIP_HPP +#endif // BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_END_SKIP_HPP diff --git a/include/boost/geometry/strategies/agnostic/buffer_side.hpp b/include/boost/geometry/strategies/agnostic/buffer_side.hpp deleted file mode 100644 index 187e91a76..000000000 --- a/include/boost/geometry/strategies/agnostic/buffer_side.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) - -// Copyright (c) 2012-2014 Barend Gehrels, 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_STRATEGIES_CARTESIAN_BUFFER_SIDE_HPP -#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_SIDE_HPP - -namespace boost { namespace geometry -{ - -// TODO: consider if this enum can be placed in another headerfile -// or probably there will be more enum's or constants for the buffer -enum buffer_side_selector { buffer_side_left, buffer_side_right }; - -// Piece type, temporary here, might be reloaced TODO decid this -enum piece_type -{ - buffered_segment, buffered_join, buffered_round_end, buffered_flat_end, buffered_circle -}; - -}} // namespace boost::geometry - -#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_SIDE_HPP diff --git a/include/boost/geometry/strategies/agnostic/buffer.hpp b/include/boost/geometry/strategies/buffer.hpp similarity index 67% rename from include/boost/geometry/strategies/agnostic/buffer.hpp rename to include/boost/geometry/strategies/buffer.hpp index d45b4c10b..5de08eab7 100644 --- a/include/boost/geometry/strategies/agnostic/buffer.hpp +++ b/include/boost/geometry/strategies/buffer.hpp @@ -9,14 +9,6 @@ #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_HPP #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_HPP -#include -#include -#include -#include -#include -#include - - namespace boost { namespace geometry { @@ -52,6 +44,26 @@ namespace strategy { namespace buffer +/*! +\brief Enumerates options for side of buffer (left/right w.r.t. directed + segment) +\ingroup enum +\details Around a linestring, a buffer can be defined left or right. + Around a polygon, assumed clockwise internally, + a buffer is either on the left side (inflates the polygon), or on the + right side (deflates the polygon) +*/ +enum buffer_side_selector { buffer_side_left, buffer_side_right }; + +/*! +\brief Enumerates types of pieces (parts of buffer) around geometries +\ingroup enum +*/ +enum piece_type +{ + buffered_segment, buffered_join, buffered_round_end, buffered_flat_end, buffered_circle +}; + }} // namespace strategy::buffer diff --git a/include/boost/geometry/strategies/agnostic/buffer_end_flat.hpp b/include/boost/geometry/strategies/cartesian/buffer_end_flat.hpp similarity index 97% rename from include/boost/geometry/strategies/agnostic/buffer_end_flat.hpp rename to include/boost/geometry/strategies/cartesian/buffer_end_flat.hpp index 00dcc57c9..871902c5f 100644 --- a/include/boost/geometry/strategies/agnostic/buffer_end_flat.hpp +++ b/include/boost/geometry/strategies/cartesian/buffer_end_flat.hpp @@ -15,7 +15,7 @@ #include #include -#include +#include diff --git a/include/boost/geometry/strategies/agnostic/buffer_end_round.hpp b/include/boost/geometry/strategies/cartesian/buffer_end_round.hpp similarity index 98% rename from include/boost/geometry/strategies/agnostic/buffer_end_round.hpp rename to include/boost/geometry/strategies/cartesian/buffer_end_round.hpp index ed9926601..b89f07b49 100644 --- a/include/boost/geometry/strategies/agnostic/buffer_end_round.hpp +++ b/include/boost/geometry/strategies/cartesian/buffer_end_round.hpp @@ -15,7 +15,7 @@ #include #include -#include +#include diff --git a/include/boost/geometry/strategies/agnostic/buffer_join_miter.hpp b/include/boost/geometry/strategies/cartesian/buffer_join_miter.hpp similarity index 97% rename from include/boost/geometry/strategies/agnostic/buffer_join_miter.hpp rename to include/boost/geometry/strategies/cartesian/buffer_join_miter.hpp index 4f14c46cf..ffbb8cd03 100644 --- a/include/boost/geometry/strategies/agnostic/buffer_join_miter.hpp +++ b/include/boost/geometry/strategies/cartesian/buffer_join_miter.hpp @@ -15,7 +15,7 @@ #include #include -#include +#include namespace boost { namespace geometry diff --git a/include/boost/geometry/strategies/agnostic/buffer_join_round.hpp b/include/boost/geometry/strategies/cartesian/buffer_join_round.hpp similarity index 95% rename from include/boost/geometry/strategies/agnostic/buffer_join_round.hpp rename to include/boost/geometry/strategies/cartesian/buffer_join_round.hpp index 00f8d68e6..9c04a1abd 100644 --- a/include/boost/geometry/strategies/agnostic/buffer_join_round.hpp +++ b/include/boost/geometry/strategies/cartesian/buffer_join_round.hpp @@ -10,14 +10,13 @@ #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_JOIN_ROUND_HPP #include +#include +#include #include #include #include #include -#include - - namespace boost { namespace geometry { @@ -32,8 +31,13 @@ template typename PointIn, typename PointOut > -struct join_round +class join_round { +private : + geometry::equal_to equals; + +public : + inline join_round(int steps_per_circle = 100) : m_steps_per_circle(steps_per_circle) {} @@ -107,7 +111,7 @@ struct join_round coordinate_type const& buffer_distance, RangeOut& range_out) const { - if (geometry::equals(perp1, perp2)) + if (equals(perp1, perp2)) { //std::cout << "Corner for equal points " << geometry::wkt(ip) << " " << geometry::wkt(perp1) << std::endl; return; diff --git a/include/boost/geometry/strategies/agnostic/buffer_join_round_by_divide.hpp b/include/boost/geometry/strategies/cartesian/buffer_join_round_by_divide.hpp similarity index 95% rename from include/boost/geometry/strategies/agnostic/buffer_join_round_by_divide.hpp rename to include/boost/geometry/strategies/cartesian/buffer_join_round_by_divide.hpp index 88cee5fcc..0326f8ade 100644 --- a/include/boost/geometry/strategies/agnostic/buffer_join_round_by_divide.hpp +++ b/include/boost/geometry/strategies/cartesian/buffer_join_round_by_divide.hpp @@ -10,14 +10,13 @@ #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_JOIN_ROUND_BY_DIVIDE_HPP #include +#include +#include #include #include #include #include -#include - - namespace boost { namespace geometry { @@ -32,8 +31,13 @@ template typename PointIn, typename PointOut > -struct join_round_by_divide +class join_round_by_divide { +private : + geometry::equal_to equals; + +public : + inline join_round_by_divide(int max_level = 4) : m_max_level(max_level) {} @@ -98,7 +102,7 @@ struct join_round_by_divide coordinate_type const& buffer_distance, RangeOut& range_out) const { - if (geometry::equals(perp1, perp2)) + if (equals(perp1, perp2)) { //std::cout << "Corner for equal points " << geometry::wkt(ip) << " " << geometry::wkt(perp1) << std::endl; return; diff --git a/include/boost/geometry/strategies/strategies.hpp b/include/boost/geometry/strategies/strategies.hpp index 321df8808..a90045978 100644 --- a/include/boost/geometry/strategies/strategies.hpp +++ b/include/boost/geometry/strategies/strategies.hpp @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -34,6 +35,11 @@ #include #include +#include +#include +#include +#include +#include #include #include #include @@ -53,6 +59,9 @@ #include #include +#include +#include +#include #include #include #include diff --git a/test/algorithms/buffer/test_buffer.hpp b/test/algorithms/buffer/test_buffer.hpp index d8e174f4c..7c810f3a7 100644 --- a/test/algorithms/buffer/test_buffer.hpp +++ b/test/algorithms/buffer/test_buffer.hpp @@ -36,15 +36,7 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include