Use size_t instead of int for index.

The functions estamate_points_properties used some ints to manipulate
indexes that led to compiler warrnings.
This commit is contained in:
Martin Šach 2023-09-26 13:10:19 +02:00 committed by SachCZ
parent 9e3b9e43e3
commit cf44ad22fe

View File

@ -50,27 +50,27 @@ std::vector<ExtendedPoint> estimate_points_properties(const POINTS
float max_line_length = -1.0f) float max_line_length = -1.0f)
{ {
bool looped = input_points.front() == input_points.back(); bool looped = input_points.front() == input_points.back();
std::function<int(int,size_t)> get_prev_index = [](int idx, size_t count) { std::function<size_t(size_t,size_t)> get_prev_index = [](size_t idx, size_t count) {
if (idx > 0) { if (idx > 0) {
return idx - 1; return idx - 1;
} else } else
return idx; return idx;
}; };
if (looped) { if (looped) {
get_prev_index = [](int idx, size_t count) { get_prev_index = [](size_t idx, size_t count) {
if (idx == 0) if (idx == 0)
idx = count; idx = count;
return --idx; return --idx;
}; };
}; };
std::function<int(int,size_t)> get_next_index = [](int idx, size_t size) { std::function<size_t(size_t,size_t)> get_next_index = [](size_t idx, size_t size) {
if (idx + 1 < size) { if (idx + 1 < size) {
return idx + 1; return idx + 1;
} else } else
return idx; return idx;
}; };
if (looped) { if (looped) {
get_next_index = [](int idx, size_t count) { get_next_index = [](size_t idx, size_t count) {
if (++idx == count) if (++idx == count)
idx = 0; idx = 0;
return idx; return idx;
@ -186,7 +186,7 @@ std::vector<ExtendedPoint> estimate_points_properties(const POINTS
float accumulated_distance = 0; float accumulated_distance = 0;
std::vector<float> distances_for_curvature(points.size()); std::vector<float> distances_for_curvature(points.size());
for (int point_idx = 0; point_idx < int(points.size()); ++point_idx) { for (size_t point_idx = 0; point_idx < points.size(); ++point_idx) {
const ExtendedPoint &a = points[point_idx]; const ExtendedPoint &a = points[point_idx];
const ExtendedPoint &b = points[get_prev_index(point_idx, points.size())]; const ExtendedPoint &b = points[get_prev_index(point_idx, points.size())];