Closed mildred closed 1 year ago
I'm trying to replace clip with a standard corefine_and_compute_difference
with a large bounding box clipped by my clip plane and I got an assertion error too. Could it come from the geometry that is too unusual?
terminate called after throwing an instance of 'CGAL::Assertion_exception'
what(): CGAL ERROR: assertion violation!
Expr: insert_ok || mesh_to_vertex_to_node_id[&tm][target(h,tm)]==node_id
File: /usr/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Visitor.h
Line: 768
Error: signal 6:
Just looking at the mesh, I can see that it is not correctly oriented (nested volume should be counterclockwise oriented). If you call the function PMP::does_bound_a_volume()
it should return false. Calling the function PMP::orient_to_bound_a_volume()
should fix it. Please let us know if it is enough to fix the issue.
The normals from the cavity are oriented to the inside, which is away from the solid volume itself, which seems completely logical to me. That's how the boolean operations oriented them anyway. (By the way that's not a nested volume but a cavity).
After calling orient_to_bound_a_volume
, the normals do not seems flipped (see dbg_convex_step_0.obj.gz), and I added an extra check with does_bound_a_volume
before the clip but I got the same exception.
The volume contains a cavity, perhaps clip is not able to deal with that. But how different is a cavity from let's say a glass shaped convex volume when clipping?
Sorry the input is indeed valid.
However, you should not use using Kernel = CGAL::Simple_cartesian<double>;
but using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel
. If you know that the plane is axis aligned I would recommend the second approach you tried with a bbox. With the plane, I noticed that due to rounding issues, some coordinates of the internally created box have -128.00000000000003
coordinates which lead to an output which is not what you would expect.
Using CGAL::Exact_predicates_inexact_constructions_kernel
instead of CGAL::Simple_cartesian<double>
made it work. Thank you. I didn't know the kernel could have such dramatic consequences.
As for the rounding, this is to be expected but perhaps I can round all coordinates to some limited precision so I can get back neatly arranged vertices. And for the cutting plane, I have no guarantee that it should match an axis, so the bounding box creation involves some cutting in any case along a possibly non orthogonal plane.
What is the reason of the assertion failure, can I expect assertion failures due to geometry or am I safe with the new kernel?
edit: I think I got my anser here: https://www.cgal.org/exact.html
Thank you very much. I'll let you close the issue.
Please use the following template to help us solving your issue.
Issue Details
I have a complex geometry using Surface_mesh. It is constructed by boolean operations and it is basically a solid rectangle which is hollowed inside (in rectangle form), only a thin shell is around. Within the inner rectangle there is another rectangle added that makes a bump.
mesh gzipped: dbg_convex_step_0.obj.gz
I'm trying to split this geometry to form multiple convex meshes. I'm using
clip()
withclip_volume(true)
. I'm clipping with a plane normal to the Z axis (0,0,1) at the offset z=-128. This should open up one face of the shell as the z=-128 coordinate is coplanar with the inner substracted space.The exception message:
basic stack trace:
CGAL_triangulation_assertion( s != LEFT_TURN );
fails within theis_valid()
function. InVisitor.h:1406
is_valid()
is called on the variablecdt
, and this is this variable that is the cause of the crash. When this variable is defined, there is a strange TODO comment:Source Code
To give you an idea of the code:
source code: https://github.com/mildred/t3d2map/commit/53bc8c6815278bb098abc468f8ea7a9397114502
command-line:
make && rm -f dbg_*.obj && ./t3d2map --debug-mesh ./examples/test.t3d
complete source code is one file, not that long. First part is constructing the geometry with CSG then
Environment