Improved distance queries in libigl and gptoolbox

Alec Jacobson

June 07, 2015

weblog/

tiny torus wire mesh, distance isosurface

I've stripped out the CGAL dependency from the libigl igl::point_mesh_squared_distance and igl::signed_distance functions. I've been meaning to do this for a while since it wasn't really using anything that needs CGAL. Just conveniently wrapped around its axis-aligned bounding box hierarchy for a list of triangles.

Unfortunately CGAL tends to rely on callers to handle degeneracies, so zero-area triangles threw assertions. And it's not particularly easy to use CGAL's AABB hierarchy to hold a mixture of faces, edges and points.

Implementing a AABB-tree is really quite simple and libigl already had one for the igl::in_element function. I added distance query functions to this implementation and cleaned it up a bit.

The matlab wrappers (e.g. signed_distance_isosurface) in gptoolbox now use these distances. For example, the image above was created by using

 signed_distance_isosurface(V,E,'SignedDistanceType','unsigned', ...)

where E are the edges of the "Tiny Torus mesh" (grey with black wireframe). The blue surface is the watertight "inflated wire mesh".