Skip to content

Commit

Permalink
Merge pull request #8501 from afabri/CGAL-assert-GF
Browse files Browse the repository at this point in the history
assert() ->  CGAL::assertion()
  • Loading branch information
sloriot committed Oct 21, 2024
2 parents ba70570 + 463bfcd commit 7c4badc
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 52 deletions.
2 changes: 1 addition & 1 deletion Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -4260,7 +4260,7 @@ class Arr_conic_traits_2 {
// Compute the radi of the hyperbola:
ts = std::asinh(ys_t/b);
tt = std::asinh(yt_t/b);
assert(std::signbit(xs_t) == std::signbit(xt_t));
CGAL_assertion(std::signbit(xs_t) == std::signbit(xt_t));

if (std::signbit(xs_t)) a = -a;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ namespace CGAL {
void init_storage()
{
// Allocate a dart for null_dart_descriptor
assert(mdarts.empty()); // the compact container is empty
CGAL_assertion(mdarts.empty()); // the compact container is empty
Dart_index local_null_dart_descriptor = mdarts.emplace();
if(local_null_dart_descriptor!=0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Free_list_management<CC_with_index, CGAL::Tag_true, CGAL::Tag_true>
void init()
{
m_free_list=std::stack<size_type>();
assert(m_free_list.empty());
CGAL_assertion(m_free_list.empty());
if(m_cc_with_index->capacity()>0)
{ m_used.assign(m_cc_with_index->capacity(), false); }
else { m_used.clear(); }
Expand Down
2 changes: 1 addition & 1 deletion Combinatorial_map/include/CGAL/Dart.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ namespace CGAL {

Dart_descriptor get_f(unsigned int i) const
{
assert(i<=dimension);
CGAL_assertion(i<=dimension);
return mf[i];
}

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
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
36 changes: 18 additions & 18 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 @@ -971,7 +971,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 @@ -1039,7 +1039,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 @@ -1146,7 +1146,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 @@ -1201,14 +1201,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 @@ -1299,8 +1299,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 @@ -1816,7 +1816,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 @@ -1883,7 +1883,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 @@ -1901,11 +1901,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 @@ -1972,7 +1972,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 @@ -1995,15 +1995,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 @@ -2099,7 +2099,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 @@ -691,7 +691,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 @@ -1626,7 +1626,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 @@ -2008,7 +2008,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
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ namespace CGAL {
void init_storage()
{
// Allocate a dart for null_dart_descriptor
assert(mdarts.empty()); // the compact container is empty
CGAL_assertion(mdarts.empty()); // the compact container is empty
Dart_index local_null_dart_descriptor = mdarts.emplace();
if(local_null_dart_descriptor!=0)
{
Expand Down
4 changes: 2 additions & 2 deletions Number_types/include/CGAL/CORE_BigFloat.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class Interval_traits<CORE::BigFloat>
// shift such that err.m()+err.err() fits into long
int digits_long = std::numeric_limits<long>::digits;
if(::CORE::bitLength(err.m()+err.err()) >= static_cast<std::size_t>(digits_long)){
assert(std::size_t((std::numeric_limits<long>::max)()) > ::CORE::bitLength(err.m()));
CGAL_assertion(std::size_t((std::numeric_limits<long>::max)()) > ::CORE::bitLength(err.m()));
long shift = static_cast<long>(::CORE::bitLength(err.m())) - digits_long + 1;
//std::cout << "shift " << shift<< std::endl;
CORE::BigInt bi = (err.m() + err.err());
Expand Down Expand Up @@ -276,7 +276,7 @@ round(const CORE::BigFloat& x, long rel_prec = CORE::get_static_defRelPrec().toL

long shift ;
if (err == 0) {
assert(std::size_t((std::numeric_limits<long>::max)()) > ::CORE::bitLength(m));
CGAL_assertion(std::size_t((std::numeric_limits<long>::max)()) > ::CORE::bitLength(m));
shift = static_cast<long>(::CORE::bitLength(m)) - rel_prec - 3;
}else
shift = CGAL::relative_precision(x) - rel_prec -1;
Expand Down
Loading

0 comments on commit 7c4badc

Please sign in to comment.