OpenVDB: openvdb/openvdb.h Source File

OpenVDB 9.1.0

openvdb.h
Go to the documentation of this file.
1// Copyright Contributors to the OpenVDB Project
2// SPDX-License-Identifier: MPL-2.0
3
4#ifndef OPENVDB_OPENVDB_HAS_BEEN_INCLUDED
5#define OPENVDB_OPENVDB_HAS_BEEN_INCLUDED
6
7#include "Platform.h"
8#include "Types.h"
9#include "TypeList.h"
10#include "Metadata.h"
11#include "math/Maps.h"
12#include "math/Transform.h"
13#include "Grid.h"
14#include "tree/Tree.h"
15#include "points/PointDataGrid.h"
16#include "io/File.h"
17
18
19namespace openvdb {
20 OPENVDB_USE_VERSION_NAMESPACE
21namespace OPENVDB_VERSION_NAME {
22
23/// @brief Global registration of native Grid, Transform, Metadata and Point
24/// attribute types. Also initializes blosc (if enabled).
25/// @details Calling this methods registers factory callbacks for the set of
26/// native grid, transform, metadata and point attribute types that OpenVDB
27/// supports by default. For most types, calling openvdb::initialize is only
28/// required for serialization support. However, openvdb::initialize must be
29/// called for PointDataGrid attribute usage as these callbacks are used in
30/// various tools.
31/// @note This method is thread safe - it can be concurrently called multiple
32/// times, early exiting if it has already been called so long as
33/// openvdb::uninitialize() has not been called.
34 OPENVDB_API void initialize();
35
36/// @brief Global deregistration of native Grid, Transform, Metadata and Point
37/// attribute types.
38/// @details Clears all registered factory callbacks. This includes everything
39/// registered by openvdb::initialize() but will also include any manually
40/// registered types.
41/// @note This method is thread safe - it can be concurrently called multiple
42/// times.
43/// @warning This method does *not* uninitialize blosc. This is to avoid
44/// changing program states should another library also be using blosc. If
45/// blosc is enabled, consider calling blosc_destroy() in your application.
46 OPENVDB_API void uninitialize();
47
48
49// foward declare some default types
50 namespace io { class DelayedLoadMetadata; }
51
52/// Common tree types
53 using BoolTree = tree::Tree4<bool, 5, 4, 3>::Type;
54 using DoubleTree = tree::Tree4<double, 5, 4, 3>::Type;
55 using FloatTree = tree::Tree4<float, 5, 4, 3>::Type;
56 using Int32Tree = tree::Tree4<int32_t, 5, 4, 3>::Type;
57 using Int64Tree = tree::Tree4<int64_t, 5, 4, 3>::Type;
58 using MaskTree = tree::Tree4<ValueMask, 5, 4, 3>::Type;
59 using UInt32Tree = tree::Tree4<uint32_t, 5, 4, 3>::Type;
60 using Vec2DTree = tree::Tree4<Vec2d, 5, 4, 3>::Type;
61 using Vec2ITree = tree::Tree4<Vec2i, 5, 4, 3>::Type;
62 using Vec2STree = tree::Tree4<Vec2s, 5, 4, 3>::Type;
63 using Vec3DTree = tree::Tree4<Vec3d, 5, 4, 3>::Type;
64 using Vec3ITree = tree::Tree4<Vec3i, 5, 4, 3>::Type;
65 using Vec3STree = tree::Tree4<Vec3f, 5, 4, 3>::Type;
66 using ScalarTree = FloatTree;
67 using TopologyTree = MaskTree;
68 using Vec3dTree = Vec3DTree;
69 using Vec3fTree = Vec3STree;
70 using VectorTree = Vec3fTree;
71
72/// Common grid types
73 using BoolGrid = Grid<BoolTree>;
74 using DoubleGrid = Grid<DoubleTree>;
75 using FloatGrid = Grid<FloatTree>;
76 using Int32Grid = Grid<Int32Tree>;
77 using Int64Grid = Grid<Int64Tree>;
78 using MaskGrid = Grid<MaskTree>;
79 using Vec3DGrid = Grid<Vec3DTree>;
80 using Vec3IGrid = Grid<Vec3ITree>;
81 using Vec3SGrid = Grid<Vec3STree>;
82 using ScalarGrid = FloatGrid;
83 using TopologyGrid = MaskGrid;
84 using Vec3dGrid = Vec3DGrid;
85 using Vec3fGrid = Vec3SGrid;
86 using VectorGrid = Vec3fGrid;
87
88/// @name Lists of native Grid Types
89/// @{
90/// The floating point Grid types which OpenVDB will register by default.
91 using RealGridTypes = TypeList<FloatGrid, DoubleGrid>;
92/// The integer Grid types which OpenVDB will register by default.
93 using IntegerGridTypes = TypeList<Int32Grid, Int64Grid>;
94/// The scalar Grid types which OpenVDB will register by default. This is a
95/// combination of native floating point and integer grid types. Note that
96/// this list does not include Bool or Mask Grids.
97 using NumericGridTypes = RealGridTypes::Append<IntegerGridTypes>;
98/// The Vec3 Grid types which OpenVDB will register by default.
99 using Vec3GridTypes = TypeList<Vec3IGrid, Vec3SGrid, Vec3DGrid>;
100
101/// The Grid types which OpenVDB will register by default.
102 using GridTypes =
103 NumericGridTypes::
104 Append<Vec3GridTypes>::
105 Append<tools::PointIndexGrid>::
106 // #define unfortunately required for one of the tests that removes this alias
107#ifndef OPENVDB_DISABLE_POINT_DATA_TREE_ALIAS
108 Append<points::PointDataGrid>::
109#endif
110 Append<BoolGrid, MaskGrid>;
111/// @}
112
113
114 namespace internal {
115 template <typename T> using ToTreeType = typename T::TreeType;
116}
117/// @name Lists of native Tree Types
118/// @{
119 using RealTreeTypes = RealGridTypes::Transform<internal::ToTreeType>;
120 using IntegerTreeTypes = IntegerGridTypes::Transform<internal::ToTreeType>;
121 using NumericTreeTypes = NumericGridTypes::Transform<internal::ToTreeType>;
122 using Vec3TreeTypes = Vec3GridTypes::Transform<internal::ToTreeType>;
123 using TreeTypes = GridTypes::Transform<internal::ToTreeType>;
124/// @}
125
126
127/// @name Lists of native TypedAttributeArray Types (for PointDataGrids)
128/// @{
129/// The floating point attribute array types which OpenVDB will register by default.
130 using RealAttributeTypes = TypeList<
131 points::TypedAttributeArray<float>,
132 points::TypedAttributeArray<double>,
133 points::TypedAttributeArray<float, points::TruncateCodec>,
134 points::TypedAttributeArray<float, points::FixedPointCodec<true, points::UnitRange>>,
135 points::TypedAttributeArray<float, points::FixedPointCodec<false, points::UnitRange>>
136 >;
137/// The integer attribute array types which OpenVDB will register by default.
138 using IntegerAttributeTypes = TypeList<
139 points::TypedAttributeArray<int8_t>,
140 points::TypedAttributeArray<int16_t>,
141 points::TypedAttributeArray<int32_t>,
142 points::TypedAttributeArray<int64_t>
143 >;
144/// The scalar attribute array types which OpenVDB will register by default.
145/// This is a combination of native floating point and integer array types.
146/// Note that this list does not include bool arrays.
147 using NumericAttributeTypes =
148 RealAttributeTypes::Append<IntegerAttributeTypes>;
149/// The Vec3 attribute array types which OpenVDB will register by default.
150 using Vec3AttributeTypes = TypeList<
151 points::TypedAttributeArray<math::Vec3<int32_t>>,
152 points::TypedAttributeArray<math::Vec3<float>>,
153 points::TypedAttributeArray<math::Vec3<double>>,
154 points::TypedAttributeArray<math::Vec3<float>, points::TruncateCodec>,
155 points::TypedAttributeArray<math::Vec3<float>, points::FixedPointCodec<true, points::PositionRange>>,
156 points::TypedAttributeArray<math::Vec3<float>, points::FixedPointCodec<false, points::PositionRange>>,
157 points::TypedAttributeArray<math::Vec3<float>, points::FixedPointCodec<true, points::UnitRange>>,
158 points::TypedAttributeArray<math::Vec3<float>, points::FixedPointCodec<false, points::UnitRange>>,
159 points::TypedAttributeArray<math::Vec3<float>, points::UnitVecCodec>
160 >;
161/// The Mat3 attribute array types which OpenVDB will register by default.
162 using Mat3AttributeTypes = TypeList<
163 points::TypedAttributeArray<math::Mat3<float>>,
164 points::TypedAttributeArray<math::Mat3<double>>
165 >;
166/// The Mat4 attribute array types which OpenVDB will register by default.
167 using Mat4AttributeTypes = TypeList<
168 points::TypedAttributeArray<math::Mat4<float>>,
169 points::TypedAttributeArray<math::Mat4<double>>
170 >;
171/// The Quat attribute array types which OpenVDB will register by default.
172 using QuatAttributeTypes = TypeList<
173 points::TypedAttributeArray<math::Quat<float>>,
174 points::TypedAttributeArray<math::Quat<double>>
175 >;
176
177/// The attribute array types which OpenVDB will register by default.
178 using AttributeTypes =
179 NumericAttributeTypes::
180 Append<Vec3AttributeTypes>::
181 Append<Mat3AttributeTypes>::
182 Append<Mat4AttributeTypes>::
183 Append<QuatAttributeTypes>::
184 Append<points::GroupAttributeArray>::
185 Append<points::StringAttributeArray>::
186 Append<points::TypedAttributeArray<bool>>;
187/// @}
188
189
190/// The Map types which OpenVDB will register by default.
191 using MapTypes = TypeList<
192 math::AffineMap,
193 math::UnitaryMap,
194 math::ScaleMap,
195 math::UniformScaleMap,
196 math::TranslationMap,
197 math::ScaleTranslateMap,
198 math::UniformScaleTranslateMap,
199 math::NonlinearFrustumMap>;
200
201
202/// The Metadata types which OpenVDB will register by default.
203 using MetaTypes = TypeList<
204 BoolMetadata,
205 DoubleMetadata,
206 FloatMetadata,
207 Int32Metadata,
208 Int64Metadata,
209 StringMetadata,
210 Vec2IMetadata,
211 Vec2SMetadata,
212 Vec2DMetadata,
213 Vec3IMetadata,
214 Vec3SMetadata,
215 Vec3DMetadata,
216 Vec4IMetadata,
217 Vec4SMetadata,
218 Vec4DMetadata,
219 Mat4SMetadata,
220 Mat4DMetadata,
221 io::DelayedLoadMetadata>;
222
223
224// Deprecated types
225/// @note Customizing the type of a VDB tree to an arbitrary class is still
226/// supported however std::string Trees will, in the future, no longer be
227/// provided as a native type by OpenVDB.
228 using StringTree OPENVDB_DEPRECATED_MESSAGE("Support for std::string Trees "
229 "as a native type will be dropped in future versions. Please feedback with any concerns.")
230 = tree::Tree4<std::string, 5, 4, 3>::Type;
231 using StringGrid OPENVDB_DEPRECATED_MESSAGE("Support for std::string Grids "
232 "as a native type will be dropped in future versions. Please feedback with any concerns.")
233 = Grid<tree::Tree4<std::string, 5, 4, 3>::Type>;
234
235} // namespace OPENVDB_VERSION_NAME
236} // namespace openvdb
237
238#endif // OPENVDB_OPENVDB_HAS_BEEN_INCLUDED
File.h
Grid.h
Maps.h
Metadata.h
Platform.h
OPENVDB_API
#define OPENVDB_API
Definition: Platform.h:249
OPENVDB_DEPRECATED_MESSAGE
#define OPENVDB_DEPRECATED_MESSAGE(msg)
Definition: Platform.h:123
PointDataGrid.h
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
Transform.h
Tree.h
TypeList.h
A TypeList provides a compile time sequence of heterogeneous types which can be accessed,...
Types.h
Consolidated llvm types for most supported types.
openvdb::v9_1::Grid
Container class that associates a tree with a transform and metadata.
Definition: Grid.h:573
openvdb::v9_1::io::DelayedLoadMetadata
Store a buffer of data that can be optionally used during reading for faster delayed-load I/O perform...
Definition: DelayedLoadMetadata.h:22
openvdb::v9_1::math::AffineMap
A general linear transform using homogeneous coordinates to perform rotation, scaling,...
Definition: Maps.h:310
openvdb::v9_1::math::NonlinearFrustumMap
This map is composed of three steps. First it will take a box of size (Lx X Ly X Lz) defined by a mem...
Definition: Maps.h:1911
openvdb::v9_1::math::ScaleMap
A specialized Affine transform that scales along the principal axis the scaling need not be uniform i...
Definition: Maps.h:670
openvdb::v9_1::math::ScaleTranslateMap
A specialized Affine transform that scales along the principal axis the scaling need not be uniform i...
Definition: Maps.h:1179
openvdb::v9_1::math::TranslationMap
A specialized linear transform that performs a translation.
Definition: Maps.h:994
openvdb::v9_1::math::UniformScaleMap
A specialized Affine transform that scales along the principal axis the scaling is uniform in the thr...
Definition: Maps.h:921
openvdb::v9_1::math::UniformScaleTranslateMap
A specialized Affine transform that uniformaly scales along the principal axis and then translates th...
Definition: Maps.h:1496
openvdb::v9_1::math::UnitaryMap
A specialized linear transform that performs a unitary maping i.e. rotation and or reflection.
Definition: Maps.h:1639
openvdb::v9_1::points::TypedAttributeArray
Typed class for storing attribute data.
Definition: AttributeArray.h:539
openvdb::v9_1::tree::Tree
Definition: Tree.h:178
openvdb::v9_1::internal::ToTreeType
typename T::TreeType ToTreeType
Definition: openvdb.h:115
openvdb::v9_1::AttributeTypes
NumericAttributeTypes::Append< Vec3AttributeTypes >::Append< Mat3AttributeTypes >::Append< Mat4AttributeTypes >::Append< QuatAttributeTypes >::Append< points::GroupAttributeArray >::Append< points::StringAttributeArray >::Append< points::TypedAttributeArray< bool > > AttributeTypes
The attribute array types which OpenVDB will register by default.
Definition: openvdb.h:186
openvdb::v9_1::Vec4DMetadata
TypedMetadata< Vec4d > Vec4DMetadata
Definition: Metadata.h:370
openvdb::v9_1::FloatMetadata
TypedMetadata< float > FloatMetadata
Definition: Metadata.h:360
openvdb::v9_1::FloatGrid
Grid< FloatTree > FloatGrid
Definition: openvdb.h:75
openvdb::v9_1::TreeTypes
GridTypes::Transform< internal::ToTreeType > TreeTypes
Definition: openvdb.h:123
openvdb::v9_1::Vec2DMetadata
TypedMetadata< Vec2d > Vec2DMetadata
Definition: Metadata.h:364
openvdb::v9_1::Vec3DGrid
Grid< Vec3DTree > Vec3DGrid
Definition: openvdb.h:79
openvdb::v9_1::IntegerTreeTypes
IntegerGridTypes::Transform< internal::ToTreeType > IntegerTreeTypes
Definition: openvdb.h:120
openvdb::v9_1::RealTreeTypes
RealGridTypes::Transform< internal::ToTreeType > RealTreeTypes
Definition: openvdb.h:119
openvdb::v9_1::Vec3DMetadata
TypedMetadata< Vec3d > Vec3DMetadata
Definition: Metadata.h:367
openvdb::v9_1::NumericGridTypes
RealGridTypes::Append< IntegerGridTypes > NumericGridTypes
Definition: openvdb.h:97
openvdb::v9_1::Vec3fGrid
Vec3SGrid Vec3fGrid
Definition: openvdb.h:85
openvdb::v9_1::Int32Metadata
TypedMetadata< int32_t > Int32Metadata
Definition: Metadata.h:361
openvdb::v9_1::Vec3TreeTypes
Vec3GridTypes::Transform< internal::ToTreeType > Vec3TreeTypes
Definition: openvdb.h:122
openvdb::v9_1::Mat4DMetadata
TypedMetadata< Mat4d > Mat4DMetadata
Definition: Metadata.h:374
openvdb::v9_1::NumericAttributeTypes
RealAttributeTypes::Append< IntegerAttributeTypes > NumericAttributeTypes
Definition: openvdb.h:148
openvdb::v9_1::Vec3SGrid
Grid< Vec3STree > Vec3SGrid
Definition: openvdb.h:81
openvdb::v9_1::FloatTree
tree::Tree4< float, 5, 4, 3 >::Type FloatTree
Definition: openvdb.h:55
openvdb::v9_1::Vec2IMetadata
TypedMetadata< Vec2i > Vec2IMetadata
Definition: Metadata.h:365
openvdb::v9_1::MaskTree
tree::Tree4< ValueMask, 5, 4, 3 >::Type MaskTree
Definition: openvdb.h:58
openvdb::v9_1::StringMetadata
TypedMetadata< std::string > StringMetadata
Definition: Metadata.h:363
openvdb::v9_1::Vec3STree
tree::Tree4< Vec3f, 5, 4, 3 >::Type Vec3STree
Definition: openvdb.h:65
openvdb::v9_1::MaskGrid
Grid< MaskTree > MaskGrid
Definition: openvdb.h:78
openvdb::v9_1::Vec4SMetadata
TypedMetadata< Vec4s > Vec4SMetadata
Definition: Metadata.h:372
openvdb::v9_1::NumericTreeTypes
NumericGridTypes::Transform< internal::ToTreeType > NumericTreeTypes
Definition: openvdb.h:121
openvdb::v9_1::Vec3SMetadata
TypedMetadata< Vec3s > Vec3SMetadata
Definition: Metadata.h:369
openvdb::v9_1::Vec3fTree
Vec3STree Vec3fTree
Definition: openvdb.h:69
openvdb::v9_1::Vec3DTree
tree::Tree4< Vec3d, 5, 4, 3 >::Type Vec3DTree
Definition: openvdb.h:63
openvdb::v9_1::Vec2SMetadata
TypedMetadata< Vec2s > Vec2SMetadata
Definition: Metadata.h:366
openvdb::v9_1::initialize
OPENVDB_IMPORT void initialize()
Global registration of native Grid, Transform, Metadata and Point attribute types....
openvdb::v9_1::Vec4IMetadata
TypedMetadata< Vec4i > Vec4IMetadata
Definition: Metadata.h:371
openvdb::v9_1::Mat4SMetadata
TypedMetadata< Mat4s > Mat4SMetadata
Definition: Metadata.h:373
openvdb::v9_1::Vec3IMetadata
TypedMetadata< Vec3i > Vec3IMetadata
Definition: Metadata.h:368
openvdb::v9_1::BoolMetadata
TypedMetadata< bool > BoolMetadata
Definition: Metadata.h:358
openvdb::v9_1::Int64Metadata
TypedMetadata< int64_t > Int64Metadata
Definition: Metadata.h:362
openvdb::v9_1::uninitialize
OPENVDB_IMPORT void uninitialize()
Global deregistration of native Grid, Transform, Metadata and Point attribute types.
openvdb::v9_1::DoubleMetadata
TypedMetadata< double > DoubleMetadata
Definition: Metadata.h:359
openvdb::v9_1::GridTypes
NumericGridTypes::Append< Vec3GridTypes >::Append< tools::PointIndexGrid >::Append< points::PointDataGrid >::Append< BoolGrid, MaskGrid > GridTypes
The Grid types which OpenVDB will register by default.
Definition: openvdb.h:110
openvdb
Definition: Exceptions.h:13
openvdb::v9_1::TypeList
A list of types (not necessarily unique)
Definition: TypeList.h:484
openvdb::v9_1::TypeList::Transform
typename typelist_internal::TSTranformImpl< OpT, Ts... >::type Transform
Transform each type of this TypeList, rebuiling a new list of converted types. This method instantiat...
Definition: TypeList.h:640
openvdb::v9_1::TypeList::Append
typename typelist_internal::TSAppendImpl< Self, TypesToAppend... >::type Append
Append types, or the members of another TypeList, to this list.
Definition: TypeList.h:560
openvdb::v9_1::points::FixedPointCodec
Definition: AttributeArray.h:505
openvdb::v9_1::points::TruncateCodec
Definition: AttributeArray.h:475
openvdb::v9_1::points::UnitVecCodec
Definition: AttributeArray.h:520
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202