OpenVDB: openvdb/points/PointAttribute.h Source File

OpenVDB 10.1.0

Loading...
Searching...
No Matches
PointAttribute.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, Khang Ngo
5///
6/// @file points/PointAttribute.h
7///
8/// @brief Point attribute manipulation in a VDB Point Grid.
9
10#ifndef OPENVDB_POINTS_POINT_ATTRIBUTE_HAS_BEEN_INCLUDED
11#define OPENVDB_POINTS_POINT_ATTRIBUTE_HAS_BEEN_INCLUDED
12
13#include <openvdb/openvdb.h>
14
15#include "AttributeArrayString.h"
16#include "AttributeSet.h"
17#include "AttributeGroup.h"
18#include "PointDataGrid.h"
19
20
21namespace openvdb {
22 OPENVDB_USE_VERSION_NAMESPACE
23namespace OPENVDB_VERSION_NAME {
24namespace points {
25
26 namespace point_attribute_internal {
27
28template <typename ValueType>
29 struct Default
30{
31 static inline ValueType value() { return zeroVal<ValueType>(); }
32};
33
34} // namespace point_attribute_internal
35
36
37/// @brief Appends a new attribute to the VDB tree
38/// (this method does not require a templated AttributeType)
39///
40/// @param tree the PointDataTree to be appended to.
41/// @param name name for the new attribute.
42/// @param type the type of the attibute.
43/// @param strideOrTotalSize the stride of the attribute
44/// @param constantStride if @c false, stride is interpreted as total size of the array
45/// @param defaultValue metadata default attribute value
46/// @param hidden mark attribute as hidden
47/// @param transient mark attribute as transient
48template <typename PointDataTreeT>
49inline void appendAttribute(PointDataTreeT& tree,
50 const Name& name,
51 const NamePair& type,
52 const Index strideOrTotalSize = 1,
53 const bool constantStride = true,
54 const Metadata* defaultValue = nullptr,
55 const bool hidden = false,
56 const bool transient = false);
57
58/// @brief Appends a new attribute to the VDB tree.
59///
60/// @param tree the PointDataTree to be appended to.
61/// @param name name for the new attribute
62/// @param uniformValue the initial value of the attribute
63/// @param strideOrTotalSize the stride of the attribute
64/// @param constantStride if @c false, stride is interpreted as total size of the array
65/// @param defaultValue metadata default attribute value
66/// @param hidden mark attribute as hidden
67/// @param transient mark attribute as transient
68template <typename ValueType,
69 typename CodecType = NullCodec,
70 typename PointDataTreeT>
71inline void appendAttribute(PointDataTreeT& tree,
72 const std::string& name,
73 const ValueType& uniformValue =
74 point_attribute_internal::Default<ValueType>::value(),
75 const Index strideOrTotalSize = 1,
76 const bool constantStride = true,
77 const TypedMetadata<ValueType>* defaultValue = nullptr,
78 const bool hidden = false,
79 const bool transient = false);
80
81/// @brief Collapse the attribute into a uniform value
82///
83/// @param tree the PointDataTree in which to collapse the attribute.
84/// @param name name for the attribute.
85/// @param uniformValue value of the attribute
86template <typename ValueType, typename PointDataTreeT>
87inline void collapseAttribute( PointDataTreeT& tree,
88 const Name& name,
89 const ValueType& uniformValue =
90 point_attribute_internal::Default<ValueType>::value());
91
92/// @brief Drops attributes from the VDB tree.
93///
94/// @param tree the PointDataTree to be dropped from.
95/// @param indices indices of the attributes to drop.
96template <typename PointDataTreeT>
97inline void dropAttributes( PointDataTreeT& tree,
98 const std::vector<size_t>& indices);
99
100/// @brief Drops attributes from the VDB tree.
101///
102/// @param tree the PointDataTree to be dropped from.
103/// @param names names of the attributes to drop.
104template <typename PointDataTreeT>
105inline void dropAttributes( PointDataTreeT& tree,
106 const std::vector<Name>& names);
107
108/// @brief Drop one attribute from the VDB tree (convenience method).
109///
110/// @param tree the PointDataTree to be dropped from.
111/// @param index index of the attribute to drop.
112template <typename PointDataTreeT>
113inline void dropAttribute( PointDataTreeT& tree,
114 const size_t& index);
115
116/// @brief Drop one attribute from the VDB tree (convenience method).
117///
118/// @param tree the PointDataTree to be dropped from.
119/// @param name name of the attribute to drop.
120template <typename PointDataTreeT>
121inline void dropAttribute( PointDataTreeT& tree,
122 const Name& name);
123
124/// @brief Rename attributes in a VDB tree.
125///
126/// @param tree the PointDataTree.
127/// @param oldNames a list of old attribute names to rename from.
128/// @param newNames a list of new attribute names to rename to.
129///
130/// @note Number of oldNames must match the number of newNames.
131///
132/// @note Duplicate names and renaming group attributes are not allowed.
133template <typename PointDataTreeT>
134inline void renameAttributes(PointDataTreeT& tree,
135 const std::vector<Name>& oldNames,
136 const std::vector<Name>& newNames);
137
138/// @brief Rename an attribute in a VDB tree.
139///
140/// @param tree the PointDataTree.
141/// @param oldName the old attribute name to rename from.
142/// @param newName the new attribute name to rename to.
143///
144/// @note newName must not already exist and must not be a group attribute.
145template <typename PointDataTreeT>
146inline void renameAttribute(PointDataTreeT& tree,
147 const Name& oldName,
148 const Name& newName);
149
150/// @brief Compact attributes in a VDB tree (if possible).
151///
152/// @param tree the PointDataTree.
153template <typename PointDataTreeT>
154inline void compactAttributes(PointDataTreeT& tree);
155
156
157} // namespace points
158} // namespace OPENVDB_VERSION_NAME
159} // namespace openvdb
160
161#include "impl/PointAttributeImpl.h"
162
163#endif // OPENVDB_POINTS_POINT_ATTRIBUTE_HAS_BEEN_INCLUDED
AttributeArrayString.h
Attribute array storage for string data using Descriptor Metadata.
AttributeGroup.h
Attribute Group access and filtering for iteration.
AttributeSet.h
Set of Attribute Arrays which tracks metadata about each array.
PointAttributeImpl.h
PointDataGrid.h
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
openvdb::v10_1::Metadata
Base class for storing metadata information in a grid.
Definition Metadata.h:24
openvdb::v10_1::TypedMetadata
Templated metadata class to hold specific types.
Definition Metadata.h:122
openvdb::v10_1::Name
std::string Name
Definition Name.h:19
openvdb::v10_1::Index
Index32 Index
Definition Types.h:54
openvdb::v10_1::NamePair
std::pair< Name, Name > NamePair
Definition AttributeArray.h:39
openvdb
Definition Exceptions.h:13
openvdb.h
openvdb::v10_1::points::point_attribute_internal::Default
Definition PointAttribute.h:30
openvdb::v10_1::points::point_attribute_internal::Default::value
static ValueType value()
Definition PointAttribute.h:31
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