fixed warnings from testing examples

This commit is contained in:
Dmitry Anisimov 2021-08-03 18:17:14 +02:00
parent fbcb52bb27
commit 072c1bf460
6 changed files with 48 additions and 73 deletions

View File

@ -205,8 +205,8 @@ namespace Segments {
const std::size_t i,
const std::size_t j) const {
CGAL_precondition(i >= 0 && i < m_input_range.size());
CGAL_precondition(j >= 0 && j < m_input_range.size());
CGAL_precondition(i < m_input_range.size());
CGAL_precondition(j < m_input_range.size());
CGAL_assertion(m_wraps.size() == m_input_range.size());
const auto& wrapi = m_wraps[i];
@ -250,8 +250,7 @@ namespace Segments {
// Get angle.
const std::size_t seg_index = wrap.index;
CGAL_assertion(
seg_index >= 0 && seg_index < solution.size());
CGAL_assertion(seg_index < solution.size());
const FT difference = solution[seg_index];
FT angle_deg = wrap.orientation + difference;
if (angle_deg < FT(0)) angle_deg += FT(180);
@ -392,8 +391,7 @@ namespace Segments {
const IndexRange& index_range) {
for (const auto seg_index : index_range) {
CGAL_assertion(
seg_index >= 0 && seg_index < m_wraps.size());
CGAL_assertion(seg_index < m_wraps.size());
auto& wrap = m_wraps[seg_index];
const auto& segment = get(m_segment_map,
@ -407,8 +405,7 @@ namespace Segments {
const IndexRange& index_range) {
for (const auto seg_index : index_range) {
CGAL_assertion(
seg_index >= 0 && seg_index < m_wraps.size());
CGAL_assertion(seg_index < m_wraps.size());
auto& wrap = m_wraps[seg_index];
wrap.is_used = true;
}

View File

@ -161,10 +161,8 @@ namespace Segments {
std::vector<std::size_t>& neighbors) const {
neighbors.clear();
CGAL_precondition(
query_index >= 0 && query_index < m_input_range.size());
CGAL_precondition(
m_groups.size() == m_input_range.size());
CGAL_precondition(query_index < m_input_range.size());
CGAL_precondition(m_groups.size() == m_input_range.size());
if (query_index >= m_input_range.size()) return;
neighbors = m_groups[query_index];
}
@ -249,8 +247,7 @@ namespace Segments {
m_delaunay.clear();
for (const auto seg_index : index_range) {
CGAL_assertion(
seg_index >= 0 && seg_index < m_input_range.size());
CGAL_assertion(seg_index < m_input_range.size());
const auto& segment = get(
m_segment_map, *(m_input_range.begin() + seg_index));
@ -268,8 +265,7 @@ namespace Segments {
vit != m_delaunay.finite_vertices_end(); ++vit) {
const std::size_t seg_index_1 = vit->info();
CGAL_assertion(
seg_index_1 >= 0 && seg_index_1 < m_input_range.size());
CGAL_assertion(seg_index_1 < m_input_range.size());
auto& neighbors = m_groups[seg_index_1];
neighbors.clear();
@ -280,8 +276,7 @@ namespace Segments {
if (!m_delaunay.is_infinite(vc)) {
const std::size_t seg_index_2 = vc->info();
CGAL_assertion(
seg_index_2 >= 0 && seg_index_2 < m_input_range.size());
CGAL_assertion(seg_index_2 < m_input_range.size());
neighbors.push_back(seg_index_2);
}
++vc;
@ -314,8 +309,7 @@ namespace Segments {
const Point_2 get_midpoint(
const std::size_t seg_index) const {
CGAL_assertion(
seg_index >= 0 && seg_index < m_input_range.size());
CGAL_assertion(seg_index < m_input_range.size());
const auto& segment = get(
m_segment_map, *(m_input_range.begin() + seg_index));
const auto& source = segment.source();

View File

@ -211,8 +211,8 @@ namespace Segments {
const std::size_t i,
const std::size_t j) const {
CGAL_precondition(i >= 0 && i < m_input_range.size());
CGAL_precondition(j >= 0 && j < m_input_range.size());
CGAL_precondition(i < m_input_range.size());
CGAL_precondition(j < m_input_range.size());
CGAL_assertion(m_wraps.size() == m_input_range.size());
const auto& wrapi = m_wraps[i];
@ -256,16 +256,14 @@ namespace Segments {
// Get segment.
const std::size_t seg_index = wrap.index;
CGAL_assertion(
seg_index >= 0 && seg_index < m_input_range.size());
CGAL_assertion(seg_index < m_input_range.size());
const auto& segment = get(m_segment_map,
*(m_input_range.begin() + seg_index));
const auto& source = segment.source();
const auto& target = segment.target();
// Get update values.
CGAL_assertion(
seg_index >= 0 && seg_index < solution.size());
CGAL_assertion(seg_index < solution.size());
const FT difference = solution[seg_index];
const auto normal =
internal::perpendicular_vector_2(wrap.direction);
@ -395,10 +393,9 @@ namespace Segments {
void update_segment_data(
const IndexRange& index_range) {
Point_2 frame_origin; std::size_t count = 0;
Point_2 frame_origin(FT(0), FT(0)); std::size_t count = 0;
for (const auto seg_index : index_range) {
CGAL_assertion(
seg_index >= 0 && seg_index < m_wraps.size());
CGAL_assertion(seg_index < m_wraps.size());
auto& wrap = m_wraps[seg_index];
const auto& segment =
@ -415,10 +412,9 @@ namespace Segments {
void update_wrappers(
const IndexRange& index_range) {
Point_2 frame_origin; std::size_t count = 0;
Point_2 frame_origin(FT(0), FT(0)); std::size_t count = 0;
for (const auto seg_index : index_range) {
CGAL_assertion(
seg_index >= 0 && seg_index < m_wraps.size());
CGAL_assertion(seg_index < m_wraps.size());
auto& wrap = m_wraps[seg_index];
wrap.is_used = true;

View File

@ -289,22 +289,23 @@ namespace internal {
std::vector<Segment_wrapper_2>& wraps,
std::vector<std::size_t>& assigned) const {
const std::size_t n = wraps.size();
CGAL_assertion(assigned.size() == n);
for (std::size_t i = 0; i < n; ++i) {
CGAL_assertion(assigned.size() == wraps.size());
const int n = static_cast<int>(wraps.size());
for (int i = 0; i < n; ++i) {
auto& wrap = wraps[i];
if (wrap.is_used) continue;
std::size_t im = std::size_t(-1);
int im = -1;
if (i > 0) im = i - 1;
std::size_t ip = std::size_t(-1);
int ip = -1;
if (i < n - 1) ip = i + 1;
bool stop = false;
std::size_t max_count = 0;
int max_count = 0;
do {
if (im != std::size_t(-1) && wraps[im].is_used) {
if (im != -1 && wraps[im].is_used) {
CGAL_assertion(i >= 0 && i < n);
CGAL_assertion(im >= 0 && im < n);
assigned[i] = assigned[im];
@ -312,7 +313,7 @@ namespace internal {
break;
}
if (ip != std::size_t(-1) && wraps[ip].is_used) {
if (ip != -1 && wraps[ip].is_used) {
CGAL_assertion(i >= 0 && i < n);
CGAL_assertion(ip >= 0 && ip < n);
assigned[i] = assigned[ip];
@ -321,10 +322,10 @@ namespace internal {
}
if (stop) break;
if (im != std::size_t(-1) && im > 0) {
if (im != -1 && im > 0) {
im = im - 1;
}
if (ip != std::size_t(-1) && ip < n - 1) {
if (ip != -1 && ip < n - 1) {
ip = ip + 1;
}
@ -346,15 +347,15 @@ namespace internal {
std::vector<Segment_wrapper_2>& wraps,
std::vector<std::size_t>& assigned) const {
const std::size_t n = wraps.size();
CGAL_assertion(assigned.size() == wraps.size());
const int n = static_cast<int>(wraps.size());
std::vector<std::size_t> clean;
clean.reserve(n);
CGAL_assertion(assigned.size() == n);
for (std::size_t i = 0; i < n; ++i) {
for (int i = 0; i < n; ++i) {
if (i == 0) {
const std::size_t ip = 1;
const int ip = 1;
CGAL_assertion(ip >= 0 && ip < n);
const std::size_t di = assigned[i];
const std::size_t dp = assigned[ip];
@ -367,7 +368,7 @@ namespace internal {
}
if (i == n - 1) {
const std::size_t im = n - 2;
const int im = n - 2;
CGAL_assertion(im >= 0 && im < n);
const std::size_t dm = assigned[im];
const std::size_t di = assigned[i];
@ -379,8 +380,8 @@ namespace internal {
continue;
}
const std::size_t im = i - 1;
const std::size_t ip = i + 1;
const int im = i - 1;
const int ip = i + 1;
CGAL_assertion(im >= 0 && im < n);
const std::size_t dm = assigned[im];
CGAL_assertion(i >= 0 && i < n);
@ -462,19 +463,14 @@ namespace internal {
CGAL_assertion(assigned.size() > 0);
CGAL_assertion(bounds.size() == directions.size());
CGAL_assertion(
query_index >= 0 &&
query_index < assigned.size());
CGAL_assertion(query_index < assigned.size());
const std::size_t direction_index = assigned[query_index];
if (direction_index == std::size_t(-1)) {
return;
}
CGAL_assertion(
direction_index >= 0 &&
direction_index < directions.size());
CGAL_assertion(direction_index < directions.size());
const auto& ref_direction = directions[direction_index];
const auto& ref_bounds = bounds[direction_index];

View File

@ -97,8 +97,7 @@ namespace internal {
CGAL_assertion(collinear_group.size() > 0);
if (collinear_group.size() == 1) {
const std::size_t seg_index = collinear_group[0];
CGAL_assertion(
seg_index >= 0 && seg_index < m_input_range.size());
CGAL_assertion(seg_index < m_input_range.size());
const auto& first = get(m_segment_map,
*(m_input_range.begin() + seg_index));
m_segments.push_back(first);
@ -116,8 +115,7 @@ namespace internal {
const std::size_t longest =
find_longest_segment(collinear_group);
CGAL_assertion(
longest >= 0 && longest < m_input_range.size());
CGAL_assertion(longest < m_input_range.size());
const auto& ref_segment = get(m_segment_map,
*(m_input_range.begin() + longest));
@ -153,8 +151,7 @@ namespace internal {
FT sum_distance = FT(0);
for (const std::size_t seg_index : collinear_group) {
CGAL_assertion(
seg_index >= 0 && seg_index < m_input_range.size());
CGAL_assertion(seg_index < m_input_range.size());
const auto& segment = get(m_segment_map,
*(m_input_range.begin() + seg_index));
@ -178,8 +175,7 @@ namespace internal {
std::size_t longest = std::size_t(-1);
for (const std::size_t seg_index : collinear_group) {
CGAL_assertion(
seg_index >= 0 && seg_index < m_input_range.size());
CGAL_assertion(seg_index < m_input_range.size());
const auto& segment = get(m_segment_map,
*(m_input_range.begin() + seg_index));
@ -208,8 +204,7 @@ namespace internal {
const FT weight = weights[i];
const std::size_t seg_index = collinear_group[i];
CGAL_assertion(
seg_index >= 0 && seg_index < m_input_range.size());
CGAL_assertion(seg_index < m_input_range.size());
const auto& segment = get(m_segment_map,
*(m_input_range.begin() + seg_index));
@ -237,16 +232,13 @@ namespace internal {
FT max_proj_value = -max_value;
CGAL_assertion(collinear_group.size() > 0);
CGAL_assertion(
collinear_group[0] >= 0 &&
collinear_group[0] < m_input_range.size());
CGAL_assertion(collinear_group[0] < m_input_range.size());
const auto& first = get(m_segment_map,
*(m_input_range.begin() + collinear_group[0]));
const Point_2& ref_point = first.source();
for (const std::size_t seg_index : collinear_group) {
CGAL_assertion(
seg_index >= 0 && seg_index < m_input_range.size());
CGAL_assertion(seg_index < m_input_range.size());
const auto& segment = get(m_segment_map,
*(m_input_range.begin() + seg_index));

View File

@ -105,8 +105,8 @@ public:
/// Changes the number of variables and the number of constraints of the problem.
///
/// \warning Calling this function also clears all previous entries.
void resize(const int new_n,
const int new_m = 0)
void resize(const std::size_t new_n,
const std::size_t new_m = 0)
{
clear();
n = new_n;