HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
openvdb.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: Apache-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 
19 namespace openvdb {
21 namespace 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.
47 
48 
49 // foward declare some default types
50 namespace io { class DelayedLoadMetadata; }
51 
52 /// Common tree types
72 
73 /// Common grid types
89 
90 /// @name Lists of native Grid Types
91 /// @{
92 /// The floating point Grid types which OpenVDB will register by default.
94 /// The integer Grid types which OpenVDB will register by default.
96 /// The scalar Grid types which OpenVDB will register by default. This is a
97 /// combination of native floating point and integer grid types. Note that
98 /// this list does not include Bool or Mask Grids.
100 /// The Vec3 Grid types which OpenVDB will register by default.
102 
103 /// The Grid types which OpenVDB will register by default.
104 using GridTypes =
105  NumericGridTypes::
106  Append<Vec3GridTypes>::
107  Append<tools::PointIndexGrid>::
108  // #define unfortunately required for one of the tests that removes this alias
109 #ifndef OPENVDB_DISABLE_POINT_DATA_TREE_ALIAS
110  Append<points::PointDataGrid>::
111 #endif
112  Append<BoolGrid, MaskGrid>;
113 /// @}
114 
115 
116 namespace internal {
117 template <typename T> using ToTreeType = typename T::TreeType;
118 }
119 /// @name Lists of native Tree Types
120 /// @{
123 using NumericTreeTypes = NumericGridTypes::Transform<internal::ToTreeType>;
125 using TreeTypes = GridTypes::Transform<internal::ToTreeType>;
126 /// @}
127 
128 
129 /// @name Lists of native TypedAttributeArray Types (for PointDataGrids)
130 /// @{
131 /// The floating point attribute array types which OpenVDB will register by default.
133  points::TypedAttributeArray<float>,
134  points::TypedAttributeArray<double>,
135  points::TypedAttributeArray<float, points::TruncateCodec>,
136  points::TypedAttributeArray<float, points::FixedPointCodec<true, points::UnitRange>>,
137  points::TypedAttributeArray<float, points::FixedPointCodec<false, points::UnitRange>>
138  >;
139 /// The integer attribute array types which OpenVDB will register by default.
141  points::TypedAttributeArray<int8_t>,
142  points::TypedAttributeArray<int16_t>,
143  points::TypedAttributeArray<int32_t>,
144  points::TypedAttributeArray<int64_t>
145  >;
146 /// The scalar attribute array types which OpenVDB will register by default.
147 /// This is a combination of native floating point and integer array types.
148 /// Note that this list does not include bool arrays.
149 using NumericAttributeTypes =
151 /// The Vec3 attribute array types which OpenVDB will register by default.
153  points::TypedAttributeArray<math::Vec3<int32_t>>,
154  points::TypedAttributeArray<math::Vec3<float>>,
155  points::TypedAttributeArray<math::Vec3<double>>,
156  points::TypedAttributeArray<math::Vec3<float>, points::TruncateCodec>,
157  points::TypedAttributeArray<math::Vec3<float>, points::FixedPointCodec<true, points::PositionRange>>,
158  points::TypedAttributeArray<math::Vec3<float>, points::FixedPointCodec<false, points::PositionRange>>,
159  points::TypedAttributeArray<math::Vec3<float>, points::FixedPointCodec<true, points::UnitRange>>,
160  points::TypedAttributeArray<math::Vec3<float>, points::FixedPointCodec<false, points::UnitRange>>,
161  points::TypedAttributeArray<math::Vec3<float>, points::UnitVecCodec>
162  >;
163 /// The Mat3 attribute array types which OpenVDB will register by default.
165  points::TypedAttributeArray<math::Mat3<float>>,
166  points::TypedAttributeArray<math::Mat3<double>>
167  >;
168 /// The Mat4 attribute array types which OpenVDB will register by default.
170  points::TypedAttributeArray<math::Mat4<float>>,
171  points::TypedAttributeArray<math::Mat4<double>>
172  >;
173 /// The Quat attribute array types which OpenVDB will register by default.
175  points::TypedAttributeArray<math::Quat<float>>,
176  points::TypedAttributeArray<math::Quat<double>>
177  >;
178 
179 /// The attribute array types which OpenVDB will register by default.
180 using AttributeTypes =
181  NumericAttributeTypes::
182  Append<Vec3AttributeTypes>::
183  Append<Mat3AttributeTypes>::
184  Append<Mat4AttributeTypes>::
185  Append<QuatAttributeTypes>::
186  Append<points::GroupAttributeArray>::
187  Append<points::StringAttributeArray>::
188  Append<points::TypedAttributeArray<bool>>;
189 /// @}
190 
191 
192 /// The Map types which OpenVDB will register by default.
193 using MapTypes = TypeList<
202 
203 
204 /// The Metadata types which OpenVDB will register by default.
205 using MetaTypes = TypeList<
206  BoolMetadata,
209  HalfMetadata,
225 
226 
227 } // namespace OPENVDB_VERSION_NAME
228 } // namespace openvdb
229 
230 #endif // OPENVDB_OPENVDB_HAS_BEEN_INCLUDED
Grid< Vec3DTree > Vec3DGrid
Definition: openvdb.h:81
A specialized Affine transform that scales along the principal axis the scaling is uniform in the thr...
Definition: Maps.h:905
TypedMetadata< Vec3d > Vec3DMetadata
Definition: Metadata.h:369
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:112
Store a buffer of data that can be optionally used during reading for faster delayed-load I/O perform...
OPENVDB_API void uninitialize()
Global deregistration of native Grid, Transform, Metadata and Point attribute types.
TypedMetadata< Vec4d > Vec4DMetadata
Definition: Metadata.h:372
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:188
A specialized Affine transform that scales along the principal axis the scaling need not be uniform i...
Definition: Maps.h:655
typename typelist_internal::TSAppendImpl< Self, TypesToAppend...>::type Append
Append types, or the members of another TypeList, to this list.
Definition: TypeList.h:656
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:1891
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:246
tree::Tree4< ValueMask, 5, 4, 3 >::Type MaskTree
Definition: openvdb.h:59
TypedMetadata< Mat4d > Mat4DMetadata
Definition: Metadata.h:376
Vec3GridTypes::Transform< internal::ToTreeType > Vec3TreeTypes
Definition: openvdb.h:124
tree::Tree4< Vec3d, 5, 4, 3 >::Type Vec3DTree
Definition: openvdb.h:64
TypedMetadata< Vec3i > Vec3IMetadata
Definition: Metadata.h:370
TypedMetadata< Mat4s > Mat4SMetadata
Definition: Metadata.h:375
TypedMetadata< std::string > StringMetadata
Definition: Metadata.h:365
#define OPENVDB_API
Definition: Platform.h:291
A TypeList provides a compile time sequence of heterogeneous types which can be accessed, transformed and executed over in various ways. It incorporates a subset of functionality similar to hboost::mpl::vector however provides most of its content through using declarations rather than additional typed classes.
TypedMetadata< math::half > HalfMetadata
Definition: Metadata.h:362
A general linear transform using homogeneous coordinates to perform rotation, scaling, shear and translation.
Definition: Maps.h:295
Grid< MaskTree > MaskGrid
Definition: openvdb.h:80
TypedMetadata< int32_t > Int32Metadata
Definition: Metadata.h:363
TypedMetadata< bool > BoolMetadata
Definition: Metadata.h:359
GridTypes::Transform< internal::ToTreeType > TreeTypes
Definition: openvdb.h:125
OPENVDB_API void initialize()
Global registration of native Grid, Transform, Metadata and Point attribute types. Also initializes blosc (if enabled).
Definition: logging.h:294
TypedMetadata< int64_t > Int64Metadata
Definition: Metadata.h:364
IntegerGridTypes::Transform< internal::ToTreeType > IntegerTreeTypes
Definition: openvdb.h:122
Container class that associates a tree with a transform and metadata.
Definition: Grid.h:28
RealGridTypes::Append< IntegerGridTypes >::Append< HalfGrid > NumericGridTypes
Definition: openvdb.h:99
typename T::TreeType ToTreeType
Definition: openvdb.h:117
tree::Tree4< float, 5, 4, 3 >::Type FloatTree
Definition: openvdb.h:55
TypedMetadata< Vec2d > Vec2DMetadata
Definition: Metadata.h:366
NumericGridTypes::Transform< internal::ToTreeType > NumericTreeTypes
Definition: openvdb.h:123
RealGridTypes::Transform< internal::ToTreeType > RealTreeTypes
Definition: openvdb.h:121
RealAttributeTypes::Append< IntegerAttributeTypes > NumericAttributeTypes
Definition: openvdb.h:150
A specialized Affine transform that scales along the principal axis the scaling need not be uniform i...
Definition: Maps.h:1162
A specialized linear transform that performs a unitary maping i.e. rotation and or reflection...
Definition: Maps.h:1620
TypedMetadata< Vec2i > Vec2IMetadata
Definition: Metadata.h:367
TypedMetadata< Vec2s > Vec2SMetadata
Definition: Metadata.h:368
A specialized Affine transform that uniformaly scales along the principal axis and then translates th...
Definition: Maps.h:1478
TypedMetadata< float > FloatMetadata
Definition: Metadata.h:361
tree::Tree4< Vec3f, 5, 4, 3 >::Type Vec3STree
Definition: openvdb.h:66
TypedMetadata< Vec4i > Vec4IMetadata
Definition: Metadata.h:373
TypedMetadata< Vec4s > Vec4SMetadata
Definition: Metadata.h:374
TypedMetadata< Vec3s > Vec3SMetadata
Definition: Metadata.h:371
Grid< FloatTree > FloatGrid
Definition: openvdb.h:76
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:736
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:119
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
A list of types (not necessarily unique)
Definition: TypeList.h:577
TypedMetadata< double > DoubleMetadata
Definition: Metadata.h:360
Grid< Vec3STree > Vec3SGrid
Definition: openvdb.h:83
A specialized linear transform that performs a translation.
Definition: Maps.h:977