[buffer] Replace int with signed_index_type.

This commit is contained in:
Adam Wulkiewicz
2015-06-05 13:44:37 +02:00
parent 3cc4ef17ca
commit 06c06dab25
4 changed files with 47 additions and 45 deletions

View File

@@ -82,8 +82,8 @@ template <typename Point, typename SegmentRatio>
struct buffer_turn_operation
: public detail::overlay::traversal_turn_operation<Point, SegmentRatio>
{
int piece_index;
int index_in_robust_ring;
signed_index_type piece_index;
signed_index_type index_in_robust_ring;
inline buffer_turn_operation()
: piece_index(-1)
@@ -104,7 +104,7 @@ struct buffer_turn_info
typedef Point point_type;
typedef RobustPoint robust_point_type;
int turn_index; // TODO: this might go if partition can operate on non-const input
signed_index_type turn_index; // TODO: this might go if partition can operate on non-const input
RobustPoint robust_point;
#if defined(BOOST_GEOMETRY_BUFFER_ENLARGED_CLUSTERS)
@@ -127,23 +127,23 @@ struct buffer_turn_info
robust_point_type rob_pi, rob_pj, rob_qi, rob_qj;
#endif
int count_within;
signed_index_type count_within;
bool within_original;
int count_on_original_boundary;
int count_in_original; // increased by +1 for in ext.ring, -1 for int.ring
signed_index_type count_on_original_boundary;
signed_index_type count_in_original; // increased by +1 for in ext.ring, -1 for int.ring
int count_on_offsetted;
int count_on_helper;
signed_index_type count_on_offsetted;
signed_index_type count_on_helper;
#if ! defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
int count_within_near_offsetted;
signed_index_type count_within_near_offsetted;
#endif
bool remove_on_multi;
// Obsolete:
int count_on_occupied;
int count_on_multi;
signed_index_type count_on_occupied;
signed_index_type count_on_multi;
inline buffer_turn_info()
: turn_index(-1)

View File

@@ -167,7 +167,7 @@ struct buffered_piece_collection
struct robust_turn
{
int turn_index;
signed_index_type turn_index;
int operation_index;
robust_point_type point;
segment_identifier seg_id;
@@ -180,10 +180,10 @@ struct buffered_piece_collection
typedef geometry::section<robust_box_type, 1> section_type;
strategy::buffer::piece_type type;
int index;
signed_index_type index;
int left_index; // points to previous piece of same ring
int right_index; // points to next piece of same ring
signed_index_type left_index; // points to previous piece of same ring
signed_index_type right_index; // points to next piece of same ring
// The next two members (1, 2) form together a complete clockwise ring
// for each piece (with one dupped point)
@@ -191,8 +191,8 @@ struct buffered_piece_collection
// 1: half, part of offsetted_rings
segment_identifier first_seg_id;
int last_segment_index; // no segment-identifier - it is the same as first_seg_id
int offsetted_count; // part in robust_ring which is part of offsetted ring
signed_index_type last_segment_index; // no segment-identifier - it is the same as first_seg_id
signed_index_type offsetted_count; // part in robust_ring which is part of offsetted ring
#if defined(BOOST_GEOMETRY_BUFFER_USE_HELPER_POINTS)
// 2: half, not part of offsetted rings - part of robust ring
@@ -273,7 +273,7 @@ struct buffered_piece_collection
piece_vector_type m_pieces;
turn_vector_type m_turns;
int m_first_piece_index;
signed_index_type m_first_piece_index;
buffered_ring_collection<buffered_ring<Ring> > offsetted_rings; // indexed by multi_index
std::vector<robust_original> robust_originals; // robust representation of the original(s)
@@ -546,7 +546,7 @@ struct buffered_piece_collection
{
// Add rescaled turn points to corresponding pieces
// (after this, each turn occurs twice)
int index = 0;
signed_index_type index = 0;
for (typename boost::range_iterator<turn_vector_type>::type it =
boost::begin(m_turns); it != boost::end(m_turns); ++it, ++index)
{
@@ -584,7 +584,7 @@ struct buffered_piece_collection
it = boost::begin(m_pieces); it != boost::end(m_pieces); ++it)
{
piece& pc = *it;
int piece_segment_index = pc.first_seg_id.segment_index;
signed_index_type piece_segment_index = pc.first_seg_id.segment_index;
if (! pc.robust_turns.empty())
{
if (pc.robust_turns.size() > 1u)
@@ -592,13 +592,13 @@ struct buffered_piece_collection
std::sort(pc.robust_turns.begin(), pc.robust_turns.end(), buffer_operation_less());
}
// Walk through them, in reverse to insert at right index
int index_offset = pc.robust_turns.size() - 1;
signed_index_type index_offset = pc.robust_turns.size() - 1;
for (typename boost::range_reverse_iterator<const std::vector<robust_turn> >::type
rit = boost::const_rbegin(pc.robust_turns);
rit != boost::const_rend(pc.robust_turns);
++rit, --index_offset)
{
int const index_in_vector = 1 + rit->seg_id.segment_index - piece_segment_index;
signed_index_type const index_in_vector = 1 + rit->seg_id.segment_index - piece_segment_index;
BOOST_ASSERT
(
index_in_vector > 0
@@ -649,7 +649,7 @@ struct buffered_piece_collection
typename robust_ring_type::const_iterator current = pc.robust_ring.begin();
typename robust_ring_type::const_iterator next = current + 1;
for (int i = 1; i < pc.offsetted_count; i++)
for (signed_index_type i = 1; i < pc.offsetted_count; i++)
{
determine_monotonicity<0>(pc, *current, *next);
determine_monotonicity<1>(pc, *current, *next);
@@ -699,7 +699,7 @@ struct buffered_piece_collection
typename robust_ring_type::const_iterator current = pc.robust_ring.begin();
typename robust_ring_type::const_iterator next = current + 1;
for (int i = 1; i < pc.offsetted_count; i++)
for (signed_index_type i = 1; i < pc.offsetted_count; i++)
{
robust_segment_type s(*current, *next);
robust_comparable_radius_type const d
@@ -787,7 +787,7 @@ struct buffered_piece_collection
inline void start_new_ring()
{
int const n = static_cast<int>(offsetted_rings.size());
signed_index_type const n = static_cast<signed_index_type>(offsetted_rings.size());
current_segment_id.source_index = 0;
current_segment_id.multi_index = n;
current_segment_id.ring_index = -1;
@@ -796,7 +796,7 @@ struct buffered_piece_collection
offsetted_rings.resize(n + 1);
current_robust_ring.clear();
m_first_piece_index = static_cast<int>(boost::size(m_pieces));
m_first_piece_index = static_cast<signed_index_type>(boost::size(m_pieces));
}
inline void update_closing_point()
@@ -849,7 +849,7 @@ struct buffered_piece_collection
// If piece was added
// Reassign left-of-first and right-of-last
geometry::range::at(m_pieces, m_first_piece_index).left_index
= static_cast<int>(boost::size(m_pieces)) - 1;
= static_cast<signed_index_type>(boost::size(m_pieces)) - 1;
geometry::range::back(m_pieces).right_index = m_first_piece_index;
}
m_first_piece_index = -1;
@@ -876,7 +876,7 @@ struct buffered_piece_collection
offsetted_rings.back().has_concave = true;
}
inline int add_point(point_type const& p)
inline signed_index_type add_point(point_type const& p)
{
BOOST_ASSERT(boost::size(offsetted_rings) > 0);
@@ -885,7 +885,7 @@ struct buffered_piece_collection
current_segment_id.segment_index++;
current_ring.push_back(p);
return static_cast<int>(current_ring.size());
return static_cast<signed_index_type>(current_ring.size());
}
//-------------------------------------------------------------------------
@@ -900,7 +900,7 @@ struct buffered_piece_collection
piece pc;
pc.type = type;
pc.index = static_cast<int>(boost::size(m_pieces));
pc.index = static_cast<signed_index_type>(boost::size(m_pieces));
pc.first_seg_id = current_segment_id;
// Assign left/right (for first/last piece per ring they will be re-assigned later)
@@ -983,7 +983,7 @@ struct buffered_piece_collection
pc.robust_envelope);
geometry::assign_inverse(pc.robust_offsetted_envelope);
for (int i = 0; i < pc.offsetted_count; i++)
for (signed_index_type i = 0; i < pc.offsetted_count; i++)
{
geometry::expand(pc.robust_offsetted_envelope, pc.robust_ring[i]);
}
@@ -1197,7 +1197,7 @@ struct buffered_piece_collection
robust_point_type any_point;
geometry::recalculate(any_point, point, m_robust_policy);
int count_in_original = 0;
signed_index_type count_in_original = 0;
// Check of the robust point of this outputted ring is in
// any of the robust original rings
@@ -1343,7 +1343,7 @@ struct buffered_piece_collection
// Inner rings, for deflate, which do not have intersections, and
// which are outside originals, are skipped
// (other ones should be traversed)
int index = 0;
signed_index_type index = 0;
for(typename buffered_ring_collection<buffered_ring<Ring> >::const_iterator it = boost::begin(offsetted_rings);
it != boost::end(offsetted_rings);
++it, ++index)

View File

@@ -120,7 +120,7 @@ class piece_turn_visitor
template <std::size_t Dimension, typename Iterator, typename Box>
inline void move_begin_iterator(Iterator& it_begin, Iterator it_beyond,
int& index, int dir, Box const& other_bounding_box)
signed_index_type& index, int dir, Box const& other_bounding_box)
{
for(; it_begin != it_beyond
&& it_begin + 1 != it_beyond
@@ -158,20 +158,20 @@ class piece_turn_visitor
typedef typename boost::range_value<Turns const>::type turn_type;
typedef typename boost::range_iterator<ring_type const>::type iterator;
int const piece1_first_index = piece1.first_seg_id.segment_index;
int const piece2_first_index = piece2.first_seg_id.segment_index;
signed_index_type const piece1_first_index = piece1.first_seg_id.segment_index;
signed_index_type const piece2_first_index = piece2.first_seg_id.segment_index;
if (piece1_first_index < 0 || piece2_first_index < 0)
{
return;
}
// Get indices of part of offsetted_rings for this monotonic section:
int const sec1_first_index = piece1_first_index + section1.begin_index;
int const sec2_first_index = piece2_first_index + section2.begin_index;
signed_index_type const sec1_first_index = piece1_first_index + section1.begin_index;
signed_index_type const sec2_first_index = piece2_first_index + section2.begin_index;
// index of last point in section, beyond-end is one further
int const sec1_last_index = piece1_first_index + section1.end_index;
int const sec2_last_index = piece2_first_index + section2.end_index;
signed_index_type const sec1_last_index = piece1_first_index + section1.end_index;
signed_index_type const sec2_last_index = piece2_first_index + section2.end_index;
// get geometry and iterators over these sections
ring_type const& ring1 = m_rings[piece1.first_seg_id.multi_index];
@@ -183,7 +183,7 @@ class piece_turn_visitor
iterator it2_beyond = boost::begin(ring2) + sec2_last_index + 1;
// Set begin/end of monotonic ranges, in both x/y directions
int index1 = sec1_first_index;
signed_index_type index1 = sec1_first_index;
move_begin_iterator<0>(it1_first, it1_beyond, index1,
section1.directions[0], section2.bounding_box);
move_end_iterator<0>(it1_first, it1_beyond,
@@ -193,7 +193,7 @@ class piece_turn_visitor
move_end_iterator<1>(it1_first, it1_beyond,
section1.directions[1], section2.bounding_box);
int index2 = sec2_first_index;
signed_index_type index2 = sec2_first_index;
move_begin_iterator<0>(it2_first, it2_beyond, index2,
section2.directions[0], section1.bounding_box);
move_end_iterator<0>(it2_first, it2_beyond,

View File

@@ -227,7 +227,7 @@ public :
&& point_y >= geometry::get<min_corner, 1>(section.bounding_box) - 1
&& point_y <= geometry::get<max_corner, 1>(section.bounding_box) + 1)
{
for (int i = section.begin_index + 1; i <= section.end_index; i++)
for (signed_index_type i = section.begin_index + 1; i <= section.end_index; i++)
{
point_type const& previous = piece.robust_ring[i - 1];
point_type const& current = piece.robust_ring[i];
@@ -409,7 +409,8 @@ class analyse_turn_wrt_piece
point_type points[4];
int helper_count = static_cast<int>(piece.robust_ring.size()) - piece.offsetted_count;
signed_index_type helper_count = static_cast<signed_index_type>(piece.robust_ring.size())
- piece.offsetted_count;
if (helper_count == 4)
{
for (int i = 0; i < 4; i++)
@@ -559,7 +560,7 @@ public :
// It is small or not monotonic, walk linearly through offset
// TODO: this will be combined with winding strategy
for (int i = 1; i < piece.offsetted_count; i++)
for (signed_index_type i = 1; i < piece.offsetted_count; i++)
{
point_type const& previous = piece.robust_ring[i - 1];
point_type const& current = piece.robust_ring[i];
@@ -616,6 +617,7 @@ class turn_in_piece_visitor
}
#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION)
// NOTE: this function returns a side value in {-1, 0, 1}
template <typename Turn, typename Piece>
static inline int turn_in_convex_piece(Turn const& turn,
Piece const& piece)