OpenVDB 14.0.0
Loading...
Searching...
No Matches
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
23namespace openvdb {
25namespace OPENVDB_VERSION_NAME {
26namespace 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 threaded enable or disable threading (threading is enabled by default)
32template <typename PointDataTreeT, typename FilterT = NullFilter>
33inline Index64 pointCount( const PointDataTreeT& tree,
34 const FilterT& filter = NullFilter(),
35 const bool threaded = true);
36
37/// @brief Populate an array of cumulative point offsets per leaf node.
38/// @param pointOffsets array of offsets to be populated
39/// @param tree the PointDataTree from which to populate the offsets
40/// @param filter an optional index filter
41/// @param threaded enable or disable threading (threading is enabled by default)
42/// @return The final cumulative point offset.
43template <typename PointDataTreeT, typename FilterT = NullFilter>
44inline Index64 pointOffsets(std::vector<Index64>& pointOffsets,
45 const PointDataTreeT& tree,
46 const FilterT& filter = NullFilter(),
47 const bool threaded = true);
48
49/// @brief Generate a new grid with voxel values to store the number of points per voxel
50/// @param grid the PointDataGrid to use to compute the count grid
51/// @param filter an optional index filter
52/// @note The return type of the grid must be an integer or floating-point scalar grid.
53template <typename PointDataGridT,
54 typename GridT = typename PointDataGridT::template ValueConverter<Int32>::Type,
55 typename FilterT = NullFilter>
56inline typename GridT::Ptr
57pointCountGrid( const PointDataGridT& grid,
58 const FilterT& filter = NullFilter());
59
60/// @brief Generate a new grid that uses the supplied transform with voxel values to store the
61/// number of points per voxel.
62/// @param grid the PointDataGrid to use to compute the count grid
63/// @param transform the transform to use to compute the count grid
64/// @param filter an optional index filter
65/// @note The return type of the grid must be an integer or floating-point scalar grid.
66template <typename PointDataGridT,
67 typename GridT = typename PointDataGridT::template ValueConverter<Int32>::Type,
68 typename FilterT = NullFilter>
69inline typename GridT::Ptr
70pointCountGrid( const PointDataGridT& grid,
71 const openvdb::math::Transform& transform,
72 const FilterT& filter = NullFilter());
73
74} // namespace points
75} // namespace OPENVDB_VERSION_NAME
76} // namespace openvdb
77
78#include "impl/PointCountImpl.h"
79
80#endif // OPENVDB_POINTS_POINT_COUNT_HAS_BEEN_INCLUDED
Index filters primarily designed to be used with a FilterIndexIter.
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
Methods for extracting masks from VDB Point grids.
A no-op filter that can be used when iterating over all indices.
Definition IndexIterator.h:52
Index64 pointOffsets(std::vector< Index64 > &pointOffsets, const PointDataTreeT &tree, const FilterT &filter=NullFilter(), const bool threaded=true)
Populate an array of cumulative point offsets per leaf node.
Index64 pointCount(const PointDataTreeT &tree, const FilterT &filter=NullFilter(), const bool threaded=true)
Count the total number of points in a PointDataTree.
GridT::Ptr pointCountGrid(const PointDataGridT &grid, const FilterT &filter=NullFilter())
Generate a new grid with voxel values to store the number of points per voxel.
Definition PointDataGrid.h:48
uint64_t Index64
Definition Types.h:33
Definition Exceptions.h:13
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:291