Loading...
Searching...
No Matches
LevelSetFilter< GridT, MaskT, InterruptT > Class Template Reference

Filtering (e.g. diffusion) of narrow-band level sets. An optional scalar field can be used to produce a (smooth) alpha mask for the filtering. More...

`#include <openvdb/tools/LevelSetFilter.h>`

Inheritance diagram for LevelSetFilter< GridT, MaskT, InterruptT >:

## Public Types

using | BaseType = LevelSetTracker<GridT, InterruptT>
using | GridType = GridT
using | MaskType = MaskT
using | TreeType = typename GridType::TreeType
using | ValueType = typename TreeType::ValueType
using | AlphaType = typename MaskType::ValueType
using | TrimMode
using | LeafType
using | LeafManagerType
using | LeafRange
using | BufferType
using | MaskTreeType

## Public Member Functions

| LevelSetFilter (GridType &grid, InterruptT *interrupt=nullptr)
| Main constructor from a grid.
| ~LevelSetFilter () override
| Default destructor.
AlphaType | minMask () const
| Return the minimum value of the mask to be used for the derivation of a smooth alpha value.
AlphaType | maxMask () const
| Return the maximum value of the mask to be used for the derivation of a smooth alpha value.
void | setMaskRange (AlphaType min, AlphaType max)
| Define the range for the (optional) scalar mask.
bool | isMaskInverted () const
| Return true if the mask is inverted, i.e. min->max in the original mask maps to 1->0 in the inverted alpha mask.
void | invertMask (bool invert=true)
| Invert the optional mask, i.e. min->max in the original mask maps to 1->0 in the inverted alpha mask.
void | meanCurvature (const MaskType *mask=nullptr)
| One iteration of mean-curvature flow of the level set.
void | laplacian (const MaskType *mask=nullptr)
| One iteration of Laplacian flow of the level set.
void | gaussian (int width=1, const MaskType *mask=nullptr)
| One iteration of a fast separable Gaussian filter.
void | offset (ValueType offset, const MaskType *mask=nullptr)
| Offset the level set by the specified (world) distance.
void | median (int width=1, const MaskType *mask=nullptr)
| One iteration of median-value flow of the level set.
void | mean (int width=1, const MaskType *mask=nullptr)
| One iteration of mean-value flow of the level set.
void | normalize (const MaskT *mask)
void | track ()
| Track the level set interface, i.e. rebuild and normalize the narrow band of the level set.
void | prune ()
| Set voxels that are outside the narrow band to the background value (if trimming is enabled) and prune the grid.
void | dilate (int iterations=1)
| Fast but approximate dilation of the narrow band - one layer at a time. Normally we recommend using the resize method below which internally calls dilate (or erode) with the correct number of iterations to achieve the desired half voxel width of the narrow band (3 is recommended for most level set applications).
void | erode (int iterations=1)
| Erodes the width of the narrow-band and update the background values.
bool | resize (Index halfWidth=static_cast< Index >(LEVEL_SET_HALF_WIDTH))
| Resize the width of the narrow band, i.e. perform dilation and renormalization or erosion as required.
ValueType | getHalfWidth () const
| Return the half width of the narrow band in floating-point voxel units.
State | getState () const
| Return the state of the tracker (see struct defined above).
void | setState (const State &s)
| Set the state of the tracker (see struct defined above).
math::BiasedGradientScheme | getSpatialScheme () const
void | setSpatialScheme (math::BiasedGradientScheme s)
| Set the spatial finite difference scheme.
math::TemporalIntegrationScheme | getTemporalScheme () const
void | setTemporalScheme (math::TemporalIntegrationScheme s)
| Set the spatial finite difference scheme.
int | getNormCount () const
void | setNormCount (int n)
| Set the number of normalizations performed per track or normalize call.
int | getGrainSize () const
void | setGrainSize (int grainsize)
| Set the grain-size used for multi-threading.
TrimMode | trimming () const
| Return the trimming mode for voxels outside the narrow band.
void | setTrimming (TrimMode mode)
| Specify whether to trim voxels outside the narrow band prior to pruning.
ValueType | voxelSize () const
void | startInterrupter (const char *msg)
void | endInterrupter ()
bool | checkInterrupter ()
const GridType & | grid () const
LeafManagerType & | leafs ()

## Detailed Description

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>
class openvdb::v10_0::tools::LevelSetFilter< GridT, MaskT, InterruptT >

Filtering (e.g. diffusion) of narrow-band level sets. An optional scalar field can be used to produce a (smooth) alpha mask for the filtering.

Note
  This class performs proper interface tracking which allows for unrestricted surface deformations

## Member Typedef Documentation

## AlphaType

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

using AlphaType = typename MaskType::ValueType

## BaseType

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

using BaseType = LevelSetTracker<GridT, InterruptT>

## BufferType

using BufferType

inherited

## GridType

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

using GridType = GridT

## LeafManagerType

using LeafManagerType

inherited

## LeafRange

using LeafRange

inherited

## LeafType

using LeafType

inherited

## MaskTreeType

using MaskTreeType

inherited

## MaskType

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

using MaskType = MaskT

## TreeType

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

using TreeType = typename GridType::TreeType

## TrimMode

using TrimMode

inherited

## ValueType

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

using ValueType = typename TreeType::ValueType

## Constructor & Destructor Documentation

## LevelSetFilter()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

LevelSetFilter | ( | GridType & | grid,
|  | InterruptT * | interrupt = nullptr )

inline

Main constructor from a grid.

Parameters

  grid | The level set to be filtered.
  interrupt | Optional interrupter.

## ~LevelSetFilter()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

~LevelSetFilter | ( |  | ) |

inline override

Default destructor.

## Member Function Documentation

## checkInterrupter()

bool checkInterrupter | ( |  | ) |

inline inherited

Returns
  false if the process was interrupted

## dilate()

void dilate | ( | int | iterations = 1 | ) |

inherited

Fast but approximate dilation of the narrow band - one layer at a time. Normally we recommend using the resize method below which internally calls dilate (or erode) with the correct number of iterations to achieve the desired half voxel width of the narrow band (3 is recommended for most level set applications).

Note
  Since many level set applications perform interface-tracking, which in turn rebuilds the narrow-band accurately, this dilate method can often be used with a single iterations of low-order re-normalization. This effectively allows very narrow bands to be created from points or polygons (e.g. with a half voxel width of 1), followed by a fast but approximate dilation (typically with a half voxel width of 3). This can be significantly faster than generating the final width of the narrow band from points or polygons.

## endInterrupter()

void endInterrupter | ( |  | ) |

inline inherited

## erode()

void erode | ( | int | iterations = 1 | ) |

inherited

Erodes the width of the narrow-band and update the background values.

Exceptions

  ValueError | if iterations is larger than the current half-width.

## gaussian()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

void gaussian | ( | int | width = 1,
|  | const MaskType * | mask = nullptr )

inline

One iteration of a fast separable Gaussian filter.

Parameters

  width | Width of the Gaussian kernel in voxel units.
  mask | Optional alpha mask.

Note
  This is approximated as 4 iterations of a separable mean filter which typically leads an approximation that's better than 95%!

## getGrainSize()

int getGrainSize | ( |  | ) | const

inline inherited

Returns
  the grain-size used for multi-threading

## getHalfWidth()

ValueType getHalfWidth | ( |  | ) | const

inline inherited

Return the half width of the narrow band in floating-point voxel units.

## getNormCount()

int getNormCount | ( |  | ) | const

inline inherited

Returns
  The number of normalizations performed per track or normalize call.

## getSpatialScheme()

math::BiasedGradientScheme getSpatialScheme | ( |  | ) | const

inline inherited

Returns
  the spatial finite difference scheme

## getState()

State getState | ( |  | ) | const

inline inherited

Return the state of the tracker (see struct defined above).

## getTemporalScheme()

math::TemporalIntegrationScheme getTemporalScheme | ( |  | ) | const

inline inherited

Returns
  the temporal integration scheme

## grid()

const GridType & grid | ( |  | ) | const

inline inherited

## invertMask()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

void invertMask | ( | bool | invert = true | ) |

inline

Invert the optional mask, i.e. min->max in the original mask maps to 1->0 in the inverted alpha mask.

## isMaskInverted()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

bool isMaskInverted | ( |  | ) | const

inline

Return true if the mask is inverted, i.e. min->max in the original mask maps to 1->0 in the inverted alpha mask.

## laplacian()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

void laplacian | ( | const MaskType * | mask = nullptr | ) |

inline

One iteration of Laplacian flow of the level set.

Parameters

  mask | Optional alpha mask.

## leafs()

LeafManagerType & leafs | ( |  | ) |

inline inherited

## maxMask()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

AlphaType maxMask | ( |  | ) | const

inline

Return the maximum value of the mask to be used for the derivation of a smooth alpha value.

## mean()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

void mean | ( | int | width = 1,
|  | const MaskType * | mask = nullptr )

inline

One iteration of mean-value flow of the level set.

Parameters

  width | Width of the mean-value kernel in voxel units.
  mask | Optional alpha mask.

Note
  This filter is separable so it's fast!

## meanCurvature()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

void meanCurvature | ( | const MaskType * | mask = nullptr | ) |

inline

One iteration of mean-curvature flow of the level set.

Parameters

  mask | Optional alpha mask.

## median()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

void median | ( | int | width = 1,
|  | const MaskType * | mask = nullptr )

inline

One iteration of median-value flow of the level set.

Parameters

  width | Width of the median-value kernel in voxel units.
  mask | Optional alpha mask.

Warning
  This filter is not separable and is hence relatively slow!

## minMask()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

AlphaType minMask | ( |  | ) | const

inline

Return the minimum value of the mask to be used for the derivation of a smooth alpha value.

## normalize()

void normalize | ( | const MaskT * | mask | ) |

inherited

## offset()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

void offset | ( | ValueType | offset,
|  | const MaskType * | mask = nullptr )

inline

Offset the level set by the specified (world) distance.

Parameters

  offset | Value of the offset.
  mask | Optional alpha mask.

## prune()

void prune | ( |  | ) |

inherited

Set voxels that are outside the narrow band to the background value (if trimming is enabled) and prune the grid.

Pruning is done automatically as a step in tracking.

See also
  setTrimming, trimming

## resize()

bool resize | ( | Index | halfWidth = static_cast<Index>(LEVEL_SET_HALF_WIDTH) | ) |

inherited

Resize the width of the narrow band, i.e. perform dilation and renormalization or erosion as required.

## setGrainSize()

void setGrainSize | ( | int | grainsize | ) |

inline inherited

Set the grain-size used for multi-threading.

Note
  A grainsize of 0 or less disables multi-threading!

## setMaskRange()

template<typename GridT, typename MaskT = typename GridT::template ValueConverter<float>::Type, typename InterruptT = util::NullInterrupter>

void setMaskRange | ( | AlphaType | min,
|  | AlphaType | max )

inline

Define the range for the (optional) scalar mask.

Parameters

  min | Minimum value of the range.
  max | Maximum value of the range.

Mask values outside the range maps to alpha values of respectfully zero and one, and values inside the range maps smoothly to 0->1 (unless of course the mask is inverted).

Exceptions

  ValueError | if min is not smaller than max.

## setNormCount()

void setNormCount | ( | int | n | ) |

inline inherited

Set the number of normalizations performed per track or normalize call.

## setSpatialScheme()

void setSpatialScheme | ( | math::BiasedGradientScheme | s | ) |

inline inherited

Set the spatial finite difference scheme.

## setState()

void setState | ( | const State & | s | ) |

inline inherited

Set the state of the tracker (see struct defined above).

## setTemporalScheme()

void setTemporalScheme | ( | math::TemporalIntegrationScheme | s | ) |

inline inherited

Set the spatial finite difference scheme.

## setTrimming()

void setTrimming | ( | TrimMode | mode | ) |

inline inherited

Specify whether to trim voxels outside the narrow band prior to pruning.

See also
  trimming, prune

## startInterrupter()

void startInterrupter | ( | const char * | msg | ) |

inline inherited

## track()

void track | ( |  | ) |

inherited

Track the level set interface, i.e. rebuild and normalize the narrow band of the level set.

## trimming()

TrimMode trimming | ( |  | ) | const

inline inherited

Return the trimming mode for voxels outside the narrow band.

Trimming is enabled by default and is applied automatically prior to pruning.

See also
  setTrimming, prune

## voxelSize()

ValueType voxelSize | ( |  | ) | const

inline inherited