KSP, KSR: assert -> CGAL_assertion

This commit is contained in:
Sven Oesau 2024-10-01 09:51:57 +02:00
parent 782e741310
commit 0a1d294965
9 changed files with 36 additions and 35 deletions

View File

@ -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<std::string>(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";
}

View File

@ -539,7 +539,7 @@ public:
const std::vector<Point_3>& vertices,
const std::vector<std::size_t>& tris,
const std::string file_name) const {
assert((tris.size() % 3) == 0);
CGAL_assertion((tris.size() % 3) == 0);
std::stringstream stream;
initialize(stream);

View File

@ -440,7 +440,7 @@ private:
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 @@ private:
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);
}
}

View File

@ -404,9 +404,9 @@ public:
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]);
}
}

View File

@ -501,8 +501,8 @@ public:
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 @@ public:
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 @@ private:
};
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 @@ private:
template<class OutputIterator>
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 @@ private:
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<int, int>(static_cast<int>(it->second), static_cast<int>(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<int, int>(static_cast<int>(it1->second), static_cast<int>(it2->second));
}
}
@ -1288,8 +1288,8 @@ private:
}
vertices.back()->info().idA2 = pts_idx[f][v];
assert(pts_idx[f][v].first != static_cast<std::size_t>(-1));
assert(pts_idx[f][v].second != static_cast<std::size_t>(-1));
CGAL_assertion(pts_idx[f][v].first != static_cast<std::size_t>(-1));
CGAL_assertion(pts_idx[f][v].second != static_cast<std::size_t>(-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 @@ private:
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 @@ private:
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 @@ private:
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<Index>& 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 @@ private:
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 @@ private:
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 @@ private:
// 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 @@ private:
}
void adapt_internal_edges(const CDTplus& cdtC, const std::vector<Index> &faces_node, std::vector<std::vector<Constraint_info> >& c) {
assert(faces_node.size() == c.size());
CGAL_assertion(faces_node.size() == c.size());
//std::size_t not_skipped = 0;
@ -2092,7 +2092,7 @@ private:
// 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));

View File

@ -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<Kernel>().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;
}

View File

@ -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<std::string>(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";
}

View File

@ -46,12 +46,12 @@ namespace KSR_3 {
const FT beta) : m_beta(beta) { }
void solve(const std::vector<std::pair<std::size_t, std::size_t> >& edges, const std::vector<FT>& edge_weights, const std::vector<std::vector<double> > &cost_matrix, std::vector<std::size_t> &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);

View File

@ -653,7 +653,7 @@ private:
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 @@ private:
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 @@ private:
std::vector<Index> faces;
if (polygon_index >= m_kinetic_partition.input_planes().size())
assert(false);
CGAL_assertion(false);
From_exact from_exact;