Closest Point Transform

Introduction

This code implements an algorithm for computing the closest point transform to a triangle mesh surface on a regular 3-D grid. The closest point transform finds the Euclidean distance to the triangle mesh. In addition, it can compute the closest point on the surface, the closest triangle face in the mesh and the gradient of the distance. The distance, etc., are computed to within a specified distance of the surface. The closest point, closest face, distance and gradient of the distance to the mesh surface are calculated by solving the Eikonal equation $ |\nabla u|^2 = 1 $ with the method of characteristics. The method of characteristics is implemented efficiently with the aid of computational geometry and polyhedron scan conversion. The computed distance is accurate to within machine precision. The computational complexity of the algorithm is linear in both the number of grid points for which the distance is computed and the size of the mesh. Thus for many problems, it has the optimal computational complexity. Visit my web page for publications on solving static Hamilton-Jacobi equations and in particular for computing the CPT.

Compiling

The following compilers are supported:
Compiler Versions Language Flags Optimization Flags Date Tested Notes

GCC, g++ 4.0, 4.2 -ansi -pedantic -Wall -O3 -funroll-loops June 20, 2007

IBM XL, xlC September 2004 June 30, 2006 Warns that it cannot inline some functions.

Intel, icc 8.0 -strict_ansi -O3 -Zp16 -ip -ansi_alias June 3, 2007

PathScale, pathCC 2.5 -ansi -O3 -INLINE:aggressive=ON -OPT:alias=typed June 20, 2007

PGI, pgCC 7.0 -O3 -fastsse -Minline June 20, 2007

When using the GNU compilers, you cannot use the -fstrict-aliasing flag. I don't know if this is an issue with my code or the compiler. I'll try to resolve this when I get the time.

The Standard Interface

The classes State<3,T> and State<2,T> contain the standard interface (C++ interface) to the CPT package. If you use the standard interface, there is no library to build. Just include cpt.h to get the templated class library.

To use the standard interface, instantiate a State<3,T> or State<2,T> class. Its member functions provide the interface. Consult the class for this documentation.

The C and Fortran Interfaces

There is a C interface and a fortran interface contained in the headers: cpt_c.h and cpt_f.h, respectively. These interfaces are free functions that are analogous to the member functions of the C++ interface.

The C interface is not in the cpt namespace. Instead the functions have a cpt prefix. For example: cptComputeClosestPointTransform3(). The C interface wraps the standard interface. Functions in the fortran interface have a cpt prefix and an F suffix. For example: cptComputeClosestPointTransform3F(). The fortran interface wraps the C interface.

Both the C and fortran interfaces instantiate a static instance of State<3,T> and State<2,T>. Thus you must make and link with the library. Use gnu "make" in stlib/packages/cpt to build the libcpt.a archive.

The Drivers

The 2-D CPT Driver and The 3-D CPT Driver are example applications that use the CPT package. They read a b-rep from a file and write the distance, the gradient of the distance, the closest point and the closest face transforms to files.

STLib Home / http://www.its.caltech.edu/~sean/ / at(sean, dot(caltech, edu))