From ec017da3f0c621a7fcf08ca2aa8a5349bb6126cd Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 14 Oct 2015 12:57:46 +0200 Subject: [PATCH] [buffer] move same code fragments to finish_ring --- .../detail/buffer/buffer_inserter.hpp | 28 ++++--------------- .../buffer/buffered_piece_collection.hpp | 9 +++++- .../geometry/extensions/algorithms/offset.hpp | 2 +- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp b/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp index 0a6588ee1..6aca00084 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp @@ -392,7 +392,7 @@ inline void buffer_point(Point const& point, Collection& collection, point_strategy.apply(point, distance_strategy, range_out); collection.add_piece(strategy::buffer::buffered_point, range_out, false); collection.set_piece_center(point); - collection.finish_ring(); + collection.finish_ring(strategy::buffer::result_normal); } @@ -680,14 +680,7 @@ struct buffer_inserter distance, side_strategy, join_strategy, end_strategy, robust_policy, first_p1); } - if (code == strategy::buffer::result_error_numerical) - { - collection.abort_ring(); - } - else - { - collection.finish_ring(); - } + collection.finish_ring(code); } if (code == strategy::buffer::result_no_output && n >= 1) { @@ -747,12 +740,7 @@ private: join_strategy, end_strategy, point_strategy, robust_policy); - if (code == strategy::buffer::result_error_numerical) - { - collection.abort_ring(); - return; - } - collection.finish_ring(is_interior); + collection.finish_ring(code, is_interior); } } @@ -812,14 +800,8 @@ public: join_strategy, end_strategy, point_strategy, robust_policy); - if (code == strategy::buffer::result_error_numerical) - { - collection.abort_ring(); - } - else - { - collection.finish_ring(false, geometry::num_interior_rings(polygon) > 0u); - } + collection.finish_ring(code, false, + geometry::num_interior_rings(polygon) > 0u); } apply_interior_rings(interior_rings(polygon), 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 545d89cb9..dd64261b0 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp @@ -860,8 +860,15 @@ struct buffered_piece_collection m_robust_policy); } - inline void finish_ring(bool is_interior = false, bool has_interiors = false) + inline void finish_ring(strategy::buffer::result_code code, + bool is_interior = false, bool has_interiors = false) { + if (code == strategy::buffer::result_error_numerical) + { + abort_ring(); + return; + } + if (m_first_piece_index == -1) { return; diff --git a/include/boost/geometry/extensions/algorithms/offset.hpp b/include/boost/geometry/extensions/algorithms/offset.hpp index ec8943d2a..525b7c44c 100644 --- a/include/boost/geometry/extensions/algorithms/offset.hpp +++ b/include/boost/geometry/extensions/algorithms/offset.hpp @@ -81,7 +81,7 @@ struct offset_range distance_strategy, side_strategy, join_strategy, end_strategy, robust_policy, first_p1, first_p2, last_p1, last_p2); } - collection.finish_ring(); + collection.finish_ring(strategy::buffer::result_normal); } };