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;
}
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) );
break;
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) );
break;
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) );
break;
default:
CGAL_assertion(false);
CGAL_unreachable();
}
}

View File

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

View File

@ -91,10 +91,8 @@ public:
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;

View File

@ -93,10 +93,7 @@ public:
): 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 */

View File

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

View File

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

View File

@ -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()

View File

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

View File

@ -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:
@ -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
@ -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);
}
}

View File

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

View File

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

View File

@ -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;
}
};

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
break;
default:
CGAL_assertion(false);
CGAL_unreachable();
}
}

View File

@ -489,7 +489,7 @@ public:
pit = propagate_conflicts(p,fh,2,pit);
return pit;
}
CGAL_assertion(false);
CGAL_unreachable();
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:
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();
}