9 #ifndef OPENVDB_POINTS_POINT_COUNT_IMPL_HAS_BEEN_INCLUDED
10 #define OPENVDB_POINTS_POINT_COUNT_IMPL_HAS_BEEN_INCLUDED
17 template <
typename Po
intDataTreeT,
typename FilterT>
20 const bool inCoreOnly,
24 using LeafRangeT =
typename LeafManagerT::LeafRange;
28 for (
const auto& leaf : range) {
29 if (inCoreOnly && leaf.buffer().isOutOfCore())
continue;
30 auto state = filter.state(leaf);
32 sum += leaf.pointCount();
34 sum +=
iterCount(leaf.beginIndexAll(filter));
40 LeafManagerT leafManager(tree);
42 return tbb::parallel_reduce(leafManager.leafRange(),
Index64(0), countLambda,
46 return countLambda(leafManager.leafRange(),
Index64(0));
51 template <
typename Po
intDataTreeT,
typename FilterT>
53 const PointDataTreeT& tree,
55 const bool inCoreOnly,
58 using LeafT =
typename PointDataTreeT::LeafNodeType;
63 pointOffsets.assign(tree.leafCount(),
Index64(0));
64 if (pointOffsets.empty())
return 0;
68 LeafManagerT leafManager(tree);
70 [&pointOffsets, &filter, &inCoreOnly](
const LeafT& leaf,
size_t pos) {
71 if (inCoreOnly && leaf.buffer().isOutOfCore())
return;
72 auto state = filter.state(leaf);
74 pointOffsets[pos] = leaf.pointCount();
76 pointOffsets[pos] =
iterCount(leaf.beginIndexAll(filter));
83 Index64 pointOffset(pointOffsets[0]);
84 for (
size_t n = 1;
n < pointOffsets.size();
n++) {
85 pointOffset += pointOffsets[
n];
86 pointOffsets[
n] = pointOffset;
93 template <
typename Po
intDataGr
idT,
typename Gr
idT,
typename FilterT>
100 "openvdb::points::pointCountGrid must return an integer or floating-point scalar grid");
102 using PointDataTreeT =
typename PointDataGridT::TreeType;
103 using TreeT =
typename GridT::TreeType;
105 typename TreeT::Ptr tree =
106 point_mask_internal::convertPointsToScalar<TreeT, PointDataTreeT, FilterT>
109 typename GridT::Ptr grid(
new GridT(tree));
110 grid->setTransform(points.transform().copy());
115 template <
typename Po
intDataGr
idT,
typename Gr
idT,
typename FilterT>
118 const openvdb::math::Transform&
transform,
123 "openvdb::points::pointCountGrid must return an integer or floating-point scalar grid");
127 auto& nonConstPoints =
const_cast<typename AdapterT::NonConstGridType&
>(
points);
130 return point_mask_internal::convertPointsToScalar<GridT>(
142 #endif // OPENVDB_POINTS_POINT_COUNT_IMPL_HAS_BEEN_INCLUDED
GLdouble GLdouble GLint GLint const GLdouble * points
GLsizei const GLfloat * value
GridT::Ptr pointCountGrid(const PointDataGridT &points, const FilterT &filter)
Generate a new grid with voxel values to store the number of points per voxel.
#define OPENVDB_USE_VERSION_NAMESPACE
This adapter allows code that is templated on a Tree type to accept either a Tree type or a Grid type...
This class manages a linear array of pointers to a given tree's leaf nodes, as well as optional auxil...
Index64 pointCount(const PointDataTreeT &tree, const FilterT &filter, const bool inCoreOnly, const bool threaded)
Count the total number of points in a PointDataTree.
GA_API const UT_StringHolder transform
Index64 pointOffsets(std::vector< Index64 > &pointOffsets, const PointDataTreeT &tree, const FilterT &filter, const bool inCoreOnly, const bool threaded)
Populate an array of cumulative point offsets per leaf node.
Index64 iterCount(const IterT &iter)
Count up the number of times the iterator can iterate.
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter