OpenVDB  11.0.0
PointMask.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3 
4 /// @file points/PointMask.h
5 ///
6 /// @author Dan Bailey
7 ///
8 /// @brief Methods for extracting masks from VDB Point grids.
9 
10 #ifndef OPENVDB_POINTS_POINT_MASK_HAS_BEEN_INCLUDED
11 #define OPENVDB_POINTS_POINT_MASK_HAS_BEEN_INCLUDED
12 
13 #include <openvdb/openvdb.h>
14 #include <openvdb/tools/ValueTransformer.h> // valxform::SumOp
15 
16 #include "PointDataGrid.h"
17 #include "IndexFilter.h"
18 
19 #include <tbb/combinable.h>
20 
21 #include <type_traits>
22 #include <vector>
23 
24 namespace openvdb {
26 namespace OPENVDB_VERSION_NAME {
27 namespace points {
28 
29 /// @brief Extract a Mask Tree from a Point Data Tree
30 /// @param tree the PointDataTree to extract the mask from.
31 /// @param filter an optional index filter
32 /// @param threaded enable or disable threading (threading is enabled by default)
33 template <typename PointDataTreeT,
34  typename MaskTreeT = typename PointDataTreeT::template ValueConverter<bool>::Type,
35  typename FilterT = NullFilter>
36 inline typename std::enable_if<std::is_base_of<TreeBase, PointDataTreeT>::value &&
37  std::is_same<typename MaskTreeT::ValueType, bool>::value, typename MaskTreeT::Ptr>::type
38 convertPointsToMask(const PointDataTreeT& tree,
39  const FilterT& filter = NullFilter(),
40  bool threaded = true);
41 
42 /// @brief Extract a Mask Grid from a Point Data Grid
43 /// @param grid the PointDataGrid to extract the mask from.
44 /// @param filter an optional index filter
45 /// @param threaded enable or disable threading (threading is enabled by default)
46 /// @note this method is only available for Bool Grids and Mask Grids
47 template <typename PointDataGridT,
48  typename MaskGridT = typename PointDataGridT::template ValueConverter<bool>::Type,
49  typename FilterT = NullFilter>
50 inline typename std::enable_if<std::is_base_of<GridBase, PointDataGridT>::value &&
51  std::is_same<typename MaskGridT::ValueType, bool>::value, typename MaskGridT::Ptr>::type
52 convertPointsToMask(const PointDataGridT& grid,
53  const FilterT& filter = NullFilter(),
54  bool threaded = true);
55 
56 /// @brief Extract a Mask Grid from a Point Data Grid using a new transform
57 /// @param grid the PointDataGrid to extract the mask from.
58 /// @param transform target transform for the mask.
59 /// @param filter an optional index filter
60 /// @param threaded enable or disable threading (threading is enabled by default)
61 /// @note this method is only available for Bool Grids and Mask Grids
62 template <typename PointDataGridT,
63  typename MaskT = typename PointDataGridT::template ValueConverter<bool>::Type,
64  typename FilterT = NullFilter>
65 inline typename std::enable_if<std::is_same<typename MaskT::ValueType, bool>::value,
66  typename MaskT::Ptr>::type
67 convertPointsToMask(const PointDataGridT& grid,
68  const openvdb::math::Transform& transform,
69  const FilterT& filter = NullFilter(),
70  bool threaded = true);
71 
72 /// @brief No-op deformer (adheres to the deformer interface documented in PointMove.h)
74 {
75  template <typename LeafT>
76  void reset(LeafT&, size_t /*idx*/ = 0) { }
77 
78  template <typename IterT>
79  void apply(Vec3d&, IterT&) const { }
80 };
81 
82 /// @brief Deformer Traits for optionally configuring deformers to be applied
83 /// in index-space. The default is world-space.
84 template <typename DeformerT>
86 {
87  static const bool IndexSpace = false;
88 };
89 
90 } // namespace points
91 } // namespace OPENVDB_VERSION_NAME
92 } // namespace openvdb
93 
94 #include "impl/PointMaskImpl.h"
95 
96 #endif // OPENVDB_POINTS_POINT_MASK_HAS_BEEN_INCLUDED
Deformer Traits for optionally configuring deformers to be applied in index-space. The default is world-space.
Definition: PointMask.h:85
Index filters primarily designed to be used with a FilterIndexIter.
Definition: Exceptions.h:13
void apply(Vec3d &, IterT &) const
Definition: PointMask.h:79
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
std::enable_if< std::is_same< typename MaskT::ValueType, bool >::value, typename MaskT::Ptr >::type convertPointsToMask(const PointDataGridT &grid, const openvdb::math::Transform &transform, const FilterT &filter=NullFilter(), bool threaded=true)
Extract a Mask Grid from a Point Data Grid using a new transform.
Definition: PointMaskImpl.h:335
void reset(LeafT &, size_t=0)
Definition: PointMask.h:76
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:212
No-op deformer (adheres to the deformer interface documented in PointMove.h)
Definition: PointMask.h:73