CGAL: Deal with CGAL_assertion(false)

This commit is contained in:
Andreas Fabri 2024-09-25 15:49:47 +01:00
parent 420ed32ef6
commit 9ed9a45a08
17 changed files with 29 additions and 41 deletions

View File

@ -890,7 +890,7 @@ private:
break; break;
} }
default:{ default:{
CGAL_assertion(false); // !!! Never reached CGAL_unreachable();
} }
} }
} }

View File

@ -212,7 +212,7 @@ public:
exact_ = Exact_squared_radius()( to_exact(*data().p0),to_exact(*data().p1),to_exact(*data().p2) ); exact_ = Exact_squared_radius()( to_exact(*data().p0),to_exact(*data().p1),to_exact(*data().p2) );
break; break;
default: default:
CGAL_assertion(false); CGAL_unreachable();
} }
} }
@ -229,7 +229,7 @@ public:
approx_ = Approx_squared_radius()( to_approx(*data().p0),to_approx(*data().p1),to_approx(*data().p2) ); approx_ = Approx_squared_radius()( to_approx(*data().p0),to_approx(*data().p1),to_approx(*data().p2) );
break; break;
default: default:
CGAL_assertion(false); CGAL_unreachable());
} }
} }

View File

@ -224,7 +224,7 @@ public:
approx_ = Approx_squared_radius()( to_approx(*data().p0),to_approx(*data().p1),to_approx(*data().p2),to_approx(*data().p3) ); approx_ = Approx_squared_radius()( to_approx(*data().p0),to_approx(*data().p1),to_approx(*data().p2),to_approx(*data().p3) );
break; break;
default: default:
CGAL_assertion(false); CGAL_unreachable();
} }
} }

View File

@ -605,8 +605,7 @@ public:
case CGAL_TD_VERTEX: case CGAL_TD_VERTEX:
return TD_VERTEX; return TD_VERTEX;
default: default:
CGAL_assertion(false); CGAL_unreachable();
return TD_TRAPEZOID;
} }
} }

View File

@ -91,10 +91,8 @@ public:
DirectionOutputIterator operator()(const unsigned int cone_number, DirectionOutputIterator operator()(const unsigned int cone_number,
const Direction_2& initial_direction, const Direction_2& initial_direction,
DirectionOutputIterator result) { DirectionOutputIterator result) {
if (cone_number<2) {
std::cout << "The number of cones must be larger than 1!" << std::endl; CGAL_assertion_msg(cone_number>1, "The number of cones must be larger than 1");
CGAL_assertion(false);
}
*result++ = initial_direction; *result++ = initial_direction;

View File

@ -93,10 +93,7 @@ public:
): cone_number(k), cones_choice(cones_selected), rays(std::vector<Direction_2>(k)) ): cone_number(k), cones_choice(cones_selected), rays(std::vector<Direction_2>(k))
{ {
if (k<2) { CGAL_assertion_msg(k>1, "The number of cones must be larger than 1");
std::cout << "The number of cones must be larger than 1!" << std::endl;
CGAL_assertion(false);
}
/* Initialize a functor, specialization will happen here depending on the kernel type to /* Initialize a functor, specialization will happen here depending on the kernel type to
compute the cone boundaries either exactly or inexactly */ compute the cone boundaries either exactly or inexactly */

View File

@ -420,7 +420,7 @@ public:
} }
void set_crossed(const Edge_descriptor& edge, std::size_t sp_idx) { 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); m_graph[edge].crossed.insert(sp_idx);
} }
}; };

View File

@ -728,7 +728,7 @@ end()
endPolygonMesh(transform_matrix); endPolygonMesh(transform_matrix);
break; break;
default: default:
CGAL_assertion(false); CGAL_unreachable();
} }
dockWidget->hide(); dockWidget->hide();

View File

@ -191,12 +191,8 @@ namespace CGAL {
// Allocate a dart for null_dart_descriptor // Allocate a dart for null_dart_descriptor
assert(mdarts.empty()); // the compact container is empty assert(mdarts.empty()); // the compact container is empty
Dart_index local_null_dart_descriptor = mdarts.emplace(); Dart_index local_null_dart_descriptor = mdarts.emplace();
if(local_null_dart_descriptor!=0) CGAL_assertion_msg(local_null_dart_descriptor==0,
{ "[ERROR] fatal in CMap_linear_cell_complex_storage_with_index::init_storage");
std::cerr<<"[ERROR] fatal in CMap_linear_cell_complex_storage_with_index::init_storage"
<<std::endl;
CGAL_assertion(false);
}
} }
void clear_storage() void clear_storage()

View File

@ -100,9 +100,7 @@ public:
break; break;
default: default:
// Should not happen // Should not happen
CGAL_assertion(false); CGAL_unreachable();
return CGAL::NULL_VECTOR;
break;
} }
return CGAL::NULL_VECTOR; return CGAL::NULL_VECTOR;

View File

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

View File

@ -205,7 +205,7 @@ public:
V1_max = zmax; V1_max = zmax;
break; break;
default: default:
CGAL_assertion(false); CGAL_unreachable();
} }
switch (second_longest_axis) switch (second_longest_axis)
{ {
@ -225,7 +225,7 @@ public:
V2_max = zmax; V2_max = zmax;
break; break;
default: default:
CGAL_assertion(false); CGAL_unreachable();
} }
// Project onto longest bounding box axes, // Project onto longest bounding box axes,

View File

@ -1118,7 +1118,7 @@ insert_dim_up(Vertex_handle w, bool orient)
} }
break; break;
default: default:
CGAL_assertion(false); CGAL_unreachable();
break; } break; }
return v; return v;
} }

View File

@ -875,7 +875,7 @@ std::size_t smooth_vertices_on_surfaces(C3t3& c3t3,
return CGAL::midpoint(s->source(), s->target()); return CGAL::midpoint(s->source(), s->target());
else else
{ {
CGAL_assertion(false); CGAL_assertion(false); AF: So are we not completely sure?
return std::nullopt; return std::nullopt;
} }
}; };

View File

@ -844,7 +844,7 @@ void set_index(typename C3t3::Vertex_handle v, const C3t3& c3t3)
case -1://far points from concurrent Mesh_3 case -1://far points from concurrent Mesh_3
break; break;
default: default:
CGAL_assertion(false); CGAL_unreachable();
} }
} }

View File

@ -489,7 +489,7 @@ public:
pit = propagate_conflicts(p,fh,2,pit); pit = propagate_conflicts(p,fh,2,pit);
return pit; return pit;
} }
CGAL_assertion(false); CGAL_unreachable();
return std::make_pair(fit,eit); return std::make_pair(fit,eit);
} }

View File

@ -1488,7 +1488,7 @@ insert(const Point& p, Locate_type lt, Face_handle loc, int li)
case VERTEX: case VERTEX:
return loc->vertex(li); 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(); return Vertex_handle();
} }