OpenVDB: openvdb/points/PointAttribute.h Source File

OpenVDB 12.1.1

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