Skip to content

Commit

Permalink
KSP, KSR: assert -> CGAL_assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
soesau committed Oct 1, 2024
1 parent 782e741 commit 0a1d294
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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";
}

Expand Down
2 changes: 1 addition & 1 deletion Kinetic_space_partition/include/CGAL/KSP/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ class Saver {
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);
Expand Down
4 changes: 2 additions & 2 deletions Kinetic_space_partition/include/CGAL/KSP_3/Initializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Kinetic_space_partition/include/CGAL/KSP_3/Support_plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}

Expand Down
38 changes: 19 additions & 19 deletions Kinetic_space_partition/include/CGAL/Kinetic_space_partition_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -1135,7 +1135,7 @@ class Kinetic_space_partition_3 {
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) {
Expand Down Expand Up @@ -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<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));
}
}
Expand Down Expand Up @@ -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<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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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<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++) {
Expand Down Expand Up @@ -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

Expand All @@ -1984,15 +1984,15 @@ 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
// First find index of vertex in that face
// 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.
Expand Down Expand Up @@ -2055,7 +2055,7 @@ class Kinetic_space_partition_3 {
}

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;

Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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";
}

Expand Down
6 changes: 3 additions & 3 deletions Kinetic_surface_reconstruction/include/CGAL/KSR_3/Graphcut.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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++) {

Expand Down Expand Up @@ -1942,7 +1942,7 @@ class Kinetic_surface_reconstruction_3 {
std::vector<Index> faces;

if (polygon_index >= m_kinetic_partition.input_planes().size())
assert(false);
CGAL_assertion(false);

From_exact from_exact;

Expand Down

0 comments on commit 0a1d294

Please sign in to comment.