Loading...
Searching...
No Matches
GridOperators.h
Go to the documentation of this file.
// Copyright Contributors to the OpenVDB Project
// SPDX-License-Identifier: MPL-2.0
/// @file tools/GridOperators.h
///
/// @brief Apply an operator to an input grid to produce an output grid
/// with the same active voxel topology but a potentially different value type.
#ifndef OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
#define OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
#include <openvdb/openvdb.h>
#include <openvdb/Grid.h>
#include <openvdb/math/Operators.h>
#include <openvdb/util/NullInterrupter.h>
#include <openvdb/thread/Threading.h>
#include <openvdb/tree/LeafManager.h>
#include <openvdb/tree/ValueAccessor.h>
#include "ValueTransformer.h" // for tools::foreach()
#include <tbb/parallel_for.h>
namespace openvdb {
OPENVDB_USE_VERSION_NAMESPACE
namespace OPENVDB_VERSION_NAME {
namespace tools {
/// @brief VectorToScalarConverter<VectorGridType>::Type is the type of a grid
/// having the same tree configuration as VectorGridType but a scalar value type, T,
/// where T is the type of the original vector components.
/// @details For example, VectorToScalarConverter<Vec3DGrid>::Type is equivalent to DoubleGrid.
template<typename VectorGridType> struct VectorToScalarConverter {
typedef typename VectorGridType::ValueType::value_type VecComponentValueT;
typedef typename VectorGridType::template ValueConverter<VecComponentValueT>::Type Type;
};
/// @brief ScalarToVectorConverter<ScalarGridType>::Type is the type of a grid
/// having the same tree configuration as ScalarGridType but value type Vec3<T>
/// where T is ScalarGridType::ValueType.
/// @details For example, ScalarToVectorConverter<DoubleGrid>::Type is equivalent to Vec3DGrid.
template<typename ScalarGridType> struct ScalarToVectorConverter {
typedef math::Vec3<typename ScalarGridType::ValueType> VectorValueT;
typedef typename ScalarGridType::template ValueConverter<VectorValueT>::Type Type;
};
/// @brief Compute the Closest-Point Transform (CPT) from a distance field.
/// @return a new vector-valued grid with the same numerical precision as the input grid
/// (for example, if the input grid is a DoubleGrid, the output grid will be a Vec3DGrid)
/// @details When a mask grid is specified, the solution is calculated only in
/// the intersection of the mask active topology and the input active topology
/// independent of the transforms associated with either grid.
template<typename GridType, typename InterruptT>
typename ScalarToVectorConverter<GridType>::Type::Ptr
cpt(const GridType& grid, bool threaded, InterruptT* interrupt);
template<typename GridType, typename MaskT, typename InterruptT>
typename ScalarToVectorConverter<GridType>::Type::Ptr
cpt(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt);
template<typename GridType>
typename ScalarToVectorConverter<GridType>::Type::Ptr
cpt(const GridType& grid, bool threaded = true)
{
return cpt<GridType, util::NullInterrupter>(grid, threaded, nullptr);
}
template<typename GridType, typename MaskT>
typename ScalarToVectorConverter<GridType>::Type::Ptr
cpt(const GridType& grid, const MaskT& mask, bool threaded = true)
{
return cpt<GridType, MaskT, util::NullInterrupter>(grid, mask, threaded, nullptr);
}
/// @brief Compute the curl of the given vector-valued grid.
/// @return a new vector-valued grid
/// @details When a mask grid is specified, the solution is calculated only in
/// the intersection of the mask active topology and the input active topology
/// independent of the transforms associated with either grid.
template<typename GridType, typename InterruptT>
typename GridType::Ptr
curl(const GridType& grid, bool threaded, InterruptT* interrupt);
template<typename GridType, typename MaskT, typename InterruptT>
typename GridType::Ptr
curl(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt);
template<typename GridType>
typename GridType::Ptr
curl(const GridType& grid, bool threaded = true)
{
return curl<GridType, util::NullInterrupter>(grid, threaded, nullptr);
}
template<typename GridType, typename MaskT>
typename GridType::Ptr
curl(const GridType& grid, const MaskT& mask, bool threaded = true)
{
return curl<GridType, MaskT, util::NullInterrupter>(grid, mask, threaded, nullptr);
}
/// @brief Compute the divergence of the given vector-valued grid.
/// @return a new scalar-valued grid with the same numerical precision as the input grid
/// (for example, if the input grid is a Vec3DGrid, the output grid will be a DoubleGrid)
/// @details When a mask grid is specified, the solution is calculated only in
/// the intersection of the mask active topology and the input active topology
/// independent of the transforms associated with either grid.
template<typename GridType, typename InterruptT>
typename VectorToScalarConverter<GridType>::Type::Ptr
divergence(const GridType& grid, bool threaded, InterruptT* interrupt);
template<typename GridType, typename MaskT, typename InterruptT>
typename VectorToScalarConverter<GridType>::Type::Ptr
divergence(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt);
template<typename GridType>
typename VectorToScalarConverter<GridType>::Type::Ptr
divergence(const GridType& grid, bool threaded = true)
{
return divergence<GridType, util::NullInterrupter>(grid, threaded, nullptr);
}
template<typename GridType, typename MaskT>
typename VectorToScalarConverter<GridType>::Type::Ptr
divergence(const GridType& grid, const MaskT& mask, bool threaded = true)
{
return divergence<GridType, MaskT, util::NullInterrupter>(grid, mask, threaded, nullptr);
}
/// @brief Compute the gradient of the given scalar grid.
/// @return a new vector-valued grid with the same numerical precision as the input grid
/// (for example, if the input grid is a DoubleGrid, the output grid will be a Vec3DGrid)
/// @details When a mask grid is specified, the solution is calculated only in
/// the intersection of the mask active topology and the input active topology
/// independent of the transforms associated with either grid.
template<typename GridType, typename InterruptT>
typename ScalarToVectorConverter<GridType>::Type::Ptr
gradient(const GridType& grid, bool threaded, InterruptT* interrupt);
template<typename GridType, typename MaskT, typename InterruptT>
typename ScalarToVectorConverter<GridType>::Type::Ptr
gradient(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt);
template<typename GridType>
typename ScalarToVectorConverter<GridType>::Type::Ptr
gradient(const GridType& grid, bool threaded = true)
{
return gradient<GridType, util::NullInterrupter>(grid, threaded, nullptr);
}
template<typename GridType, typename MaskT>
typename ScalarToVectorConverter<GridType>::Type::Ptr
gradient(const GridType& grid, const MaskT& mask, bool threaded = true)
{
return gradient<GridType, MaskT, util::NullInterrupter>(grid, mask, threaded, nullptr);
}
/// @brief Compute the Laplacian of the given scalar grid.
/// @return a new scalar grid
/// @details When a mask grid is specified, the solution is calculated only in
/// the intersection of the mask active topology and the input active topology
/// independent of the transforms associated with either grid.
template<typename GridType, typename InterruptT>
typename GridType::Ptr
laplacian(const GridType& grid, bool threaded, InterruptT* interrupt);
template<typename GridType, typename MaskT, typename InterruptT>
typename GridType::Ptr
laplacian(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt);
template<typename GridType>
typename GridType::Ptr
laplacian(const GridType& grid, bool threaded = true)
{
return laplacian<GridType, util::NullInterrupter>(grid, threaded, nullptr);
}
template<typename GridType, typename MaskT>
typename GridType::Ptr
laplacian(const GridType& grid, const MaskT& mask, bool threaded = true)
{
return laplacian<GridType, MaskT, util::NullInterrupter>(grid, mask, threaded, nullptr);
}
/// @brief Compute the mean curvature of the given grid.
/// @return a new grid
/// @details When a mask grid is specified, the solution is calculated only in
/// the intersection of the mask active topology and the input active topology
/// independent of the transforms associated with either grid.
template<typename GridType, typename InterruptT>
typename GridType::Ptr
meanCurvature(const GridType& grid, bool threaded, InterruptT* interrupt);
template<typename GridType, typename MaskT, typename InterruptT>
typename GridType::Ptr
meanCurvature(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt);
template<typename GridType>
typename GridType::Ptr
meanCurvature(const GridType& grid, bool threaded = true)
{
return meanCurvature<GridType, util::NullInterrupter>(grid, threaded, nullptr);
}
template<typename GridType, typename MaskT>
typename GridType::Ptr
meanCurvature(const GridType& grid, const MaskT& mask, bool threaded = true)
{
return meanCurvature<GridType, MaskT, util::NullInterrupter>(grid, mask, threaded, nullptr);
}
/// @brief Compute the magnitudes of the vectors of the given vector-valued grid.
/// @return a new scalar-valued grid with the same numerical precision as the input grid
/// (for example, if the input grid is a Vec3DGrid, the output grid will be a DoubleGrid)
/// @details When a mask grid is specified, the solution is calculated only in
/// the intersection of the mask active topology and the input active topology
/// independent of the transforms associated with either grid.
template<typename GridType, typename InterruptT>
typename VectorToScalarConverter<GridType>::Type::Ptr
magnitude(const GridType& grid, bool threaded, InterruptT* interrupt);
template<typename GridType, typename MaskT, typename InterruptT>
typename VectorToScalarConverter<GridType>::Type::Ptr
magnitude(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt);
template<typename GridType>
typename VectorToScalarConverter<GridType>::Type::Ptr
magnitude(const GridType& grid, bool threaded = true)
{
return magnitude<GridType, util::NullInterrupter>(grid, threaded, nullptr);
}
template<typename GridType, typename MaskT>
typename VectorToScalarConverter<GridType>::Type::Ptr
magnitude(const GridType& grid, const MaskT& mask, bool threaded = true)
{
return magnitude<GridType, MaskT, util::NullInterrupter>(grid, mask, threaded, nullptr);
}
/// @brief Normalize the vectors of the given vector-valued grid.
/// @return a new vector-valued grid
/// @details When a mask grid is specified, the solution is calculated only in
/// the intersection of the mask active topology and the input active topology
/// independent of the transforms associated with either grid.
template<typename GridType, typename InterruptT>
typename GridType::Ptr
normalize(const GridType& grid, bool threaded, InterruptT* interrupt);
template<typename GridType, typename MaskT, typename InterruptT>
typename GridType::Ptr
normalize(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt);
template<typename GridType>
typename GridType::Ptr
normalize(const GridType& grid, bool threaded = true)
{
return normalize<GridType, util::NullInterrupter>(grid, threaded, nullptr);
}
template<typename GridType, typename MaskT>
typename GridType::Ptr
normalize(const GridType& grid, const MaskT& mask, bool threaded = true)
{
return normalize<GridType, MaskT, util::NullInterrupter>(grid, mask, threaded, nullptr);
}
////////////////////////////////////////
namespace gridop {
/// @brief ToMaskGrid<T>::Type is the type of a grid having the same
/// tree hierarchy as grid type T but a value equal to its active state.
/// @details For example, ToMaskGrid<FloatGrid>::Type is equivalent to MaskGrid.
template<typename GridType>
struct ToMaskGrid {
typedef Grid<typename GridType::TreeType::template ValueConverter<ValueMask>::Type> Type;
};
/// @brief Apply an operator to an input grid to produce an output grid
/// with the same active voxel topology but a potentially different value type.
/// @details To facilitate inlining, this class is also templated on a Map type.
///
/// @note This is a helper class and should never be used directly.
template<
typename InGridT,
typename MaskGridType,
typename OutGridT,
typename MapT,
typename OperatorT,
typename InterruptT = util::NullInterrupter>
class GridOperator
{
public:
typedef typename OutGridT::TreeType OutTreeT;
typedef typename OutTreeT::LeafNodeType OutLeafT;
typedef typename tree::LeafManager<OutTreeT> LeafManagerT;
GridOperator(const InGridT& grid, const MaskGridType* mask, const MapT& map,
InterruptT* interrupt = nullptr, bool densify = true)
: mAcc(grid.getConstAccessor())
, mMap(map)
, mInterrupt(interrupt)
, mMask(mask)
, mDensify(densify) ///< @todo consider adding a "NeedsDensification" operator trait
{
}
GridOperator(const GridOperator&) = default;
GridOperator& operator=(const GridOperator&) = default;
virtual ~GridOperator() = default;
typename OutGridT::Ptr process(bool threaded = true)
{
if (mInterrupt) mInterrupt->start("Processing grid");
// Derive background value of the output grid
typename InGridT::TreeType tmp(mAcc.tree().background());
typename OutGridT::ValueType backg = OperatorT::result(mMap, tmp, math::Coord(0));
// The output tree is topology copy, optionally densified, of the input tree.
// (Densification is necessary for some operators because applying the operator to
// a constant tile produces distinct output values, particularly along tile borders.)
/// @todo Can tiles be handled correctly without densification, or by densifying
/// only to the width of the operator stencil?
typename OutTreeT::Ptr tree(new OutTreeT(mAcc.tree(), backg, TopologyCopy()));
if (mDensify) tree->voxelizeActiveTiles();
// create grid with output tree and unit transform
typename OutGridT::Ptr result(new OutGridT(tree));
// Modify the solution area if a mask was supplied.
if (mMask) {
result->topologyIntersection(*mMask);
}
// transform of output grid = transform of input grid
result->setTransform(math::Transform::Ptr(new math::Transform( mMap.copy() )));
LeafManagerT leafManager(*tree);
if (threaded) {
tbb::parallel_for(leafManager.leafRange(), *this);
} else {
(*this)(leafManager.leafRange());
}
// If the tree wasn't densified, it might have active tiles that need to be processed.
if (!mDensify) {
using TileIter = typename OutTreeT::ValueOnIter;
TileIter tileIter = tree->beginValueOn();
tileIter.setMaxDepth(tileIter.getLeafDepth() - 1); // skip leaf values (i.e., voxels)
AccessorT inAcc = mAcc; // each thread needs its own accessor, captured by value
auto tileOp = [this, inAcc](const TileIter& it) {
// Apply the operator to the input grid's tile value at the iterator's
// current coordinates, and set the output tile's value to the result.
it.setValue(OperatorT::result(this->mMap, inAcc, it.getCoord()));
};
// Apply the operator to tile values, optionally in parallel.
// (But don't share the functor; each thread needs its own accessor.)
tools::foreach(tileIter, tileOp, threaded, /*shareFunctor=*/false);
}
if (mDensify) tree->prune();
if (mInterrupt) mInterrupt->end();
return result;
}
/// @brief Iterate sequentially over LeafNodes and voxels in the output
/// grid and apply the operator using a value accessor for the input grid.
///
/// @note Never call this public method directly - it is called by
/// TBB threads only!
void operator()(const typename LeafManagerT::LeafRange& range) const
{
if (util::wasInterrupted(mInterrupt)) {
thread::cancelGroupExecution();
}
for (typename LeafManagerT::LeafRange::Iterator leaf=range.begin(); leaf; ++leaf) {
for (typename OutLeafT::ValueOnIter value=leaf->beginValueOn(); value; ++value) {
value.setValue(OperatorT::result(mMap, mAcc, value.getCoord()));
}
}
}
protected:
typedef typename InGridT::ConstAccessor AccessorT;
mutable AccessorT mAcc;
const MapT& mMap;
InterruptT* mInterrupt;
const MaskGridType* mMask;
const bool mDensify;
}; // end of GridOperator class
} // namespace gridop
////////////////////////////////////////
/// @brief Compute the closest-point transform of a scalar grid.
template<
typename InGridT,
typename MaskGridType = typename gridop::ToMaskGrid<InGridT>::Type,
typename InterruptT = util::NullInterrupter>
class Cpt
{
public:
typedef InGridT InGridType;
typedef typename ScalarToVectorConverter<InGridT>::Type OutGridType;
Cpt(const InGridType& grid, InterruptT* interrupt = nullptr):
mInputGrid(grid), mInterrupt(interrupt), mMask(nullptr)
{
}
Cpt(const InGridType& grid, const MaskGridType& mask, InterruptT* interrupt = nullptr):
mInputGrid(grid), mInterrupt(interrupt), mMask(&mask)
{
}
typename OutGridType::Ptr process(bool threaded = true, bool useWorldTransform = true)
{
Functor functor(mInputGrid, mMask, threaded, useWorldTransform, mInterrupt);
processTypedMap(mInputGrid.transform(), functor);
if (functor.mOutputGrid) functor.mOutputGrid->setVectorType(VEC_CONTRAVARIANT_ABSOLUTE);
return functor.mOutputGrid;
}
private:
struct IsOpT
{
template<typename MapT, typename AccT>
static typename OutGridType::ValueType
result(const MapT& map, const AccT& acc, const Coord& xyz)
{
return math::CPT<MapT, math::CD_2ND>::result(map, acc, xyz);
}
};
struct WsOpT
{
template<typename MapT, typename AccT>
static typename OutGridType::ValueType
result(const MapT& map, const AccT& acc, const Coord& xyz)
{
return math::CPT_RANGE<MapT, math::CD_2ND>::result(map, acc, xyz);
}
};
struct Functor
{
Functor(const InGridType& grid, const MaskGridType* mask,
bool threaded, bool worldspace, InterruptT* interrupt)
: mThreaded(threaded)
, mWorldSpace(worldspace)
, mInputGrid(grid)
, mInterrupt(interrupt)
, mMask(mask)
{}
template<typename MapT>
void operator()(const MapT& map)
{
if (mWorldSpace) {
gridop::GridOperator<InGridType, MaskGridType, OutGridType, MapT, WsOpT, InterruptT>
op(mInputGrid, mMask, map, mInterrupt, /*densify=*/false);
mOutputGrid = op.process(mThreaded); // cache the result
} else {
gridop::GridOperator<InGridType, MaskGridType, OutGridType, MapT, IsOpT, InterruptT>
op(mInputGrid, mMask, map, mInterrupt, /*densify=*/false);
mOutputGrid = op.process(mThreaded); // cache the result
}
}
const bool mThreaded;
const bool mWorldSpace;
const InGridType& mInputGrid;
typename OutGridType::Ptr mOutputGrid;
InterruptT* mInterrupt;
const MaskGridType* mMask;
};
const InGridType& mInputGrid;
InterruptT* mInterrupt;
const MaskGridType* mMask;
}; // end of Cpt class
////////////////////////////////////////
/// @brief Compute the curl of a vector grid.
template<
typename GridT,
typename MaskGridType = typename gridop::ToMaskGrid<GridT>::Type,
typename InterruptT = util::NullInterrupter>
class Curl
{
public:
typedef GridT InGridType;
typedef GridT OutGridType;
Curl(const GridT& grid, InterruptT* interrupt = nullptr):
mInputGrid(grid), mInterrupt(interrupt), mMask(nullptr)
{
}
Curl(const GridT& grid, const MaskGridType& mask, InterruptT* interrupt = nullptr):
mInputGrid(grid), mInterrupt(interrupt), mMask(&mask)
{
}
typename GridT::Ptr process(bool threaded = true)
{
Functor functor(mInputGrid, mMask, threaded, mInterrupt);
processTypedMap(mInputGrid.transform(), functor);
if (functor.mOutputGrid) functor.mOutputGrid->setVectorType(VEC_COVARIANT);
return functor.mOutputGrid;
}
private:
struct Functor
{
Functor(const GridT& grid, const MaskGridType* mask,
bool threaded, InterruptT* interrupt):
mThreaded(threaded), mInputGrid(grid), mInterrupt(interrupt), mMask(mask) {}
template<typename MapT>
void operator()(const MapT& map)
{
typedef math::Curl<MapT, math::CD_2ND> OpT;
gridop::GridOperator<GridT, MaskGridType, GridT, MapT, OpT, InterruptT>
op(mInputGrid, mMask, map, mInterrupt);
mOutputGrid = op.process(mThreaded); // cache the result
}
const bool mThreaded;
const GridT& mInputGrid;
typename GridT::Ptr mOutputGrid;
InterruptT* mInterrupt;
const MaskGridType* mMask;
}; // Private Functor
const GridT& mInputGrid;
InterruptT* mInterrupt;
const MaskGridType* mMask;
}; // end of Curl class
////////////////////////////////////////
/// @brief Compute the divergence of a vector grid.
template<
typename InGridT,
typename MaskGridType = typename gridop::ToMaskGrid<InGridT>::Type,
typename InterruptT = util::NullInterrupter>
class Divergence
{
public:
typedef InGridT InGridType;
typedef typename VectorToScalarConverter<InGridT>::Type OutGridType;
Divergence(const InGridT& grid, InterruptT* interrupt = nullptr):
mInputGrid(grid), mInterrupt(interrupt), mMask(nullptr)
{
}
Divergence(const InGridT& grid, const MaskGridType& mask, InterruptT* interrupt = nullptr):
mInputGrid(grid), mInterrupt(interrupt), mMask(&mask)
{
}
typename OutGridType::Ptr process(bool threaded = true)
{
if (mInputGrid.getGridClass() == GRID_STAGGERED) {
Functor<math::FD_1ST> functor(mInputGrid, mMask, threaded, mInterrupt);
processTypedMap(mInputGrid.transform(), functor);
return functor.mOutputGrid;
} else {
Functor<math::CD_2ND> functor(mInputGrid, mMask, threaded, mInterrupt);
processTypedMap(mInputGrid.transform(), functor);
return functor.mOutputGrid;
}
}
protected:
template<math::DScheme DiffScheme>
struct Functor
{
Functor(const InGridT& grid, const MaskGridType* mask,
bool threaded, InterruptT* interrupt):
mThreaded(threaded), mInputGrid(grid), mInterrupt(interrupt), mMask(mask) {}
template<typename MapT>
void operator()(const MapT& map)
{
typedef math::Divergence<MapT, DiffScheme> OpT;
gridop::GridOperator<InGridType, MaskGridType, OutGridType, MapT, OpT, InterruptT>
op(mInputGrid, mMask, map, mInterrupt);
mOutputGrid = op.process(mThreaded); // cache the result
}
const bool mThreaded;
const InGridType& mInputGrid;
typename OutGridType::Ptr mOutputGrid;
InterruptT* mInterrupt;
const MaskGridType* mMask;
}; // Private Functor
const InGridType& mInputGrid;
InterruptT* mInterrupt;
const MaskGridType* mMask;
}; // end of Divergence class
////////////////////////////////////////
/// @brief Compute the gradient of a scalar grid.
template<
typename InGridT,
typename MaskGridType = typename gridop::ToMaskGrid<InGridT>::Type,
typename InterruptT = util::NullInterrupter>
class Gradient
{
public:
typedef InGridT InGridType;
typedef typename ScalarToVectorConverter<InGridT>::Type OutGridType;
Gradient(const InGridT& grid, InterruptT* interrupt = nullptr):
mInputGrid(grid), mInterrupt(interrupt), mMask(nullptr)
{
}
Gradient(const InGridT& grid, const MaskGridType& mask, InterruptT* interrupt = nullptr):
mInputGrid(grid), mInterrupt(interrupt), mMask(&mask)
{
}
typename OutGridType::Ptr process(bool threaded = true)
{
Functor functor(mInputGrid, mMask, threaded, mInterrupt);
processTypedMap(mInputGrid.transform(), functor);
if (functor.mOutputGrid) functor.mOutputGrid->setVectorType(VEC_COVARIANT);
return functor.mOutputGrid;
}
protected:
struct Functor
{
Functor(const InGridT& grid, const MaskGridType* mask,
bool threaded, InterruptT* interrupt):
mThreaded(threaded), mInputGrid(grid), mInterrupt(interrupt), mMask(mask) {}
template<typename MapT>
void operator()(const MapT& map)
{
typedef math::Gradient<MapT, math::CD_2ND> OpT;
gridop::GridOperator<InGridType, MaskGridType, OutGridType, MapT, OpT, InterruptT>
op(mInputGrid, mMask, map, mInterrupt);
mOutputGrid = op.process(mThreaded); // cache the result
}
const bool mThreaded;
const InGridT& mInputGrid;
typename OutGridType::Ptr mOutputGrid;
InterruptT* mInterrupt;
const MaskGridType* mMask;
}; // Private Functor
const InGridT& mInputGrid;
InterruptT* mInterrupt;
const MaskGridType* mMask;
}; // end of Gradient class
////////////////////////////////////////
template<
typename GridT,
typename MaskGridType = typename gridop::ToMaskGrid<GridT>::Type,
typename InterruptT = util::NullInterrupter>
class Laplacian
{
public:
typedef GridT InGridType;
typedef GridT OutGridType;
Laplacian(const GridT& grid, InterruptT* interrupt = nullptr):
mInputGrid(grid), mInterrupt(interrupt), mMask(nullptr)
{
}
Laplacian(const GridT& grid, const MaskGridType& mask, InterruptT* interrupt = nullptr):
mInputGrid(grid), mInterrupt(interrupt), mMask(&mask)
{
}
typename GridT::Ptr process(bool threaded = true)
{
Functor functor(mInputGrid, mMask, threaded, mInterrupt);
processTypedMap(mInputGrid.transform(), functor);
if (functor.mOutputGrid) functor.mOutputGrid->setVectorType(VEC_COVARIANT);
return functor.mOutputGrid;
}
protected:
struct Functor
{
Functor(const GridT& grid, const MaskGridType* mask, bool threaded, InterruptT* interrupt):
mThreaded(threaded), mInputGrid(grid), mInterrupt(interrupt), mMask(mask) {}
template<typename MapT>
void operator()(const MapT& map)
{
typedef math::Laplacian<MapT, math::CD_SECOND> OpT;
gridop::GridOperator<GridT, MaskGridType, GridT, MapT, OpT, InterruptT>
op(mInputGrid, mMask, map, mInterrupt);
mOutputGrid = op.process(mThreaded); // cache the result
}
const bool mThreaded;
const GridT& mInputGrid;
typename GridT::Ptr mOutputGrid;
InterruptT* mInterrupt;
const MaskGridType* mMask;
}; // Private Functor
const GridT& mInputGrid;
InterruptT* mInterrupt;
const MaskGridType* mMask;
}; // end of Laplacian class
////////////////////////////////////////
template<
typename GridT,
typename MaskGridType = typename gridop::ToMaskGrid<GridT>::Type,
typename InterruptT = util::NullInterrupter>
class MeanCurvature
{
public:
typedef GridT InGridType;
typedef GridT OutGridType;
MeanCurvature(const GridT& grid, InterruptT* interrupt = nullptr):
mInputGrid(grid), mInterrupt(interrupt), mMask(nullptr)
{
}
MeanCurvature(const GridT& grid, const MaskGridType& mask, InterruptT* interrupt = nullptr):
mInputGrid(grid), mInterrupt(interrupt), mMask(&mask)
{
}
typename GridT::Ptr process(bool threaded = true)
{
Functor functor(mInputGrid, mMask, threaded, mInterrupt);
processTypedMap(mInputGrid.transform(), functor);
if (functor.mOutputGrid) functor.mOutputGrid->setVectorType(VEC_COVARIANT);
return functor.mOutputGrid;
}
protected:
struct Functor
{
Functor(const GridT& grid, const MaskGridType* mask, bool threaded, InterruptT* interrupt):
mThreaded(threaded), mInputGrid(grid), mInterrupt(interrupt), mMask(mask) {}
template<typename MapT>
void operator()(const MapT& map)
{
typedef math::MeanCurvature<MapT, math::CD_SECOND, math::CD_2ND> OpT;
gridop::GridOperator<GridT, MaskGridType, GridT, MapT, OpT, InterruptT>
op(mInputGrid, mMask, map, mInterrupt);
mOutputGrid = op.process(mThreaded); // cache the result
}
const bool mThreaded;
const GridT& mInputGrid;
typename GridT::Ptr mOutputGrid;
InterruptT* mInterrupt;
const MaskGridType* mMask;
}; // Private Functor
const GridT& mInputGrid;
InterruptT* mInterrupt;
const MaskGridType* mMask;
}; // end of MeanCurvature class
////////////////////////////////////////
template<
typename InGridT,
typename MaskGridType = typename gridop::ToMaskGrid<InGridT>::Type,
typename InterruptT = util::NullInterrupter>
class Magnitude
{
public:
typedef InGridT InGridType;
typedef typename VectorToScalarConverter<InGridT>::Type OutGridType;
Magnitude(const InGridType& grid, InterruptT* interrupt = nullptr):
mInputGrid(grid), mInterrupt(interrupt), mMask(nullptr)
{
}
Magnitude(const InGridType& grid, const MaskGridType& mask, InterruptT* interrupt = nullptr):
mInputGrid(grid), mInterrupt(interrupt), mMask(&mask)
{
}
typename OutGridType::Ptr process(bool threaded = true)
{
Functor functor(mInputGrid, mMask, threaded, mInterrupt);
processTypedMap(mInputGrid.transform(), functor);
return functor.mOutputGrid;
}
protected:
struct OpT
{
template<typename MapT, typename AccT>
static typename OutGridType::ValueType
result(const MapT&, const AccT& acc, const Coord& xyz) { return acc.getValue(xyz).length();}
};
struct Functor
{
Functor(const InGridT& grid, const MaskGridType* mask,
bool threaded, InterruptT* interrupt):
mThreaded(threaded), mInputGrid(grid), mInterrupt(interrupt), mMask(mask) {}
template<typename MapT>
void operator()(const MapT& map)
{
gridop::GridOperator<InGridType, MaskGridType, OutGridType, MapT, OpT, InterruptT>
op(mInputGrid, mMask, map, mInterrupt, /*densify=*/false);
mOutputGrid = op.process(mThreaded); // cache the result
}
const bool mThreaded;
const InGridType& mInputGrid;
typename OutGridType::Ptr mOutputGrid;
InterruptT* mInterrupt;
const MaskGridType* mMask;
}; // Private Functor
const InGridType& mInputGrid;
InterruptT* mInterrupt;
const MaskGridType* mMask;
}; // end of Magnitude class
////////////////////////////////////////
template<
typename GridT,
typename MaskGridType = typename gridop::ToMaskGrid<GridT>::Type,
typename InterruptT = util::NullInterrupter>
class Normalize
{
public:
typedef GridT InGridType;
typedef GridT OutGridType;
Normalize(const GridT& grid, InterruptT* interrupt = nullptr):
mInputGrid(grid), mInterrupt(interrupt), mMask(nullptr)
{
}
Normalize(const GridT& grid, const MaskGridType& mask, InterruptT* interrupt = nullptr):
mInputGrid(grid), mInterrupt(interrupt), mMask(&mask)
{
}
typename GridT::Ptr process(bool threaded = true)
{
Functor functor(mInputGrid, mMask, threaded, mInterrupt);
processTypedMap(mInputGrid.transform(), functor);
if (typename GridT::Ptr outGrid = functor.mOutputGrid) {
const VecType vecType = mInputGrid.getVectorType();
if (vecType == VEC_COVARIANT) {
outGrid->setVectorType(VEC_COVARIANT_NORMALIZE);
} else {
outGrid->setVectorType(vecType);
}
}
return functor.mOutputGrid;
}
protected:
struct OpT
{
template<typename MapT, typename AccT>
static typename OutGridType::ValueType
result(const MapT&, const AccT& acc, const Coord& xyz)
{
typename OutGridType::ValueType vec = acc.getValue(xyz);
if ( !vec.normalize() ) vec.setZero();
return vec;
}
};
struct Functor
{
Functor(const GridT& grid, const MaskGridType* mask, bool threaded, InterruptT* interrupt):
mThreaded(threaded), mInputGrid(grid), mInterrupt(interrupt), mMask(mask) {}
template<typename MapT>
void operator()(const MapT& map)
{
gridop::GridOperator<GridT, MaskGridType, GridT, MapT, OpT, InterruptT>
op(mInputGrid, mMask, map, mInterrupt, /*densify=*/false);
mOutputGrid = op.process(mThreaded); // cache the result
}
const bool mThreaded;
const GridT& mInputGrid;
typename GridT::Ptr mOutputGrid;
InterruptT* mInterrupt;
const MaskGridType* mMask;
}; // Private Functor
const GridT& mInputGrid;
InterruptT* mInterrupt;
const MaskGridType* mMask;
}; // end of Normalize class
////////////////////////////////////////
template<typename GridType, typename InterruptT>
typename ScalarToVectorConverter<GridType>::Type::Ptr
cpt(const GridType& grid, bool threaded, InterruptT* interrupt)
{
Cpt<GridType, typename gridop::ToMaskGrid<GridType>::Type, InterruptT> op(grid, interrupt);
return op.process(threaded);
}
template<typename GridType, typename MaskT, typename InterruptT>
typename ScalarToVectorConverter<GridType>::Type::Ptr
cpt(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt)
{
Cpt<GridType, MaskT, InterruptT> op(grid, mask, interrupt);
return op.process(threaded);
}
template<typename GridType, typename InterruptT>
typename GridType::Ptr
curl(const GridType& grid, bool threaded, InterruptT* interrupt)
{
Curl<GridType, typename gridop::ToMaskGrid<GridType>::Type, InterruptT> op(grid, interrupt);
return op.process(threaded);
}
template<typename GridType, typename MaskT, typename InterruptT>
typename GridType::Ptr
curl(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt)
{
Curl<GridType, MaskT, InterruptT> op(grid, mask, interrupt);
return op.process(threaded);
}
template<typename GridType, typename InterruptT>
typename VectorToScalarConverter<GridType>::Type::Ptr
divergence(const GridType& grid, bool threaded, InterruptT* interrupt)
{
Divergence<GridType, typename gridop::ToMaskGrid<GridType>::Type, InterruptT>
op(grid, interrupt);
return op.process(threaded);
}
template<typename GridType, typename MaskT, typename InterruptT>
typename VectorToScalarConverter<GridType>::Type::Ptr
divergence(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt)
{
Divergence<GridType, MaskT, InterruptT> op(grid, mask, interrupt);
return op.process(threaded);
}
template<typename GridType, typename InterruptT>
typename ScalarToVectorConverter<GridType>::Type::Ptr
gradient(const GridType& grid, bool threaded, InterruptT* interrupt)
{
Gradient<GridType, typename gridop::ToMaskGrid<GridType>::Type, InterruptT>
op(grid, interrupt);
return op.process(threaded);
}
template<typename GridType, typename MaskT, typename InterruptT>
typename ScalarToVectorConverter<GridType>::Type::Ptr
gradient(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt)
{
Gradient<GridType, MaskT, InterruptT> op(grid, mask, interrupt);
return op.process(threaded);
}
template<typename GridType, typename InterruptT>
typename GridType::Ptr
laplacian(const GridType& grid, bool threaded, InterruptT* interrupt)
{
Laplacian<GridType, typename gridop::ToMaskGrid<GridType>::Type, InterruptT>
op(grid, interrupt);
return op.process(threaded);
}
template<typename GridType, typename MaskT, typename InterruptT>
typename GridType::Ptr
laplacian(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt)
{
Laplacian<GridType, MaskT, InterruptT> op(grid, mask, interrupt);
return op.process(threaded);
}
template<typename GridType, typename InterruptT>
typename GridType::Ptr
meanCurvature(const GridType& grid, bool threaded, InterruptT* interrupt)
{
MeanCurvature<GridType, typename gridop::ToMaskGrid<GridType>::Type, InterruptT>
op(grid, interrupt);
return op.process(threaded);
}
template<typename GridType, typename MaskT, typename InterruptT>
typename GridType::Ptr
meanCurvature(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt)
{
MeanCurvature<GridType, MaskT, InterruptT> op(grid, mask, interrupt);
return op.process(threaded);
}
template<typename GridType, typename InterruptT>
typename VectorToScalarConverter<GridType>::Type::Ptr
magnitude(const GridType& grid, bool threaded, InterruptT* interrupt)
{
Magnitude<GridType, typename gridop::ToMaskGrid<GridType>::Type, InterruptT>
op(grid, interrupt);
return op.process(threaded);
}
template<typename GridType, typename MaskT, typename InterruptT>
typename VectorToScalarConverter<GridType>::Type::Ptr
magnitude(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt)
{
Magnitude<GridType, MaskT, InterruptT> op(grid, mask, interrupt);
return op.process(threaded);
}
template<typename GridType, typename InterruptT>
typename GridType::Ptr
normalize(const GridType& grid, bool threaded, InterruptT* interrupt)
{
Normalize<GridType, typename gridop::ToMaskGrid<GridType>::Type, InterruptT>
op(grid, interrupt);
return op.process(threaded);
}
template<typename GridType, typename MaskT, typename InterruptT>
typename GridType::Ptr
normalize(const GridType& grid, const MaskT& mask, bool threaded, InterruptT* interrupt)
{
Normalize<GridType, MaskT, InterruptT> op(grid, mask, interrupt);
return op.process(threaded);
}
////////////////////////////////////////
// Explicit Template Instantiation
#ifdef OPENVDB_USE_EXPLICIT_INSTANTIATION
#ifdef OPENVDB_INSTANTIATE_GRIDOPERATORS
#include <openvdb/util/ExplicitInstantiation.h>
#endif
#define _FUNCTION(TreeT) \
ScalarToVectorConverter<Grid<TreeT>>::Type::Ptr cpt(const Grid<TreeT>&, bool, util::NullInterrupter*)
OPENVDB_REAL_TREE_INSTANTIATE(_FUNCTION)
#undef _FUNCTION
#define _FUNCTION(TreeT) \
ScalarToVectorConverter<Grid<TreeT>>::Type::Ptr cpt(const Grid<TreeT>&, const BoolGrid&, bool, util::NullInterrupter*)
OPENVDB_REAL_TREE_INSTANTIATE(_FUNCTION)
#undef _FUNCTION
#define _FUNCTION(TreeT) \
Grid<TreeT>::Ptr curl(const Grid<TreeT>&, bool, util::NullInterrupter*)
OPENVDB_VEC3_TREE_INSTANTIATE(_FUNCTION)
#undef _FUNCTION
#define _FUNCTION(TreeT) \
Grid<TreeT>::Ptr curl(const Grid<TreeT>&, const BoolGrid&, bool, util::NullInterrupter*)
OPENVDB_VEC3_TREE_INSTANTIATE(_FUNCTION)
#undef _FUNCTION
#define _FUNCTION(TreeT) \
VectorToScalarConverter<Grid<TreeT>>::Type::Ptr divergence(const Grid<TreeT>&, bool, util::NullInterrupter*)
OPENVDB_VEC3_TREE_INSTANTIATE(_FUNCTION)
#undef _FUNCTION
#define _FUNCTION(TreeT) \
VectorToScalarConverter<Grid<TreeT>>::Type::Ptr divergence(const Grid<TreeT>&, const BoolGrid&, bool, util::NullInterrupter*)
OPENVDB_VEC3_TREE_INSTANTIATE(_FUNCTION)
#undef _FUNCTION
#define _FUNCTION(TreeT) \
ScalarToVectorConverter<Grid<TreeT>>::Type::Ptr gradient(const Grid<TreeT>&, bool, util::NullInterrupter*)
OPENVDB_REAL_TREE_INSTANTIATE(_FUNCTION)
#undef _FUNCTION
#define _FUNCTION(TreeT) \
ScalarToVectorConverter<Grid<TreeT>>::Type::Ptr gradient(const Grid<TreeT>&, const BoolGrid&, bool, util::NullInterrupter*)
OPENVDB_REAL_TREE_INSTANTIATE(_FUNCTION)
#undef _FUNCTION
#define _FUNCTION(TreeT) \
Grid<TreeT>::Ptr laplacian(const Grid<TreeT>&, bool, util::NullInterrupter*)
OPENVDB_NUMERIC_TREE_INSTANTIATE(_FUNCTION)
#undef _FUNCTION
#define _FUNCTION(TreeT) \
Grid<TreeT>::Ptr laplacian(const Grid<TreeT>&, const BoolGrid&, bool, util::NullInterrupter*)
OPENVDB_NUMERIC_TREE_INSTANTIATE(_FUNCTION)
#undef _FUNCTION
#define _FUNCTION(TreeT) \
Grid<TreeT>::Ptr meanCurvature(const Grid<TreeT>&, bool, util::NullInterrupter*)
OPENVDB_NUMERIC_TREE_INSTANTIATE(_FUNCTION)
#undef _FUNCTION
#define _FUNCTION(TreeT) \
Grid<TreeT>::Ptr meanCurvature(const Grid<TreeT>&, const BoolGrid&, bool, util::NullInterrupter*)
OPENVDB_NUMERIC_TREE_INSTANTIATE(_FUNCTION)
#undef _FUNCTION
#define _FUNCTION(TreeT) \
VectorToScalarConverter<Grid<TreeT>>::Type::Ptr magnitude(const Grid<TreeT>&, bool, util::NullInterrupter*)
OPENVDB_VEC3_TREE_INSTANTIATE(_FUNCTION)
#undef _FUNCTION
#define _FUNCTION(TreeT) \
VectorToScalarConverter<Grid<TreeT>>::Type::Ptr magnitude(const Grid<TreeT>&, const BoolGrid&, bool, util::NullInterrupter*)
OPENVDB_VEC3_TREE_INSTANTIATE(_FUNCTION)
#undef _FUNCTION
#define _FUNCTION(TreeT) \
Grid<TreeT>::Ptr normalize(const Grid<TreeT>&, bool, util::NullInterrupter*)
OPENVDB_VEC3_TREE_INSTANTIATE(_FUNCTION)
#undef _FUNCTION
#define _FUNCTION(TreeT) \
Grid<TreeT>::Ptr normalize(const Grid<TreeT>&, const BoolGrid&, bool, util::NullInterrupter*)
OPENVDB_VEC3_TREE_INSTANTIATE(_FUNCTION)
#undef _FUNCTION
#endif // OPENVDB_USE_EXPLICIT_INSTANTIATION
} // namespace tools
} // namespace OPENVDB_VERSION_NAME
} // namespace openvdb
#endif // OPENVDB_TOOLS_GRID_OPERATORS_HAS_BEEN_INCLUDED
ExplicitInstantiation.h
Grid.h
LeafManager.h
A LeafManager manages a linear array of pointers to a given tree's leaf nodes, as well as optional au...
NullInterrupter.h
Operators.h
ValueAccessor.h
ValueAccessors are designed to help accelerate accesses into the OpenVDB Tree structures by storing c...
ValueTransformer.h
openvdb::v11_0::Grid
Container class that associates a tree with a transform and metadata.
Definition Grid.h:571
openvdb::v11_0::TopologyCopy
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition Types.h:683
openvdb::v11_0::math::Coord
Signed (x, y, z) 32-bit integer coordinates.
Definition Coord.h:25
openvdb::v11_0::math::Transform
Definition Transform.h:40
openvdb::v11_0::math::Transform::Ptr
SharedPtr< Transform > Ptr
Definition Transform.h:42
openvdb::v11_0::math::Vec3
Definition Vec3.h:24
openvdb::v11_0::tools::Cpt
Compute the closest-point transform of a scalar grid.
Definition GridOperators.h:421
openvdb::v11_0::tools::Cpt::Cpt
Cpt(const InGridType &grid, const MaskGridType &mask, InterruptT *interrupt=nullptr)
Definition GridOperators.h:431
openvdb::v11_0::tools::Cpt::Cpt
Cpt(const InGridType &grid, InterruptT *interrupt=nullptr)
Definition GridOperators.h:426
openvdb::v11_0::tools::Cpt::InGridType
InGridT InGridType
Definition GridOperators.h:423
openvdb::v11_0::tools::Cpt::OutGridType
ScalarToVectorConverter< InGridT >::Type OutGridType
Definition GridOperators.h:424
openvdb::v11_0::tools::Cpt::process
OutGridType::Ptr process(bool threaded=true, bool useWorldTransform=true)
Definition GridOperators.h:436
openvdb::v11_0::tools::Curl
Compute the curl of a vector grid.
Definition GridOperators.h:509
openvdb::v11_0::tools::Curl::process
GridT::Ptr process(bool threaded=true)
Definition GridOperators.h:524
openvdb::v11_0::tools::Curl::InGridType
GridT InGridType
Definition GridOperators.h:511
openvdb::v11_0::tools::Curl::Curl
Curl(const GridT &grid, const MaskGridType &mask, InterruptT *interrupt=nullptr)
Definition GridOperators.h:519
openvdb::v11_0::tools::Curl::OutGridType
GridT OutGridType
Definition GridOperators.h:512
openvdb::v11_0::tools::Curl::Curl
Curl(const GridT &grid, InterruptT *interrupt=nullptr)
Definition GridOperators.h:514
openvdb::v11_0::tools::Divergence
Compute the divergence of a vector grid.
Definition GridOperators.h:570
openvdb::v11_0::tools::Divergence::mInterrupt
InterruptT * mInterrupt
Definition GridOperators.h:623
openvdb::v11_0::tools::Divergence::mMask
const MaskGridType * mMask
Definition GridOperators.h:624
openvdb::v11_0::tools::Divergence::InGridType
InGridT InGridType
Definition GridOperators.h:572
openvdb::v11_0::tools::Divergence::Divergence
Divergence(const InGridT &grid, InterruptT *interrupt=nullptr)
Definition GridOperators.h:575
openvdb::v11_0::tools::Divergence::process
OutGridType::Ptr process(bool threaded=true)
Definition GridOperators.h:585
openvdb::v11_0::tools::Divergence::OutGridType
VectorToScalarConverter< InGridT >::Type OutGridType
Definition GridOperators.h:573
openvdb::v11_0::tools::Divergence::Divergence
Divergence(const InGridT &grid, const MaskGridType &mask, InterruptT *interrupt=nullptr)
Definition GridOperators.h:580
openvdb::v11_0::tools::Divergence::mInputGrid
const InGridType & mInputGrid
Definition GridOperators.h:622
openvdb::v11_0::tools::Gradient
Compute the gradient of a scalar grid.
Definition GridOperators.h:637
openvdb::v11_0::tools::Gradient::mInterrupt
InterruptT * mInterrupt
Definition GridOperators.h:684
openvdb::v11_0::tools::Gradient::mMask
const MaskGridType * mMask
Definition GridOperators.h:685
openvdb::v11_0::tools::Gradient::InGridType
InGridT InGridType
Definition GridOperators.h:639
openvdb::v11_0::tools::Gradient::mInputGrid
const InGridT & mInputGrid
Definition GridOperators.h:683
openvdb::v11_0::tools::Gradient::Gradient
Gradient(const InGridT &grid, const MaskGridType &mask, InterruptT *interrupt=nullptr)
Definition GridOperators.h:647
openvdb::v11_0::tools::Gradient::process
OutGridType::Ptr process(bool threaded=true)
Definition GridOperators.h:652
openvdb::v11_0::tools::Gradient::Gradient
Gradient(const InGridT &grid, InterruptT *interrupt=nullptr)
Definition GridOperators.h:642
openvdb::v11_0::tools::Gradient::OutGridType
ScalarToVectorConverter< InGridT >::Type OutGridType
Definition GridOperators.h:640
openvdb::v11_0::tools::Laplacian
Definition GridOperators.h:697
openvdb::v11_0::tools::Laplacian::process
GridT::Ptr process(bool threaded=true)
Definition GridOperators.h:712
openvdb::v11_0::tools::Laplacian::mInterrupt
InterruptT * mInterrupt
Definition GridOperators.h:743
openvdb::v11_0::tools::Laplacian::mInputGrid
const GridT & mInputGrid
Definition GridOperators.h:742
openvdb::v11_0::tools::Laplacian::mMask
const MaskGridType * mMask
Definition GridOperators.h:744
openvdb::v11_0::tools::Laplacian::InGridType
GridT InGridType
Definition GridOperators.h:699
openvdb::v11_0::tools::Laplacian::Laplacian
Laplacian(const GridT &grid, const MaskGridType &mask, InterruptT *interrupt=nullptr)
Definition GridOperators.h:707
openvdb::v11_0::tools::Laplacian::OutGridType
GridT OutGridType
Definition GridOperators.h:700
openvdb::v11_0::tools::Laplacian::Laplacian
Laplacian(const GridT &grid, InterruptT *interrupt=nullptr)
Definition GridOperators.h:702
openvdb::v11_0::tools::Magnitude
Definition GridOperators.h:815
openvdb::v11_0::tools::Magnitude::mInterrupt
InterruptT * mInterrupt
Definition GridOperators.h:866
openvdb::v11_0::tools::Magnitude::mMask
const MaskGridType * mMask
Definition GridOperators.h:867
openvdb::v11_0::tools::Magnitude::InGridType
InGridT InGridType
Definition GridOperators.h:817
openvdb::v11_0::tools::Magnitude::process
OutGridType::Ptr process(bool threaded=true)
Definition GridOperators.h:830
openvdb::v11_0::tools::Magnitude::Magnitude
Magnitude(const InGridType &grid, InterruptT *interrupt=nullptr)
Definition GridOperators.h:820
openvdb::v11_0::tools::Magnitude::OutGridType
VectorToScalarConverter< InGridT >::Type OutGridType
Definition GridOperators.h:818
openvdb::v11_0::tools::Magnitude::Magnitude
Magnitude(const InGridType &grid, const MaskGridType &mask, InterruptT *interrupt=nullptr)
Definition GridOperators.h:825
openvdb::v11_0::tools::Magnitude::mInputGrid
const InGridType & mInputGrid
Definition GridOperators.h:865
openvdb::v11_0::tools::MeanCurvature
Definition GridOperators.h:756
openvdb::v11_0::tools::MeanCurvature::process
GridT::Ptr process(bool threaded=true)
Definition GridOperators.h:771
openvdb::v11_0::tools::MeanCurvature::mInterrupt
InterruptT * mInterrupt
Definition GridOperators.h:802
openvdb::v11_0::tools::MeanCurvature::mInputGrid
const GridT & mInputGrid
Definition GridOperators.h:801
openvdb::v11_0::tools::MeanCurvature::mMask
const MaskGridType * mMask
Definition GridOperators.h:803
openvdb::v11_0::tools::MeanCurvature::MeanCurvature
MeanCurvature(const GridT &grid, const MaskGridType &mask, InterruptT *interrupt=nullptr)
Definition GridOperators.h:766
openvdb::v11_0::tools::MeanCurvature::MeanCurvature
MeanCurvature(const GridT &grid, InterruptT *interrupt=nullptr)
Definition GridOperators.h:761
openvdb::v11_0::tools::MeanCurvature::InGridType
GridT InGridType
Definition GridOperators.h:758
openvdb::v11_0::tools::MeanCurvature::OutGridType
GridT OutGridType
Definition GridOperators.h:759
openvdb::v11_0::tools::Normalize
Definition GridOperators.h:879
openvdb::v11_0::tools::Normalize::process
GridT::Ptr process(bool threaded=true)
Definition GridOperators.h:894
openvdb::v11_0::tools::Normalize::mInterrupt
InterruptT * mInterrupt
Definition GridOperators.h:942
openvdb::v11_0::tools::Normalize::mInputGrid
const GridT & mInputGrid
Definition GridOperators.h:941
openvdb::v11_0::tools::Normalize::mMask
const MaskGridType * mMask
Definition GridOperators.h:943
openvdb::v11_0::tools::Normalize::InGridType
GridT InGridType
Definition GridOperators.h:881
openvdb::v11_0::tools::Normalize::OutGridType
GridT OutGridType
Definition GridOperators.h:882
openvdb::v11_0::tools::Normalize::Normalize
Normalize(const GridT &grid, InterruptT *interrupt=nullptr)
Definition GridOperators.h:884
openvdb::v11_0::tools::Normalize::Normalize
Normalize(const GridT &grid, const MaskGridType &mask, InterruptT *interrupt=nullptr)
Definition GridOperators.h:889
openvdb::v11_0::tools::gridop::GridOperator
Apply an operator to an input grid to produce an output grid with the same active voxel topology but ...
Definition GridOperators.h:303
openvdb::v11_0::tools::gridop::GridOperator::mInterrupt
InterruptT * mInterrupt
Definition GridOperators.h:404
openvdb::v11_0::tools::gridop::GridOperator::mAcc
AccessorT mAcc
Definition GridOperators.h:402
openvdb::v11_0::tools::gridop::GridOperator::mMask
const MaskGridType * mMask
Definition GridOperators.h:405
openvdb::v11_0::tools::gridop::GridOperator::OutTreeT
OutGridT::TreeType OutTreeT
Definition GridOperators.h:305
openvdb::v11_0::tools::gridop::GridOperator::mMap
const MapT & mMap
Definition GridOperators.h:403
openvdb::v11_0::tools::gridop::GridOperator::OutLeafT
OutTreeT::LeafNodeType OutLeafT
Definition GridOperators.h:306
openvdb::v11_0::tools::gridop::GridOperator::GridOperator
GridOperator(const InGridT &grid, const MaskGridType *mask, const MapT &map, InterruptT *interrupt=nullptr, bool densify=true)
Definition GridOperators.h:309
openvdb::v11_0::tools::gridop::GridOperator::mDensify
const bool mDensify
Definition GridOperators.h:406
openvdb::v11_0::tools::gridop::GridOperator::GridOperator
GridOperator(const GridOperator &)=default
openvdb::v11_0::tools::gridop::GridOperator::operator()
void operator()(const typename LeafManagerT::LeafRange &range) const
Iterate sequentially over LeafNodes and voxels in the output grid and apply the operator using a valu...
Definition GridOperators.h:387
openvdb::v11_0::tools::gridop::GridOperator::operator=
GridOperator & operator=(const GridOperator &)=default
openvdb::v11_0::tools::gridop::GridOperator::~GridOperator
virtual ~GridOperator()=default
openvdb::v11_0::tools::gridop::GridOperator::process
OutGridT::Ptr process(bool threaded=true)
Definition GridOperators.h:322
openvdb::v11_0::tools::gridop::GridOperator::AccessorT
InGridT::ConstAccessor AccessorT
Definition GridOperators.h:401
openvdb::v11_0::tools::gridop::GridOperator::LeafManagerT
tree::LeafManager< OutTreeT > LeafManagerT
Definition GridOperators.h:307
openvdb::v11_0::tree::LeafManager::LeafRange
Definition LeafManager.h:102
openvdb::v11_0::tree::LeafManager::LeafRange::begin
Iterator begin() const
Definition LeafManager.h:155
openvdb::v11_0::tree::LeafManager
This class manages a linear array of pointers to a given tree's leaf nodes, as well as optional auxil...
Definition LeafManager.h:85
openvdb::v11_0::tree::LeafManager::leafRange
LeafRange leafRange(size_t grainsize=1) const
Return a TBB-compatible LeafRange.
Definition LeafManager.h:345
openvdb::v11_0::tools::curl
GridType::Ptr curl(const GridType &grid, bool threaded, InterruptT *interrupt)
Compute the curl of the given vector-valued grid.
Definition GridOperators.h:968
openvdb::v11_0::tools::meanCurvature
GridType::Ptr meanCurvature(const GridType &grid, bool threaded, InterruptT *interrupt)
Compute the mean curvature of the given grid.
Definition GridOperators.h:1035
openvdb::v11_0::tools::gradient
ScalarToVectorConverter< GridType >::Type::Ptr gradient(const GridType &grid, bool threaded, InterruptT *interrupt)
Compute the gradient of the given scalar grid.
Definition GridOperators.h:1001
openvdb::v11_0::tools::magnitude
VectorToScalarConverter< GridType >::Type::Ptr magnitude(const GridType &grid, bool threaded, InterruptT *interrupt)
Compute the magnitudes of the vectors of the given vector-valued grid.
Definition GridOperators.h:1052
openvdb::v11_0::tools::divergence
VectorToScalarConverter< GridType >::Type::Ptr divergence(const GridType &grid, bool threaded, InterruptT *interrupt)
Compute the divergence of the given vector-valued grid.
Definition GridOperators.h:984
openvdb::v11_0::tools::cpt
ScalarToVectorConverter< GridType >::Type::Ptr cpt(const GridType &grid, bool threaded, InterruptT *interrupt)
Compute the Closest-Point Transform (CPT) from a distance field.
Definition GridOperators.h:952
openvdb::v11_0::tools::laplacian
GridType::Ptr laplacian(const GridType &grid, bool threaded, InterruptT *interrupt)
Compute the Laplacian of the given scalar grid.
Definition GridOperators.h:1018
openvdb::v11_0::tools::normalize
GridType::Ptr normalize(const GridType &grid, bool threaded, InterruptT *interrupt)
Normalize the vectors of the given vector-valued grid.
Definition GridOperators.h:1069
openvdb::v11_0::GRID_STAGGERED
@ GRID_STAGGERED
Definition Types.h:457
openvdb::v11_0::VecType
VecType
Definition Types.h:483
openvdb::v11_0::VEC_CONTRAVARIANT_ABSOLUTE
@ VEC_CONTRAVARIANT_ABSOLUTE
Definition Types.h:488
openvdb::v11_0::VEC_COVARIANT
@ VEC_COVARIANT
Definition Types.h:485
openvdb::v11_0::VEC_COVARIANT_NORMALIZE
@ VEC_COVARIANT_NORMALIZE
Definition Types.h:486
openvdb
Definition Exceptions.h:13
openvdb.h
openvdb::v11_0::math::CPT_RANGE
Compute the closest-point transform to a level set.
Definition Operators.h:1719
openvdb::v11_0::math::CPT
Compute the closest-point transform to a level set.
Definition Operators.h:1666
openvdb::v11_0::math::Curl
Compute the curl of a vector-valued grid using differencing of various orders in the space defined by...
Definition Operators.h:1275
openvdb::v11_0::math::Divergence
Compute the divergence of a vector-valued grid using differencing of various orders,...
Definition Operators.h:950
openvdb::v11_0::math::Gradient
Center difference gradient operators, defined with respect to the range-space of the map.
Definition Operators.h:620
openvdb::v11_0::math::Laplacian
Compute the Laplacian at a given location in a grid using finite differencing of various orders....
Definition Operators.h:1420
openvdb::v11_0::math::MeanCurvature
Compute the mean curvature.
Definition Operators.h:1762
openvdb::v11_0::tools::Divergence::Functor
Definition GridOperators.h:601
openvdb::v11_0::tools::Divergence::Functor::operator()
void operator()(const MapT &map)
Definition GridOperators.h:607
openvdb::v11_0::tools::Divergence::Functor::mInterrupt
InterruptT * mInterrupt
Definition GridOperators.h:618
openvdb::v11_0::tools::Divergence::Functor::mMask
const MaskGridType * mMask
Definition GridOperators.h:619
openvdb::v11_0::tools::Divergence::Functor::mOutputGrid
OutGridType::Ptr mOutputGrid
Definition GridOperators.h:617
openvdb::v11_0::tools::Divergence::Functor::Functor
Functor(const InGridT &grid, const MaskGridType *mask, bool threaded, InterruptT *interrupt)
Definition GridOperators.h:602
openvdb::v11_0::tools::Divergence::Functor::mThreaded
const bool mThreaded
Definition GridOperators.h:615
openvdb::v11_0::tools::Divergence::Functor::mInputGrid
const InGridType & mInputGrid
Definition GridOperators.h:616
openvdb::v11_0::tools::Gradient::Functor
Definition GridOperators.h:662
openvdb::v11_0::tools::Gradient::Functor::operator()
void operator()(const MapT &map)
Definition GridOperators.h:668
openvdb::v11_0::tools::Gradient::Functor::mInterrupt
InterruptT * mInterrupt
Definition GridOperators.h:679
openvdb::v11_0::tools::Gradient::Functor::mMask
const MaskGridType * mMask
Definition GridOperators.h:680
openvdb::v11_0::tools::Gradient::Functor::mInputGrid
const InGridT & mInputGrid
Definition GridOperators.h:677
openvdb::v11_0::tools::Gradient::Functor::mOutputGrid
OutGridType::Ptr mOutputGrid
Definition GridOperators.h:678
openvdb::v11_0::tools::Gradient::Functor::Functor
Functor(const InGridT &grid, const MaskGridType *mask, bool threaded, InterruptT *interrupt)
Definition GridOperators.h:663
openvdb::v11_0::tools::Gradient::Functor::mThreaded
const bool mThreaded
Definition GridOperators.h:676
openvdb::v11_0::tools::Laplacian::Functor
Definition GridOperators.h:722
openvdb::v11_0::tools::Laplacian::Functor::operator()
void operator()(const MapT &map)
Definition GridOperators.h:727
openvdb::v11_0::tools::Laplacian::Functor::mInterrupt
InterruptT * mInterrupt
Definition GridOperators.h:738
openvdb::v11_0::tools::Laplacian::Functor::mInputGrid
const GridT & mInputGrid
Definition GridOperators.h:736
openvdb::v11_0::tools::Laplacian::Functor::mMask
const MaskGridType * mMask
Definition GridOperators.h:739
openvdb::v11_0::tools::Laplacian::Functor::mOutputGrid
GridT::Ptr mOutputGrid
Definition GridOperators.h:737
openvdb::v11_0::tools::Laplacian::Functor::Functor
Functor(const GridT &grid, const MaskGridType *mask, bool threaded, InterruptT *interrupt)
Definition GridOperators.h:723
openvdb::v11_0::tools::Laplacian::Functor::mThreaded
const bool mThreaded
Definition GridOperators.h:735
openvdb::v11_0::tools::Magnitude::Functor
Definition GridOperators.h:845
openvdb::v11_0::tools::Magnitude::Functor::operator()
void operator()(const MapT &map)
Definition GridOperators.h:851
openvdb::v11_0::tools::Magnitude::Functor::mInterrupt
InterruptT * mInterrupt
Definition GridOperators.h:861
openvdb::v11_0::tools::Magnitude::Functor::mMask
const MaskGridType * mMask
Definition GridOperators.h:862
openvdb::v11_0::tools::Magnitude::Functor::mOutputGrid
OutGridType::Ptr mOutputGrid
Definition GridOperators.h:860
openvdb::v11_0::tools::Magnitude::Functor::Functor
Functor(const InGridT &grid, const MaskGridType *mask, bool threaded, InterruptT *interrupt)
Definition GridOperators.h:846
openvdb::v11_0::tools::Magnitude::Functor::mThreaded
const bool mThreaded
Definition GridOperators.h:858
openvdb::v11_0::tools::Magnitude::Functor::mInputGrid
const InGridType & mInputGrid
Definition GridOperators.h:859
openvdb::v11_0::tools::Magnitude::OpT
Definition GridOperators.h:839
openvdb::v11_0::tools::Magnitude::OpT::result
static OutGridType::ValueType result(const MapT &, const AccT &acc, const Coord &xyz)
Definition GridOperators.h:842
openvdb::v11_0::tools::MeanCurvature::Functor
Definition GridOperators.h:781
openvdb::v11_0::tools::MeanCurvature::Functor::operator()
void operator()(const MapT &map)
Definition GridOperators.h:786
openvdb::v11_0::tools::MeanCurvature::Functor::mInterrupt
InterruptT * mInterrupt
Definition GridOperators.h:797
openvdb::v11_0::tools::MeanCurvature::Functor::mInputGrid
const GridT & mInputGrid
Definition GridOperators.h:795
openvdb::v11_0::tools::MeanCurvature::Functor::mMask
const MaskGridType * mMask
Definition GridOperators.h:798
openvdb::v11_0::tools::MeanCurvature::Functor::mOutputGrid
GridT::Ptr mOutputGrid
Definition GridOperators.h:796
openvdb::v11_0::tools::MeanCurvature::Functor::Functor
Functor(const GridT &grid, const MaskGridType *mask, bool threaded, InterruptT *interrupt)
Definition GridOperators.h:782
openvdb::v11_0::tools::MeanCurvature::Functor::mThreaded
const bool mThreaded
Definition GridOperators.h:794
openvdb::v11_0::tools::Normalize::Functor
Definition GridOperators.h:922
openvdb::v11_0::tools::Normalize::Functor::operator()
void operator()(const MapT &map)
Definition GridOperators.h:927
openvdb::v11_0::tools::Normalize::Functor::mInterrupt
InterruptT * mInterrupt
Definition GridOperators.h:937
openvdb::v11_0::tools::Normalize::Functor::mInputGrid
const GridT & mInputGrid
Definition GridOperators.h:935
openvdb::v11_0::tools::Normalize::Functor::mMask
const MaskGridType * mMask
Definition GridOperators.h:938
openvdb::v11_0::tools::Normalize::Functor::mOutputGrid
GridT::Ptr mOutputGrid
Definition GridOperators.h:936
openvdb::v11_0::tools::Normalize::Functor::Functor
Functor(const GridT &grid, const MaskGridType *mask, bool threaded, InterruptT *interrupt)
Definition GridOperators.h:923
openvdb::v11_0::tools::Normalize::Functor::mThreaded
const bool mThreaded
Definition GridOperators.h:934
openvdb::v11_0::tools::Normalize::OpT
Definition GridOperators.h:911
openvdb::v11_0::tools::Normalize::OpT::result
static OutGridType::ValueType result(const MapT &, const AccT &acc, const Coord &xyz)
Definition GridOperators.h:914
openvdb::v11_0::tools::ScalarToVectorConverter
ScalarToVectorConverter<ScalarGridType>::Type is the type of a grid having the same tree configuratio...
Definition GridOperators.h:42
openvdb::v11_0::tools::ScalarToVectorConverter::VectorValueT
math::Vec3< typename ScalarGridType::ValueType > VectorValueT
Definition GridOperators.h:43
openvdb::v11_0::tools::ScalarToVectorConverter::Type
ScalarGridType::template ValueConverter< VectorValueT >::Type Type
Definition GridOperators.h:44
openvdb::v11_0::tools::VectorToScalarConverter
VectorToScalarConverter<VectorGridType>::Type is the type of a grid having the same tree configuratio...
Definition GridOperators.h:33
openvdb::v11_0::tools::VectorToScalarConverter::Type
VectorGridType::template ValueConverter< VecComponentValueT >::Type Type
Definition GridOperators.h:35
openvdb::v11_0::tools::VectorToScalarConverter::VecComponentValueT
VectorGridType::ValueType::value_type VecComponentValueT
Definition GridOperators.h:34
openvdb::v11_0::tools::gridop::ToMaskGrid
ToMaskGrid<T>::Type is the type of a grid having the same tree hierarchy as grid type T but a value e...
Definition GridOperators.h:285
openvdb::v11_0::tools::gridop::ToMaskGrid::Type
Grid< typename GridType::TreeType::template ValueConverter< ValueMask >::Type > Type
Definition GridOperators.h:286
openvdb::v11_0::util::NullInterrupter
Base class for interrupters.
Definition NullInterrupter.h:26
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:212
OPENVDB_NUMERIC_TREE_INSTANTIATE
#define OPENVDB_NUMERIC_TREE_INSTANTIATE(Function)
Definition version.h.in:158
OPENVDB_REAL_TREE_INSTANTIATE
#define OPENVDB_REAL_TREE_INSTANTIATE(Function)
Definition version.h.in:157
OPENVDB_VEC3_TREE_INSTANTIATE
#define OPENVDB_VEC3_TREE_INSTANTIATE(Function)
Definition version.h.in:159