Package: fastsweep
Fast sweeping SDF solverThis repository contains a Python package providing an efficient solver for the Eikonal equation in 3D. The primary use for this package is toredistancea signed distance function (SDF) from its zero level set (e.g., during an optimization that optimizes the SDF). In particular, this implementation was created for the use in our paper ondifferentiable signed distance function rendering. You can find the
code for that paperhere.This library doesnotconvert meshes to SDFs, even though it can be used for such applications. This implementation runs efficiently on GPUs (using CUDA) and also provides a CPU implementation as a fallback. The solver is exposed via Python bindings and usesDr.Jitfor some of its implementation.The code implements the parallel fast sweeping algorithm for the Eikonal equation:A parallel fast sweeping method for the Eikonal equation. Miles Detrixhe,  Frédéric Gibou, Chohong Min, Journal of Computational Physics 237 (2013)The implementation is in part based onPDFS, see alsoLICENSEfor license details.InstallationPre-build binaries are provided on PyPi and can be installed usingpipinstallfastsweepAlternatively, the package is also relatively easy to build and install from source. The build setup uses CMake andscikit build. Please clone the repository including submodules usinggitclone--recursivegit@github.com:rgl-epfl/fastsweep.gitThe Python module can then be built and installed by invoking:pipinstall./fastsweepImportant: It is important that this solver anddrjitare compiled with exactly the same compiler and settings for binary compatibility. If you installed a pre-builtdrjitpackage usingpip, you most likely will want to use the pre-built package forfastsweepas well. Conversely, if you want to compile one of these packages locally, you will most likely need to compile the other one locally as well. If
there is a problem with binary compatibility, invoking the functionality of the solver will most likely throw a type-mismatch error.UsageThe solver takes a Dr.Jit 3DTensorXfas input and solves the Eikonal equation from its zero level set. It returns a valid SDF that reproduces the zero level set of the input. The solver does not support 1D or 2D problems, for these one can for example usescikit-fmm.Given an initial 3D tensor, the solver can be invoked asimportfastsweepdata=drjit.cuda.TensorXf(...)sdf=fastsweep.redistance(data)The resulting arraysdfis then a valid SDF. The solver returns either adrjit.cuda.TensorXfordfjit.llvm.TensorXf, depending on the type of the input. A complete
example script is providedhere.LimitationsThe code currently assumes the SDF to be contained in the unit cube volume and hasn't been tested for non-uniform volumes or other scales.The CPU version isn't very efficient, this code is primarily designed for GPU execution and the CPU version is really just a fallback.The computation of the zero level set does not consider different grid interpolation modes.CitationIf you use this solver for an academic paper, consider citing the following paper:@article{Vicini2022sdf,title={Differentiable Signed Distance Function Rendering},author={Delio Vicini and Sébastien Speierer and Wenzel Jakob},year=2022,month=jul,journal={Transactions on Graphics (Proceedings of SIGGRAPH)},volume=41,number=4,pages={125:1--125:18},doi={10.1145/3528223.3530139}}