CGAL / cgal

The public CGAL repository, see the README below
https://github.com/CGAL/cgal#readme
Other
5k stars 1.39k forks source link

Assertions provide no useful information for diagnosis #4666

Open M-Pixel opened 4 years ago

M-Pixel commented 4 years ago
ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: e->incident_sface() != SFace_const_handle() File: /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_S2/SM_const_decorator.h Line: 329

This error appears to be extremely common, having to do with vertices merging due to floating point inaccuracy. There are dozens of forum posts and GH issues about this error, by OpenSCAD users. Often, in these threads, an OpenSCAD developer is able to identify the area of concern. In my case, I've run into this error by unioning or differencing just about anything with a particular organic mesh, so it's very unlike the more basic situations where a glance at the input instructions by an expert could possibly yield a solution.

If the condition were to output a message indicating the 3D position of the area of concern, in addition to whatever other contextual values contribute to the value of e->incident_sface(), it would make diagnosis easier, let alone possible in particularly complex compositions or meshes. The goal of any error message on data derived from user input should be to give the user an understanding of the "where" and the "why" in their input, so that they can fix it.

Additionally, the basic message could be far more informative: In which context is the function being called? What is "e" meant to represent? Why should it not be equal to the default value? Why should I need to be proficient in C++ to understand that the error is comparing some value to a default value? Is "sface" short for "surface", or something else?

While my anecdote is about one particular assertion, I am posting the issue with a more general title, suspecting that there are likely many other assertions that should also be supplemented with contextual information and user-oriented messages.

GilesBathgate commented 1 year ago

The message could maybe mention that the failure is in the check_integrity_and_topological_planarity function. But this exception appears to be triggered only by the following minimal geometry:

image

That is to say, there is a vertex (where the triangles meet) that has more than two border edges emanating from it, so it's not a valid facet fan.

Is "sface" short for "surface", or something else?

no sface is short for sphere face: https://doc.cgal.org/latest/Nef_3/index.html#Nef_3Definition image