37 #ifndef OPENVDB_POINTS_POINT_DELETE_HAS_BEEN_INCLUDED 38 #define OPENVDB_POINTS_POINT_DELETE_HAS_BEEN_INCLUDED 65 template <
typename Po
intDataTree>
81 template <
typename Po
intDataTree>
89 namespace point_delete_internal {
92 template <
typename Po
intDataTreeT>
97 using LeafNodeT =
typename PointDataTreeT::LeafNodeType;
101 : mGroupNames(groupNames)
102 , mInvert(invert) { }
108 std::unique_ptr<MultiGroupFilter> filter;
110 filter.reset(
new MultiGroupFilter(mGroupNames, std::vector<std::string>()));
113 filter.reset(
new MultiGroupFilter(std::vector<std::string>(), mGroupNames));
116 for (
auto leaf = range.begin(); leaf != range.end(); ++leaf)
120 if (size == 0)
continue;
122 const size_t newSize =
123 iterCount(leaf->template beginIndexAll<MultiGroupFilter>(*filter));
127 leaf->clearAttributes();
131 const AttributeSet& existingAttributeSet = leaf->attributeSet();
133 existingAttributeSet, static_cast<Index>(newSize));
134 const size_t attributeSetSize = existingAttributeSet.
size();
138 std::vector<AttributeArray*> newAttributeArrays;
139 std::vector<const AttributeArray*> existingAttributeArrays;
141 for (
size_t i = 0;
i < attributeSetSize;
i++) {
142 newAttributeArrays.push_back(newAttributeSet->
get(
i));
143 existingAttributeArrays.push_back(existingAttributeSet.
getConst(
i));
146 typename ValueType::IntType attributeIndex = 0;
147 std::vector<ValueType> endOffsets;
149 endOffsets.reserve(LeafNodeT::NUM_VALUES);
153 for (
auto voxel = leaf->cbeginValueAll(); voxel; ++voxel) {
154 for (
auto iter = leaf->beginIndexVoxel(voxel.getCoord(), *filter); iter; ++iter) {
155 for (
size_t i = 0;
i < attributeSetSize;
i++) {
156 newAttributeArrays[
i]->set(static_cast<Index>(attributeIndex),
157 *(existingAttributeArrays[
i]), *iter);
161 endOffsets.push_back(
ValueType(attributeIndex));
164 leaf->replaceAttributeSet(newAttributeSet);
165 leaf->setOffsets(endOffsets);
170 const std::vector<std::string>& mGroupNames;
180 template <
typename Po
intDataTreeT>
181 inline void deleteFromGroups(PointDataTreeT& pointTree,
const std::vector<std::string>& groups,
184 const typename PointDataTreeT::LeafCIter leafIter = pointTree.cbeginLeaf();
186 if (!leafIter)
return;
188 const openvdb::points::AttributeSet& attributeSet = leafIter->attributeSet();
189 const AttributeSet::Descriptor& descriptor = attributeSet.descriptor();
190 std::vector<std::string> availableGroups;
195 for (
const auto& groupName : groups) {
196 if (descriptor.hasGroup(groupName)) {
197 availableGroups.push_back(groupName);
201 if (availableGroups.empty())
return;
205 tbb::parallel_for(leafManager.
leafRange(), deleteOp);
214 template <
typename Po
intDataTreeT>
215 inline void deleteFromGroup(PointDataTreeT& pointTree,
const std::string& group,
bool invert)
217 std::vector<std::string> groups(1, group);
227 #endif // OPENVDB_POINTS_POINT_DELETE_HAS_BEEN_INCLUDED const AttributeArray * getConst(const std::string &name) const
Return a pointer to the attribute array whose name is name or a null pointer if no match is found...
const AttributeArray * get(const std::string &name) const
Return a pointer to the attribute array whose name is name or a null pointer if no match is found...
void deleteFromGroups(PointDataTreeT &pointTree, const std::vector< std::string > &groups, bool invert)
Definition: PointDelete.h:181
tbb::atomic< Index32 > i
Definition: LeafBuffer.h:71
Definition: LeafManager.h:127
Point group manipulation in a VDB Point Grid.
Definition: IndexFilter.h:103
Index filters primarily designed to be used with a FilterIndexIter.
Index64 iterCount(const IterT &iter)
Count up the number of times the iterator can iterate.
Definition: IndexIterator.h:313
#define OPENVDB_VERSION_NAME
Definition: version.h:43
typename LeafNodeT::ValueType ValueType
Definition: PointDelete.h:98
Definition: Exceptions.h:39
size_t size() const
Return the number of attributes in this set.
Definition: AttributeSet.h:130
Ordered collection of uniquely-named attribute arrays.
Definition: AttributeSet.h:62
typename PointDataTreeT::LeafNodeType LeafNodeT
Definition: PointDelete.h:97
LeafRange leafRange(size_t grainsize=1) const
Return a TBB-compatible LeafRange.
Definition: LeafManager.h:386
void deleteFromGroup(PointDataTreeT &pointTree, const std::string &group, bool invert)
Definition: PointDelete.h:215
This class manages a linear array of pointers to a given tree's leaf nodes, as well as optional auxil...
Definition: LeafManager.h:110
Definition: PointDelete.h:93
void operator()(const LeafRangeT &range) const
Definition: PointDelete.h:104
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
DeleteGroupsOp(const std::vector< std::string > &groupNames, bool invert)
Definition: PointDelete.h:100
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
A LeafManager manages a linear array of pointers to a given tree's leaf nodes, as well as optional au...
static constexpr size_t size
The size of a LeafBuffer when LeafBuffer::mOutOfCore is atomic.
Definition: LeafBuffer.h:85
tree::Tree< tree::RootNode< tree::InternalNode< tree::InternalNode< PointDataLeafNode< PointDataIndex32, 3 >, 4 >, 5 > >> PointDataTree
Point index tree configured to match the default VDB configurations.
Definition: PointDataGrid.h:207
void dropGroups(PointDataTree &tree, const std::vector< Name > &groups)
Drops existing groups from the VDB tree, the tree is compacted after dropping.
Definition: PointGroup.h:562
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointDelete.h:96