[buffer] add empty side type

This commit is contained in:
Barend Gehrels 2022-06-08 16:25:25 +02:00
parent e5613cb8ad
commit 9f33365496
6 changed files with 24 additions and 4 deletions

View File

@ -291,7 +291,7 @@ struct buffer_range
robust_policy, strategies);
}
collection.add_side_piece(*prev, *it, generated_side, first);
collection.add_side_piece(*prev, *it, generated_side, first, distance_strategy.empty(side));
if (first && mark_flat)
{

View File

@ -917,12 +917,16 @@ struct buffered_piece_collection
template <typename Range>
inline void add_side_piece(point_type const& original_point1,
point_type const& original_point2,
Range const& range, bool first)
Range const& range, bool is_first, bool is_empty)
{
BOOST_GEOMETRY_ASSERT(boost::size(range) >= 2u);
piece& pc = create_piece(strategy::buffer::buffered_segment, ! first);
add_range_to_piece(pc, range, first);
auto const piece_type = is_empty
? strategy::buffer::buffered_empty_side
: strategy::buffer::buffered_segment;
piece& pc = create_piece(piece_type, ! is_first);
add_range_to_piece(pc, range, is_first);
// Add the four points of the side, starting with the last point of the
// range, and reversing the order of the originals to keep it clockwise

View File

@ -138,6 +138,11 @@ public:
return true;
}
if (piece.type == geometry::strategy::buffer::buffered_empty_side)
{
return false;
}
if (piece.type == geometry::strategy::buffer::buffered_point)
{
// Optimization for a buffer around points: if distance from center

View File

@ -76,6 +76,11 @@ public :
return m_left < 0 && m_right < 0;
}
inline bool empty(buffer_side_selector side) const
{
return side == buffer_side_left ? m_left == 0 : m_right == 0;
}
//! Returns the max distance distance up to the buffer will reach
template <typename JoinStrategy, typename EndStrategy>
inline NumericType max_distance(JoinStrategy const& join_strategy,

View File

@ -74,6 +74,11 @@ public :
return m_distance < 0;
}
inline bool empty(buffer_side_selector ) const
{
return m_distance == 0;
}
//! Returns the max distance distance up to the buffer will reach
template <typename JoinStrategy, typename EndStrategy>
inline NumericType max_distance(JoinStrategy const& join_strategy,

View File

@ -67,6 +67,7 @@ enum piece_type
buffered_flat_end,
buffered_point,
buffered_concave, // always on the inside
buffered_empty_side, // for one-sided buffers
piece_type_unknown
};