OpenVDB 11.0.0

Loading...
Searching...
No Matches
PointGroup.h
Go to the documentation of this file.
1// Copyright Contributors to the OpenVDB Project
2// SPDX-License-Identifier: MPL-2.0
3
4/// @author Dan Bailey
5///
6/// @file points/PointGroup.h
7///
8/// @brief Point group manipulation in a VDB Point Grid.
9
10#ifndef OPENVDB_POINTS_POINT_GROUP_HAS_BEEN_INCLUDED
11#define OPENVDB_POINTS_POINT_GROUP_HAS_BEEN_INCLUDED
12
13#include <openvdb/openvdb.h>
14
15#include "IndexIterator.h" // FilterTraits
16#include "IndexFilter.h" // FilterTraits
17#include "AttributeSet.h"
18#include "PointDataGrid.h"
19#include "PointAttribute.h"
20#include "PointCount.h"
21
22#include <tbb/parallel_reduce.h>
23
24#include <algorithm>
25#include <random>
26#include <string>
27#include <vector>
28
29 namespace openvdb {
30 OPENVDB_USE_VERSION_NAMESPACE
31 namespace OPENVDB_VERSION_NAME {
32 namespace points {
33
34/// @brief Delete any group that is not present in the Descriptor.
35///
36/// @param groups the vector of group names.
37/// @param descriptor the descriptor that holds the group map.
38 inline void deleteMissingPointGroups( std::vector<std::string>& groups,
39 const AttributeSet::Descriptor& descriptor);
40
41/// @brief Appends a new empty group to the VDB tree.
42///
43/// @param tree the PointDataTree to be appended to.
44/// @param group name of the new group.
45 template <typename PointDataTreeT>
46 inline void appendGroup(PointDataTreeT& tree,
47 const Name& group);
48
49/// @brief Appends new empty groups to the VDB tree.
50///
51/// @param tree the PointDataTree to be appended to.
52/// @param groups names of the new groups.
53 template <typename PointDataTreeT>
54 inline void appendGroups(PointDataTreeT& tree,
55 const std::vector<Name>& groups);
56
57/// @brief Drops an existing group from the VDB tree.
58///
59/// @param tree the PointDataTree to be dropped from.
60/// @param group name of the group.
61/// @param compact compact attributes if possible to reduce memory - if dropping
62/// more than one group, compacting once at the end will be faster
63 template <typename PointDataTreeT>
64 inline void dropGroup( PointDataTreeT& tree,
65 const Name& group,
66 const bool compact = true);
67
68/// @brief Drops existing groups from the VDB tree, the tree is compacted after dropping.
69///
70/// @param tree the PointDataTree to be dropped from.
71/// @param groups names of the groups.
72 template <typename PointDataTreeT>
73 inline void dropGroups( PointDataTreeT& tree,
74 const std::vector<Name>& groups);
75
76/// @brief Drops all existing groups from the VDB tree, the tree is compacted after dropping.
77///
78/// @param tree the PointDataTree to be dropped from.
79 template <typename PointDataTreeT>
80 inline void dropGroups( PointDataTreeT& tree);
81
82/// @brief Compacts existing groups of a VDB Tree to use less memory if possible.
83///
84/// @param tree the PointDataTree to be compacted.
85 template <typename PointDataTreeT>
86 inline void compactGroups(PointDataTreeT& tree);
87
88/// @brief Sets group membership from a PointIndexTree-ordered vector.
89///
90/// @param tree the PointDataTree.
91/// @param indexTree the PointIndexTree.
92/// @param membership @c 1 if the point is in the group, 0 otherwise.
93/// @param group the name of the group.
94/// @param remove if @c true also perform removal of points from the group.
95///
96/// @note vector<bool> is not thread-safe on concurrent write, so use vector<short> instead
97 template <typename PointDataTreeT, typename PointIndexTreeT>
98 inline void setGroup( PointDataTreeT& tree,
99 const PointIndexTreeT& indexTree,
100 const std::vector<short>& membership,
101 const Name& group,
102 const bool remove = false);
103
104/// @brief Sets membership for the specified group for all points (on/off).
105///
106/// @param tree the PointDataTree.
107/// @param group the name of the group.
108/// @param member true / false for membership of the group.
109 template <typename PointDataTreeT>
110 inline void setGroup( PointDataTreeT& tree,
111 const Name& group,
112 const bool member = true);
113
114/// @brief Sets group membership based on a provided filter.
115///
116/// @param tree the PointDataTree.
117/// @param group the name of the group.
118/// @param filter filter data that is used to create a per-leaf filter
119 template <typename PointDataTreeT, typename FilterT>
120 inline void setGroupByFilter( PointDataTreeT& tree,
121 const Name& group,
122 const FilterT& filter);
123
124} // namespace points
125} // namespace OPENVDB_VERSION_NAME
126} // namespace openvdb
127
128#include "impl/PointGroupImpl.h"
129
130#endif // OPENVDB_POINTS_POINT_GROUP_HAS_BEEN_INCLUDED
AttributeSet.h
Set of Attribute Arrays which tracks metadata about each array.
IndexFilter.h
Index filters primarily designed to be used with a FilterIndexIter.
IndexIterator.h
Index Iterators.
PointAttribute.h
Point attribute manipulation in a VDB Point Grid.
PointCount.h
Methods for counting points in VDB Point grids.
PointDataGrid.h
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
PointGroupImpl.h
openvdb::v11_0::points::dropGroups
void dropGroups(PointDataTreeT &tree, const std::vector< Name > &groups)
Drops existing groups from the VDB tree, the tree is compacted after dropping.
Definition PointGroupImpl.h:329
openvdb::v11_0::points::setGroup
void setGroup(PointDataTreeT &tree, const PointIndexTreeT &indexTree, const std::vector< short > &membership, const Name &group, const bool remove=false)
Sets group membership from a PointIndexTree-ordered vector.
Definition PointGroupImpl.h:438
openvdb::v11_0::points::deleteMissingPointGroups
void deleteMissingPointGroups(std::vector< std::string > &groups, const AttributeSet::Descriptor &descriptor)
Delete any group that is not present in the Descriptor.
Definition PointGroupImpl.h:195
openvdb::v11_0::points::compactGroups
void compactGroups(PointDataTreeT &tree)
Compacts existing groups of a VDB Tree to use less memory if possible.
Definition PointGroupImpl.h:377
openvdb::v11_0::points::appendGroup
void appendGroup(PointDataTreeT &tree, const Name &group)
Appends a new empty group to the VDB tree.
Definition PointGroupImpl.h:209
openvdb::v11_0::points::appendGroups
void appendGroups(PointDataTreeT &tree, const std::vector< Name > &groups)
Appends new empty groups to the VDB tree.
Definition PointGroupImpl.h:280
openvdb::v11_0::points::setGroupByFilter
void setGroupByFilter(PointDataTreeT &tree, const Name &group, const FilterT &filter)
Sets group membership based on a provided filter.
Definition PointGroupImpl.h:542
openvdb::v11_0::points::dropGroup
void dropGroup(PointDataTreeT &tree, const Name &group, const bool compact=true)
Drops an existing group from the VDB tree.
Definition PointGroupImpl.h:296
openvdb
Definition Exceptions.h:13
openvdb.h
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:212