OpenVDB 13.0.0

Loading...
Searching...
No Matches
Grid.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_GRID_HAS_BEEN_INCLUDED
5#define OPENVDB_GRID_HAS_BEEN_INCLUDED
6
7#include "Exceptions.h"
8#include "MetaMap.h"
9#include "Types.h"
10#include "io/io.h"
11#include "math/Transform.h"
12#include "tree/Tree.h"
13#include "util/Assert.h"
14#include "util/logging.h"
15#include "util/Name.h"
16#include <iostream>
17#include <set>
18#include <type_traits>
19#include <vector>
20
21
22 namespace openvdb {
23 OPENVDB_USE_VERSION_NAMESPACE
24 namespace OPENVDB_VERSION_NAME {
25
26 using TreeBase = tree::TreeBase;
27
28 template<typename> class Grid; // forward declaration
29
30
31/// @brief Create a new grid of type @c GridType with a given background value.
32///
33/// @note Calling createGrid<GridType>(background) is equivalent to calling
34/// GridType::create(background).
35 template<typename GridType>
36 inline typename GridType::Ptr createGrid(const typename GridType::ValueType& background);
37
38
39/// @brief Create a new grid of type @c GridType with background value zero.
40///
41/// @note Calling createGrid<GridType>() is equivalent to calling GridType::create().
42 template<typename GridType>
43 inline typename GridType::Ptr createGrid();
44
45
46/// @brief Create a new grid of the appropriate type that wraps the given tree.
47///
48/// @note This function can be called without specifying the template argument,
49/// i.e., as createGrid(tree).
50 template<typename TreePtrType>
51 inline typename Grid<typename TreePtrType::element_type>::Ptr createGrid(TreePtrType);
52
53
54/// @brief Create a new grid of type @c GridType classified as a "Level Set",
55/// i.e., a narrow-band level set.
56///
57/// @note @c GridType::ValueType must be a floating-point scalar.
58///
59/// @param voxelSize the size of a voxel in world units
60/// @param halfWidth the half width of the narrow band in voxel units
61///
62/// @details The voxel size and the narrow band half width define the grid's
63/// background value as halfWidth*voxelWidth. The transform is linear
64/// with a uniform scaling only corresponding to the specified voxel size.
65///
66/// @note It is generally advisable to specify a half-width of the narrow band
67/// that is larger than one voxel unit, otherwise zero crossings are not guaranteed.
68 template<typename GridType>
69 typename GridType::Ptr createLevelSet(
70 Real voxelSize = 1.0, Real halfWidth = LEVEL_SET_HALF_WIDTH);
71
72
73////////////////////////////////////////
74
75
76/// @brief Abstract base class for typed grids
77 class OPENVDB_API GridBase: public MetaMap
78{
79 public:
80 using Ptr = SharedPtr<GridBase>;
81 using ConstPtr = SharedPtr<const GridBase>;
82
83 using GridFactory = Ptr (*)();
84
85
86 ~GridBase() override {}
87
88
89 /// @name Copying
90 /// @{
91
92 /// @brief Return a new grid of the same type as this grid whose metadata is a
93 /// deep copy of this grid's and whose tree and transform are shared with this grid.
94 virtual GridBase::Ptr copyGrid() = 0;
95 /// @brief Return a new grid of the same type as this grid whose metadata is a
96 /// deep copy of this grid's and whose tree and transform are shared with this grid.
97 virtual GridBase::ConstPtr copyGrid() const = 0;
98 /// @brief Return a new grid of the same type as this grid whose metadata and
99 /// transform are deep copies of this grid's and whose tree is default-constructed.
100 virtual GridBase::Ptr copyGridWithNewTree() const = 0;
101
102 /// @brief Return a new grid of the same type as this grid whose tree and transform
103 /// is shared with this grid and whose metadata is provided as an argument.
104 virtual GridBase::ConstPtr copyGridReplacingMetadata(const MetaMap& meta) const = 0;
105 /// @brief Return a new grid of the same type as this grid whose tree is shared with
106 /// this grid, whose metadata is a deep copy of this grid's and whose transform is
107 /// provided as an argument.
108 /// @throw ValueError if the transform pointer is null
109 virtual GridBase::ConstPtr copyGridReplacingTransform(math::Transform::Ptr xform) const = 0;
110 /// @brief Return a new grid of the same type as this grid whose tree is shared with
111 /// this grid and whose transform and metadata are provided as arguments.
112 /// @throw ValueError if the transform pointer is null
113 virtual GridBase::ConstPtr copyGridReplacingMetadataAndTransform(const MetaMap& meta,
114 math::Transform::Ptr xform) const = 0;
115
116 /// Return a new grid whose metadata, transform and tree are deep copies of this grid's.
117 virtual GridBase::Ptr deepCopyGrid() const = 0;
118
119 /// @}
120
121
122 /// @name Registry
123 /// @{
124
125 /// Create a new grid of the given (registered) type.
126 static Ptr createGrid(const Name& type);
127
128 /// Return @c true if the given grid type name is registered.
129 static bool isRegistered(const Name &type);
130
131 /// Clear the grid type registry.
132 static void clearRegistry();
133
134 /// @}
135
136 /// @name Type access
137 /// @{
138
139 /// Return the name of this grid's type.
140 virtual Name type() const = 0;
141 /// Return the name of the type of a voxel's value (e.g., "float" or "vec3d").
142 virtual Name valueType() const = 0;
143
144 /// Return @c true if this grid is of the same type as the template parameter.
145 template<typename GridType>
146 bool isType() const { return (this->type() == GridType::gridType()); }
147
148 /// @}
149
150 //@{
151 /// @brief Return the result of downcasting a GridBase pointer to a Grid pointer
152 /// of the specified type, or return a null pointer if the types are incompatible.
153 template<typename GridType>
154 static typename GridType::Ptr grid(const GridBase::Ptr&);
155 template<typename GridType>
156 static typename GridType::ConstPtr grid(const GridBase::ConstPtr&);
157 template<typename GridType>
158 static typename GridType::ConstPtr constGrid(const GridBase::Ptr&);
159 template<typename GridType>
160 static typename GridType::ConstPtr constGrid(const GridBase::ConstPtr&);
161 //@}
162
163 /// @name Tree
164 /// @{
165
166 /// @brief Return a pointer to this grid's tree, which might be
167 /// shared with other grids. The pointer is guaranteed to be non-null.
168 TreeBase::Ptr baseTreePtr();
169 /// @brief Return a pointer to this grid's tree, which might be
170 /// shared with other grids. The pointer is guaranteed to be non-null.
171 TreeBase::ConstPtr baseTreePtr() const { return this->constBaseTreePtr(); }
172 /// @brief Return a pointer to this grid's tree, which might be
173 /// shared with other grids. The pointer is guaranteed to be non-null.
174 virtual TreeBase::ConstPtr constBaseTreePtr() const = 0;
175
176 /// @brief Return true if tree is not shared with another grid.
177 virtual bool isTreeUnique() const = 0;
178
179 /// @brief Return a reference to this grid's tree, which might be
180 /// shared with other grids.
181 /// @note Calling @vdblink::GridBase::setTree() setTree@endlink
182 /// on this grid invalidates all references previously returned by this method.
183 TreeBase& baseTree() { return const_cast<TreeBase&>(this->constBaseTree()); }
184 /// @brief Return a reference to this grid's tree, which might be
185 /// shared with other grids.
186 /// @note Calling @vdblink::GridBase::setTree() setTree@endlink
187 /// on this grid invalidates all references previously returned by this method.
188 const TreeBase& baseTree() const { return this->constBaseTree(); }
189 /// @brief Return a reference to this grid's tree, which might be
190 /// shared with other grids.
191 /// @note Calling @vdblink::GridBase::setTree() setTree@endlink
192 /// on this grid invalidates all references previously returned by this method.
193 const TreeBase& constBaseTree() const { return *(this->constBaseTreePtr()); }
194
195 /// @brief Associate the given tree with this grid, in place of its existing tree.
196 /// @throw ValueError if the tree pointer is null
197 /// @throw TypeError if the tree is not of the appropriate type
198 /// @note Invalidates all references previously returned by
199 /// @vdblink::GridBase::baseTree() baseTree@endlink
200 /// or @vdblink::GridBase::constBaseTree() constBaseTree@endlink.
201 virtual void setTree(TreeBase::Ptr) = 0;
202
203 /// Set a new tree with the same background value as the previous tree.
204 virtual void newTree() = 0;
205
206 /// @}
207
208 /// Return @c true if this grid contains only background voxels.
209 virtual bool empty() const = 0;
210 /// Empty this grid, setting all voxels to the background.
211 virtual void clear() = 0;
212
213
214 /// @name Tools
215 /// @{
216
217 /// @brief Reduce the memory footprint of this grid by increasing its sparseness
218 /// either losslessly (@a tolerance = 0) or lossily (@a tolerance > 0).
219 /// @details With @a tolerance > 0, sparsify regions where voxels have the same
220 /// active state and have values that differ by no more than the tolerance
221 /// (converted to this grid's value type).
222 virtual void pruneGrid(float tolerance = 0.0) = 0;
223
224 /// @brief Clip this grid to the given world-space bounding box.
225 /// @details Voxels that lie outside the bounding box are set to the background.
226 /// @warning Clipping a level set will likely produce a grid that is
227 /// no longer a valid level set.
228 void clipGrid(const BBoxd&);
229
230 /// @brief Clip this grid to the given index-space bounding box.
231 /// @details Voxels that lie outside the bounding box are set to the background.
232 /// @warning Clipping a level set will likely produce a grid that is
233 /// no longer a valid level set.
234 virtual void clip(const CoordBBox&) = 0;
235
236 /// @}
237
238 /// @{
239 /// @brief If this grid resolves to one of the listed grid types,
240 /// invoke the given functor on the resolved grid.
241 /// @return @c false if this grid's type is not one of the listed types
242 ///
243 /// @par Example:
244 /// @code
245 /// using AllowedGridTypes = openvdb::TypeList<
246 /// openvdb::Int32Grid, openvdb::Int64Grid,
247 /// openvdb::FloatGrid, openvdb::DoubleGrid>;
248 ///
249 /// const openvdb::CoordBBox bbox{
250 /// openvdb::Coord{0,0,0}, openvdb::Coord{10,10,10}};
251 ///
252 /// // Fill the grid if it is one of the allowed types.
253 /// myGridBasePtr->apply<AllowedGridTypes>(
254 /// [&bbox](auto& grid) { // C++14
255 /// using GridType = typename std::decay<decltype(grid)>::type;
256 /// grid.fill(bbox, typename GridType::ValueType(1));
257 /// }
258 /// );
259 /// @endcode
260 ///
261 /// @see @vdblink::TypeList TypeList@endlink
262 template<typename GridTypeListT, typename OpT> inline bool apply(OpT&) const;
263 template<typename GridTypeListT, typename OpT> inline bool apply(OpT&);
264 template<typename GridTypeListT, typename OpT> inline bool apply(const OpT&) const;
265 template<typename GridTypeListT, typename OpT> inline bool apply(const OpT&);
266 /// @}
267
268 /// @name Metadata
269 /// @{
270
271 /// Return this grid's user-specified name.
272 std::string getName() const;
273 /// Specify a name for this grid.
274 void setName(const std::string&);
275
276 /// Return the user-specified description of this grid's creator.
277 std::string getCreator() const;
278 /// Provide a description of this grid's creator.
279 void setCreator(const std::string&);
280
281 /// @brief Return @c true if this grid should be written out with floating-point
282 /// voxel values (including components of vectors) quantized to 16 bits.
283 bool saveFloatAsHalf() const;
284 void setSaveFloatAsHalf(bool);
285
286 /// @brief Return the class of volumetric data (level set, fog volume, etc.)
287 /// that is stored in this grid.
288 /// @sa gridClassToString, gridClassToMenuName, stringToGridClass
289 GridClass getGridClass() const;
290 /// @brief Specify the class of volumetric data (level set, fog volume, etc.)
291 /// that is stored in this grid.
292 /// @sa gridClassToString, gridClassToMenuName, stringToGridClass
293 void setGridClass(GridClass);
294 /// Remove the setting specifying the class of this grid's volumetric data.
295 void clearGridClass();
296
297 /// @}
298
299 /// Return the metadata string value for the given class of volumetric data.
300 static std::string gridClassToString(GridClass);
301 /// Return a formatted string version of the grid class.
302 static std::string gridClassToMenuName(GridClass);
303 /// @brief Return the class of volumetric data specified by the given string.
304 /// @details If the string is not one of the ones returned by
305 /// @vdblink::GridBase::gridClassToString() gridClassToString@endlink,
306 /// return @c GRID_UNKNOWN.
307 static GridClass stringToGridClass(const std::string&);
308
309 /// @name Metadata
310 /// @{
311
312 /// @brief Return the type of vector data (invariant, covariant, etc.) stored
313 /// in this grid, assuming that this grid contains a vector-valued tree.
314 /// @sa vecTypeToString, vecTypeExamples, vecTypeDescription, stringToVecType
315 VecType getVectorType() const;
316 /// @brief Specify the type of vector data (invariant, covariant, etc.) stored
317 /// in this grid, assuming that this grid contains a vector-valued tree.
318 /// @sa vecTypeToString, vecTypeExamples, vecTypeDescription, stringToVecType
319 void setVectorType(VecType);
320 /// Remove the setting specifying the type of vector data stored in this grid.
321 void clearVectorType();
322
323 /// @}
324
325 /// Return the metadata string value for the given type of vector data.
326 static std::string vecTypeToString(VecType);
327 /// Return a string listing examples of the given type of vector data
328 /// (e.g., "Gradient/Normal", given VEC_COVARIANT).
329 static std::string vecTypeExamples(VecType);
330 /// @brief Return a string describing how the given type of vector data is affected
331 /// by transformations (e.g., "Does not transform", given VEC_INVARIANT).
332 static std::string vecTypeDescription(VecType);
333 static VecType stringToVecType(const std::string&);
334
335 /// @name Metadata
336 /// @{
337
338 /// Return @c true if this grid's voxel values are in world space and should be
339 /// affected by transformations, @c false if they are in local space and should
340 /// not be affected by transformations.
341 bool isInWorldSpace() const;
342 /// Specify whether this grid's voxel values are in world space or in local space.
343 void setIsInWorldSpace(bool);
344
345 /// @}
346
347 // Standard metadata field names
348 // (These fields should normally not be accessed directly, but rather
349 // via the accessor methods above, when available.)
350 // Note: Visual C++ requires these declarations to be separate statements.
351 static const char* const META_GRID_CLASS;
352 static const char* const META_GRID_CREATOR;
353 static const char* const META_GRID_NAME;
354 static const char* const META_SAVE_HALF_FLOAT;
355 static const char* const META_IS_LOCAL_SPACE;
356 static const char* const META_VECTOR_TYPE;
357 static const char* const META_FILE_BBOX_MIN;
358 static const char* const META_FILE_BBOX_MAX;
359 static const char* const META_FILE_COMPRESSION;
360 static const char* const META_FILE_MEM_BYTES;
361 static const char* const META_FILE_VOXEL_COUNT;
362 static const char* const META_FILE_DELAYED_LOAD;
363
364
365 /// @name Statistics
366 /// @{
367
368 /// Return the number of active voxels.
369 virtual Index64 activeVoxelCount() const = 0;
370
371 /// Return the axis-aligned bounding box of all active voxels. If
372 /// the grid is empty a default bbox is returned.
373 virtual CoordBBox evalActiveVoxelBoundingBox() const = 0;
374
375 /// Return the dimensions of the axis-aligned bounding box of all active voxels.
376 virtual Coord evalActiveVoxelDim() const = 0;
377
378 /// Return the number of bytes of memory used by this grid.
379 virtual Index64 memUsage() const = 0;
380
381 /// @brief Add metadata to this grid comprising the current values
382 /// of statistics like the active voxel count and bounding box.
383 /// @note This metadata is not automatically kept up-to-date with
384 /// changes to this grid.
385 void addStatsMetadata();
386 /// @brief Return a new MetaMap containing just the metadata that
387 /// was added to this grid with @vdblink::GridBase::addStatsMetadata()
388 /// addStatsMetadata@endlink.
389 /// @details If @vdblink::GridBase::addStatsMetadata() addStatsMetadata@endlink
390 /// was never called on this grid, return an empty MetaMap.
391 MetaMap::Ptr getStatsMetadata() const;
392
393 /// @}
394
395
396 /// @name Transform
397 /// @{
398
399 //@{
400 /// @brief Return a pointer to this grid's transform, which might be
401 /// shared with other grids.
402 math::Transform::Ptr transformPtr() { return mTransform; }
403 math::Transform::ConstPtr transformPtr() const { return mTransform; }
404 math::Transform::ConstPtr constTransformPtr() const { return mTransform; }
405 //@}
406 //@{
407 /// @brief Return a reference to this grid's transform, which might be
408 /// shared with other grids.
409 /// @note Calling @vdblink::GridBase::setTransform() setTransform@endlink
410 /// on this grid invalidates all references previously returned by this method.
411 math::Transform& transform() { return *mTransform; }
412 const math::Transform& transform() const { return *mTransform; }
413 const math::Transform& constTransform() const { return *mTransform; }
414 //@}
415
416 /// @}
417
418 /// @name Transform
419 /// @{
420
421 /// @brief Associate the given transform with this grid, in place of
422 /// its existing transform.
423 /// @throw ValueError if the transform pointer is null
424 /// @note Invalidates all references previously returned by
425 /// @vdblink::GridBase::transform() transform@endlink
426 /// or @vdblink::GridBase::constTransform() constTransform@endlink.
427 void setTransform(math::Transform::Ptr);
428
429 /// Return the size of this grid's voxels.
430 Vec3d voxelSize() const { return transform().voxelSize(); }
431 /// @brief Return the size of this grid's voxel at position (x, y, z).
432 /// @note Frustum and perspective transforms have position-dependent voxel size.
433 Vec3d voxelSize(const Vec3d& xyz) const { return transform().voxelSize(xyz); }
434 /// Return true if the voxels in world space are uniformly sized cubes
435 bool hasUniformVoxels() const { return mTransform->hasUniformScale(); }
436 /// Apply this grid's transform to the given coordinates.
437 Vec3d indexToWorld(const Vec3d& xyz) const { return transform().indexToWorld(xyz); }
438 /// Apply this grid's transform to the given coordinates.
439 Vec3d indexToWorld(const Coord& ijk) const { return transform().indexToWorld(ijk); }
440 /// Apply the inverse of this grid's transform to the given coordinates.
441 Vec3d worldToIndex(const Vec3d& xyz) const { return transform().worldToIndex(xyz); }
442
443 /// @}
444
445
446 /// @name I/O
447 /// @{
448
449 /// @brief Read the grid topology from a stream.
450 /// This will read only the grid structure, not the actual data buffers.
451 virtual void readTopology(std::istream&) = 0;
452 /// @brief Write the grid topology to a stream.
453 /// This will write only the grid structure, not the actual data buffers.
454 virtual void writeTopology(std::ostream&) const = 0;
455
456 /// Read all data buffers for this grid.
457 virtual void readBuffers(std::istream&) = 0;
458 /// Read all of this grid's data buffers that intersect the given index-space bounding box.
459 virtual void readBuffers(std::istream&, const CoordBBox&) = 0;
460 /// @brief Read all of this grid's data buffers that are not yet resident in memory
461 /// (because delayed loading is in effect).
462 /// @details If this grid was read from a memory-mapped file, this operation
463 /// disconnects the grid from the file.
464 /// @sa io::File::open, io::MappedFile
465 virtual void readNonresidentBuffers() const = 0;
466 /// Write out all data buffers for this grid.
467 virtual void writeBuffers(std::ostream&) const = 0;
468
469 /// Read in the transform for this grid.
470 void readTransform(std::istream& is) { transform().read(is); }
471 /// Write out the transform for this grid.
472 void writeTransform(std::ostream& os) const { transform().write(os); }
473
474 /// Output a human-readable description of this grid.
475 virtual void print(std::ostream& = std::cout, int verboseLevel = 1) const = 0;
476
477 /// @}
478
479
480 protected:
481 /// @brief Initialize with an identity linear transform.
482 GridBase(): mTransform(math::Transform::createLinearTransform()) {}
483
484 /// @brief Initialize with metadata and a transform.
485 /// @throw ValueError if the transform pointer is null
486 GridBase(const MetaMap& meta, math::Transform::Ptr xform);
487
488 /// @brief Deep copy another grid's metadata and transform.
489 GridBase(const GridBase& other): MetaMap(other), mTransform(other.mTransform->copy()) {}
490
491 /// @brief Copy another grid's metadata but share its transform.
492 GridBase(GridBase& other, ShallowCopy): MetaMap(other), mTransform(other.mTransform) {}
493
494 /// Register a grid type along with a factory function.
495 static void registerGrid(const Name& type, GridFactory);
496 /// Remove a grid type from the registry.
497 static void unregisterGrid(const Name& type);
498
499
500 private:
501 math::Transform::Ptr mTransform;
502}; // class GridBase
503
504
505////////////////////////////////////////
506
507
508 using GridPtrVec = std::vector<GridBase::Ptr>;
509 using GridPtrVecIter = GridPtrVec::iterator;
510 using GridPtrVecCIter = GridPtrVec::const_iterator;
511 using GridPtrVecPtr = SharedPtr<GridPtrVec>;
512
513 using GridCPtrVec = std::vector<GridBase::ConstPtr>;
514 using GridCPtrVecIter = GridCPtrVec::iterator;
515 using GridCPtrVecCIter = GridCPtrVec::const_iterator;
516 using GridCPtrVecPtr = SharedPtr<GridCPtrVec>;
517
518 using GridPtrSet = std::set<GridBase::Ptr>;
519 using GridPtrSetIter = GridPtrSet::iterator;
520 using GridPtrSetCIter = GridPtrSet::const_iterator;
521 using GridPtrSetPtr = SharedPtr<GridPtrSet>;
522
523 using GridCPtrSet = std::set<GridBase::ConstPtr>;
524 using GridCPtrSetIter = GridCPtrSet::iterator;
525 using GridCPtrSetCIter = GridCPtrSet::const_iterator;
526 using GridCPtrSetPtr = SharedPtr<GridCPtrSet>;
527
528
529/// @brief Predicate functor that returns @c true for grids that have a specified name
530 struct OPENVDB_API GridNamePred
531{
532 GridNamePred(const Name& _name): name(_name) {}
533 bool operator()(const GridBase::ConstPtr& g) const { return g && g->getName() == name; }
534 Name name;
535};
536
537/// Return the first grid in the given container whose name is @a name.
538 template<typename GridPtrContainerT>
539 inline typename GridPtrContainerT::value_type
540 findGridByName(const GridPtrContainerT& container, const Name& name)
541{
542 using GridPtrT = typename GridPtrContainerT::value_type;
543 typename GridPtrContainerT::const_iterator it =
544 std::find_if(container.begin(), container.end(), GridNamePred(name));
545 return (it == container.end() ? GridPtrT() : *it);
546}
547
548/// Return the first grid in the given map whose name is @a name.
549 template<typename KeyT, typename GridPtrT>
550 inline GridPtrT
551 findGridByName(const std::map<KeyT, GridPtrT>& container, const Name& name)
552{
553 using GridPtrMapT = std::map<KeyT, GridPtrT>;
554 for (typename GridPtrMapT::const_iterator it = container.begin(), end = container.end();
555 it != end; ++it)
556 {
557 const GridPtrT& grid = it->second;
558 if (grid && grid->getName() == name) return grid;
559 }
560 return GridPtrT();
561}
562//@}
563
564
565////////////////////////////////////////
566
567
568/// @brief Container class that associates a tree with a transform and metadata
569 template<typename _TreeType>
570 class Grid: public GridBase
571{
572 public:
573 using Ptr = SharedPtr<Grid>;
574 using ConstPtr = SharedPtr<const Grid>;
575
576 using TreeType = _TreeType;
577 using TreePtrType = typename _TreeType::Ptr;
578 using ConstTreePtrType = typename _TreeType::ConstPtr;
579 using ValueType = typename _TreeType::ValueType;
580 using BuildType = typename _TreeType::BuildType;
581
582 using ValueOnIter = typename _TreeType::ValueOnIter;
583 using ValueOnCIter = typename _TreeType::ValueOnCIter;
584 using ValueOffIter = typename _TreeType::ValueOffIter;
585 using ValueOffCIter = typename _TreeType::ValueOffCIter;
586 using ValueAllIter = typename _TreeType::ValueAllIter;
587 using ValueAllCIter = typename _TreeType::ValueAllCIter;
588
589 using Accessor = typename _TreeType::Accessor;
590 using ConstAccessor = typename _TreeType::ConstAccessor;
591 using UnsafeAccessor = typename _TreeType::UnsafeAccessor;
592 using ConstUnsafeAccessor = typename _TreeType::ConstUnsafeAccessor;
593
594 /// @brief ValueConverter<T>::Type is the type of a grid having the same
595 /// hierarchy as this grid but a different value type, T.
596 ///
597 /// For example, FloatGrid::ValueConverter<double>::Type is equivalent to DoubleGrid.
598 /// @note If the source grid type is a template argument, it might be necessary
599 /// to write "typename SourceGrid::template ValueConverter<T>::Type".
600 template<typename OtherValueType>
601 struct ValueConverter {
602 using Type = Grid<typename TreeType::template ValueConverter<OtherValueType>::Type>;
603 };
604
605 /// Return a new grid with the given background value.
606 static Ptr create(const ValueType& background);
607 /// Return a new grid with background value zero.
608 static Ptr create();
609 /// @brief Return a new grid that contains the given tree.
610 /// @throw ValueError if the tree pointer is null
611 static Ptr create(TreePtrType);
612 /// @brief Return a new, empty grid with the same transform and metadata as the
613 /// given grid and with background value zero.
614 static Ptr create(const GridBase& other);
615
616
617 /// Construct a new grid with background value zero.
618 Grid();
619 /// Construct a new grid with the given background value.
620 explicit Grid(const ValueType& background);
621 /// @brief Construct a new grid that shares the given tree and associates with it
622 /// an identity linear transform.
623 /// @throw ValueError if the tree pointer is null
624 explicit Grid(TreePtrType);
625 /// Deep copy another grid's metadata, transform and tree.
626 Grid(const Grid&);
627 /// @brief Deep copy the metadata, transform and tree of another grid whose tree
628 /// configuration is the same as this grid's but whose value type is different.
629 /// Cast the other grid's values to this grid's value type.
630 /// @throw TypeError if the other grid's tree configuration doesn't match this grid's
631 /// or if this grid's ValueType is not constructible from the other grid's ValueType.
632 template<typename OtherTreeType>
633 explicit Grid(const Grid<OtherTreeType>&);
634 /// Deep copy another grid's metadata and transform, but share its tree.
635 Grid(Grid&, ShallowCopy);
636 /// @brief Deep copy another grid's metadata and transform, but construct a new tree
637 /// with background value zero.
638 explicit Grid(const GridBase&);
639
640 ~Grid() override {}
641
642 /// Disallow assignment, since it wouldn't be obvious whether the copy is deep or shallow.
643 Grid& operator=(const Grid&) = delete;
644
645 /// @name Copying
646 /// @{
647
648 /// @brief Return a new grid of the same type as this grid whose metadata and
649 /// transform are deep copies of this grid's and whose tree is shared with this grid.
650 Ptr copy();
651 /// @brief Return a new grid of the same type as this grid whose metadata and
652 /// transform are deep copies of this grid's and whose tree is shared with this grid.
653 ConstPtr copy() const;
654 /// @brief Return a new grid of the same type as this grid whose metadata and
655 /// transform are deep copies of this grid's and whose tree is default-constructed.
656 Ptr copyWithNewTree() const;
657
658 /// @brief Return a new grid of the same type as this grid whose metadata is a
659 /// deep copy of this grid's and whose tree and transform are shared with this grid.
660 GridBase::Ptr copyGrid() override;
661 /// @brief Return a new grid of the same type as this grid whose metadata is a
662 /// deep copy of this grid's and whose tree and transform are shared with this grid.
663 GridBase::ConstPtr copyGrid() const override;
664 /// @brief Return a new grid of the same type as this grid whose metadata and
665 /// transform are deep copies of this grid's and whose tree is default-constructed.
666 GridBase::Ptr copyGridWithNewTree() const override;
667 //@}
668
669 /// @name Copying
670 /// @{
671
672 /// @brief Return a new grid of the same type as this grid whose tree and transform
673 /// is shared with this grid and whose metadata is provided as an argument.
674 ConstPtr copyReplacingMetadata(const MetaMap& meta) const;
675 /// @brief Return a new grid of the same type as this grid whose tree is shared with
676 /// this grid, whose metadata is a deep copy of this grid's and whose transform is
677 /// provided as an argument.
678 /// @throw ValueError if the transform pointer is null
679 ConstPtr copyReplacingTransform(math::Transform::Ptr xform) const;
680 /// @brief Return a new grid of the same type as this grid whose tree is shared with
681 /// this grid and whose transform and metadata are provided as arguments.
682 /// @throw ValueError if the transform pointer is null
683 ConstPtr copyReplacingMetadataAndTransform(const MetaMap& meta,
684 math::Transform::Ptr xform) const;
685
686 /// @brief Return a new grid of the same type as this grid whose tree and transform
687 /// is shared with this grid and whose metadata is provided as an argument.
688 GridBase::ConstPtr copyGridReplacingMetadata(const MetaMap& meta) const override;
689 /// @brief Return a new grid of the same type as this grid whose tree is shared with
690 /// this grid, whose metadata is a deep copy of this grid's and whose transform is
691 /// provided as an argument.
692 /// @throw ValueError if the transform pointer is null
693 GridBase::ConstPtr copyGridReplacingTransform(math::Transform::Ptr xform) const override;
694 /// @brief Return a new grid of the same type as this grid whose tree is shared with
695 /// this grid and whose transform and metadata are provided as arguments.
696 /// @throw ValueError if the transform pointer is null
697 GridBase::ConstPtr copyGridReplacingMetadataAndTransform(const MetaMap& meta,
698 math::Transform::Ptr xform) const override;
699
700 /// @brief Return a new grid whose metadata, transform and tree are deep copies of this grid's.
701 Ptr deepCopy() const { return Ptr(new Grid(*this)); }
702 /// @brief Return a new grid whose metadata, transform and tree are deep copies of this grid's.
703 GridBase::Ptr deepCopyGrid() const override { return this->deepCopy(); }
704
705 //@}
706
707
708 /// Return the name of this grid's type.
709 Name type() const override { return this->gridType(); }
710 /// Return the name of this type of grid.
711 static Name gridType() { return TreeType::treeType(); }
712
713 /// Return the name of the type of a voxel's value (e.g., "float" or "vec3d").
714 Name valueType() const override { return tree().valueType(); }
715
716
717 /// @name Voxel access
718 /// @{
719
720 /// @brief Return this grid's background value.
721 /// @note Use tools::changeBackground to efficiently modify the background value.
722 const ValueType& background() const { return mTree->background(); }
723
724 /// Return @c true if this grid contains only inactive background voxels.
725 bool empty() const override { return tree().empty(); }
726 /// Empty this grid, so that all voxels become inactive background voxels.
727 void clear() override { tree().clear(); }
728
729 /// @brief Return an accessor that provides random read and write access
730 /// to this grid's voxels.
731 /// @details The accessor is safe in the sense that it is registered with this grid's tree.
732 Accessor getAccessor() { return mTree->getAccessor(); }
733 /// @brief Return an unsafe accessor that provides random read and write access
734 /// to this grid's voxels.
735 /// @details The accessor is unsafe in the sense that it is not registered
736 /// with this grid's tree. In some rare cases this can give a performance advantage
737 /// over a registered accessor, but it is unsafe if the tree topology is modified.
738 /// @warning Only use this method if you're an expert and know the
739 /// risks of using an unregistered accessor (see tree/ValueAccessor.h)
740 UnsafeAccessor getUnsafeAccessor() { return mTree->getUnsafeAccessor(); }
741 /// Return an accessor that provides random read-only access to this grid's voxels.
742 ConstAccessor getAccessor() const { return mTree->getConstAccessor(); }
743 /// Return an accessor that provides random read-only access to this grid's voxels.
744 ConstAccessor getConstAccessor() const { return mTree->getConstAccessor(); }
745 /// @brief Return an unsafe accessor that provides random read-only access
746 /// to this grid's voxels.
747 /// @details The accessor is unsafe in the sense that it is not registered
748 /// with this grid's tree. In some rare cases this can give a performance advantage
749 /// over a registered accessor, but it is unsafe if the tree topology is modified.
750 /// @warning Only use this method if you're an expert and know the
751 /// risks of using an unregistered accessor (see tree/ValueAccessor.h)
752 ConstUnsafeAccessor getConstUnsafeAccessor() const { return mTree->getConstUnsafeAccessor(); }
753
754 /// Return an iterator over all of this grid's active values (tile and voxel).
755 ValueOnIter beginValueOn() { return tree().beginValueOn(); }
756 /// Return an iterator over all of this grid's active values (tile and voxel).
757 ValueOnCIter beginValueOn() const { return tree().cbeginValueOn(); }
758 /// Return an iterator over all of this grid's active values (tile and voxel).
759 ValueOnCIter cbeginValueOn() const { return tree().cbeginValueOn(); }
760 /// Return an iterator over all of this grid's inactive values (tile and voxel).
761 ValueOffIter beginValueOff() { return tree().beginValueOff(); }
762 /// Return an iterator over all of this grid's inactive values (tile and voxel).
763 ValueOffCIter beginValueOff() const { return tree().cbeginValueOff(); }
764 /// Return an iterator over all of this grid's inactive values (tile and voxel).
765 ValueOffCIter cbeginValueOff() const { return tree().cbeginValueOff(); }
766 /// Return an iterator over all of this grid's values (tile and voxel).
767 ValueAllIter beginValueAll() { return tree().beginValueAll(); }
768 /// Return an iterator over all of this grid's values (tile and voxel).
769 ValueAllCIter beginValueAll() const { return tree().cbeginValueAll(); }
770 /// Return an iterator over all of this grid's values (tile and voxel).
771 ValueAllCIter cbeginValueAll() const { return tree().cbeginValueAll(); }
772
773 /// @}
774
775 /// @name Tools
776 /// @{
777
778 /// @brief Set all voxels within a given axis-aligned box to a constant value.
779 /// @param bbox inclusive coordinates of opposite corners of an axis-aligned box
780 /// @param value the value to which to set voxels within the box
781 /// @param active if true, mark voxels within the box as active,
782 /// otherwise mark them as inactive
783 /// @note This operation generates a sparse, but not always optimally sparse,
784 /// representation of the filled box. Follow fill operations with a prune()
785 /// operation for optimal sparseness.
786 void sparseFill(const CoordBBox& bbox, const ValueType& value, bool active = true);
787 /// @brief Set all voxels within a given axis-aligned box to a constant value.
788 /// @param bbox inclusive coordinates of opposite corners of an axis-aligned box
789 /// @param value the value to which to set voxels within the box
790 /// @param active if true, mark voxels within the box as active,
791 /// otherwise mark them as inactive
792 /// @note This operation generates a sparse, but not always optimally sparse,
793 /// representation of the filled box. Follow fill operations with a prune()
794 /// operation for optimal sparseness.
795 void fill(const CoordBBox& bbox, const ValueType& value, bool active = true);
796
797 /// @brief Set all voxels within a given axis-aligned box to a constant value
798 /// and ensure that those voxels are all represented at the leaf level.
799 /// @param bbox inclusive coordinates of opposite corners of an axis-aligned box.
800 /// @param value the value to which to set voxels within the box.
801 /// @param active if true, mark voxels within the box as active,
802 /// otherwise mark them as inactive.
803 void denseFill(const CoordBBox& bbox, const ValueType& value, bool active = true);
804
805 /// Reduce the memory footprint of this grid by increasing its sparseness.
806 void pruneGrid(float tolerance = 0.0) override;
807
808 /// @brief Clip this grid to the given index-space bounding box.
809 /// @details Voxels that lie outside the bounding box are set to the background.
810 /// @warning Clipping a level set will likely produce a grid that is
811 /// no longer a valid level set.
812 void clip(const CoordBBox&) override;
813
814 /// @brief Efficiently merge another grid into this grid using one of several schemes.
815 /// @details This operation is primarily intended to combine grids that are mostly
816 /// non-overlapping (for example, intermediate grids from computations that are
817 /// parallelized across disjoint regions of space).
818 /// @warning This operation always empties the other grid.
819 void merge(Grid& other, MergePolicy policy = MERGE_ACTIVE_STATES);
820
821 /// @brief Union this grid's set of active values with the active values
822 /// of the other grid, whose value type may be different.
823 /// @details The resulting state of a value is active if the corresponding value
824 /// was already active OR if it is active in the other grid. Also, a resulting
825 /// value maps to a voxel if the corresponding value already mapped to a voxel
826 /// OR if it is a voxel in the other grid. Thus, a resulting value can only
827 /// map to a tile if the corresponding value already mapped to a tile
828 /// AND if it is a tile value in the other grid.
829 ///
830 /// @note This operation modifies only active states, not values.
831 /// Specifically, active tiles and voxels in this grid are not changed, and
832 /// tiles or voxels that were inactive in this grid but active in the other grid
833 /// are marked as active in this grid but left with their original values.
834 template<typename OtherTreeType>
835 void topologyUnion(const Grid<OtherTreeType>& other);
836
837 /// @brief Intersect this grid's set of active values with the active values
838 /// of the other grid, whose value type may be different.
839 /// @details The resulting state of a value is active only if the corresponding
840 /// value was already active AND if it is active in the other tree. Also, a
841 /// resulting value maps to a voxel if the corresponding value
842 /// already mapped to an active voxel in either of the two grids
843 /// and it maps to an active tile or voxel in the other grid.
844 ///
845 /// @note This operation can delete branches of this grid that overlap with
846 /// inactive tiles in the other grid. Also, because it can deactivate voxels,
847 /// it can create leaf nodes with no active values. Thus, it is recommended
848 /// to prune this grid after calling this method.
849 template<typename OtherTreeType>
850 void topologyIntersection(const Grid<OtherTreeType>& other);
851
852 /// @brief Difference this grid's set of active values with the active values
853 /// of the other grid, whose value type may be different.
854 /// @details After this method is called, voxels in this grid will be active
855 /// only if they were active to begin with and if the corresponding voxels
856 /// in the other grid were inactive.
857 ///
858 /// @note This operation can delete branches of this grid that overlap with
859 /// active tiles in the other grid. Also, because it can deactivate voxels,
860 /// it can create leaf nodes with no active values. Thus, it is recommended
861 /// to prune this grid after calling this method.
862 template<typename OtherTreeType>
863 void topologyDifference(const Grid<OtherTreeType>& other);
864
865 /// @}
866
867 /// @name Statistics
868 /// @{
869
870 /// Return the number of active voxels.
871 Index64 activeVoxelCount() const override { return tree().activeVoxelCount(); }
872 /// Return the axis-aligned bounding box of all active voxels.
873 CoordBBox evalActiveVoxelBoundingBox() const override;
874 /// Return the dimensions of the axis-aligned bounding box of all active voxels.
875 Coord evalActiveVoxelDim() const override;
876
877 /// Return the number of bytes of memory used by this grid.
878 /// @todo Add transform().memUsage()
879 Index64 memUsage() const override { return tree().memUsage(); }
880
881 /// @}
882
883
884 /// @name Tree
885 /// @{
886
887 //@{
888 /// @brief Return a pointer to this grid's tree, which might be
889 /// shared with other grids. The pointer is guaranteed to be non-null.
890 TreePtrType treePtr() { return mTree; }
891 ConstTreePtrType treePtr() const { return mTree; }
892 ConstTreePtrType constTreePtr() const { return mTree; }
893 TreeBase::ConstPtr constBaseTreePtr() const override { return mTree; }
894 //@}
895 /// @brief Return true if tree is not shared with another grid.
896 /// @note This is a virtual function with ABI=8
897 bool isTreeUnique() const final;
898
899 //@{
900 /// @brief Return a reference to this grid's tree, which might be
901 /// shared with other grids.
902 /// @note Calling setTree() on this grid invalidates all references
903 /// previously returned by this method.
904 TreeType& tree() { return *mTree; }
905 const TreeType& tree() const { return *mTree; }
906 const TreeType& constTree() const { return *mTree; }
907 //@}
908
909 /// @}
910
911 /// @name Tree
912 /// @{
913
914 /// @brief Associate the given tree with this grid, in place of its existing tree.
915 /// @throw ValueError if the tree pointer is null
916 /// @throw TypeError if the tree is not of type TreeType
917 /// @note Invalidates all references previously returned by baseTree(),
918 /// constBaseTree(), tree() or constTree().
919 void setTree(TreeBase::Ptr) override;
920
921 /// @brief Associate a new, empty tree with this grid, in place of its existing tree.
922 /// @note The new tree has the same background value as the existing tree.
923 void newTree() override;
924
925 /// @}
926
927
928 /// @name I/O
929 /// @{
930
931 /// @brief Read the grid topology from a stream.
932 /// This will read only the grid structure, not the actual data buffers.
933 void readTopology(std::istream&) override;
934 /// @brief Write the grid topology to a stream.
935 /// This will write only the grid structure, not the actual data buffers.
936 void writeTopology(std::ostream&) const override;
937
938 /// Read all data buffers for this grid.
939 void readBuffers(std::istream&) override;
940 /// Read all of this grid's data buffers that intersect the given index-space bounding box.
941 void readBuffers(std::istream&, const CoordBBox&) override;
942 /// @brief Read all of this grid's data buffers that are not yet resident in memory
943 /// (because delayed loading is in effect).
944 /// @details If this grid was read from a memory-mapped file, this operation
945 /// disconnects the grid from the file.
946 /// @sa io::File::open, io::MappedFile
947 void readNonresidentBuffers() const override;
948 /// Write out all data buffers for this grid.
949 void writeBuffers(std::ostream&) const override;
950
951 /// Output a human-readable description of this grid.
952 void print(std::ostream& = std::cout, int verboseLevel = 1) const override;
953
954 /// @}
955
956 /// @brief Return @c true if grids of this type require multiple I/O passes
957 /// to read and write data buffers.
958 /// @sa HasMultiPassIO
959 static inline bool hasMultiPassIO();
960
961
962 /// @name Registry
963 /// @{
964
965 /// Return @c true if this grid type is registered.
966 static bool isRegistered() { return GridBase::isRegistered(Grid::gridType()); }
967 /// Register this grid type along with a factory function.
968 static void registerGrid() { GridBase::registerGrid(Grid::gridType(), Grid::factory); }
969 /// Remove this grid type from the registry.
970 static void unregisterGrid() { GridBase::unregisterGrid(Grid::gridType()); }
971
972 /// @}
973
974
975 private:
976 /// Deep copy metadata, but share tree and transform.
977 Grid(TreePtrType tree, const MetaMap& meta, math::Transform::Ptr xform);
978
979 /// Helper function for use with registerGrid()
980 static GridBase::Ptr factory() { return Grid::create(); }
981
982 TreePtrType mTree;
983}; // class Grid
984
985
986////////////////////////////////////////
987
988
989/// @brief Cast a generic grid pointer to a pointer to a grid of a concrete class.
990///
991/// Return a null pointer if the input pointer is null or if it
992/// points to a grid that is not of type @c GridType.
993///
994/// @note Calling gridPtrCast<GridType>(grid) is equivalent to calling
995/// GridBase::grid<GridType>(grid).
996 template<typename GridType>
997 inline typename GridType::Ptr
998 gridPtrCast(const GridBase::Ptr& grid)
999{
1000 return GridBase::grid<GridType>(grid);
1001}
1002
1003
1004/// @brief Cast a generic const grid pointer to a const pointer to a grid
1005/// of a concrete class.
1006///
1007/// Return a null pointer if the input pointer is null or if it
1008/// points to a grid that is not of type @c GridType.
1009///
1010/// @note Calling gridConstPtrCast<GridType>(grid) is equivalent to calling
1011/// GridBase::constGrid<GridType>(grid).
1012 template<typename GridType>
1013 inline typename GridType::ConstPtr
1014 gridConstPtrCast(const GridBase::ConstPtr& grid)
1015{
1016 return GridBase::constGrid<GridType>(grid);
1017}
1018
1019
1020////////////////////////////////////////
1021
1022
1023/// @{
1024/// @brief Return a pointer to a deep copy of the given grid, provided that
1025/// the grid's concrete type is @c GridType.
1026///
1027/// Return a null pointer if the input pointer is null or if it
1028/// points to a grid that is not of type @c GridType.
1029 template<typename GridType>
1030 inline typename GridType::Ptr
1031 deepCopyTypedGrid(const GridBase::ConstPtr& grid)
1032{
1033 if (!grid || !grid->isType<GridType>()) return typename GridType::Ptr();
1034 return gridPtrCast<GridType>(grid->deepCopyGrid());
1035}
1036
1037
1038 template<typename GridType>
1039 inline typename GridType::Ptr
1040 deepCopyTypedGrid(const GridBase& grid)
1041{
1042 if (!grid.isType<GridType>()) return typename GridType::Ptr();
1043 return gridPtrCast<GridType>(grid.deepCopyGrid());
1044}
1045/// @}
1046
1047
1048////////////////////////////////////////
1049
1050
1051//@{
1052/// @brief This adapter allows code that is templated on a Tree type to
1053/// accept either a Tree type or a Grid type.
1054 template<typename _TreeType>
1055 struct TreeAdapter
1056{
1057 using TreeType = _TreeType;
1058 using NonConstTreeType = typename std::remove_const<TreeType>::type;
1059 using TreePtrType = typename TreeType::Ptr;
1060 using ConstTreePtrType = typename TreeType::ConstPtr;
1061 using NonConstTreePtrType = typename NonConstTreeType::Ptr;
1062 using GridType = Grid<NonConstTreeType>;
1063 using NonConstGridType = Grid<NonConstTreeType>;
1064 using GridPtrType = typename GridType::Ptr;
1065 using NonConstGridPtrType = typename NonConstGridType::Ptr;
1066 using ConstGridPtrType = typename GridType::ConstPtr;
1067 using ValueType = typename TreeType::ValueType;
1068 using AccessorType = typename tree::ValueAccessor<TreeType>;
1069 using ConstAccessorType = typename tree::ValueAccessor<const TreeType>;
1070 using NonConstAccessorType = typename tree::ValueAccessor<NonConstTreeType>;
1071
1072 static NonConstTreeType& tree(NonConstTreeType& t) { return t; }
1073 static NonConstTreeType& tree(NonConstGridType& g) { return g.tree(); }
1074 static const NonConstTreeType& tree(const NonConstTreeType& t) { return t; }
1075 static const NonConstTreeType& tree(const NonConstGridType& g) { return g.tree(); }
1076 static const NonConstTreeType& constTree(NonConstTreeType& t) { return t; }
1077 static const NonConstTreeType& constTree(NonConstGridType& g) { return g.constTree(); }
1078 static const NonConstTreeType& constTree(const NonConstTreeType& t) { return t; }
1079 static const NonConstTreeType& constTree(const NonConstGridType& g) { return g.constTree(); }
1080};
1081
1082
1083/// Partial specialization for Grid types
1084 template<typename _TreeType>
1085 struct TreeAdapter<Grid<_TreeType> >
1086{
1087 using TreeType = _TreeType;
1088 using NonConstTreeType = typename std::remove_const<TreeType>::type;
1089 using TreePtrType = typename TreeType::Ptr;
1090 using ConstTreePtrType = typename TreeType::ConstPtr;
1091 using NonConstTreePtrType = typename NonConstTreeType::Ptr;
1092 using GridType = Grid<TreeType>;
1093 using NonConstGridType = Grid<NonConstTreeType>;
1094 using GridPtrType = typename GridType::Ptr;
1095 using NonConstGridPtrType = typename NonConstGridType::Ptr;
1096 using ConstGridPtrType = typename GridType::ConstPtr;
1097 using ValueType = typename TreeType::ValueType;
1098 using AccessorType = typename tree::ValueAccessor<TreeType>;
1099 using ConstAccessorType = typename tree::ValueAccessor<const TreeType>;
1100 using NonConstAccessorType = typename tree::ValueAccessor<NonConstTreeType>;
1101
1102 static NonConstTreeType& tree(NonConstTreeType& t) { return t; }
1103 static NonConstTreeType& tree(NonConstGridType& g) { return g.tree(); }
1104 static const NonConstTreeType& tree(const NonConstTreeType& t) { return t; }
1105 static const NonConstTreeType& tree(const NonConstGridType& g) { return g.tree(); }
1106 static const NonConstTreeType& constTree(NonConstTreeType& t) { return t; }
1107 static const NonConstTreeType& constTree(NonConstGridType& g) { return g.constTree(); }
1108 static const NonConstTreeType& constTree(const NonConstTreeType& t) { return t; }
1109 static const NonConstTreeType& constTree(const NonConstGridType& g) { return g.constTree(); }
1110};
1111
1112/// Partial specialization for const Grid types
1113 template<typename _TreeType>
1114 struct TreeAdapter<const Grid<_TreeType> >
1115{
1116 using TreeType = _TreeType;
1117 using NonConstTreeType = typename std::remove_const<TreeType>::type;
1118 using TreePtrType = typename TreeType::Ptr;
1119 using ConstTreePtrType = typename TreeType::ConstPtr;
1120 using NonConstTreePtrType = typename NonConstTreeType::Ptr;
1121 using GridType = Grid<TreeType>;
1122 using NonConstGridType = Grid<NonConstTreeType>;
1123 using GridPtrType = typename GridType::Ptr;
1124 using NonConstGridPtrType = typename NonConstGridType::Ptr;
1125 using ConstGridPtrType = typename GridType::ConstPtr;
1126 using ValueType = typename TreeType::ValueType;
1127 using AccessorType = typename tree::ValueAccessor<TreeType>;
1128 using ConstAccessorType = typename tree::ValueAccessor<const TreeType>;
1129 using NonConstAccessorType = typename tree::ValueAccessor<NonConstTreeType>;
1130
1131 static NonConstTreeType& tree(NonConstTreeType& t) { return t; }
1132 static NonConstTreeType& tree(NonConstGridType& g) { return g.tree(); }
1133 static const NonConstTreeType& tree(const NonConstTreeType& t) { return t; }
1134 static const NonConstTreeType& tree(const NonConstGridType& g) { return g.tree(); }
1135 static const NonConstTreeType& constTree(NonConstTreeType& t) { return t; }
1136 static const NonConstTreeType& constTree(NonConstGridType& g) { return g.constTree(); }
1137 static const NonConstTreeType& constTree(const NonConstTreeType& t) { return t; }
1138 static const NonConstTreeType& constTree(const NonConstGridType& g) { return g.constTree(); }
1139};
1140
1141/// Partial specialization for ValueAccessor types
1142 template<typename _TreeType>
1143 struct TreeAdapter<tree::ValueAccessor<_TreeType> >
1144{
1145 using TreeType = _TreeType;
1146 using NonConstTreeType = typename std::remove_const<TreeType>::type;
1147 using TreePtrType = typename TreeType::Ptr;
1148 using ConstTreePtrType = typename TreeType::ConstPtr;
1149 using NonConstTreePtrType = typename NonConstTreeType::Ptr;
1150 using GridType = Grid<NonConstTreeType>;
1151 using NonConstGridType = Grid<NonConstTreeType>;
1152 using GridPtrType = typename GridType::Ptr;
1153 using NonConstGridPtrType = typename NonConstGridType::Ptr;
1154 using ConstGridPtrType = typename GridType::ConstPtr;
1155 using ValueType = typename TreeType::ValueType;
1156 using AccessorType = typename tree::ValueAccessor<TreeType>;
1157 using ConstAccessorType = typename tree::ValueAccessor<const NonConstTreeType>;
1158 using NonConstAccessorType = typename tree::ValueAccessor<NonConstTreeType>;
1159
1160 static NonConstTreeType& tree(NonConstTreeType& t) { return t; }
1161 static NonConstTreeType& tree(NonConstGridType& g) { return g.tree(); }
1162 static NonConstTreeType& tree(NonConstAccessorType& a) { return a.tree(); }
1163 static const NonConstTreeType& tree(ConstAccessorType& a) { return a.tree(); }
1164 static const NonConstTreeType& tree(const NonConstTreeType& t) { return t; }
1165 static const NonConstTreeType& tree(const NonConstGridType& g) { return g.tree(); }
1166 static const NonConstTreeType& tree(const NonConstAccessorType& a) { return a.tree(); }
1167 static const NonConstTreeType& tree(const ConstAccessorType& a) { return a.tree(); }
1168 static const NonConstTreeType& constTree(NonConstTreeType& t) { return t; }
1169 static const NonConstTreeType& constTree(NonConstGridType& g) { return g.constTree(); }
1170 static const NonConstTreeType& constTree(NonConstAccessorType& a) { return a.tree(); }
1171 static const NonConstTreeType& constTree(ConstAccessorType& a) { return a.tree(); }
1172 static const NonConstTreeType& constTree(const NonConstTreeType& t) { return t; }
1173 static const NonConstTreeType& constTree(const NonConstGridType& g) { return g.constTree(); }
1174 static const NonConstTreeType& constTree(const NonConstAccessorType& a) { return a.tree(); }
1175 static const NonConstTreeType& constTree(const ConstAccessorType& a) { return a.tree(); }
1176};
1177
1178//@}
1179
1180
1181////////////////////////////////////////
1182
1183
1184/// @brief Metafunction that specifies whether a given leaf node, tree, or grid type
1185/// requires multiple passes to read and write voxel data
1186/// @details Multi-pass I/O allows one to optimize the data layout of leaf nodes
1187/// for certain access patterns during delayed loading.
1188/// @sa io::MultiPass
1189 template<typename LeafNodeType>
1190 struct HasMultiPassIO {
1191 static const bool value = std::is_base_of<io::MultiPass, LeafNodeType>::value;
1192};
1193
1194// Partial specialization for Tree types
1195 template<typename RootNodeType>
1196 struct HasMultiPassIO<tree::Tree<RootNodeType>> {
1197 // A tree is multi-pass if its (root node's) leaf node type is multi-pass.
1198 static const bool value = HasMultiPassIO<typename RootNodeType::LeafNodeType>::value;
1199};
1200
1201// Partial specialization for Grid types
1202 template<typename TreeType>
1203 struct HasMultiPassIO<Grid<TreeType>> {
1204 // A grid is multi-pass if its tree's leaf node type is multi-pass.
1205 static const bool value = HasMultiPassIO<typename TreeType::LeafNodeType>::value;
1206};
1207
1208
1209////////////////////////////////////////
1210
1211 inline GridBase::GridBase(const MetaMap& meta, math::Transform::Ptr xform)
1212 : MetaMap(meta)
1213 , mTransform(xform)
1214{
1215 if (!xform) OPENVDB_THROW(ValueError, "Transform pointer is null");
1216}
1217
1218 template<typename GridType>
1219 inline typename GridType::Ptr
1220 GridBase::grid(const GridBase::Ptr& grid)
1221{
1222 // The string comparison on type names is slower than a dynamic pointer cast, but
1223 // it is safer when pointers cross DSO boundaries, as they do in many Houdini nodes.
1224 if (grid && grid->type() == GridType::gridType()) {
1225 return StaticPtrCast<GridType>(grid);
1226 }
1227 return typename GridType::Ptr();
1228}
1229
1230
1231 template<typename GridType>
1232 inline typename GridType::ConstPtr
1233 GridBase::grid(const GridBase::ConstPtr& grid)
1234{
1235 return ConstPtrCast<const GridType>(
1236 GridBase::grid<GridType>(ConstPtrCast<GridBase>(grid)));
1237}
1238
1239
1240 template<typename GridType>
1241 inline typename GridType::ConstPtr
1242 GridBase::constGrid(const GridBase::Ptr& grid)
1243{
1244 return ConstPtrCast<const GridType>(GridBase::grid<GridType>(grid));
1245}
1246
1247
1248 template<typename GridType>
1249 inline typename GridType::ConstPtr
1250 GridBase::constGrid(const GridBase::ConstPtr& grid)
1251{
1252 return ConstPtrCast<const GridType>(
1253 GridBase::grid<GridType>(ConstPtrCast<GridBase>(grid)));
1254}
1255
1256
1257 inline TreeBase::Ptr
1258 GridBase::baseTreePtr()
1259{
1260 return ConstPtrCast<TreeBase>(this->constBaseTreePtr());
1261}
1262
1263
1264 inline void
1265 GridBase::setTransform(math::Transform::Ptr xform)
1266{
1267 if (!xform) OPENVDB_THROW(ValueError, "Transform pointer is null");
1268 mTransform = xform;
1269}
1270
1271
1272////////////////////////////////////////
1273
1274
1275 template<typename TreeT>
1276 inline Grid<TreeT>::Grid(): mTree(new TreeType)
1277{
1278}
1279
1280
1281 template<typename TreeT>
1282 inline Grid<TreeT>::Grid(const ValueType &background): mTree(new TreeType(background))
1283{
1284}
1285
1286
1287 template<typename TreeT>
1288 inline Grid<TreeT>::Grid(TreePtrType tree): mTree(tree)
1289{
1290 if (!tree) OPENVDB_THROW(ValueError, "Tree pointer is null");
1291}
1292
1293
1294 template<typename TreeT>
1295 inline Grid<TreeT>::Grid(TreePtrType tree, const MetaMap& meta, math::Transform::Ptr xform):
1296 GridBase(meta, xform),
1297 mTree(tree)
1298{
1299 if (!tree) OPENVDB_THROW(ValueError, "Tree pointer is null");
1300}
1301
1302
1303 template<typename TreeT>
1304 inline Grid<TreeT>::Grid(const Grid& other):
1305 GridBase(other),
1306 mTree(StaticPtrCast<TreeType>(other.mTree->copy()))
1307{
1308}
1309
1310
1311 template<typename TreeT>
1312 template<typename OtherTreeType>
1313 inline Grid<TreeT>::Grid(const Grid<OtherTreeType>& other):
1314 GridBase(other),
1315 mTree(new TreeType(other.constTree()))
1316{
1317}
1318
1319
1320 template<typename TreeT>
1321 inline Grid<TreeT>::Grid(Grid& other, ShallowCopy):
1322 GridBase(other),
1323 mTree(other.mTree)
1324{
1325}
1326
1327
1328 template<typename TreeT>
1329 inline Grid<TreeT>::Grid(const GridBase& other):
1330 GridBase(other),
1331 mTree(new TreeType)
1332{
1333}
1334
1335
1336//static
1337 template<typename TreeT>
1338 inline typename Grid<TreeT>::Ptr
1339 Grid<TreeT>::create()
1340{
1341 return Grid::create(zeroVal<ValueType>());
1342}
1343
1344
1345//static
1346 template<typename TreeT>
1347 inline typename Grid<TreeT>::Ptr
1348 Grid<TreeT>::create(const ValueType& background)
1349{
1350 return Ptr(new Grid(background));
1351}
1352
1353
1354//static
1355 template<typename TreeT>
1356 inline typename Grid<TreeT>::Ptr
1357 Grid<TreeT>::create(TreePtrType tree)
1358{
1359 return Ptr(new Grid(tree));
1360}
1361
1362
1363//static
1364 template<typename TreeT>
1365 inline typename Grid<TreeT>::Ptr
1366 Grid<TreeT>::create(const GridBase& other)
1367{
1368 return Ptr(new Grid(other));
1369}
1370
1371
1372////////////////////////////////////////
1373
1374
1375 template<typename TreeT>
1376 inline typename Grid<TreeT>::ConstPtr
1377 Grid<TreeT>::copy() const
1378{
1379 return ConstPtr{new Grid{*const_cast<Grid*>(this), ShallowCopy{}}};
1380}
1381
1382
1383 template<typename TreeT>
1384 inline typename Grid<TreeT>::ConstPtr
1385 Grid<TreeT>::copyReplacingMetadata(const MetaMap& meta) const
1386{
1387 math::Transform::Ptr transformPtr = ConstPtrCast<math::Transform>(
1388 this->constTransformPtr());
1389 TreePtrType treePtr = ConstPtrCast<TreeT>(this->constTreePtr());
1390 return ConstPtr{new Grid<TreeT>{treePtr, meta, transformPtr}};
1391}
1392
1393 template<typename TreeT>
1394 inline typename Grid<TreeT>::ConstPtr
1395 Grid<TreeT>::copyReplacingTransform(math::Transform::Ptr xform) const
1396{
1397 return this->copyReplacingMetadataAndTransform(*this, xform);
1398}
1399
1400 template<typename TreeT>
1401 inline typename Grid<TreeT>::ConstPtr
1402 Grid<TreeT>::copyReplacingMetadataAndTransform(const MetaMap& meta,
1403 math::Transform::Ptr xform) const
1404{
1405 TreePtrType treePtr = ConstPtrCast<TreeT>(this->constTreePtr());
1406 return ConstPtr{new Grid<TreeT>{treePtr, meta, xform}};
1407}
1408
1409
1410 template<typename TreeT>
1411 inline typename Grid<TreeT>::Ptr
1412 Grid<TreeT>::copy()
1413{
1414 return Ptr{new Grid{*this, ShallowCopy{}}};
1415}
1416
1417
1418 template<typename TreeT>
1419 inline typename Grid<TreeT>::Ptr
1420 Grid<TreeT>::copyWithNewTree() const
1421{
1422 Ptr result{new Grid{*const_cast<Grid*>(this), ShallowCopy{}}};
1423 result->newTree();
1424 return result;
1425}
1426
1427
1428 template<typename TreeT>
1429 inline GridBase::Ptr
1430 Grid<TreeT>::copyGrid()
1431{
1432 return this->copy();
1433}
1434
1435 template<typename TreeT>
1436 inline GridBase::ConstPtr
1437 Grid<TreeT>::copyGrid() const
1438{
1439 return this->copy();
1440}
1441
1442 template<typename TreeT>
1443 inline GridBase::ConstPtr
1444 Grid<TreeT>::copyGridReplacingMetadata(const MetaMap& meta) const
1445{
1446 return this->copyReplacingMetadata(meta);
1447}
1448
1449 template<typename TreeT>
1450 inline GridBase::ConstPtr
1451 Grid<TreeT>::copyGridReplacingTransform(math::Transform::Ptr xform) const
1452{
1453 return this->copyReplacingTransform(xform);
1454}
1455
1456 template<typename TreeT>
1457 inline GridBase::ConstPtr
1458 Grid<TreeT>::copyGridReplacingMetadataAndTransform(const MetaMap& meta,
1459 math::Transform::Ptr xform) const
1460{
1461 return this->copyReplacingMetadataAndTransform(meta, xform);
1462}
1463
1464 template<typename TreeT>
1465 inline GridBase::Ptr
1466 Grid<TreeT>::copyGridWithNewTree() const
1467{
1468 return this->copyWithNewTree();
1469}
1470
1471
1472////////////////////////////////////////
1473
1474
1475 template<typename TreeT>
1476 inline bool
1477 Grid<TreeT>::isTreeUnique() const
1478{
1479 return mTree.use_count() == 1;
1480}
1481
1482
1483 template<typename TreeT>
1484 inline void
1485 Grid<TreeT>::setTree(TreeBase::Ptr tree)
1486{
1487 if (!tree) OPENVDB_THROW(ValueError, "Tree pointer is null");
1488 if (tree->type() != TreeType::treeType()) {
1489 OPENVDB_THROW(TypeError, "Cannot assign a tree of type "
1490 + tree->type() + " to a grid of type " + this->type());
1491 }
1492 mTree = StaticPtrCast<TreeType>(tree);
1493}
1494
1495
1496 template<typename TreeT>
1497 inline void
1498 Grid<TreeT>::newTree()
1499{
1500 mTree.reset(new TreeType(this->background()));
1501}
1502
1503
1504////////////////////////////////////////
1505
1506
1507 template<typename TreeT>
1508 inline void
1509 Grid<TreeT>::sparseFill(const CoordBBox& bbox, const ValueType& value, bool active)
1510{
1511 tree().sparseFill(bbox, value, active);
1512}
1513
1514
1515 template<typename TreeT>
1516 inline void
1517 Grid<TreeT>::fill(const CoordBBox& bbox, const ValueType& value, bool active)
1518{
1519 this->sparseFill(bbox, value, active);
1520}
1521
1522 template<typename TreeT>
1523 inline void
1524 Grid<TreeT>::denseFill(const CoordBBox& bbox, const ValueType& value, bool active)
1525{
1526 tree().denseFill(bbox, value, active);
1527}
1528
1529 template<typename TreeT>
1530 inline void
1531 Grid<TreeT>::pruneGrid(float tolerance)
1532{
1533 const auto value = math::cwiseAdd(zeroVal<ValueType>(), tolerance);
1534 this->tree().prune(static_cast<ValueType>(value));
1535}
1536
1537 template<typename TreeT>
1538 inline void
1539 Grid<TreeT>::clip(const CoordBBox& bbox)
1540{
1541 tree().clip(bbox);
1542}
1543
1544 template<typename TreeT>
1545 inline void
1546 Grid<TreeT>::merge(Grid& other, MergePolicy policy)
1547{
1548 tree().merge(other.tree(), policy);
1549}
1550
1551
1552 template<typename TreeT>
1553 template<typename OtherTreeType>
1554 inline void
1555 Grid<TreeT>::topologyUnion(const Grid<OtherTreeType>& other)
1556{
1557 tree().topologyUnion(other.tree());
1558}
1559
1560
1561 template<typename TreeT>
1562 template<typename OtherTreeType>
1563 inline void
1564 Grid<TreeT>::topologyIntersection(const Grid<OtherTreeType>& other)
1565{
1566 tree().topologyIntersection(other.tree());
1567}
1568
1569
1570 template<typename TreeT>
1571 template<typename OtherTreeType>
1572 inline void
1573 Grid<TreeT>::topologyDifference(const Grid<OtherTreeType>& other)
1574{
1575 tree().topologyDifference(other.tree());
1576}
1577
1578
1579////////////////////////////////////////
1580
1581
1582 template<typename TreeT>
1583 inline CoordBBox
1584 Grid<TreeT>::evalActiveVoxelBoundingBox() const
1585{
1586 CoordBBox bbox;
1587 tree().evalActiveVoxelBoundingBox(bbox);
1588 return bbox;
1589}
1590
1591
1592 template<typename TreeT>
1593 inline Coord
1594 Grid<TreeT>::evalActiveVoxelDim() const
1595{
1596 Coord dim;
1597 const bool nonempty = tree().evalActiveVoxelDim(dim);
1598 return (nonempty ? dim : Coord());
1599}
1600
1601
1602////////////////////////////////////////
1603
1604
1605/// @internal Consider using the stream tagging mechanism (see io::Archive)
1606/// to specify the float precision, but note that the setting is per-grid.
1607
1608 template<typename TreeT>
1609 inline void
1610 Grid<TreeT>::readTopology(std::istream& is)
1611{
1612 tree().readTopology(is, saveFloatAsHalf());
1613}
1614
1615
1616 template<typename TreeT>
1617 inline void
1618 Grid<TreeT>::writeTopology(std::ostream& os) const
1619{
1620 tree().writeTopology(os, saveFloatAsHalf());
1621}
1622
1623
1624 template<typename TreeT>
1625 inline void
1626 Grid<TreeT>::readBuffers(std::istream& is)
1627{
1628 io::checkFormatVersion(is);
1629
1630 if (!hasMultiPassIO()) {
1631 tree().readBuffers(is, saveFloatAsHalf());
1632 } else {
1633 uint16_t numPasses = 1;
1634 is.read(reinterpret_cast<char*>(&numPasses), sizeof(uint16_t));
1635 const io::StreamMetadata::Ptr meta = io::getStreamMetadataPtr(is);
1636 OPENVDB_ASSERT(bool(meta));
1637 for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1638 uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1639 meta->setPass(pass);
1640 tree().readBuffers(is, saveFloatAsHalf());
1641 }
1642 }
1643}
1644
1645
1646/// @todo Refactor this and the readBuffers() above
1647/// once support for ABI 2 compatibility is dropped.
1648 template<typename TreeT>
1649 inline void
1650 Grid<TreeT>::readBuffers(std::istream& is, const CoordBBox& bbox)
1651{
1652 io::checkFormatVersion(is);
1653
1654 if (!hasMultiPassIO()) {
1655 tree().readBuffers(is, bbox, saveFloatAsHalf());
1656 } else {
1657 uint16_t numPasses = 1;
1658 is.read(reinterpret_cast<char*>(&numPasses), sizeof(uint16_t));
1659 const io::StreamMetadata::Ptr meta = io::getStreamMetadataPtr(is);
1660 OPENVDB_ASSERT(bool(meta));
1661 for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1662 uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1663 meta->setPass(pass);
1664 tree().readBuffers(is, saveFloatAsHalf());
1665 }
1666 // Cannot clip inside readBuffers() when using multiple passes,
1667 // so instead clip afterwards.
1668 tree().clip(bbox);
1669 }
1670}
1671
1672
1673 template<typename TreeT>
1674 inline void
1675 Grid<TreeT>::readNonresidentBuffers() const
1676{
1677 tree().readNonresidentBuffers();
1678}
1679
1680
1681 template<typename TreeT>
1682 inline void
1683 Grid<TreeT>::writeBuffers(std::ostream& os) const
1684{
1685 if (!hasMultiPassIO()) {
1686 tree().writeBuffers(os, saveFloatAsHalf());
1687 } else {
1688 // Determine how many leaf buffer passes are required for this grid
1689 const io::StreamMetadata::Ptr meta = io::getStreamMetadataPtr(os);
1690 OPENVDB_ASSERT(bool(meta));
1691 uint16_t numPasses = 1;
1692 meta->setCountingPasses(true);
1693 meta->setPass(0);
1694 tree().writeBuffers(os, saveFloatAsHalf());
1695 numPasses = static_cast<uint16_t>(meta->pass());
1696 os.write(reinterpret_cast<const char*>(&numPasses), sizeof(uint16_t));
1697 meta->setCountingPasses(false);
1698
1699 // Save out the data blocks of the grid.
1700 for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1701 uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1702 meta->setPass(pass);
1703 tree().writeBuffers(os, saveFloatAsHalf());
1704 }
1705 }
1706}
1707
1708
1709//static
1710 template<typename TreeT>
1711 inline bool
1712 Grid<TreeT>::hasMultiPassIO()
1713{
1714 return HasMultiPassIO<Grid>::value;
1715}
1716
1717
1718 template<typename TreeT>
1719 inline void
1720 Grid<TreeT>::print(std::ostream& os, int verboseLevel) const
1721{
1722 tree().print(os, verboseLevel);
1723
1724 if (metaCount() > 0) {
1725 os << "Additional metadata:" << std::endl;
1726 for (ConstMetaIterator it = beginMeta(), end = endMeta(); it != end; ++it) {
1727 os << " " << it->first;
1728 if (it->second) {
1729 const std::string value = it->second->str();
1730 if (!value.empty()) os << ": " << value;
1731 }
1732 os << "\n";
1733 }
1734 }
1735
1736 os << "Transform:" << std::endl;
1737 transform().print(os, /*indent=*/" ");
1738 os << std::endl;
1739}
1740
1741
1742////////////////////////////////////////
1743
1744
1745 template<typename GridType>
1746 inline typename GridType::Ptr
1747 createGrid(const typename GridType::ValueType& background)
1748{
1749 return GridType::create(background);
1750}
1751
1752
1753 template<typename GridType>
1754 inline typename GridType::Ptr
1755 createGrid()
1756{
1757 return GridType::create();
1758}
1759
1760
1761 template<typename TreePtrType>
1762 inline typename Grid<typename TreePtrType::element_type>::Ptr
1763 createGrid(TreePtrType tree)
1764{
1765 using TreeType = typename TreePtrType::element_type;
1766 return Grid<TreeType>::create(tree);
1767}
1768
1769
1770 template<typename GridType>
1771 typename GridType::Ptr
1772 createLevelSet(Real voxelSize, Real halfWidth)
1773{
1774 using ValueType = typename GridType::ValueType;
1775
1776 // GridType::ValueType is required to be a floating-point scalar.
1777 static_assert(openvdb::is_floating_point<ValueType>::value,
1778 "level-set grids must be floating-point-valued");
1779
1780 typename GridType::Ptr grid = GridType::create(
1781 /*background=*/static_cast<ValueType>(voxelSize * halfWidth));
1782 grid->setTransform(math::Transform::createLinearTransform(voxelSize));
1783 grid->setGridClass(GRID_LEVEL_SET);
1784 return grid;
1785}
1786
1787
1788////////////////////////////////////////
1789
1790
1791 template<typename GridTypeListT, typename OpT>
1792 inline bool
1793 GridBase::apply(OpT& op) const
1794{
1795 return GridTypeListT::template apply<OpT&, const GridBase>(std::ref(op), *this);
1796}
1797
1798 template<typename GridTypeListT, typename OpT>
1799 inline bool
1800 GridBase::apply(OpT& op)
1801{
1802 return GridTypeListT::template apply<OpT&, GridBase>(std::ref(op), *this);
1803}
1804
1805 template<typename GridTypeListT, typename OpT>
1806 inline bool
1807 GridBase::apply(const OpT& op) const
1808{
1809 return GridTypeListT::template apply<const OpT&, const GridBase>(std::ref(op), *this);
1810}
1811
1812 template<typename GridTypeListT, typename OpT>
1813 inline bool
1814 GridBase::apply(const OpT& op)
1815{
1816 return GridTypeListT::template apply<const OpT&, GridBase>(std::ref(op), *this);
1817}
1818
1819
1820} // namespace OPENVDB_VERSION_NAME
1821} // namespace openvdb
1822
1823#endif // OPENVDB_GRID_HAS_BEEN_INCLUDED
Assert.h
OPENVDB_ASSERT
#define OPENVDB_ASSERT(X)
Definition Assert.h:41
MetaMap.h
Name.h
OPENVDB_API
#define OPENVDB_API
Definition Platform.h:291
Transform.h
Tree.h
openvdb::v13_0::GridBase
Abstract base class for typed grids.
Definition Grid.h:78
openvdb::v13_0::GridBase::valueType
virtual Name valueType() const =0
Return the name of the type of a voxel's value (e.g., "float" or "vec3d").
openvdb::v13_0::GridBase::copyGrid
virtual GridBase::Ptr copyGrid()=0
Return a new grid of the same type as this grid whose metadata is a deep copy of this grid's and whos...
openvdb::v13_0::GridBase::copyGridReplacingMetadataAndTransform
virtual GridBase::ConstPtr copyGridReplacingMetadataAndTransform(const MetaMap &meta, math::Transform::Ptr xform) const =0
Return a new grid of the same type as this grid whose tree is shared with this grid and whose transfo...
openvdb::v13_0::GridBase::copyGridReplacingMetadata
virtual GridBase::ConstPtr copyGridReplacingMetadata(const MetaMap &meta) const =0
Return a new grid of the same type as this grid whose tree and transform is shared with this grid and...
openvdb::v13_0::GridBase::META_FILE_MEM_BYTES
static const char *const META_FILE_MEM_BYTES
Definition Grid.h:360
openvdb::v13_0::GridBase::GridFactory
Ptr(*)() GridFactory
Definition Grid.h:83
openvdb::v13_0::GridBase::grid
static GridType::Ptr grid(const GridBase::Ptr &)
Return the result of downcasting a GridBase pointer to a Grid pointer of the specified type,...
Definition Grid.h:1220
openvdb::v13_0::GridBase::META_FILE_BBOX_MAX
static const char *const META_FILE_BBOX_MAX
Definition Grid.h:358
openvdb::v13_0::GridBase::readBuffers
virtual void readBuffers(std::istream &)=0
Read all data buffers for this grid.
openvdb::v13_0::GridBase::writeBuffers
virtual void writeBuffers(std::ostream &) const =0
Write out all data buffers for this grid.
openvdb::v13_0::GridBase::gridClassToMenuName
static std::string gridClassToMenuName(GridClass)
Return a formatted string version of the grid class.
openvdb::v13_0::GridBase::hasUniformVoxels
bool hasUniformVoxels() const
Return true if the voxels in world space are uniformly sized cubes.
Definition Grid.h:435
openvdb::v13_0::GridBase::constTransformPtr
math::Transform::ConstPtr constTransformPtr() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition Grid.h:404
openvdb::v13_0::GridBase::setSaveFloatAsHalf
void setSaveFloatAsHalf(bool)
Return this grid's user-specified name.
openvdb::v13_0::GridBase::~GridBase
~GridBase() override
Definition Grid.h:86
openvdb::v13_0::GridBase::copyGridReplacingTransform
virtual GridBase::ConstPtr copyGridReplacingTransform(math::Transform::Ptr xform) const =0
Return a new grid of the same type as this grid whose tree is shared with this grid,...
openvdb::v13_0::GridBase::indexToWorld
Vec3d indexToWorld(const Coord &ijk) const
Apply this grid's transform to the given coordinates.
Definition Grid.h:439
openvdb::v13_0::GridBase::voxelSize
Vec3d voxelSize() const
Return the size of this grid's voxels.
Definition Grid.h:430
openvdb::v13_0::GridBase::vecTypeDescription
static std::string vecTypeDescription(VecType)
Return a string describing how the given type of vector data is affected by transformations (e....
openvdb::v13_0::GridBase::constTransform
const math::Transform & constTransform() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition Grid.h:413
openvdb::v13_0::GridBase::setName
void setName(const std::string &)
Specify a name for this grid.
openvdb::v13_0::GridBase::META_FILE_DELAYED_LOAD
static const char *const META_FILE_DELAYED_LOAD
Definition Grid.h:362
openvdb::v13_0::GridBase::apply
bool apply(const OpT &) const
If this grid resolves to one of the listed grid types, invoke the given functor on the resolved grid.
Definition Grid.h:1807
openvdb::v13_0::GridBase::indexToWorld
Vec3d indexToWorld(const Vec3d &xyz) const
Apply this grid's transform to the given coordinates.
Definition Grid.h:437
openvdb::v13_0::GridBase::clearGridClass
void clearGridClass()
Remove the setting specifying the class of this grid's volumetric data.
openvdb::v13_0::GridBase::isTreeUnique
virtual bool isTreeUnique() const =0
Return true if tree is not shared with another grid.
openvdb::v13_0::GridBase::isType
bool isType() const
Return true if this grid is of the same type as the template parameter.
Definition Grid.h:146
openvdb::v13_0::GridBase::vecTypeToString
static std::string vecTypeToString(VecType)
Return the metadata string value for the given type of vector data.
openvdb::v13_0::GridBase::META_IS_LOCAL_SPACE
static const char *const META_IS_LOCAL_SPACE
Definition Grid.h:355
openvdb::v13_0::GridBase::worldToIndex
Vec3d worldToIndex(const Vec3d &xyz) const
Apply the inverse of this grid's transform to the given coordinates.
Definition Grid.h:441
openvdb::v13_0::GridBase::ConstPtr
SharedPtr< const GridBase > ConstPtr
Definition Grid.h:81
openvdb::v13_0::GridBase::copyGridWithNewTree
virtual GridBase::Ptr copyGridWithNewTree() const =0
Return a new grid of the same type as this grid whose metadata and transform are deep copies of this ...
openvdb::v13_0::GridBase::transform
math::Transform & transform()
Return a reference to this grid's transform, which might be shared with other grids.
Definition Grid.h:411
openvdb::v13_0::GridBase::GridBase
GridBase(GridBase &other, ShallowCopy)
Copy another grid's metadata but share its transform.
Definition Grid.h:492
openvdb::v13_0::GridBase::META_SAVE_HALF_FLOAT
static const char *const META_SAVE_HALF_FLOAT
Definition Grid.h:354
openvdb::v13_0::GridBase::constGrid
static GridType::ConstPtr constGrid(const GridBase::ConstPtr &)
Definition Grid.h:1250
openvdb::v13_0::GridBase::apply
bool apply(OpT &)
If this grid resolves to one of the listed grid types, invoke the given functor on the resolved grid.
Definition Grid.h:1800
openvdb::v13_0::GridBase::clear
virtual void clear()=0
Empty this grid, setting all voxels to the background.
openvdb::v13_0::GridBase::setGridClass
void setGridClass(GridClass)
Specify the class of volumetric data (level set, fog volume, etc.) that is stored in this grid.
openvdb::v13_0::GridBase::writeTopology
virtual void writeTopology(std::ostream &) const =0
Write the grid topology to a stream. This will write only the grid structure, not the actual data buf...
openvdb::v13_0::GridBase::grid
static GridType::ConstPtr grid(const GridBase::ConstPtr &)
Definition Grid.h:1233
openvdb::v13_0::GridBase::baseTreePtr
TreeBase::ConstPtr baseTreePtr() const
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition Grid.h:171
openvdb::v13_0::GridBase::addStatsMetadata
void addStatsMetadata()
Add metadata to this grid comprising the current values of statistics like the active voxel count and...
openvdb::v13_0::GridBase::baseTree
const TreeBase & baseTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition Grid.h:188
openvdb::v13_0::GridBase::clearVectorType
void clearVectorType()
Remove the setting specifying the type of vector data stored in this grid.
openvdb::v13_0::GridBase::newTree
virtual void newTree()=0
Set a new tree with the same background value as the previous tree.
openvdb::v13_0::GridBase::META_FILE_COMPRESSION
static const char *const META_FILE_COMPRESSION
Definition Grid.h:359
openvdb::v13_0::GridBase::constBaseTreePtr
virtual TreeBase::ConstPtr constBaseTreePtr() const =0
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
openvdb::v13_0::GridBase::vecTypeExamples
static std::string vecTypeExamples(VecType)
openvdb::v13_0::GridBase::clipGrid
void clipGrid(const BBoxd &)
Clip this grid to the given world-space bounding box.
openvdb::v13_0::GridBase::evalActiveVoxelBoundingBox
virtual CoordBBox evalActiveVoxelBoundingBox() const =0
openvdb::v13_0::GridBase::META_FILE_BBOX_MIN
static const char *const META_FILE_BBOX_MIN
Definition Grid.h:357
openvdb::v13_0::GridBase::memUsage
virtual Index64 memUsage() const =0
Return the number of bytes of memory used by this grid.
openvdb::v13_0::GridBase::setVectorType
void setVectorType(VecType)
Specify the type of vector data (invariant, covariant, etc.) stored in this grid, assuming that this ...
openvdb::v13_0::GridBase::activeVoxelCount
virtual Index64 activeVoxelCount() const =0
Return the number of active voxels.
openvdb::v13_0::GridBase::isRegistered
static bool isRegistered(const Name &type)
Return true if the given grid type name is registered.
openvdb::v13_0::GridBase::voxelSize
Vec3d voxelSize(const Vec3d &xyz) const
Return the size of this grid's voxel at position (x, y, z).
Definition Grid.h:433
openvdb::v13_0::GridBase::getName
std::string getName() const
Return this grid's user-specified name.
openvdb::v13_0::GridBase::apply
bool apply(const OpT &)
If this grid resolves to one of the listed grid types, invoke the given functor on the resolved grid.
Definition Grid.h:1814
openvdb::v13_0::GridBase::print
virtual void print(std::ostream &=std::cout, int verboseLevel=1) const =0
Output a human-readable description of this grid.
openvdb::v13_0::GridBase::setTransform
void setTransform(math::Transform::Ptr)
Associate the given transform with this grid, in place of its existing transform.
Definition Grid.h:1265
openvdb::v13_0::GridBase::pruneGrid
virtual void pruneGrid(float tolerance=0.0)=0
Reduce the memory footprint of this grid by increasing its sparseness either losslessly (tolerance = ...
openvdb::v13_0::GridBase::apply
bool apply(OpT &) const
If this grid resolves to one of the listed grid types, invoke the given functor on the resolved grid.
Definition Grid.h:1793
openvdb::v13_0::GridBase::constGrid
static GridType::ConstPtr constGrid(const GridBase::Ptr &)
Definition Grid.h:1242
openvdb::v13_0::GridBase::getGridClass
GridClass getGridClass() const
Return the class of volumetric data (level set, fog volume, etc.) that is stored in this grid.
openvdb::v13_0::GridBase::stringToVecType
static VecType stringToVecType(const std::string &)
openvdb::v13_0::GridBase::unregisterGrid
static void unregisterGrid(const Name &type)
Remove a grid type from the registry.
openvdb::v13_0::GridBase::readNonresidentBuffers
virtual void readNonresidentBuffers() const =0
Read all of this grid's data buffers that are not yet resident in memory (because delayed loading is ...
openvdb::v13_0::GridBase::META_GRID_CREATOR
static const char *const META_GRID_CREATOR
Definition Grid.h:352
openvdb::v13_0::GridBase::readTransform
void readTransform(std::istream &is)
Read in the transform for this grid.
Definition Grid.h:470
openvdb::v13_0::GridBase::META_GRID_NAME
static const char *const META_GRID_NAME
Definition Grid.h:353
openvdb::v13_0::GridBase::META_GRID_CLASS
static const char *const META_GRID_CLASS
Definition Grid.h:351
openvdb::v13_0::GridBase::GridBase
GridBase(const GridBase &other)
Deep copy another grid's metadata and transform.
Definition Grid.h:489
openvdb::v13_0::GridBase::transformPtr
math::Transform::Ptr transformPtr()
Return a pointer to this grid's transform, which might be shared with other grids.
Definition Grid.h:402
openvdb::v13_0::GridBase::META_VECTOR_TYPE
static const char *const META_VECTOR_TYPE
Definition Grid.h:356
openvdb::v13_0::GridBase::stringToGridClass
static GridClass stringToGridClass(const std::string &)
Return the class of volumetric data specified by the given string.
openvdb::v13_0::GridBase::evalActiveVoxelDim
virtual Coord evalActiveVoxelDim() const =0
Return the dimensions of the axis-aligned bounding box of all active voxels.
openvdb::v13_0::GridBase::setCreator
void setCreator(const std::string &)
Provide a description of this grid's creator.
openvdb::v13_0::GridBase::saveFloatAsHalf
bool saveFloatAsHalf() const
Return true if this grid should be written out with floating-point voxel values (including components...
openvdb::v13_0::GridBase::getStatsMetadata
MetaMap::Ptr getStatsMetadata() const
Return a new MetaMap containing just the metadata that was added to this grid with addStatsMetadata.
openvdb::v13_0::GridBase::transform
const math::Transform & transform() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition Grid.h:412
openvdb::v13_0::GridBase::gridClassToString
static std::string gridClassToString(GridClass)
Return the metadata string value for the given class of volumetric data.
openvdb::v13_0::GridBase::clip
virtual void clip(const CoordBBox &)=0
Clip this grid to the given index-space bounding box.
openvdb::v13_0::GridBase::type
virtual Name type() const =0
Return the name of this grid's type.
openvdb::v13_0::GridBase::baseTree
TreeBase & baseTree()
Return a reference to this grid's tree, which might be shared with other grids.
Definition Grid.h:183
openvdb::v13_0::GridBase::readTopology
virtual void readTopology(std::istream &)=0
Read the grid topology from a stream. This will read only the grid structure, not the actual data buf...
openvdb::v13_0::GridBase::readBuffers
virtual void readBuffers(std::istream &, const CoordBBox &)=0
Read all of this grid's data buffers that intersect the given index-space bounding box.
openvdb::v13_0::GridBase::constBaseTree
const TreeBase & constBaseTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition Grid.h:193
openvdb::v13_0::GridBase::clearRegistry
static void clearRegistry()
Clear the grid type registry.
openvdb::v13_0::GridBase::getCreator
std::string getCreator() const
Return the user-specified description of this grid's creator.
openvdb::v13_0::GridBase::writeTransform
void writeTransform(std::ostream &os) const
Write out the transform for this grid.
Definition Grid.h:472
openvdb::v13_0::GridBase::getVectorType
VecType getVectorType() const
Return the type of vector data (invariant, covariant, etc.) stored in this grid, assuming that this g...
openvdb::v13_0::GridBase::createGrid
static Ptr createGrid(const Name &type)
Create a new grid of the given (registered) type.
openvdb::v13_0::GridBase::Ptr
SharedPtr< GridBase > Ptr
Definition Grid.h:80
openvdb::v13_0::GridBase::registerGrid
static void registerGrid(const Name &type, GridFactory)
Register a grid type along with a factory function.
openvdb::v13_0::GridBase::baseTreePtr
TreeBase::Ptr baseTreePtr()
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition Grid.h:1258
openvdb::v13_0::GridBase::empty
virtual bool empty() const =0
Return true if this grid contains only background voxels.
openvdb::v13_0::GridBase::META_FILE_VOXEL_COUNT
static const char *const META_FILE_VOXEL_COUNT
Definition Grid.h:361
openvdb::v13_0::GridBase::setTree
virtual void setTree(TreeBase::Ptr)=0
Associate the given tree with this grid, in place of its existing tree.
openvdb::v13_0::GridBase::deepCopyGrid
virtual GridBase::Ptr deepCopyGrid() const =0
Return a new grid whose metadata, transform and tree are deep copies of this grid's.
openvdb::v13_0::GridBase::copyGrid
virtual GridBase::ConstPtr copyGrid() const =0
Return a new grid of the same type as this grid whose metadata is a deep copy of this grid's and whos...
openvdb::v13_0::GridBase::GridBase
GridBase()
Initialize with an identity linear transform.
Definition Grid.h:482
openvdb::v13_0::GridBase::isInWorldSpace
bool isInWorldSpace() const
openvdb::v13_0::GridBase::transformPtr
math::Transform::ConstPtr transformPtr() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition Grid.h:403
openvdb::v13_0::GridBase::setIsInWorldSpace
void setIsInWorldSpace(bool)
Specify whether this grid's voxel values are in world space or in local space.
openvdb::v13_0::Grid
Container class that associates a tree with a transform and metadata.
Definition Grid.h:571
openvdb::v13_0::Grid::tree
const TreeType & tree() const
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition Grid.h:905
openvdb::v13_0::Grid::TreePtrType
typename _TreeType::Ptr TreePtrType
Definition Grid.h:577
openvdb::v13_0::Grid::Grid
Grid()
Construct a new grid with background value zero.
Definition Grid.h:1276
openvdb::v13_0::Grid::ValueOffCIter
typename _TreeType::ValueOffCIter ValueOffCIter
Definition Grid.h:585
openvdb::v13_0::Grid::empty
bool empty() const override
Return true if this grid contains only inactive background voxels.
Definition Grid.h:725
openvdb::v13_0::Grid::ValueOffIter
typename _TreeType::ValueOffIter ValueOffIter
Definition Grid.h:584
openvdb::v13_0::Grid< typename TreeType::template ValueConverter< OtherValueType >::Type >::tree
TreeType & tree()
Definition Grid.h:904
openvdb::v13_0::Grid::topologyIntersection
void topologyIntersection(const Grid< OtherTreeType > &other)
Intersect this grid's set of active values with the active values of the other grid,...
Definition Grid.h:1564
openvdb::v13_0::Grid::cbeginValueOff
ValueOffCIter cbeginValueOff() const
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition Grid.h:765
openvdb::v13_0::Grid::readBuffers
void readBuffers(std::istream &) override
Read all data buffers for this grid.
Definition Grid.h:1626
openvdb::v13_0::Grid< typename TreeType::template ValueConverter< OtherValueType >::Type >::gridType
static Name gridType()
Definition Grid.h:711
openvdb::v13_0::Grid::memUsage
Index64 memUsage() const override
Definition Grid.h:879
openvdb::v13_0::Grid::writeBuffers
void writeBuffers(std::ostream &) const override
Write out all data buffers for this grid.
Definition Grid.h:1683
openvdb::v13_0::Grid::hasMultiPassIO
static bool hasMultiPassIO()
Return true if grids of this type require multiple I/O passes to read and write data buffers.
Definition Grid.h:1712
openvdb::v13_0::Grid::copyReplacingTransform
ConstPtr copyReplacingTransform(math::Transform::Ptr xform) const
Return a new grid of the same type as this grid whose tree is shared with this grid,...
Definition Grid.h:1395
openvdb::v13_0::Grid::Grid
Grid(const Grid &)
Deep copy another grid's metadata, transform and tree.
Definition Grid.h:1304
openvdb::v13_0::Grid::copy
Ptr copy()
Return a new grid of the same type as this grid whose metadata and transform are deep copies of this ...
Definition Grid.h:1412
openvdb::v13_0::Grid::isTreeUnique
bool isTreeUnique() const final
Return true if tree is not shared with another grid.
Definition Grid.h:1477
openvdb::v13_0::Grid::pruneGrid
void pruneGrid(float tolerance=0.0) override
Reduce the memory footprint of this grid by increasing its sparseness.
Definition Grid.h:1531
openvdb::v13_0::Grid::create
static Ptr create(const ValueType &background)
Return a new grid with the given background value.
Definition Grid.h:1348
openvdb::v13_0::Grid::readBuffers
void readBuffers(std::istream &, const CoordBBox &) override
Read all of this grid's data buffers that intersect the given index-space bounding box.
Definition Grid.h:1650
openvdb::v13_0::Grid::create
static Ptr create(const GridBase &other)
Return a new, empty grid with the same transform and metadata as the given grid and with background v...
Definition Grid.h:1366
openvdb::v13_0::Grid::clip
void clip(const CoordBBox &) override
Clip this grid to the given index-space bounding box.
Definition Grid.h:1539
openvdb::v13_0::Grid::cbeginValueAll
ValueAllCIter cbeginValueAll() const
Return an iterator over all of this grid's values (tile and voxel).
Definition Grid.h:771
openvdb::v13_0::Grid::constTreePtr
ConstTreePtrType constTreePtr() const
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition Grid.h:892
openvdb::v13_0::Grid::Grid
Grid(Grid &, ShallowCopy)
Deep copy another grid's metadata and transform, but share its tree.
Definition Grid.h:1321
openvdb::v13_0::Grid::evalActiveVoxelDim
Coord evalActiveVoxelDim() const override
Return the dimensions of the axis-aligned bounding box of all active voxels.
Definition Grid.h:1594
openvdb::v13_0::Grid::beginValueOn
ValueOnCIter beginValueOn() const
Return an iterator over all of this grid's active values (tile and voxel).
Definition Grid.h:757
openvdb::v13_0::Grid::setTree
void setTree(TreeBase::Ptr) override
Associate the given tree with this grid, in place of its existing tree.
Definition Grid.h:1485
openvdb::v13_0::Grid::copyWithNewTree
Ptr copyWithNewTree() const
Return a new grid of the same type as this grid whose metadata and transform are deep copies of this ...
Definition Grid.h:1420
openvdb::v13_0::Grid::Grid
Grid(const ValueType &background)
Construct a new grid with the given background value.
Definition Grid.h:1282
openvdb::v13_0::Grid::copyGridWithNewTree
GridBase::Ptr copyGridWithNewTree() const override
Return a new grid of the same type as this grid whose metadata and transform are deep copies of this ...
Definition Grid.h:1466
openvdb::v13_0::Grid::Accessor
typename _TreeType::Accessor Accessor
Definition Grid.h:589
openvdb::v13_0::Grid::~Grid
~Grid() override
Definition Grid.h:640
openvdb::v13_0::Grid::type
Name type() const override
Return the name of this grid's type.
Definition Grid.h:709
openvdb::v13_0::Grid::print
void print(std::ostream &=std::cout, int verboseLevel=1) const override
Output a human-readable description of this grid.
Definition Grid.h:1720
openvdb::v13_0::Grid::copyGridReplacingMetadata
GridBase::ConstPtr copyGridReplacingMetadata(const MetaMap &meta) const override
Return a new grid of the same type as this grid whose tree and transform is shared with this grid and...
Definition Grid.h:1444
openvdb::v13_0::Grid::ValueAllCIter
typename _TreeType::ValueAllCIter ValueAllCIter
Definition Grid.h:587
openvdb::v13_0::Grid::activeVoxelCount
Index64 activeVoxelCount() const override
Return the number of active voxels.
Definition Grid.h:871
openvdb::v13_0::Grid::getAccessor
ConstAccessor getAccessor() const
Return an accessor that provides random read-only access to this grid's voxels.
Definition Grid.h:742
openvdb::v13_0::Grid::deepCopyGrid
GridBase::Ptr deepCopyGrid() const override
Return a new grid whose metadata, transform and tree are deep copies of this grid's.
Definition Grid.h:703
openvdb::v13_0::Grid::fill
void fill(const CoordBBox &bbox, const ValueType &value, bool active=true)
Set all voxels within a given axis-aligned box to a constant value.
Definition Grid.h:1517
openvdb::v13_0::Grid::beginValueOff
ValueOffCIter beginValueOff() const
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition Grid.h:763
openvdb::v13_0::Grid::getUnsafeAccessor
UnsafeAccessor getUnsafeAccessor()
Return an unsafe accessor that provides random read and write access to this grid's voxels.
Definition Grid.h:740
openvdb::v13_0::Grid::copyGrid
GridBase::Ptr copyGrid() override
Return a new grid of the same type as this grid whose metadata is a deep copy of this grid's and whos...
Definition Grid.h:1430
openvdb::v13_0::Grid::ValueType
typename _TreeType::ValueType ValueType
Definition Grid.h:579
openvdb::v13_0::Grid::ConstTreePtrType
typename _TreeType::ConstPtr ConstTreePtrType
Definition Grid.h:578
openvdb::v13_0::Grid::copy
ConstPtr copy() const
Return a new grid of the same type as this grid whose metadata and transform are deep copies of this ...
Definition Grid.h:1377
openvdb::v13_0::Grid::beginValueOn
ValueOnIter beginValueOn()
Return an iterator over all of this grid's active values (tile and voxel).
Definition Grid.h:755
openvdb::v13_0::Grid::ValueOnCIter
typename _TreeType::ValueOnCIter ValueOnCIter
Definition Grid.h:583
openvdb::v13_0::Grid::ConstPtr
SharedPtr< const Grid > ConstPtr
Definition Grid.h:574
openvdb::v13_0::Grid::readTopology
void readTopology(std::istream &) override
Read the grid topology from a stream. This will read only the grid structure, not the actual data buf...
Definition Grid.h:1610
openvdb::v13_0::Grid::registerGrid
static void registerGrid()
Register this grid type along with a factory function.
Definition Grid.h:968
openvdb::v13_0::Grid::cbeginValueOn
ValueOnCIter cbeginValueOn() const
Return an iterator over all of this grid's active values (tile and voxel).
Definition Grid.h:759
openvdb::v13_0::Grid::UnsafeAccessor
typename _TreeType::UnsafeAccessor UnsafeAccessor
Definition Grid.h:591
openvdb::v13_0::Grid::copyReplacingMetadataAndTransform
ConstPtr copyReplacingMetadataAndTransform(const MetaMap &meta, math::Transform::Ptr xform) const
Return a new grid of the same type as this grid whose tree is shared with this grid and whose transfo...
Definition Grid.h:1402
openvdb::v13_0::Grid::isRegistered
static bool isRegistered()
Return true if this grid type is registered.
Definition Grid.h:966
openvdb::v13_0::Grid::ValueOnIter
typename _TreeType::ValueOnIter ValueOnIter
Definition Grid.h:582
openvdb::v13_0::Grid::ConstAccessor
typename _TreeType::ConstAccessor ConstAccessor
Definition Grid.h:590
openvdb::v13_0::Grid::readNonresidentBuffers
void readNonresidentBuffers() const override
Read all of this grid's data buffers that are not yet resident in memory (because delayed loading is ...
Definition Grid.h:1675
openvdb::v13_0::Grid::copyGridReplacingMetadataAndTransform
GridBase::ConstPtr copyGridReplacingMetadataAndTransform(const MetaMap &meta, math::Transform::Ptr xform) const override
Return a new grid of the same type as this grid whose tree is shared with this grid and whose transfo...
Definition Grid.h:1458
openvdb::v13_0::Grid::ConstUnsafeAccessor
typename _TreeType::ConstUnsafeAccessor ConstUnsafeAccessor
Definition Grid.h:592
openvdb::v13_0::Grid::BuildType
typename _TreeType::BuildType BuildType
Definition Grid.h:580
openvdb::v13_0::Grid::getConstAccessor
ConstAccessor getConstAccessor() const
Return an accessor that provides random read-only access to this grid's voxels.
Definition Grid.h:744
openvdb::v13_0::Grid::denseFill
void denseFill(const CoordBBox &bbox, const ValueType &value, bool active=true)
Set all voxels within a given axis-aligned box to a constant value and ensure that those voxels are a...
Definition Grid.h:1524
openvdb::v13_0::Grid::treePtr
ConstTreePtrType treePtr() const
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition Grid.h:891
openvdb::v13_0::Grid::topologyDifference
void topologyDifference(const Grid< OtherTreeType > &other)
Difference this grid's set of active values with the active values of the other grid,...
Definition Grid.h:1573
openvdb::v13_0::Grid::constBaseTreePtr
TreeBase::ConstPtr constBaseTreePtr() const override
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition Grid.h:893
openvdb::v13_0::Grid::Grid
Grid(TreePtrType)
Construct a new grid that shares the given tree and associates with it an identity linear transform.
Definition Grid.h:1288
openvdb::v13_0::Grid::copyGridReplacingTransform
GridBase::ConstPtr copyGridReplacingTransform(math::Transform::Ptr xform) const override
Return a new grid of the same type as this grid whose tree is shared with this grid,...
Definition Grid.h:1451
openvdb::v13_0::Grid::evalActiveVoxelBoundingBox
CoordBBox evalActiveVoxelBoundingBox() const override
Return the axis-aligned bounding box of all active voxels.
Definition Grid.h:1584
openvdb::v13_0::Grid::deepCopy
Ptr deepCopy() const
Return a new grid whose metadata, transform and tree are deep copies of this grid's.
Definition Grid.h:701
openvdb::v13_0::Grid< typename TreeType::template ValueConverter< OtherValueType >::Type >::background
const ValueType & background() const
Definition Grid.h:722
openvdb::v13_0::Grid::copyGrid
GridBase::ConstPtr copyGrid() const override
Return a new grid of the same type as this grid whose metadata is a deep copy of this grid's and whos...
Definition Grid.h:1437
openvdb::v13_0::Grid::beginValueOff
ValueOffIter beginValueOff()
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition Grid.h:761
openvdb::v13_0::Grid::sparseFill
void sparseFill(const CoordBBox &bbox, const ValueType &value, bool active=true)
Set all voxels within a given axis-aligned box to a constant value.
Definition Grid.h:1509
openvdb::v13_0::Grid::treePtr
TreePtrType treePtr()
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition Grid.h:890
openvdb::v13_0::Grid::writeTopology
void writeTopology(std::ostream &) const override
Write the grid topology to a stream. This will write only the grid structure, not the actual data buf...
Definition Grid.h:1618
openvdb::v13_0::Grid::merge
void merge(Grid &other, MergePolicy policy=MERGE_ACTIVE_STATES)
Efficiently merge another grid into this grid using one of several schemes.
Definition Grid.h:1546
openvdb::v13_0::Grid::unregisterGrid
static void unregisterGrid()
Remove this grid type from the registry.
Definition Grid.h:970
openvdb::v13_0::Grid::copyReplacingMetadata
ConstPtr copyReplacingMetadata(const MetaMap &meta) const
Return a new grid of the same type as this grid whose tree and transform is shared with this grid and...
Definition Grid.h:1385
openvdb::v13_0::Grid::ValueAllIter
typename _TreeType::ValueAllIter ValueAllIter
Definition Grid.h:586
openvdb::v13_0::Grid::TreeType
_TreeType TreeType
Definition Grid.h:576
openvdb::v13_0::Grid::valueType
Name valueType() const override
Return the name of the type of a voxel's value (e.g., "float" or "vec3d").
Definition Grid.h:714
openvdb::v13_0::Grid::clear
void clear() override
Empty this grid, so that all voxels become inactive background voxels.
Definition Grid.h:727
openvdb::v13_0::Grid::Grid
Grid(const GridBase &)
Deep copy another grid's metadata and transform, but construct a new tree with background value zero.
Definition Grid.h:1329
openvdb::v13_0::Grid::constTree
const TreeType & constTree() const
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition Grid.h:906
openvdb::v13_0::Grid::beginValueAll
ValueAllCIter beginValueAll() const
Return an iterator over all of this grid's values (tile and voxel).
Definition Grid.h:769
openvdb::v13_0::Grid::newTree
void newTree() override
Associate a new, empty tree with this grid, in place of its existing tree.
Definition Grid.h:1498
openvdb::v13_0::Grid::operator=
Grid & operator=(const Grid &)=delete
Disallow assignment, since it wouldn't be obvious whether the copy is deep or shallow.
openvdb::v13_0::Grid::getConstUnsafeAccessor
ConstUnsafeAccessor getConstUnsafeAccessor() const
Return an unsafe accessor that provides random read-only access to this grid's voxels.
Definition Grid.h:752
openvdb::v13_0::Grid::create
static Ptr create(TreePtrType)
Return a new grid that contains the given tree.
Definition Grid.h:1357
openvdb::v13_0::Grid::topologyUnion
void topologyUnion(const Grid< OtherTreeType > &other)
Union this grid's set of active values with the active values of the other grid, whose value type may...
Definition Grid.h:1555
openvdb::v13_0::Grid::Ptr
SharedPtr< Grid > Ptr
Definition Grid.h:573
openvdb::v13_0::Grid::getAccessor
Accessor getAccessor()
Return an accessor that provides random read and write access to this grid's voxels.
Definition Grid.h:732
openvdb::v13_0::Grid::beginValueAll
ValueAllIter beginValueAll()
Return an iterator over all of this grid's values (tile and voxel).
Definition Grid.h:767
openvdb::v13_0::Grid::create
static Ptr create()
Return a new grid with background value zero.
Definition Grid.h:1339
openvdb::v13_0::Grid::Grid
Grid(const Grid< OtherTreeType > &)
Deep copy the metadata, transform and tree of another grid whose tree configuration is the same as th...
Definition Grid.h:1313
openvdb::v13_0::MetaMap
Container that maps names (strings) to values of arbitrary types.
Definition MetaMap.h:20
openvdb::v13_0::MetaMap::metaCount
size_t metaCount() const
Definition MetaMap.h:91
openvdb::v13_0::MetaMap::beginMeta
MetaIterator beginMeta()
Definition MetaMap.h:84
openvdb::v13_0::MetaMap::ConstMetaIterator
MetadataMap::const_iterator ConstMetaIterator
Definition MetaMap.h:27
openvdb::v13_0::MetaMap::Ptr
SharedPtr< MetaMap > Ptr
Definition MetaMap.h:22
openvdb::v13_0::MetaMap::endMeta
MetaIterator endMeta()
Definition MetaMap.h:85
openvdb::v13_0::MetaMap::MetaMap
MetaMap()
Definition MetaMap.h:30
openvdb::v13_0::ShallowCopy
Tag dispatch class that distinguishes shallow copy constructors from deep copy constructors.
Definition Types.h:747
openvdb::v13_0::TypeError
Definition Exceptions.h:64
openvdb::v13_0::ValueError
Definition Exceptions.h:65
openvdb::v13_0::io::StreamMetadata::Ptr
SharedPtr< StreamMetadata > Ptr
Definition io.h:33
openvdb::v13_0::math::CoordBBox
Axis-aligned bounding box of signed integer coordinates.
Definition Coord.h:252
openvdb::v13_0::math::Coord
Signed (x, y, z) 32-bit integer coordinates.
Definition Coord.h:26
openvdb::v13_0::math::Transform
Definition Transform.h:40
openvdb::v13_0::math::Transform::ConstPtr
SharedPtr< const Transform > ConstPtr
Definition Transform.h:43
openvdb::v13_0::math::Transform::Ptr
SharedPtr< Transform > Ptr
Definition Transform.h:42
openvdb::v13_0::math::Transform::createLinearTransform
static Transform::Ptr createLinearTransform(double voxelSize=1.0)
Create and return a shared pointer to a new transform.
openvdb::v13_0::tree::TreeBase
Base class for typed trees.
Definition Tree.h:38
openvdb::v13_0::tree::TreeBase::Ptr
SharedPtr< TreeBase > Ptr
Definition Tree.h:40
openvdb::v13_0::tree::TreeBase::ConstPtr
SharedPtr< const TreeBase > ConstPtr
Definition Tree.h:41
logging.h
openvdb::v13_0::io::checkFormatVersion
OPENVDB_API void checkFormatVersion(std::ios_base &)
Throws an IoError if the file format version number is not supported.
openvdb::v13_0::io::getStreamMetadataPtr
OPENVDB_API SharedPtr< StreamMetadata > getStreamMetadataPtr(std::ios_base &)
Return a shared pointer to an object that stores metadata (file format, compression scheme,...
openvdb::v13_0::math
Definition Types.h:759
openvdb::v13_0::math::Vec3d
Vec3< double > Vec3d
Definition Vec3.h:665
openvdb::v13_0::math::cwiseAdd
auto cwiseAdd(const Vec3H &v, const float s)
Definition Types.h:761
openvdb::v13_0::tree
Definition PointDataGrid.h:170
openvdb::v13_0::tree::ValueAccessor
ValueAccessorImpl< TreeType, IsSafe, MutexType, openvdb::make_index_sequence< CacheLevels > > ValueAccessor
Default alias for a ValueAccessor. This is simply a helper alias for the generic definition but takes...
Definition ValueAccessor.h:86
openvdb::v13_0::Name
std::string Name
Definition Name.h:19
openvdb::v13_0::LEVEL_SET_HALF_WIDTH
static const Real LEVEL_SET_HALF_WIDTH
Definition Types.h:528
openvdb::v13_0::GridPtrVecCIter
GridPtrVec::const_iterator GridPtrVecCIter
Definition Grid.h:510
openvdb::v13_0::GridPtrVec
std::vector< GridBase::Ptr > GridPtrVec
Definition Grid.h:508
openvdb::v13_0::GridPtrSetPtr
SharedPtr< GridPtrSet > GridPtrSetPtr
Definition Grid.h:521
openvdb::v13_0::GridCPtrSetIter
GridCPtrSet::iterator GridCPtrSetIter
Definition Grid.h:524
openvdb::v13_0::GridCPtrSetPtr
SharedPtr< GridCPtrSet > GridCPtrSetPtr
Definition Grid.h:526
openvdb::v13_0::gridConstPtrCast
GridType::ConstPtr gridConstPtrCast(const GridBase::ConstPtr &grid)
Cast a generic const grid pointer to a const pointer to a grid of a concrete class.
Definition Grid.h:1014
openvdb::v13_0::Real
double Real
Definition Types.h:40
openvdb::v13_0::GridClass
GridClass
Definition Types.h:520
openvdb::v13_0::GRID_LEVEL_SET
@ GRID_LEVEL_SET
Definition Types.h:522
openvdb::v13_0::gridPtrCast
GridType::Ptr gridPtrCast(const GridBase::Ptr &grid)
Cast a generic grid pointer to a pointer to a grid of a concrete class.
Definition Grid.h:998
openvdb::v13_0::GridCPtrSet
std::set< GridBase::ConstPtr > GridCPtrSet
Definition Grid.h:523
openvdb::v13_0::findGridByName
GridPtrContainerT::value_type findGridByName(const GridPtrContainerT &container, const Name &name)
Return the first grid in the given container whose name is name.
Definition Grid.h:540
openvdb::v13_0::GridPtrSet
std::set< GridBase::Ptr > GridPtrSet
Definition Grid.h:518
openvdb::v13_0::GridCPtrVecPtr
SharedPtr< GridCPtrVec > GridCPtrVecPtr
Definition Grid.h:516
openvdb::v13_0::GridCPtrVecIter
GridCPtrVec::iterator GridCPtrVecIter
Definition Grid.h:514
openvdb::v13_0::zeroVal
constexpr T zeroVal()
Return the value of type T that corresponds to zero.
Definition Math.h:71
openvdb::v13_0::GridPtrVecPtr
SharedPtr< GridPtrVec > GridPtrVecPtr
Definition Grid.h:511
openvdb::v13_0::GridCPtrVecCIter
GridCPtrVec::const_iterator GridCPtrVecCIter
Definition Grid.h:515
openvdb::v13_0::GridPtrSetIter
GridPtrSet::iterator GridPtrSetIter
Definition Grid.h:519
openvdb::v13_0::ConstPtrCast
SharedPtr< T > ConstPtrCast(const SharedPtr< U > &ptr)
Return a new shared pointer that points to the same object as the given pointer but with possibly dif...
Definition Types.h:107
openvdb::v13_0::GridCPtrSetCIter
GridCPtrSet::const_iterator GridCPtrSetCIter
Definition Grid.h:525
openvdb::v13_0::BBoxd
math::BBox< Vec3d > BBoxd
Definition Types.h:65
openvdb::v13_0::GridPtrSetCIter
GridPtrSet::const_iterator GridPtrSetCIter
Definition Grid.h:520
openvdb::v13_0::createLevelSet
GridType::Ptr createLevelSet(Real voxelSize=1.0, Real halfWidth=LEVEL_SET_HALF_WIDTH)
Create a new grid of type GridType classified as a "Level Set", i.e., a narrow-band level set.
Definition Grid.h:1772
openvdb::v13_0::createGrid
GridType::Ptr createGrid(const typename GridType::ValueType &background)
Create a new grid of type GridType with a given background value.
Definition Grid.h:1747
openvdb::v13_0::Index64
uint64_t Index64
Definition Types.h:33
openvdb::v13_0::TreeBase
tree::TreeBase TreeBase
Definition Grid.h:26
openvdb::v13_0::GridPtrVecIter
GridPtrVec::iterator GridPtrVecIter
Definition Grid.h:509
openvdb::v13_0::SharedPtr
std::shared_ptr< T > SharedPtr
Definition Types.h:95
openvdb::v13_0::MergePolicy
MergePolicy
Definition Types.h:573
openvdb::v13_0::MERGE_ACTIVE_STATES
@ MERGE_ACTIVE_STATES
Definition Types.h:574
openvdb::v13_0::VecType
VecType
Definition Types.h:550
openvdb::v13_0::StaticPtrCast
SharedPtr< T > StaticPtrCast(const SharedPtr< U > &ptr)
Return a new shared pointer that points to the same object as the given pointer after a static_cast.
Definition Types.h:127
openvdb::v13_0::GridCPtrVec
std::vector< GridBase::ConstPtr > GridCPtrVec
Definition Grid.h:513
openvdb::v13_0::deepCopyTypedGrid
GridType::Ptr deepCopyTypedGrid(const GridBase::ConstPtr &grid)
Return a pointer to a deep copy of the given grid, provided that the grid's concrete type is GridType...
Definition Grid.h:1031
openvdb::v13_0::createGrid
GridType::Ptr createGrid()
Create a new grid of type GridType with background value zero.
Definition Grid.h:1755
openvdb
Definition Exceptions.h:13
Exceptions.h
OPENVDB_THROW
#define OPENVDB_THROW(exception, message)
Definition Exceptions.h:74
Types.h
io.h
openvdb::v13_0::Grid::ValueConverter
ValueConverter<T>::Type is the type of a grid having the same hierarchy as this grid but a different ...
Definition Grid.h:601
openvdb::v13_0::Grid::ValueConverter::Type
Grid< typename TreeType::template ValueConverter< OtherValueType >::Type > Type
Definition Grid.h:602
openvdb::v13_0::GridNamePred
Predicate functor that returns true for grids that have a specified name.
Definition Grid.h:531
openvdb::v13_0::GridNamePred::name
Name name
Definition Grid.h:534
openvdb::v13_0::GridNamePred::GridNamePred
GridNamePred(const Name &_name)
Definition Grid.h:532
openvdb::v13_0::GridNamePred::operator()
bool operator()(const GridBase::ConstPtr &g) const
Definition Grid.h:533
openvdb::v13_0::HasMultiPassIO< Grid< TreeType > >::value
static const bool value
Definition Grid.h:1205
openvdb::v13_0::HasMultiPassIO< tree::Tree< RootNodeType > >::value
static const bool value
Definition Grid.h:1198
openvdb::v13_0::HasMultiPassIO
Metafunction that specifies whether a given leaf node, tree, or grid type requires multiple passes to...
Definition Grid.h:1190
openvdb::v13_0::HasMultiPassIO::value
static const bool value
Definition Grid.h:1191
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::constTree
static const NonConstTreeType & constTree(NonConstTreeType &t)
Definition Grid.h:1106
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::GridType
Grid< TreeType > GridType
Definition Grid.h:1092
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::NonConstTreeType
typename std::remove_const< TreeType >::type NonConstTreeType
Definition Grid.h:1088
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::constTree
static const NonConstTreeType & constTree(const NonConstGridType &g)
Definition Grid.h:1109
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::ValueType
typename TreeType::ValueType ValueType
Definition Grid.h:1097
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::constTree
static const NonConstTreeType & constTree(const NonConstTreeType &t)
Definition Grid.h:1108
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::NonConstAccessorType
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition Grid.h:1100
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::ConstAccessorType
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition Grid.h:1099
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::tree
static const NonConstTreeType & tree(const NonConstGridType &g)
Definition Grid.h:1105
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::NonConstTreePtrType
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition Grid.h:1091
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::ConstTreePtrType
typename TreeType::ConstPtr ConstTreePtrType
Definition Grid.h:1090
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::tree
static NonConstTreeType & tree(NonConstTreeType &t)
Definition Grid.h:1102
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::tree
static NonConstTreeType & tree(NonConstGridType &g)
Definition Grid.h:1103
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::GridPtrType
typename GridType::Ptr GridPtrType
Definition Grid.h:1094
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::constTree
static const NonConstTreeType & constTree(NonConstGridType &g)
Definition Grid.h:1107
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::NonConstGridType
Grid< NonConstTreeType > NonConstGridType
Definition Grid.h:1093
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::ConstGridPtrType
typename GridType::ConstPtr ConstGridPtrType
Definition Grid.h:1096
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::TreePtrType
typename TreeType::Ptr TreePtrType
Definition Grid.h:1089
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::tree
static const NonConstTreeType & tree(const NonConstTreeType &t)
Definition Grid.h:1104
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::TreeType
_TreeType TreeType
Definition Grid.h:1087
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::NonConstGridPtrType
typename NonConstGridType::Ptr NonConstGridPtrType
Definition Grid.h:1095
openvdb::v13_0::TreeAdapter< Grid< _TreeType > >::AccessorType
typename tree::ValueAccessor< TreeType > AccessorType
Definition Grid.h:1098
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::constTree
static const NonConstTreeType & constTree(NonConstTreeType &t)
Definition Grid.h:1135
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::GridType
Grid< TreeType > GridType
Definition Grid.h:1121
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::NonConstTreeType
typename std::remove_const< TreeType >::type NonConstTreeType
Definition Grid.h:1117
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::constTree
static const NonConstTreeType & constTree(const NonConstGridType &g)
Definition Grid.h:1138
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::ValueType
typename TreeType::ValueType ValueType
Definition Grid.h:1126
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::constTree
static const NonConstTreeType & constTree(const NonConstTreeType &t)
Definition Grid.h:1137
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::NonConstAccessorType
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition Grid.h:1129
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::ConstAccessorType
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition Grid.h:1128
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::tree
static const NonConstTreeType & tree(const NonConstGridType &g)
Definition Grid.h:1134
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::NonConstTreePtrType
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition Grid.h:1120
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::ConstTreePtrType
typename TreeType::ConstPtr ConstTreePtrType
Definition Grid.h:1119
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::tree
static NonConstTreeType & tree(NonConstTreeType &t)
Definition Grid.h:1131
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::tree
static NonConstTreeType & tree(NonConstGridType &g)
Definition Grid.h:1132
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::GridPtrType
typename GridType::Ptr GridPtrType
Definition Grid.h:1123
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::constTree
static const NonConstTreeType & constTree(NonConstGridType &g)
Definition Grid.h:1136
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::NonConstGridType
Grid< NonConstTreeType > NonConstGridType
Definition Grid.h:1122
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::ConstGridPtrType
typename GridType::ConstPtr ConstGridPtrType
Definition Grid.h:1125
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::TreePtrType
typename TreeType::Ptr TreePtrType
Definition Grid.h:1118
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::tree
static const NonConstTreeType & tree(const NonConstTreeType &t)
Definition Grid.h:1133
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::TreeType
_TreeType TreeType
Definition Grid.h:1116
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::NonConstGridPtrType
typename NonConstGridType::Ptr NonConstGridPtrType
Definition Grid.h:1124
openvdb::v13_0::TreeAdapter< const Grid< _TreeType > >::AccessorType
typename tree::ValueAccessor< TreeType > AccessorType
Definition Grid.h:1127
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const NonConstTreeType & constTree(NonConstTreeType &t)
Definition Grid.h:1168
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static NonConstTreeType & tree(NonConstAccessorType &a)
Definition Grid.h:1162
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstTreeType
typename std::remove_const< TreeType >::type NonConstTreeType
Definition Grid.h:1146
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::ConstAccessorType
typename tree::ValueAccessor< const NonConstTreeType > ConstAccessorType
Definition Grid.h:1157
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const NonConstTreeType & constTree(NonConstAccessorType &a)
Definition Grid.h:1170
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const NonConstTreeType & constTree(const NonConstGridType &g)
Definition Grid.h:1173
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::ValueType
typename TreeType::ValueType ValueType
Definition Grid.h:1155
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const NonConstTreeType & constTree(const ConstAccessorType &a)
Definition Grid.h:1175
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const NonConstTreeType & constTree(const NonConstTreeType &t)
Definition Grid.h:1172
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstAccessorType
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition Grid.h:1158
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static const NonConstTreeType & tree(const ConstAccessorType &a)
Definition Grid.h:1167
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static const NonConstTreeType & tree(const NonConstGridType &g)
Definition Grid.h:1165
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static const NonConstTreeType & tree(const NonConstAccessorType &a)
Definition Grid.h:1166
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstTreePtrType
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition Grid.h:1149
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::ConstTreePtrType
typename TreeType::ConstPtr ConstTreePtrType
Definition Grid.h:1148
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static NonConstTreeType & tree(NonConstTreeType &t)
Definition Grid.h:1160
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static NonConstTreeType & tree(NonConstGridType &g)
Definition Grid.h:1161
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static const NonConstTreeType & tree(ConstAccessorType &a)
Definition Grid.h:1163
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::GridPtrType
typename GridType::Ptr GridPtrType
Definition Grid.h:1152
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const NonConstTreeType & constTree(NonConstGridType &g)
Definition Grid.h:1169
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const NonConstTreeType & constTree(const NonConstAccessorType &a)
Definition Grid.h:1174
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstGridType
Grid< NonConstTreeType > NonConstGridType
Definition Grid.h:1151
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::ConstGridPtrType
typename GridType::ConstPtr ConstGridPtrType
Definition Grid.h:1154
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::TreePtrType
typename TreeType::Ptr TreePtrType
Definition Grid.h:1147
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static const NonConstTreeType & tree(const NonConstTreeType &t)
Definition Grid.h:1164
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::TreeType
_TreeType TreeType
Definition Grid.h:1145
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::GridType
Grid< NonConstTreeType > GridType
Definition Grid.h:1150
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstGridPtrType
typename NonConstGridType::Ptr NonConstGridPtrType
Definition Grid.h:1153
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const NonConstTreeType & constTree(ConstAccessorType &a)
Definition Grid.h:1171
openvdb::v13_0::TreeAdapter< tree::ValueAccessor< _TreeType > >::AccessorType
typename tree::ValueAccessor< TreeType > AccessorType
Definition Grid.h:1156
openvdb::v13_0::TreeAdapter
This adapter allows code that is templated on a Tree type to accept either a Tree type or a Grid type...
Definition Grid.h:1056
openvdb::v13_0::TreeAdapter::constTree
static const NonConstTreeType & constTree(NonConstTreeType &t)
Definition Grid.h:1076
openvdb::v13_0::TreeAdapter::NonConstTreeType
typename std::remove_const< TreeType >::type NonConstTreeType
Definition Grid.h:1058
openvdb::v13_0::TreeAdapter::constTree
static const NonConstTreeType & constTree(const NonConstGridType &g)
Definition Grid.h:1079
openvdb::v13_0::TreeAdapter::ValueType
typename TreeType::ValueType ValueType
Definition Grid.h:1067
openvdb::v13_0::TreeAdapter::constTree
static const NonConstTreeType & constTree(const NonConstTreeType &t)
Definition Grid.h:1078
openvdb::v13_0::TreeAdapter::NonConstAccessorType
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition Grid.h:1070
openvdb::v13_0::TreeAdapter::ConstAccessorType
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition Grid.h:1069
openvdb::v13_0::TreeAdapter::tree
static const NonConstTreeType & tree(const NonConstGridType &g)
Definition Grid.h:1075
openvdb::v13_0::TreeAdapter::NonConstTreePtrType
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition Grid.h:1061
openvdb::v13_0::TreeAdapter::ConstTreePtrType
typename TreeType::ConstPtr ConstTreePtrType
Definition Grid.h:1060
openvdb::v13_0::TreeAdapter::tree
static NonConstTreeType & tree(NonConstTreeType &t)
Definition Grid.h:1072
openvdb::v13_0::TreeAdapter::tree
static NonConstTreeType & tree(NonConstGridType &g)
Definition Grid.h:1073
openvdb::v13_0::TreeAdapter::GridPtrType
typename GridType::Ptr GridPtrType
Definition Grid.h:1064
openvdb::v13_0::TreeAdapter::constTree
static const NonConstTreeType & constTree(NonConstGridType &g)
Definition Grid.h:1077
openvdb::v13_0::TreeAdapter::NonConstGridType
Grid< NonConstTreeType > NonConstGridType
Definition Grid.h:1063
openvdb::v13_0::TreeAdapter::ConstGridPtrType
typename GridType::ConstPtr ConstGridPtrType
Definition Grid.h:1066
openvdb::v13_0::TreeAdapter::TreePtrType
typename TreeType::Ptr TreePtrType
Definition Grid.h:1059
openvdb::v13_0::TreeAdapter::tree
static const NonConstTreeType & tree(const NonConstTreeType &t)
Definition Grid.h:1074
openvdb::v13_0::TreeAdapter::TreeType
_TreeType TreeType
Definition Grid.h:1057
openvdb::v13_0::TreeAdapter::GridType
Grid< NonConstTreeType > GridType
Definition Grid.h:1062
openvdb::v13_0::TreeAdapter::NonConstGridPtrType
typename NonConstGridType::Ptr NonConstGridPtrType
Definition Grid.h:1065
openvdb::v13_0::TreeAdapter::AccessorType
typename tree::ValueAccessor< TreeType > AccessorType
Definition Grid.h:1068
openvdb::v13_0::is_floating_point
Definition Types.h:503
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