8 #ifndef OPENVDB_TOOLS_MASK_HAS_BEEN_INCLUDED
9 #define OPENVDB_TOOLS_MASK_HAS_BEEN_INCLUDED
13 #include <type_traits>
27 template<
typename Gr
idType>
28 inline typename GridType::template ValueConverter<bool>::Type::Ptr
29 interiorMask(
const GridType& grid,
const double isovalue = 0.0);
36 namespace mask_internal {
37 template<
typename Gr
idType>
39 static const bool isBool = std::is_same<typename GridType::ValueType, bool>::value;
40 using BoolGridType =
typename GridType::template ValueConverter<bool>::Type;
41 using BoolGridPtrType =
typename BoolGridType::Ptr;
44 template<
typename Gr
idType>
45 inline typename std::enable_if<std::is_floating_point<typename GridType::ValueType>::value,
46 typename mask_internal::Traits<GridType>::BoolGridPtrType>::type
47 doLevelSetInteriorMask(
const GridType& grid,
const double isovalue)
49 using GridValueT =
typename GridType::ValueType;
50 using MaskGridPtrT =
typename mask_internal::Traits<GridType>::BoolGridPtrType;
56 return MaskGridPtrT{};
60 template<
typename Gr
idType>
61 inline typename std::enable_if<!std::is_floating_point<typename GridType::ValueType>::value,
62 typename mask_internal::Traits<GridType>::BoolGridPtrType>::type
63 doLevelSetInteriorMask(
const GridType&,
const double )
65 using MaskGridPtrT =
typename mask_internal::Traits<GridType>::BoolGridPtrType;
66 return MaskGridPtrT{};
69 template<
typename Gr
idType>
70 inline typename std::enable_if<mask_internal::Traits<GridType>::isBool,
71 typename mask_internal::Traits<GridType>::BoolGridPtrType>::type
72 doInteriorMask(
const GridType& grid,
const double )
75 return grid.deepCopy();
78 template<
typename Gr
idType>
79 inline typename std::enable_if<!(mask_internal::Traits<GridType>::isBool),
80 typename mask_internal::Traits<GridType>::BoolGridPtrType>::type
81 doInteriorMask(
const GridType& grid,
const double isovalue)
83 using MaskGridT =
typename mask_internal::Traits<GridType>::BoolGridType;
86 if (
auto maskGridPtr = doLevelSetInteriorMask(grid, isovalue)) {
91 auto maskGridPtr = MaskGridT::create(
false);
92 maskGridPtr->setTransform(grid.transform().copy());
93 maskGridPtr->topologyUnion(grid);
102 template<
typename Gr
idType>
103 inline typename GridType::template ValueConverter<bool>::Type::Ptr
106 return mask_internal::doInteriorMask(grid, isovalue);
Miscellaneous utility methods that operate primarily or exclusively on level set grids.
@ GRID_LEVEL_SET
Definition: Types.h:337
Definition: Exceptions.h:13
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:180