stla/cgalMeshes

boundsVolume() causes crash after SSSreconstruction(..., forceManifold=FALSE)

dwoll opened this issue · 3 comments

dwoll commented

Thank you very much for considering the submitted issues! Using the current github branch, I encountered the problem that calling boundsVolume() crashes R when used on a mesh that was returned by SSSreconstruction(..., forceManifold=FALSE). Consider

library(cgalMeshes)
mesh <- cgalMesh$new("1_HERZ_HRO.ply")
SSSr_fm1 <- SSSreconstruction(mesh$getVertices(), forceManifold=TRUE)
SSSr_fm0 <- SSSreconstruction(mesh$getVertices(), forceManifold=FALSE)
SSSr_fm1$boundsVolume()
## TRUE

SSSr_fm0$boundsVolume()
## crashes R

1_HERZ_HRO.txt

stla commented

Thanks.

I realize I forgot to implement the check of whether the mesh is closed before running boundsVolume. Is it closed? If it is not, the crash is not surprising.

Moreover, I've just read the CGAL doc and it says that the behavior of this function is undefined when the mesh self-intersects. Does it self-intersect?

dwoll commented

Thanks for checking! Indeed, both meshes are not closed, but SSSr_fm0 also self intersects whereas SSSr_fm1 does not:

SSSr_fm1$selfIntersects()
## FALSE

SSSr_fm0$selfIntersects()
## TRUE

SSSr_fm1$isClosed()
## FALSE

SSSr_fm0$isClosed()
## FALSE

Note that SSSr_fm1$boundsVolume() returns TRUE even though SSSr_fm1$isClosed() is FALSE.

stla commented

Ok. That makes no sense for a mesh to bound a volume while it is not closed. I will add the two checks (closed and no self-intersection). Thanks!