From 14059a2c69d04cad8a5aac81c5603009d92a329b Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 22 Apr 2020 12:36:40 +0200 Subject: [PATCH] [buffer] remove rescaling from the turn-in-original check --- .../detail/buffer/buffer_policies.hpp | 7 +- .../buffer/buffered_piece_collection.hpp | 66 ++++++------------- .../buffer/turn_in_original_visitor.hpp | 13 ++-- 3 files changed, 31 insertions(+), 55 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp b/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp index 4d071dc1d..6e10bc3bd 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp @@ -139,8 +139,8 @@ struct buffer_turn_operation {} }; -// Version for buffer including type of location, is_opposite, and helper variables -template +// Version of turn_info for buffer with its turn index and other helper variables +template struct buffer_turn_info : public detail::overlay::turn_info < @@ -153,9 +153,6 @@ struct buffer_turn_info std::size_t turn_index; - // Still necessary for turn-in-original calculations - RobustPoint robust_point; - // Information if turn can be used. It is not traversable if it is within // another piece, or within the original (depending on deflation), // or (for deflate) if there are not enough points to traverse it. 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 8bc7e370f..438921be5 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp @@ -123,16 +123,11 @@ struct buffered_piece_collection { typedef typename geometry::point_type::type point_type; typedef typename geometry::coordinate_type::type coordinate_type; - typedef typename geometry::robust_point_type - < - point_type, - RobustPolicy - >::type robust_point_type; // Robust ring/polygon type, always clockwise - typedef geometry::model::ring robust_ring_type; + typedef geometry::model::ring clockwise_ring_type; - typedef geometry::model::box normal_box_type; + typedef geometry::model::box box_type; typedef typename IntersectionStrategy::side_strategy_type side_strategy_type; typedef typename IntersectionStrategy::envelope_strategy_type envelope_strategy_type; @@ -150,32 +145,21 @@ struct buffered_piece_collection typedef typename IntersectionStrategy::template point_in_geometry_strategy < - robust_point_type, - robust_ring_type + point_type, + clockwise_ring_type >::type point_in_geometry_strategy_type; - typedef typename geometry::rescale_policy_type - < - typename geometry::point_type::type, - typename IntersectionStrategy::cs_tag - >::type rescale_policy_type; - - typedef geometry::segment_ratio - < - typename geometry::coordinate_type::type - > ratio_type; typedef buffer_turn_info < point_type, - robust_point_type, - ratio_type + typename segment_ratio_type::type > buffer_turn_info_type; typedef buffer_turn_operation < point_type, - ratio_type + typename segment_ratio_type::type > buffer_turn_operation_type; typedef std::vector turn_vector_type; @@ -237,8 +221,7 @@ struct buffered_piece_collection struct original_ring { - typedef geometry::model::box robust_box_type; - typedef geometry::sections sections_type; + typedef geometry::sections sections_type; // Creates an empty instance inline original_ring() @@ -246,7 +229,7 @@ struct buffered_piece_collection , m_has_interiors(false) {} - inline original_ring(robust_ring_type const& ring, + inline original_ring(clockwise_ring_type const& ring, bool is_interior, bool has_interiors, envelope_strategy_type const& envelope_strategy, expand_strategy_type const& expand_strategy) @@ -266,8 +249,8 @@ struct buffered_piece_collection envelope_strategy, expand_strategy); } - robust_ring_type m_ring; - robust_box_type m_box; + clockwise_ring_type m_ring; + box_type m_box; sections_type m_sections; bool m_is_interior; @@ -293,7 +276,7 @@ struct buffered_piece_collection // Specificly for offsetted rings around points // but also for large joins with many points - typedef geometry::sections sections_type; + typedef geometry::sections sections_type; sections_type monotonic_sections; // Define the clusters, mapping cluster_id -> turns @@ -329,8 +312,7 @@ struct buffered_piece_collection , m_envelope_strategy(intersection_strategy.get_envelope_strategy()) , m_expand_strategy(intersection_strategy.get_expand_strategy()) , m_point_in_geometry_strategy(intersection_strategy - .template get_point_in_geometry_strategy()) + .template get_point_in_geometry_strategy()) , m_robust_policy(robust_policy) {} @@ -496,7 +478,7 @@ struct buffered_piece_collection geometry::partition < - normal_box_type, + box_type, include_turn_policy, detail::partition::include_all_policy >::apply(m_turns, original_rings, visitor, @@ -534,9 +516,6 @@ struct buffered_piece_collection { buffer_turn_info_type& turn = *it; - // Calculate rescaled turn points - geometry::recalculate(turn.robust_point, turn.point, m_robust_policy); - // Update member used turn.turn_index = index; @@ -612,7 +591,7 @@ struct buffered_piece_collection m_envelope_strategy); geometry::partition < - normal_box_type + box_type >::apply(monotonic_sections, visitor, get_section_box_type(), overlaps_section_box_type()); @@ -639,7 +618,7 @@ struct buffered_piece_collection geometry::partition < - normal_box_type + box_type >::apply(m_turns, m_pieces, visitor, turn_get_box(), turn_ovelaps_box_type(), piece_get_box(), piece_ovelaps_box_type()); @@ -771,7 +750,7 @@ struct buffered_piece_collection // For rescaling, it is recalculated. Without rescaling, it // is just assigning (note that this Ring type is the // GeometryOut type, which might differ from the input ring type) - geometry::model::ring adapted_ring; + clockwise_ring_type clockwise_ring; typedef detail::normalized_view view_type; view_type const view(input_ring); @@ -779,13 +758,11 @@ struct buffered_piece_collection for (typename boost::range_iterator::type it = boost::begin(view); it != boost::end(view); ++it) { - robust_point_type adapted_point; - geometry::recalculate(adapted_point, *it, m_robust_policy); - adapted_ring.push_back(adapted_point); + clockwise_ring.push_back(*it); } original_rings.back() - = original_ring(adapted_ring, + = original_ring(clockwise_ring, is_interior, has_interiors, m_envelope_strategy, m_expand_strategy); } @@ -1085,9 +1062,6 @@ struct buffered_piece_collection { typedef typename IntersectionStrategy::disjoint_point_box_strategy_type d_pb_strategy_type; - robust_point_type any_point; - geometry::recalculate(any_point, point, m_robust_policy); - signed_size_type count_in_original = 0; // Check of the robust point of this outputted ring is in @@ -1104,7 +1078,7 @@ struct buffered_piece_collection { continue; } - if (detail::disjoint::disjoint_point_box(any_point, + if (detail::disjoint::disjoint_point_box(point, original.m_box, d_pb_strategy_type())) { @@ -1112,7 +1086,7 @@ struct buffered_piece_collection } int const geometry_code - = detail::within::point_in_geometry(any_point, + = detail::within::point_in_geometry(point, original.m_ring, m_point_in_geometry_strategy); if (geometry_code == -1) diff --git a/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp b/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp index 4e20f9662..ab9ab08da 100644 --- a/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp @@ -35,7 +35,12 @@ struct original_get_box template static inline void apply(Box& total, Original const& original) { - geometry::expand(total, original.m_box); + typedef typename strategy::expand::services::default_strategy + < + box_tag, typename cs_tag::type + >::type expand_strategy_type; + + geometry::expand(total, original.m_box, expand_strategy_type()); } }; @@ -72,7 +77,7 @@ struct turn_in_original_ovelaps_box } return ! geometry::detail::disjoint::disjoint_point_box( - turn.robust_point, box, DisjointPointBoxStrategy()); + turn.point, box, DisjointPointBoxStrategy()); } }; @@ -226,13 +231,13 @@ public: return true; } - if (geometry::disjoint(turn.robust_point, original.m_box)) + if (geometry::disjoint(turn.point, original.m_box)) { // Skip all disjoint return true; } - int const code = point_in_original(turn.robust_point, original, m_point_in_geometry_strategy); + int const code = point_in_original(turn.point, original, m_point_in_geometry_strategy); if (code == -1) {