OpenVDB  12.0.0
PointCount.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/PointCount.h
5 ///
6 /// @author Dan Bailey
7 ///
8 /// @brief Methods for counting points in VDB Point grids.
9 
10 #ifndef OPENVDB_POINTS_POINT_COUNT_HAS_BEEN_INCLUDED
11 #define OPENVDB_POINTS_POINT_COUNT_HAS_BEEN_INCLUDED
12 
13 #include <openvdb/openvdb.h>
14 
15 #include "PointDataGrid.h"
16 #include "PointMask.h"
17 #include "IndexFilter.h"
18 
19 #include <tbb/parallel_reduce.h>
20 
21 #include <vector>
22 
23 namespace openvdb {
25 namespace OPENVDB_VERSION_NAME {
26 namespace points {
27 
28 /// @brief Count the total number of points in a PointDataTree
29 /// @param tree the PointDataTree in which to count the points
30 /// @param filter an optional index filter
31 /// @param inCoreOnly if true, points in out-of-core leaf nodes are not counted
32 /// @param threaded enable or disable threading (threading is enabled by default)
33 template <typename PointDataTreeT, typename FilterT = NullFilter>
34 inline Index64 pointCount( const PointDataTreeT& tree,
35  const FilterT& filter = NullFilter(),
36  const bool inCoreOnly = false,
37  const bool threaded = true);
38 
39 /// @brief Populate an array of cumulative point offsets per leaf node.
40 /// @param pointOffsets array of offsets to be populated
41 /// @param tree the PointDataTree from which to populate the offsets
42 /// @param filter an optional index filter
43 /// @param inCoreOnly if true, points in out-of-core leaf nodes are ignored
44 /// @param threaded enable or disable threading (threading is enabled by default)
45 /// @return The final cumulative point offset.
46 template <typename PointDataTreeT, typename FilterT = NullFilter>
47 inline Index64 pointOffsets(std::vector<Index64>& pointOffsets,
48  const PointDataTreeT& tree,
49  const FilterT& filter = NullFilter(),
50  const bool inCoreOnly = false,
51  const bool threaded = true);
52 
53 /// @brief Generate a new grid with voxel values to store the number of points per voxel
54 /// @param grid the PointDataGrid to use to compute the count grid
55 /// @param filter an optional index filter
56 /// @note The return type of the grid must be an integer or floating-point scalar grid.
57 template <typename PointDataGridT,
58  typename GridT = typename PointDataGridT::template ValueConverter<Int32>::Type,
59  typename FilterT = NullFilter>
60 inline typename GridT::Ptr
61 pointCountGrid( const PointDataGridT& grid,
62  const FilterT& filter = NullFilter());
63 
64 /// @brief Generate a new grid that uses the supplied transform with voxel values to store the
65 /// number of points per voxel.
66 /// @param grid the PointDataGrid to use to compute the count grid
67 /// @param transform the transform to use to compute the count grid
68 /// @param filter an optional index filter
69 /// @note The return type of the grid must be an integer or floating-point scalar grid.
70 template <typename PointDataGridT,
71  typename GridT = typename PointDataGridT::template ValueConverter<Int32>::Type,
72  typename FilterT = NullFilter>
73 inline typename GridT::Ptr
74 pointCountGrid( const PointDataGridT& grid,
75  const openvdb::math::Transform& transform,
76  const FilterT& filter = NullFilter());
77 
78 } // namespace points
79 } // namespace OPENVDB_VERSION_NAME
80 } // namespace openvdb
81 
82 #include "impl/PointCountImpl.h"
83 
84 #endif // OPENVDB_POINTS_POINT_COUNT_HAS_BEEN_INCLUDED
Index64 pointOffsets(std::vector< Index64 > &pointOffsets, const PointDataTreeT &tree, const FilterT &filter=NullFilter(), const bool inCoreOnly=false, const bool threaded=true)
Populate an array of cumulative point offsets per leaf node.
Definition: PointCountImpl.h:52
GridT::Ptr pointCountGrid(const PointDataGridT &grid, const openvdb::math::Transform &transform, const FilterT &filter=NullFilter())
Generate a new grid that uses the supplied transform with voxel values to store the number of points ...
Definition: PointCountImpl.h:117
uint64_t Index64
Definition: Types.h:53
Index filters primarily designed to be used with a FilterIndexIter.
Index64 pointCount(const PointDataTreeT &tree, const FilterT &filter=NullFilter(), const bool inCoreOnly=false, const bool threaded=true)
Count the total number of points in a PointDataTree.
Definition: PointCountImpl.h:18
OutGridT XformOp bool threaded
Definition: ValueTransformer.h:140
Definition: Exceptions.h:13
Methods for extracting masks from VDB Point grids.
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
Tree< typename RootNodeType::template ValueConverter< Int32 >::Type > Type
Definition: Tree.h:220
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:218