OpenVDB  11.0.0
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Friends | List of all members
GradStencil< GridT > Class Template Reference

#include <nanovdb/util/Stencils.h>

Inherits BaseStencil< GradStencil< GridT >, 7, GridT >.

Public Types

using GridType = GridT
 
using TreeType = typename GridT::TreeType
 
using ValueType = typename GridT::ValueType
 
using AccessorType = typename GridT::AccessorType
 

Public Member Functions

__hostdev__ GradStencil (const GridType &grid)
 
__hostdev__ GradStencil (const GridType &grid, double dx)
 
__hostdev__ ValueType normSqGrad () const
 Return the norm square of the single-sided upwind gradient (computed via Godunov's scheme) at the previously buffered location. More...
 
__hostdev__ Vec3< ValueTypegradient () const
 Return the gradient computed at the previously buffered location by second order central differencing. More...
 
__hostdev__ Vec3< ValueTypegradient (const Vec3< ValueType > &V) const
 Return the first-order upwind gradient corresponding to the direction V. More...
 
__hostdev__ ValueType laplacian () const
 
__hostdev__ bool zeroCrossing () const
 
__hostdev__ Vec3< ValueTypecpt ()
 Compute the closest-point transform to a level set. More...
 
template<int i, int j, int k>
__hostdev__ unsigned int pos () const
 Return linear offset for the specified stencil point relative to its center. More...
 
__hostdev__ void moveTo (const Coord &ijk)
 Initialize the stencil buffer with the values of voxel (i, j, k) and its neighbors. More...
 
__hostdev__ void moveTo (const Coord &ijk, const ValueType &centerValue)
 Initialize the stencil buffer with the values of voxel (i, j, k) and its neighbors. The method also takes a value of the center element of the stencil, assuming it is already known. More...
 
__hostdev__ void moveTo (const IterType &iter)
 Initialize the stencil buffer with the values of voxel (x, y, z) and its neighbors. More...
 
__hostdev__ void moveTo (const Vec3< RealType > &xyz)
 Initialize the stencil buffer with the values of voxel (x, y, z) and its neighbors. More...
 
__hostdev__ const ValueTypegetValue (unsigned int pos=0) const
 Return the value from the stencil buffer with linear offset pos. More...
 
__hostdev__ const ValueTypegetValue () const
 Return the value at the specified location relative to the center of the stencil. More...
 
__hostdev__ void setValue (const ValueType &value)
 Set the value at the specified location relative to the center of the stencil. More...
 
__hostdev__ ValueType mean () const
 Return the mean value of the current stencil. More...
 
__hostdev__ ValueType min () const
 Return the smallest value in the stencil buffer. More...
 
__hostdev__ ValueType max () const
 Return the largest value in the stencil buffer. More...
 
__hostdev__ const CoordgetCenterCoord () const
 Return the coordinates of the center point of the stencil. More...
 
__hostdev__ const ValueTypegetCenterValue () const
 Return the value at the center of the stencil. More...
 
__hostdev__ bool intersects (const ValueType &isoValue=ValueType(0)) const
 Return true if the center of the stencil intersects the iso-contour specified by the isoValue. More...
 
__hostdev__ Mask intersectionMask (ValueType isoValue=ValueType(0)) const
 Return true a bit-mask where the 6 lower bits indicates if the center of the stencil intersects the iso-contour specified by the isoValue. More...
 
__hostdev__ const GridTypegrid () const
 Return a const reference to the grid from which this stencil was constructed. More...
 
__hostdev__ const AccessorTypeaccessor () const
 Return a const reference to the ValueAccessor associated with this Stencil. More...
 

Static Public Member Functions

static __hostdev__ int size ()
 Return the size of the stencil buffer. More...
 

Static Public Attributes

static constexpr int SIZE = 7
 

Protected Attributes

const GridTypemGrid
 
AccessorType mAcc
 
ValueType mValues [SIZE]
 
Coord mCenter
 

Friends

template<typename , int , typename >
class BaseStencil
 

Detailed Description

template<typename GridT>
class nanovdb::GradStencil< GridT >

This is a simple 7-point nearest neighbor stencil that supports gradient by second-order central differencing, first-order upwinding, Laplacian, closest-point transform and zero-crossing test.

Note
For optimal random access performance this class includes its own grid accessor.

Member Typedef Documentation

using AccessorType = typename GridT::AccessorType
inherited
using GridType = GridT
using TreeType = typename GridT::TreeType
using ValueType = typename GridT::ValueType

Constructor & Destructor Documentation

__hostdev__ GradStencil ( const GridType grid)
inline
__hostdev__ GradStencil ( const GridType grid,
double  dx 
)
inline

Member Function Documentation

__hostdev__ const AccessorType& accessor ( ) const
inlineinherited

Return a const reference to the ValueAccessor associated with this Stencil.

__hostdev__ Vec3<ValueType> cpt ( )
inline

Compute the closest-point transform to a level set.

Returns
the closest point in index space to the surface from which the level set was derived.
Note
This method assumes that the grid represents a level set with distances in world units and a simple affine transfrom with uniform scaling.
__hostdev__ const Coord& getCenterCoord ( ) const
inlineinherited

Return the coordinates of the center point of the stencil.

__hostdev__ const ValueType& getCenterValue ( ) const
inlineinherited

Return the value at the center of the stencil.

__hostdev__ const ValueType& getValue ( unsigned int  pos = 0) const
inlineinherited

Return the value from the stencil buffer with linear offset pos.

Note
The default (pos = 0) corresponds to the first element which is typically the center point of the stencil.
__hostdev__ const ValueType& getValue ( ) const
inlineinherited

Return the value at the specified location relative to the center of the stencil.

__hostdev__ Vec3<ValueType> gradient ( ) const
inline

Return the gradient computed at the previously buffered location by second order central differencing.

Note
This method should not be called until the stencil buffer has been populated via a call to moveTo(ijk).
__hostdev__ Vec3<ValueType> gradient ( const Vec3< ValueType > &  V) const
inline

Return the first-order upwind gradient corresponding to the direction V.

Note
This method should not be called until the stencil buffer has been populated via a call to moveTo(ijk).
__hostdev__ const GridType& grid ( ) const
inlineinherited

Return a const reference to the grid from which this stencil was constructed.

__hostdev__ Mask intersectionMask ( ValueType  isoValue = ValueType(0)) const
inlineinherited

Return true a bit-mask where the 6 lower bits indicates if the center of the stencil intersects the iso-contour specified by the isoValue.

Note
There are 2^6 = 64 different possible cases, including no intersections!

The ordering of bit mask is ( -x, +x, -y, +y, -z, +z ), so to check if there is an intersection in -y use (mask & (1u<<2)) where mask is ther return value from this function. To check if there are any intersections use mask!=0u, and for no intersections use mask==0u. To count the number of intersections use __builtin_popcount(mask).

__hostdev__ bool intersects ( const ValueType isoValue = ValueType(0)) const
inlineinherited

Return true if the center of the stencil intersects the iso-contour specified by the isoValue.

__hostdev__ ValueType laplacian ( ) const
inline

Return the Laplacian computed at the previously buffered location by second-order central differencing.

__hostdev__ ValueType max ( ) const
inlineinherited

Return the largest value in the stencil buffer.

__hostdev__ ValueType mean ( ) const
inlineinherited

Return the mean value of the current stencil.

__hostdev__ ValueType min ( ) const
inlineinherited

Return the smallest value in the stencil buffer.

__hostdev__ void moveTo ( const Coord ijk)
inlineinherited

Initialize the stencil buffer with the values of voxel (i, j, k) and its neighbors.

Parameters
ijkIndex coordinates of stencil center
__hostdev__ void moveTo ( const Coord ijk,
const ValueType centerValue 
)
inlineinherited

Initialize the stencil buffer with the values of voxel (i, j, k) and its neighbors. The method also takes a value of the center element of the stencil, assuming it is already known.

Parameters
ijkIndex coordinates of stencil center
centerValueValue of the center element of the stencil
__hostdev__ void moveTo ( const IterType &  iter)
inlineinherited

Initialize the stencil buffer with the values of voxel (x, y, z) and its neighbors.

Note
This version is slightly faster than the one above, since the center voxel's value is read directly from the iterator.
__hostdev__ void moveTo ( const Vec3< RealType > &  xyz)
inlineinherited

Initialize the stencil buffer with the values of voxel (x, y, z) and its neighbors.

Parameters
xyzFloating point voxel coordinates of stencil center

This method will check to see if it is necessary to update the stencil based on the cached index coordinates of the center point.

__hostdev__ ValueType normSqGrad ( ) const
inline

Return the norm square of the single-sided upwind gradient (computed via Godunov's scheme) at the previously buffered location.

Note
This method should not be called until the stencil buffer has been populated via a call to moveTo(ijk).
__hostdev__ unsigned int pos ( ) const
inline

Return linear offset for the specified stencil point relative to its center.

__hostdev__ void setValue ( const ValueType value)
inlineinherited

Set the value at the specified location relative to the center of the stencil.

static __hostdev__ int size ( )
inlinestaticinherited

Return the size of the stencil buffer.

__hostdev__ bool zeroCrossing ( ) const
inline

Return true if the sign of the value at the center point of the stencil is different from the signs of any of its six nearest neighbors.

Friends And Related Function Documentation

friend class BaseStencil
friend

Member Data Documentation

AccessorType mAcc
protectedinherited
Coord mCenter
protectedinherited
const GridType* mGrid
protectedinherited
ValueType mValues[SIZE]
protectedinherited
constexpr int SIZE = 7
static