Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CGAL: Deal with CGAL_assertion(false) #8496

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ class Curve_analysis_2 : public ::CGAL::Handle_with_policy< Rep_ > {
break;
}
default:{
CGAL_assertion(false); // !!! Never reached
CGAL_unreachable();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class Lazy_alpha_nt_2
exact_ = Exact_squared_radius()( to_exact(*data().p0),to_exact(*data().p1),to_exact(*data().p2) );
break;
default:
CGAL_assertion(false);
CGAL_unreachable();
}
}

Expand All @@ -229,7 +229,7 @@ class Lazy_alpha_nt_2
approx_ = Approx_squared_radius()( to_approx(*data().p0),to_approx(*data().p1),to_approx(*data().p2) );
break;
default:
CGAL_assertion(false);
CGAL_unreachable();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class Lazy_alpha_nt_3{
approx_ = Approx_squared_radius()( to_approx(*data().p0),to_approx(*data().p1),to_approx(*data().p2),to_approx(*data().p3) );
break;
default:
CGAL_assertion(false);
CGAL_unreachable();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,10 +605,9 @@ class Td_X_trapezoid : public Handle
case CGAL_TD_VERTEX:
return TD_VERTEX;
default:
CGAL_assertion(false);
return TD_TRAPEZOID;
}
CGAL_unreachable();
}
}

/*! Access trapezoid type flag. */
CGAL_TD_INLINE unsigned char type_flag() const
Expand Down
6 changes: 2 additions & 4 deletions Cone_spanners_2/include/CGAL/Compute_cone_boundaries_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,8 @@ class Compute_cone_boundaries_2 {
DirectionOutputIterator operator()(const unsigned int cone_number,
const Direction_2& initial_direction,
DirectionOutputIterator result) {
if (cone_number<2) {
std::cout << "The number of cones must be larger than 1!" << std::endl;
CGAL_assertion(false);
}

CGAL_assertion_msg(cone_number>1, "The number of cones must be larger than 1");

*result++ = initial_direction;

Expand Down
5 changes: 1 addition & 4 deletions Cone_spanners_2/include/CGAL/Construct_theta_graph_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,7 @@ class Construct_theta_graph_2 {
): cone_number(k), cones_choice(cones_selected), rays(std::vector<Direction_2>(k))

{
if (k<2) {
std::cout << "The number of cones must be larger than 1!" << std::endl;
CGAL_assertion(false);
}
CGAL_assertion_msg(k>1, "The number of cones must be larger than 1");

/* Initialize a functor, specialization will happen here depending on the kernel type to
compute the cone boundaries either exactly or inexactly */
Expand Down
5 changes: 1 addition & 4 deletions Cone_spanners_2/include/CGAL/Construct_yao_graph_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ class Construct_yao_graph_2 {
): cone_number(k), cones_choice(cones_selected), rays(std::vector<Direction_2>(k))

{
if (k<2) {
std::cout << "The number of cones must be larger than 1!" << std::endl;
CGAL_assertion(false);
}
CGAL_assertion_msg(k>1, "The number of cones must be larger than 1");

/* Initialize a functor, specialization will happen here depending on the kernel type to
compute the cone boundaries either exactly or inexactly */
Expand Down
2 changes: 1 addition & 1 deletion Kinetic_space_partition/include/CGAL/KSP_3/Finalizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ class Finalizer {
return true;
}

CGAL_assertion(false);
CGAL_unreachable();
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ class Intersection_graph {
}

void set_crossed(const Edge_descriptor& edge, std::size_t sp_idx) {
CGAL_assertion(false);
CGAL_assertion(false); // AF: I am surprised that after the assert we do something
m_graph[edge].crossed.insert(sp_idx);
}
};
Expand Down
2 changes: 1 addition & 1 deletion Lab/demo/Lab/Plugins/PCA/Affine_transform_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ end()
endPolygonMesh(transform_matrix);
break;
default:
CGAL_assertion(false);
CGAL_unreachable();
}

dockWidget->hide();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,8 @@ namespace CGAL {
// Allocate a dart for null_dart_descriptor
assert(mdarts.empty()); // the compact container is empty
Dart_index local_null_dart_descriptor = mdarts.emplace();
if(local_null_dart_descriptor!=0)
{
std::cerr<<"[ERROR] fatal in CMap_linear_cell_complex_storage_with_index::init_storage"
<<std::endl;
CGAL_assertion(false);
}
CGAL_assertion_msg(local_null_dart_descriptor==0,
"[ERROR] fatal in CMap_linear_cell_complex_storage_with_index::init_storage");
}

void clear_storage()
Expand Down
4 changes: 1 addition & 3 deletions Mesh_3/include/CGAL/Mesh_3/Lloyd_move.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ class Lloyd_move
break;
default:
// Should not happen
CGAL_assertion(false);
return CGAL::NULL_VECTOR;
break;
CGAL_unreachable();
}

return CGAL::NULL_VECTOR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ intersection_type(
// p sees the triangle in counterclockwise order
return find_intersection(p,q,a,b,c,h_2,tm2,false,true);

default: // should not happen.
CGAL_assertion(false);
default:
CGAL_unreachable();
return result_type(EMPTY,GT::null_halfedge(),false,false);
}
case NEGATIVE:
Expand All @@ -143,8 +143,8 @@ intersection_type(
// q belongs to the triangle's supporting plane
// p sees the triangle in clockwise order
return find_intersection(q,p,a,b,c,h_2,tm2,false,true);
default: // should not happen.
CGAL_assertion(false);
default:
CGAL_unreachable();
return result_type(EMPTY,GT::null_halfedge(),false,false);
}
case COPLANAR: // p belongs to the triangle's supporting plane
Expand All @@ -163,12 +163,12 @@ intersection_type(
return result_type(COPLANAR_TRIANGLES,GT::null_halfedge(),true,true);
return result_type(EMPTY,GT::null_halfedge(),true,true);

default: // should not happen.
CGAL_assertion(false);
default:
CGAL_unreachable();
return result_type(EMPTY,GT::null_halfedge(),false,false);
}
default: // should not happen.
CGAL_assertion(false);
default:
CGAL_unreachable();
return result_type(EMPTY,GT::null_halfedge(),false,false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1940,7 +1940,7 @@ namespace internal {
else if(is_on_mesh(h)) nb_mesh++;
else if(is_on_border(h)) nb_border++;
else if(is_an_isolated_constraint(h)) nb_isolated++;
else CGAL_assertion(false);
else CGAL_unreachable();
}
CGAL_USE(nb_border);
CGAL_USE(nb_mesh);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class Two_vertices_parameterizer_3
V1_max = zmax;
break;
default:
CGAL_assertion(false);
CGAL_unreachable();
}
switch (second_longest_axis)
{
Expand All @@ -225,7 +225,7 @@ class Two_vertices_parameterizer_3
V2_max = zmax;
break;
default:
CGAL_assertion(false);
CGAL_unreachable();
}

// Project onto longest bounding box axes,
Expand Down
2 changes: 1 addition & 1 deletion TDS_2/include/CGAL/Triangulation_data_structure_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ insert_dim_up(Vertex_handle w, bool orient)
}
break;
default:
CGAL_assertion(false);
CGAL_unreachable();
break; }
return v;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ std::size_t smooth_vertices_on_surfaces(C3t3& c3t3,
return CGAL::midpoint(s->source(), s->target());
else
{
CGAL_assertion(false);
CGAL_assertion(false); // AF: So are we not completely sure?
return std::nullopt;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ void set_index(typename C3t3::Vertex_handle v, const C3t3& c3t3)
case -1://far points from concurrent Mesh_3
break;
default:
CGAL_assertion(false);
CGAL_unreachable();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ class Constrained_Delaunay_triangulation_2
pit = propagate_conflicts(p,fh,2,pit);
return pit;
}
CGAL_assertion(false);
CGAL_unreachable();
return std::make_pair(fit,eit);
}

Expand Down
2 changes: 1 addition & 1 deletion Triangulation_2/include/CGAL/Triangulation_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ insert(const Point& p, Locate_type lt, Face_handle loc, int li)
case VERTEX:
return loc->vertex(li);
}
CGAL_assertion(false); // locate step failed
CGAL_unreachable(); // AF: The comment "locate step failed" gives the idea that it may fail, but all cases are covered
return Vertex_handle();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -964,18 +964,12 @@ march_locate_2D(Face_handle f,
li = (o0 == COLLINEAR) ? 2 : (o1 == COLLINEAR) ? 0 : 1;
break;
}
case 2:
default: // i.e., case 2:
{
lt = VERTEX;
li = (o0 != COLLINEAR) ? 2 : (o1 != COLLINEAR) ? 0 : 1;
break;
}
default:
{
// impossible
CGAL_assertion(false);
return f;
}
}
afabri marked this conversation as resolved.
Show resolved Hide resolved

test_distance(t, f, lt, li);
Expand Down