OpenVDB  9.0.1
Classes | Namespaces | Enumerations | Functions
FastSweeping.h File Reference

Defined the six functions {fog,sdf}To{Sdf,Ext,SdfAndExt} in addition to the two functions maskSdf and dilateSdf. Sdf denotes a signed-distance field (i.e. negative values are inside), fog is a scalar fog volume (i.e. higher values are inside), and Ext is a field (of arbitrary type) that is extended off the iso-surface. All these functions are implemented with the methods in the class named FastSweeping. More...

#include <openvdb/Platform.h>
#include <openvdb/math/Math.h>
#include <openvdb/math/Stencils.h>
#include <openvdb/tree/LeafManager.h>
#include "LevelSetUtil.h"
#include "Morphology.h"
#include <openvdb/openvdb.h>
#include "Statistics.h"
#include <tbb/parallel_for.h>
#include <tbb/enumerable_thread_specific.h>
#include <tbb/task_group.h>
#include <type_traits>
#include <cmath>
#include <limits>
#include <deque>
#include <unordered_map>
#include <utility>

Go to the source code of this file.

Classes

class  FastSweeping< SdfGridT, ExtValueT >
 Computes signed distance values from an initial iso-surface and optionally performs velocity extension at the same time. This is done by means of a novel sparse and parallel fast sweeping algorithm based on a first order Godunov's scheme. More...
 
struct  FastSweeping< SdfGridT, ExtValueT >::MinMaxKernel
 
struct  FastSweeping< SdfGridT, ExtValueT >::DilateKernel
 Private class of FastSweeping to perform multi-threaded initialization. More...
 
struct  FastSweeping< SdfGridT, ExtValueT >::InitSdf
 
struct  FastSweeping< SdfGridT, ExtValueT >::SweepingKernel
 Private class of FastSweeping to perform concurrent fast sweeping in two directions. More...
 
struct  FastSweeping< SdfGridT, ExtValueT >::SweepingKernel::NN
 

Namespaces

 openvdb
 
 openvdb::v9_0
 
 openvdb::v9_0::tools
 

Enumerations

enum  FastSweepingDomain { SWEEP_ALL, SWEEP_GREATER_THAN_ISOVALUE, SWEEP_LESS_THAN_ISOVALUE }
 Fast Sweeping update mode. This is useful to determine narrow-band extension or field extension in one side of a signed distance field. More...
 

Functions

template<typename GridT >
GridT::Ptr fogToSdf (const GridT &fogGrid, typename GridT::ValueType isoValue, int nIter=1)
 Converts a scalar fog volume into a signed distance function. Active input voxels with scalar values above the given isoValue will have NEGATIVE distance values on output, i.e. they are assumed to be INSIDE the iso-surface. More...
 
template<typename GridT >
GridT::Ptr sdfToSdf (const GridT &sdfGrid, typename GridT::ValueType isoValue=0, int nIter=1)
 Given an existing approximate SDF it solves the Eikonal equation for all its active voxels. Active input voxels with a signed distance value above the given isoValue will have POSITIVE distance values on output, i.e. they are assumed to be OUTSIDE the iso-surface. More...
 
template<typename FogGridT , typename ExtOpT , typename ExtValueT >
FogGridT::template ValueConverter< ExtValueT >::Type::Ptr fogToExt (const FogGridT &fogGrid, const ExtOpT &op, const ExtValueT &background, typename FogGridT::ValueType isoValue, int nIter=1, FastSweepingDomain mode=FastSweepingDomain::SWEEP_ALL, const typename FogGridT::template ValueConverter< ExtValueT >::Type::ConstPtr extGrid=nullptr)
 Computes the extension of a field (scalar, vector, or int are supported), defined by the specified functor, off an iso-surface from an input FOG volume. More...
 
template<typename SdfGridT , typename ExtOpT , typename ExtValueT >
SdfGridT::template ValueConverter< ExtValueT >::Type::Ptr sdfToExt (const SdfGridT &sdfGrid, const ExtOpT &op, const ExtValueT &background, typename SdfGridT::ValueType isoValue=0, int nIter=1, FastSweepingDomain mode=FastSweepingDomain::SWEEP_ALL, const typename SdfGridT::template ValueConverter< ExtValueT >::Type::ConstPtr extGrid=nullptr)
 Computes the extension of a field (scalar, vector, or int are supported), defined by the specified functor, off an iso-surface from an input SDF volume. More...
 
template<typename FogGridT , typename ExtOpT , typename ExtValueT >
std::pair< typename FogGridT::Ptr, typename FogGridT::template ValueConverter< ExtValueT >::Type::Ptr > fogToSdfAndExt (const FogGridT &fogGrid, const ExtOpT &op, const ExtValueT &background, typename FogGridT::ValueType isoValue, int nIter=1, FastSweepingDomain mode=FastSweepingDomain::SWEEP_ALL, const typename FogGridT::template ValueConverter< ExtValueT >::Type::ConstPtr extGrid=nullptr)
 Computes the signed distance field and the extension of a field (scalar, vector, or int are supported), defined by the specified functor, off an iso-surface from an input FOG volume. More...
 
template<typename SdfGridT , typename ExtOpT , typename ExtValueT >
std::pair< typename SdfGridT::Ptr, typename SdfGridT::template ValueConverter< ExtValueT >::Type::Ptr > sdfToSdfAndExt (const SdfGridT &sdfGrid, const ExtOpT &op, const ExtValueT &background, typename SdfGridT::ValueType isoValue=0, int nIter=1, FastSweepingDomain mode=FastSweepingDomain::SWEEP_ALL, const typename SdfGridT::template ValueConverter< ExtValueT >::Type::ConstPtr extGrid=nullptr)
 Computes the signed distance field and the extension of a field (scalar, vector, or int are supported), defined by the specified functor, off an iso-surface from an input SDF volume. More...
 
template<typename GridT >
GridT::Ptr dilateSdf (const GridT &sdfGrid, int dilation, NearestNeighbors nn=NN_FACE, int nIter=1, FastSweepingDomain mode=FastSweepingDomain::SWEEP_ALL)
 Dilates the narrow band of an existing signed distance field by a specified number of voxels (like adding "onion-rings"). More...
 
template<typename GridT , typename MaskTreeT >
GridT::Ptr maskSdf (const GridT &sdfGrid, const Grid< MaskTreeT > &mask, bool ignoreActiveTiles=false, int nIter=1)
 Fills mask by extending an existing signed distance field into the active values of this input ree of arbitrary value type. More...
 
template<typename SdfGridT , typename OpT , typename ExtValueT >
SdfGridT::template ValueConverter< ExtValueT >::Type::Ptr sdfToExt (const SdfGridT &sdfGrid, const OpT &op, const ExtValueT &background, typename SdfGridT::ValueType isoValue, int nIter, FastSweepingDomain mode, const typename SdfGridT::template ValueConverter< ExtValueT >::Type::ConstPtr extGrid)
 

Detailed Description

Defined the six functions {fog,sdf}To{Sdf,Ext,SdfAndExt} in addition to the two functions maskSdf and dilateSdf. Sdf denotes a signed-distance field (i.e. negative values are inside), fog is a scalar fog volume (i.e. higher values are inside), and Ext is a field (of arbitrary type) that is extended off the iso-surface. All these functions are implemented with the methods in the class named FastSweeping.

Author
Ken Museth
Note
Solves the (simplified) Eikonal Eq: $|\nabla \phi|^2 = 1$ and performs velocity extension, $\nabla f\nabla \phi = 0$, both by means of the fast sweeping algorithm detailed in: "A Fast Sweeping Method For Eikonal Equations" by H. Zhao, Mathematics of Computation, Vol 74(230), pp 603-627, 2004

The algorithm used below for parallel fast sweeping was first published in: "New Algorithm for Sparse and Parallel Fast Sweeping: Efficient Computation of Sparse Distance Fields" by K. Museth, ACM SIGGRAPH Talk, 2017, http://www.museth.org/Ken/Publications_files/Museth_SIG17.pdf