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