From 0a1d294965eb256e93ac82550a58b8c0069461d5 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Tue, 1 Oct 2024 09:51:57 +0200 Subject: [PATCH] KSP, KSR: assert -> CGAL_assertion --- .../include/Terminal_parser.h | 4 +- .../include/CGAL/KSP/debug.h | 2 +- .../include/CGAL/KSP_3/Initializer.h | 4 +- .../include/CGAL/KSP_3/Support_plane.h | 4 +- .../include/CGAL/Kinetic_space_partition_3.h | 38 +++++++++---------- .../kinetic_3d_test_all.cpp | 3 +- .../include/Terminal_parser.h | 4 +- .../include/CGAL/KSR_3/Graphcut.h | 6 +-- .../CGAL/Kinetic_surface_reconstruction_3.h | 6 +-- 9 files changed, 36 insertions(+), 35 deletions(-) diff --git a/Kinetic_space_partition/examples/Kinetic_space_partition/include/Terminal_parser.h b/Kinetic_space_partition/examples/Kinetic_space_partition/include/Terminal_parser.h index 2011d6508714..33c136f051c6 100644 --- a/Kinetic_space_partition/examples/Kinetic_space_partition/include/Terminal_parser.h +++ b/Kinetic_space_partition/examples/Kinetic_space_partition/include/Terminal_parser.h @@ -163,7 +163,7 @@ namespace KSR { const char** parameters, Input_parameters& input_parameters) { - assert(num_parameters > 0); + CGAL_assertion(num_parameters > 0); for (int i = 1; i < num_parameters; ++i) { std::string str = static_cast(parameters[i]); @@ -232,7 +232,7 @@ namespace KSR { bool does_parameter_have_default_value( const std::string parameter_name, const Input_parameters& input_parameters) { - assert(does_parameter_exist(parameter_name, input_parameters)); + CGAL_assertion(does_parameter_exist(parameter_name, input_parameters)); return input_parameters.at(parameter_name) == "default"; } diff --git a/Kinetic_space_partition/include/CGAL/KSP/debug.h b/Kinetic_space_partition/include/CGAL/KSP/debug.h index d2f8b408ea37..7dced2973520 100644 --- a/Kinetic_space_partition/include/CGAL/KSP/debug.h +++ b/Kinetic_space_partition/include/CGAL/KSP/debug.h @@ -539,7 +539,7 @@ class Saver { const std::vector& vertices, const std::vector& tris, const std::string file_name) const { - assert((tris.size() % 3) == 0); + CGAL_assertion((tris.size() % 3) == 0); std::stringstream stream; initialize(stream); diff --git a/Kinetic_space_partition/include/CGAL/KSP_3/Initializer.h b/Kinetic_space_partition/include/CGAL/KSP_3/Initializer.h index be34da2cb05e..f8e38728d2d6 100644 --- a/Kinetic_space_partition/include/CGAL/KSP_3/Initializer.h +++ b/Kinetic_space_partition/include/CGAL/KSP_3/Initializer.h @@ -440,7 +440,7 @@ class Initializer { minp = from_exact(intersection); //min = proj; typename Intersection_kernel::FT p = dir * edge_dir; - assert(p != 0); + CGAL_assertion(p != 0); min_speed = CGAL::approximate_sqrt(edge_dir * edge_dir) / from_exact(p); } if (emax < eproj) { @@ -449,7 +449,7 @@ class Initializer { maxp = from_exact(intersection); //max = proj; typename Intersection_kernel::FT p = dir * edge_dir; - assert(p != 0); + CGAL_assertion(p != 0); max_speed = CGAL::approximate_sqrt(edge_dir * edge_dir) / from_exact(p); } } diff --git a/Kinetic_space_partition/include/CGAL/KSP_3/Support_plane.h b/Kinetic_space_partition/include/CGAL/KSP_3/Support_plane.h index b15330727372..10ef59f9cfc8 100644 --- a/Kinetic_space_partition/include/CGAL/KSP_3/Support_plane.h +++ b/Kinetic_space_partition/include/CGAL/KSP_3/Support_plane.h @@ -404,9 +404,9 @@ class Support_plane { for (std::size_t i = 0; i < m_data->original_directions.size(); i++) { for (std::size_t j = 0; j < m_data->original_directions.size(); j++) { if (j < i) - assert(m_data->original_directions[j] < m_data->original_directions[i]); + CGAL_assertion(m_data->original_directions[j] < m_data->original_directions[i]); if (j > i) - assert(m_data->original_directions[i] < m_data->original_directions[j]); + CGAL_assertion(m_data->original_directions[i] < m_data->original_directions[j]); } } diff --git a/Kinetic_space_partition/include/CGAL/Kinetic_space_partition_3.h b/Kinetic_space_partition/include/CGAL/Kinetic_space_partition_3.h index ab53a84a6d93..4a8353e90a3e 100644 --- a/Kinetic_space_partition/include/CGAL/Kinetic_space_partition_3.h +++ b/Kinetic_space_partition/include/CGAL/Kinetic_space_partition_3.h @@ -501,8 +501,8 @@ class Kinetic_space_partition_3 { for (auto p : m_input2regularized) n.insert(p); - assert(m_regularized2input.size() == m_input_polygons.size()); - assert(m_regularized2input.size() == n.size()); + CGAL_assertion(m_regularized2input.size() == m_input_polygons.size()); + CGAL_assertion(m_regularized2input.size() == n.size()); if (m_parameters.bbox_dilation_ratio < FT(1)) { CGAL_warning_msg(m_parameters.bbox_dilation_ratio >= FT(1), @@ -963,7 +963,7 @@ class Kinetic_space_partition_3 { lcc.template info<2>(face_dart).plane = m_partition_nodes[faces_of_volume[j].first].m_data->support_plane(m_partition_nodes[faces_of_volume[j].first].m_data->face_to_support_plane()[faces_of_volume[j].second]).exact_plane(); } else { - assert(lcc.template info<2>(face_dart).part_of_initial_polygon == m_partition_nodes[faces_of_volume[j].first].m_data->face_is_part_of_input_polygon()[faces_of_volume[j].second]); + CGAL_assertion(lcc.template info<2>(face_dart).part_of_initial_polygon == m_partition_nodes[faces_of_volume[j].first].m_data->face_is_part_of_input_polygon()[faces_of_volume[j].second]); } vtx_of_face.clear(); @@ -1031,7 +1031,7 @@ class Kinetic_space_partition_3 { }; const Point_3& volume_centroid(std::size_t volume_index) const { - assert(volume_index < m_volumes.size()); + CGAL_assertion(volume_index < m_volumes.size()); auto p = m_volumes[volume_index]; return m_partition_nodes[p.first].m_data->volumes()[p.second].centroid; } @@ -1135,7 +1135,7 @@ class Kinetic_space_partition_3 { template void faces_of_input_polygon(const std::size_t polygon_index, OutputIterator it) const { if (polygon_index >= m_input_planes.size()) { - assert(false); + CGAL_assertion(false); } for (std::size_t idx : m_partitions) { @@ -1190,14 +1190,14 @@ class Kinetic_space_partition_3 { const auto &p = m_partition_nodes[face_index.first].face_neighbors[face_index.second]; if (p.second.second >= std::size_t(-6)) { // Faces on the boundary box are neighbors with an infinite outside volume auto it = m_index2volume.find(p.first); - assert(it != m_index2volume.end()); + CGAL_assertion(it != m_index2volume.end()); return std::pair(static_cast(it->second), static_cast(p.second.second)); } else { auto it1 = m_index2volume.find(p.first); - assert(it1 != m_index2volume.end()); + CGAL_assertion(it1 != m_index2volume.end()); auto it2 = m_index2volume.find(p.second); - assert(it2 != m_index2volume.end()); + CGAL_assertion(it2 != m_index2volume.end()); return std::pair(static_cast(it1->second), static_cast(it2->second)); } } @@ -1288,8 +1288,8 @@ class Kinetic_space_partition_3 { } vertices.back()->info().idA2 = pts_idx[f][v]; - assert(pts_idx[f][v].first != static_cast(-1)); - assert(pts_idx[f][v].second != static_cast(-1)); + CGAL_assertion(pts_idx[f][v].first != static_cast(-1)); + CGAL_assertion(pts_idx[f][v].second != static_cast(-1)); vertices.back()->info().adjacent.insert(faces[f]); vertices.back()->info().set_point(pts[f][v]); face2vtx[pts_idx[f][v]] = vertices.size() - 1; @@ -1805,7 +1805,7 @@ class Kinetic_space_partition_3 { for (std::size_t j = 0; j < vtx.size(); j++) { auto it = vtx2index.find(vtx[j]); - assert(it != vtx2index.end()); + CGAL_assertion(it != vtx2index.end()); if (vertices_of_volume.find(vtx[j]) == vertices_of_volume.end() && added_vertices[it->second]) return false; } @@ -1872,7 +1872,7 @@ class Kinetic_space_partition_3 { From_exact from_exact; auto pair = replaced.insert(f); std::size_t idx; - assert(m_partition_nodes[f.first].face_neighbors[f.second].first.first == f.first); + CGAL_assertion(m_partition_nodes[f.first].face_neighbors[f.second].first.first == f.first); std::size_t vol_idx = m_partition_nodes[f.first].face_neighbors[f.second].first.second; if (!pair.second) { @@ -1890,11 +1890,11 @@ class Kinetic_space_partition_3 { else { idx = f.second; // All boundary faces should have a negative second neighbor. - assert(m_partition_nodes[f.first].face_neighbors[idx].second.second >= std::size_t(-6)); + CGAL_assertion(m_partition_nodes[f.first].face_neighbors[idx].second.second >= std::size_t(-6)); } std::vector& vertices = m_partition_nodes[f.first].face2vertices[idx]; // First neighbor of other face should point to the inside volume in the other partition and thus cannot be negative - assert(m_partition_nodes[other.first].face_neighbors[other.second].first.second < std::size_t(-6)); + CGAL_assertion(m_partition_nodes[other.first].face_neighbors[other.second].first.second < std::size_t(-6)); m_partition_nodes[f.first].face_neighbors[idx].second = m_partition_nodes[other.first].face_neighbors[other.second].first; vertices.resize(polygon.size()); for (std::size_t i = 0; i < polygon.size(); i++) { @@ -1961,7 +1961,7 @@ class Kinetic_space_partition_3 { auto eit = cdt.incident_edges(face.back(), last); auto first = eit; - assert(!cdt.is_infinite(eit->first)); + CGAL_assertion(!cdt.is_infinite(eit->first)); do { // Export tri @@ -1984,7 +1984,7 @@ class Kinetic_space_partition_3 { break; } eit++; - assert(eit != first); + CGAL_assertion(eit != first); } while (eit != first); // If last vertex is equal to first vertex, stop // Take last vertex and face @@ -1992,7 +1992,7 @@ class Kinetic_space_partition_3 { // Check if opposite face of next edge, if not same, add next vertex and reloop // if not, check next face - assert(face.size() < 100); + CGAL_assertion(face.size() < 100); } // The last vertex is equal to the first one, so it should be removed. @@ -2055,7 +2055,7 @@ class Kinetic_space_partition_3 { } void adapt_internal_edges(const CDTplus& cdtC, const std::vector &faces_node, std::vector >& c) { - assert(faces_node.size() == c.size()); + CGAL_assertion(faces_node.size() == c.size()); //std::size_t not_skipped = 0; @@ -2092,7 +2092,7 @@ class Kinetic_space_partition_3 { // Check length of constraint // size 2 means it has not been split, thus there are no t-junctions. - assert (vertices_of_edge.size() >= 2); + CGAL_assertion(vertices_of_edge.size() >= 2); faces_of_volume.clear(); faces(volume, std::back_inserter(faces_of_volume)); diff --git a/Kinetic_space_partition/test/Kinetic_space_partition/kinetic_3d_test_all.cpp b/Kinetic_space_partition/test/Kinetic_space_partition/kinetic_3d_test_all.cpp index 77531de7cc0f..1fb8898a1535 100644 --- a/Kinetic_space_partition/test/Kinetic_space_partition/kinetic_3d_test_all.cpp +++ b/Kinetic_space_partition/test/Kinetic_space_partition/kinetic_3d_test_all.cpp @@ -33,6 +33,7 @@ bool run_test( input_file_ply.close(); else { std::cerr << "ERROR: can't read the OFF/PLY file " << filename << "!" << std::endl; + different++; return false; } @@ -278,7 +279,7 @@ void run_all_tests() { const auto kernel_name = boost::typeindex::type_id().pretty_name(); if (different != 0) { - std::cout << std::endl << kernel_name << different << " TESTS differ from typical values!" << std::endl << std::endl; + std::cout << std::endl << kernel_name << " " << different << " TESTS differ from typical values!" << std::endl << std::endl; } std::cout << std::endl << kernel_name << " TESTS SUCCESS!" << std::endl << std::endl; } diff --git a/Kinetic_surface_reconstruction/examples/Kinetic_surface_reconstruction/include/Terminal_parser.h b/Kinetic_surface_reconstruction/examples/Kinetic_surface_reconstruction/include/Terminal_parser.h index 248abe895c0f..126ab1fe03a4 100644 --- a/Kinetic_surface_reconstruction/examples/Kinetic_surface_reconstruction/include/Terminal_parser.h +++ b/Kinetic_surface_reconstruction/examples/Kinetic_surface_reconstruction/include/Terminal_parser.h @@ -163,7 +163,7 @@ namespace KSR { const char** parameters, Input_parameters& input_parameters) { - assert(num_parameters > 0); + CGAL_assertion(num_parameters > 0); for (int i = 1; i < num_parameters; ++i) { std::string str = static_cast(parameters[i]); @@ -232,7 +232,7 @@ namespace KSR { bool does_parameter_have_default_value( const std::string parameter_name, const Input_parameters& input_parameters) { - assert(does_parameter_exist(parameter_name, input_parameters)); + CGAL_assertion(does_parameter_exist(parameter_name, input_parameters)); return input_parameters.at(parameter_name) == "default"; } diff --git a/Kinetic_surface_reconstruction/include/CGAL/KSR_3/Graphcut.h b/Kinetic_surface_reconstruction/include/CGAL/KSR_3/Graphcut.h index 4c9453d4cb2d..1ab1a8fcb6cf 100644 --- a/Kinetic_surface_reconstruction/include/CGAL/KSR_3/Graphcut.h +++ b/Kinetic_surface_reconstruction/include/CGAL/KSR_3/Graphcut.h @@ -46,12 +46,12 @@ namespace KSR_3 { const FT beta) : m_beta(beta) { } void solve(const std::vector >& edges, const std::vector& edge_weights, const std::vector > &cost_matrix, std::vector &labels) { - assert(edges.size() == edge_weights.size()); - assert(!cost_matrix.empty()); + CGAL_assertion(edges.size() == edge_weights.size()); + CGAL_assertion(!cost_matrix.empty()); labels.resize(cost_matrix[0].size()); for (std::size_t i = 0; i < cost_matrix[0].size(); i++) { // Verify quadratic size - assert(cost_matrix[0].size() == cost_matrix[1].size()); + CGAL_assertion(cost_matrix[0].size() == cost_matrix[1].size()); labels[i] = (cost_matrix[0][i] > cost_matrix[1][0]) ? 1 : 0; } compute_graphcut(edges, edge_weights, cost_matrix, labels); diff --git a/Kinetic_surface_reconstruction/include/CGAL/Kinetic_surface_reconstruction_3.h b/Kinetic_surface_reconstruction/include/CGAL/Kinetic_surface_reconstruction_3.h index 7df975df13c3..30c2f6f4e30f 100644 --- a/Kinetic_surface_reconstruction/include/CGAL/Kinetic_surface_reconstruction_3.h +++ b/Kinetic_surface_reconstruction/include/CGAL/Kinetic_surface_reconstruction_3.h @@ -653,7 +653,7 @@ class Kinetic_surface_reconstruction_3 { for (std::size_t i = 0; i < m_faces_lcc.size(); i++) { auto n = m_lcc.template one_dart_per_incident_cell<3, 2>(m_faces_lcc[i]); - assert(n.size() == 1 || n.size() == 2); + CGAL_assertion(n.size() == 1 || n.size() == 2); auto it = n.begin(); // auto& finf = m_lcc.template info<2>(m_faces_lcc[i]); @@ -1585,7 +1585,7 @@ class Kinetic_surface_reconstruction_3 { other_faces.push_back(dh); // Contains faces originating from the octree decomposition as well as bbox faces } - assert(m_kinetic_partition.input_planes().size() == m_regions.size()); + CGAL_assertion(m_kinetic_partition.input_planes().size() == m_regions.size()); for (std::size_t i = 0; i < m_kinetic_partition.input_planes().size(); i++) { @@ -1942,7 +1942,7 @@ class Kinetic_surface_reconstruction_3 { std::vector faces; if (polygon_index >= m_kinetic_partition.input_planes().size()) - assert(false); + CGAL_assertion(false); From_exact from_exact;