OpenVDB: Grid.h Source File

OpenVDB 5.2.0

Grid.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2018 DreamWorks Animation LLC
4 //
5 // All rights reserved. This software is distributed under the
6 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
7 //
8 // Redistributions of source code must retain the above copyright
9 // and license notice and the following restrictions and disclaimer.
10 //
11 // * Neither the name of DreamWorks Animation nor the names of
12 // its contributors may be used to endorse or promote products derived
13 // from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
27 // LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
28 //
30
31 #ifndef OPENVDB_GRID_HAS_BEEN_INCLUDED
32 #define OPENVDB_GRID_HAS_BEEN_INCLUDED
33
34 #include "Exceptions.h"
35 #include "MetaMap.h"
36 #include "Types.h"
37 #include "io/io.h"
38 #include "math/Transform.h"
39 #include "tree/Tree.h"
40 #include "util/logging.h"
41 #include "util/Name.h"
42 #include <cassert>
43 #include <iostream>
44 #include <set>
45 #include <type_traits>
46 #include <vector>
47
48
49 namespace openvdb {
50 OPENVDB_USE_VERSION_NAMESPACE
51 namespace OPENVDB_VERSION_NAME {
52
53 using TreeBase = tree::TreeBase;
54
55 template<typename> class Grid; // forward declaration
56
57
62 template<typename GridType>
63 inline typename GridType::Ptr createGrid(const typename GridType::ValueType& background);
64
65
69 template<typename GridType>
70 inline typename GridType::Ptr createGrid();
71
72
77 template<typename TreePtrType>
78 inline typename Grid<typename TreePtrType::element_type>::Ptr createGrid(TreePtrType);
79
80
95 template<typename GridType>
96 typename GridType::Ptr createLevelSet(
97 Real voxelSize = 1.0, Real halfWidth = LEVEL_SET_HALF_WIDTH);
98
99
101
102
104 class OPENVDB_API GridBase: public MetaMap
105 {
106 public:
107 using Ptr = SharedPtr<GridBase>;
108 using ConstPtr = SharedPtr<const GridBase>;
109
110 using GridFactory = Ptr (*)();
111
112
113 ~GridBase() override {}
114
115 #if OPENVDB_ABI_VERSION_NUMBER <= 3
116 virtual GridBase::Ptr copyGrid(CopyPolicy treePolicy = CP_SHARE) const = 0;
119 #else
120
121 virtual GridBase::Ptr copyGrid() = 0;
124 virtual GridBase::ConstPtr copyGrid() const = 0;
126 virtual GridBase::Ptr copyGridWithNewTree() const = 0;
129 #endif
130 virtual GridBase::Ptr deepCopyGrid() const = 0;
132
133
134 //
135 // Registry methods
136 //
138 static Ptr createGrid(const Name& type);
139
141 static bool isRegistered(const Name &type);
142
144 static void clearRegistry();
145
146
147 //
148 // Grid type methods
149 //
151 virtual Name type() const = 0;
153 virtual Name valueType() const = 0;
154
156 template<typename GridType>
157 bool isType() const { return (this->type() == GridType::gridType()); }
158
160 template<typename GridType>
163 static typename GridType::Ptr grid(const GridBase::Ptr&);
164 template<typename GridType>
165 static typename GridType::ConstPtr grid(const GridBase::ConstPtr&);
166 template<typename GridType>
167 static typename GridType::ConstPtr constGrid(const GridBase::Ptr&);
168 template<typename GridType>
169 static typename GridType::ConstPtr constGrid(const GridBase::ConstPtr&);
171
173 TreeBase::Ptr baseTreePtr();
176 TreeBase::ConstPtr baseTreePtr() const { return this->constBaseTreePtr(); }
177 virtual TreeBase::ConstPtr constBaseTreePtr() const = 0;
179
181 TreeBase& baseTree() { return const_cast<TreeBase&>(this->constBaseTree()); }
186 const TreeBase& baseTree() const { return this->constBaseTree(); }
187 const TreeBase& constBaseTree() const { return *(this->constBaseTreePtr()); }
189
195 virtual void setTree(TreeBase::Ptr) = 0;
196
198 virtual void newTree() = 0;
199
201 virtual bool empty() const = 0;
203 virtual void clear() = 0;
204
210 virtual void pruneGrid(float tolerance = 0.0) = 0;
211
212 #if OPENVDB_ABI_VERSION_NUMBER >= 3
213 void clipGrid(const BBoxd&);
218
223 virtual void clip(const CoordBBox&) = 0;
224 #endif
225
226
227 //
228 // Metadata
229 //
231 std::string getName() const;
233 void setName(const std::string&);
234
236 std::string getCreator() const;
238 void setCreator(const std::string&);
239
242 bool saveFloatAsHalf() const;
243 void setSaveFloatAsHalf(bool);
244
246 GridClass getGridClass() const;
248 void setGridClass(GridClass);
250 void clearGridClass();
251
253 static std::string gridClassToString(GridClass);
255 static std::string gridClassToMenuName(GridClass);
259 static GridClass stringToGridClass(const std::string&);
260
263 VecType getVectorType() const;
266 void setVectorType(VecType);
268 void clearVectorType();
269
271 static std::string vecTypeToString(VecType);
274 static std::string vecTypeExamples(VecType);
277 static std::string vecTypeDescription(VecType);
278 static VecType stringToVecType(const std::string&);
279
283 bool isInWorldSpace() const;
285 void setIsInWorldSpace(bool);
286
287 // Standard metadata field names
288 // (These fields should normally not be accessed directly, but rather
289 // via the accessor methods above, when available.)
290 // Note: Visual C++ requires these declarations to be separate statements.
291 static const char* const META_GRID_CLASS;
292 static const char* const META_GRID_CREATOR;
293 static const char* const META_GRID_NAME;
294 static const char* const META_SAVE_HALF_FLOAT;
295 static const char* const META_IS_LOCAL_SPACE;
296 static const char* const META_VECTOR_TYPE;
297 static const char* const META_FILE_BBOX_MIN;
298 static const char* const META_FILE_BBOX_MAX;
299 static const char* const META_FILE_COMPRESSION;
300 static const char* const META_FILE_MEM_BYTES;
301 static const char* const META_FILE_VOXEL_COUNT;
302
303
304 //
305 // Statistics
306 //
308 virtual Index64 activeVoxelCount() const = 0;
309
312 virtual CoordBBox evalActiveVoxelBoundingBox() const = 0;
313
315 virtual Coord evalActiveVoxelDim() const = 0;
316
318 virtual Index64 memUsage() const = 0;
319
324 void addStatsMetadata();
329 MetaMap::Ptr getStatsMetadata() const;
330
331
332 //
333 // Transform methods
334 //
336 math::Transform::Ptr transformPtr() { return mTransform; }
339 math::Transform::ConstPtr transformPtr() const { return mTransform; }
340 math::Transform::ConstPtr constTransformPtr() const { return mTransform; }
342
343 math::Transform& transform() { return *mTransform; }
348 const math::Transform& transform() const { return *mTransform; }
349 const math::Transform& constTransform() const { return *mTransform; }
351 void setTransform(math::Transform::Ptr);
357
359 Vec3d voxelSize() const { return transform().voxelSize(); }
362 Vec3d voxelSize(const Vec3d& xyz) const { return transform().voxelSize(xyz); }
364 bool hasUniformVoxels() const { return mTransform->hasUniformScale(); }
366 Vec3d indexToWorld(const Vec3d& xyz) const { return transform().indexToWorld(xyz); }
368 Vec3d indexToWorld(const Coord& ijk) const { return transform().indexToWorld(ijk); }
370 Vec3d worldToIndex(const Vec3d& xyz) const { return transform().worldToIndex(xyz); }
372
373
374 //
375 // I/O methods
376 //
379 virtual void readTopology(std::istream&) = 0;
382 virtual void writeTopology(std::ostream&) const = 0;
383
385 virtual void readBuffers(std::istream&) = 0;
386 #if OPENVDB_ABI_VERSION_NUMBER >= 3
387 virtual void readBuffers(std::istream&, const CoordBBox&) = 0;
394 virtual void readNonresidentBuffers() const = 0;
395 #endif
396 virtual void writeBuffers(std::ostream&) const = 0;
398
400 void readTransform(std::istream& is) { transform().read(is); }
402 void writeTransform(std::ostream& os) const { transform().write(os); }
403
405 virtual void print(std::ostream& = std::cout, int verboseLevel = 1) const = 0;
406
407
408 protected:
410 GridBase(): mTransform(math::Transform::createLinearTransform()) {}
411
413 GridBase(const GridBase& other): MetaMap(other), mTransform(other.mTransform->copy()) {}
414
415 #if OPENVDB_ABI_VERSION_NUMBER <= 3
416 GridBase(const GridBase& other, ShallowCopy): MetaMap(other), mTransform(other.mTransform) {}
418 #else
419 GridBase(GridBase& other, ShallowCopy): MetaMap(other), mTransform(other.mTransform) {}
421 #endif
422
424 static void registerGrid(const Name& type, GridFactory);
426 static void unregisterGrid(const Name& type);
427
428
429 private:
430 math::Transform::Ptr mTransform;
431 }; // class GridBase
432
433
435
436
437 using GridPtrVec = std::vector<GridBase::Ptr>;
438 using GridPtrVecIter = GridPtrVec::iterator;
439 using GridPtrVecCIter = GridPtrVec::const_iterator;
440 using GridPtrVecPtr = SharedPtr<GridPtrVec>;
441
442 using GridCPtrVec = std::vector<GridBase::ConstPtr>;
443 using GridCPtrVecIter = GridCPtrVec::iterator;
444 using GridCPtrVecCIter = GridCPtrVec::const_iterator;
445 using GridCPtrVecPtr = SharedPtr<GridCPtrVec>;
446
447 using GridPtrSet = std::set<GridBase::Ptr>;
448 using GridPtrSetIter = GridPtrSet::iterator;
449 using GridPtrSetCIter = GridPtrSet::const_iterator;
450 using GridPtrSetPtr = SharedPtr<GridPtrSet>;
451
452 using GridCPtrSet = std::set<GridBase::ConstPtr>;
453 using GridCPtrSetIter = GridCPtrSet::iterator;
454 using GridCPtrSetCIter = GridCPtrSet::const_iterator;
455 using GridCPtrSetPtr = SharedPtr<GridCPtrSet>;
456
457
459 struct OPENVDB_API GridNamePred
460 {
461 GridNamePred(const Name& _name): name(_name) {}
462 bool operator()(const GridBase::ConstPtr& g) const { return g && g->getName() == name; }
463 Name name;
464 };
465
467 template<typename GridPtrContainerT>
468 inline typename GridPtrContainerT::value_type
469 findGridByName(const GridPtrContainerT& container, const Name& name)
470 {
471 using GridPtrT = typename GridPtrContainerT::value_type;
472 typename GridPtrContainerT::const_iterator it =
473 std::find_if(container.begin(), container.end(), GridNamePred(name));
474 return (it == container.end() ? GridPtrT() : *it);
475 }
476
478 template<typename KeyT, typename GridPtrT>
479 inline GridPtrT
480 findGridByName(const std::map<KeyT, GridPtrT>& container, const Name& name)
481 {
482 using GridPtrMapT = std::map<KeyT, GridPtrT>;
483 for (typename GridPtrMapT::const_iterator it = container.begin(), end = container.end();
484 it != end; ++it)
485 {
486 const GridPtrT& grid = it->second;
487 if (grid && grid->getName() == name) return grid;
488 }
489 return GridPtrT();
490 }
492
493
495
496
498 template<typename _TreeType>
499 class Grid: public GridBase
500 {
501 public:
502 using Ptr = SharedPtr<Grid>;
503 using ConstPtr = SharedPtr<const Grid>;
504
505 using TreeType = _TreeType;
506 using TreePtrType = typename _TreeType::Ptr;
507 using ConstTreePtrType = typename _TreeType::ConstPtr;
508 using ValueType = typename _TreeType::ValueType;
509 using BuildType = typename _TreeType::BuildType;
510
511 using ValueOnIter = typename _TreeType::ValueOnIter;
512 using ValueOnCIter = typename _TreeType::ValueOnCIter;
513 using ValueOffIter = typename _TreeType::ValueOffIter;
514 using ValueOffCIter = typename _TreeType::ValueOffCIter;
515 using ValueAllIter = typename _TreeType::ValueAllIter;
516 using ValueAllCIter = typename _TreeType::ValueAllCIter;
517
518 using Accessor = typename tree::ValueAccessor<_TreeType, true>;
519 using ConstAccessor = typename tree::ValueAccessor<const _TreeType, true>;
520 using UnsafeAccessor = typename tree::ValueAccessor<_TreeType, false>;
521 using ConstUnsafeAccessor = typename tree::ValueAccessor<const _TreeType, false>;
522
529 template<typename OtherValueType>
530 struct ValueConverter {
531 using Type = Grid<typename TreeType::template ValueConverter<OtherValueType>::Type>;
532 };
533
535 static Ptr create(const ValueType& background);
537 static Ptr create();
540 static Ptr create(TreePtrType);
543 static Ptr create(const GridBase& other);
544
545
547 Grid();
549 explicit Grid(const ValueType& background);
553 explicit Grid(TreePtrType);
555 Grid(const Grid&);
561 template<typename OtherTreeType>
562 explicit Grid(const Grid<OtherTreeType>&);
563 #if OPENVDB_ABI_VERSION_NUMBER <= 3
564 Grid(const Grid&, ShallowCopy);
566 #else
567 Grid(Grid&, ShallowCopy);
569 #endif
570 explicit Grid(const GridBase&);
573
574 ~Grid() override {}
575
577 Grid& operator=(const Grid&) = delete;
578
579
580 #if OPENVDB_ABI_VERSION_NUMBER <= 3
581
582 Ptr copy(CopyPolicy treePolicy = CP_SHARE) const;
589 GridBase::Ptr copyGrid(CopyPolicy treePolicy = CP_SHARE) const override;
591 #else
592
593 Ptr copy();
596 ConstPtr copy() const;
598 Ptr copyWithNewTree() const;
601
602 GridBase::Ptr copyGrid() override;
603 GridBase::ConstPtr copyGrid() const override;
604 GridBase::Ptr copyGridWithNewTree() const override;
605 #endif
606
607 Ptr deepCopy() const { return Ptr(new Grid(*this)); }
609 GridBase::Ptr deepCopyGrid() const override { return this->deepCopy(); }
611
613 Name type() const override { return this->gridType(); }
615 static Name gridType() { return TreeType::treeType(); }
616
617
618 //
619 // Voxel access methods
620 //
622 Name valueType() const override { return tree().valueType(); }
623
627 const ValueType& background() const { return mTree->background(); }
628
630 bool empty() const override { return tree().empty(); }
632 void clear() override { tree().clear(); }
633
637 Accessor getAccessor() { return Accessor(tree()); }
646 UnsafeAccessor getUnsafeAccessor() { return UnsafeAccessor(tree()); }
648 ConstAccessor getAccessor() const { return ConstAccessor(tree()); }
650 ConstAccessor getConstAccessor() const { return ConstAccessor(tree()); }
652 ConstUnsafeAccessor getConstUnsafeAccessor() const { return ConstUnsafeAccessor(tree()); }
661
663 ValueOnIter beginValueOn() { return tree().beginValueOn(); }
665 ValueOnCIter beginValueOn() const { return tree().cbeginValueOn(); }
666 ValueOnCIter cbeginValueOn() const { return tree().cbeginValueOn(); }
668
669 ValueOffIter beginValueOff() { return tree().beginValueOff(); }
671 ValueOffCIter beginValueOff() const { return tree().cbeginValueOff(); }
672 ValueOffCIter cbeginValueOff() const { return tree().cbeginValueOff(); }
674
675 ValueAllIter beginValueAll() { return tree().beginValueAll(); }
677 ValueAllCIter beginValueAll() const { return tree().cbeginValueAll(); }
678 ValueAllCIter cbeginValueAll() const { return tree().cbeginValueAll(); }
680
682 void evalMinMax(ValueType& minVal, ValueType& maxVal) const;
683
685 void sparseFill(const CoordBBox& bbox, const ValueType& value, bool active = true);
694 void fill(const CoordBBox& bbox, const ValueType& value, bool active = true);
696
703 void denseFill(const CoordBBox& bbox, const ValueType& value, bool active = true);
704
706 void pruneGrid(float tolerance = 0.0) override;
707
708 #if OPENVDB_ABI_VERSION_NUMBER >= 3
709 void clip(const CoordBBox&) override;
714 #endif
715
721 void merge(Grid& other, MergePolicy policy = MERGE_ACTIVE_STATES);
722
736 template<typename OtherTreeType>
737 void topologyUnion(const Grid<OtherTreeType>& other);
738
751 template<typename OtherTreeType>
752 void topologyIntersection(const Grid<OtherTreeType>& other);
753
764 template<typename OtherTreeType>
765 void topologyDifference(const Grid<OtherTreeType>& other);
766
767 //
768 // Statistics
769 //
771 Index64 activeVoxelCount() const override { return tree().activeVoxelCount(); }
773 CoordBBox evalActiveVoxelBoundingBox() const override;
775 Coord evalActiveVoxelDim() const override;
776
779 Index64 memUsage() const override { return tree().memUsage(); }
780
781
782 //
783 // Tree methods
784 //
786 TreePtrType treePtr() { return mTree; }
789 ConstTreePtrType treePtr() const { return mTree; }
790 ConstTreePtrType constTreePtr() const { return mTree; }
791 TreeBase::ConstPtr constBaseTreePtr() const override { return mTree; }
793
794 TreeType& tree() { return *mTree; }
799 const TreeType& tree() const { return *mTree; }
800 const TreeType& constTree() const { return *mTree; }
802
808 void setTree(TreeBase::Ptr) override;
809
812 void newTree() override;
813
814
815 //
816 // I/O methods
817 //
820 void readTopology(std::istream&) override;
823 void writeTopology(std::ostream&) const override;
824
826 void readBuffers(std::istream&) override;
827 #if OPENVDB_ABI_VERSION_NUMBER >= 3
828 void readBuffers(std::istream&, const CoordBBox&) override;
835 void readNonresidentBuffers() const override;
836 #endif
837 void writeBuffers(std::ostream&) const override;
839
841 void print(std::ostream& = std::cout, int verboseLevel = 1) const override;
842
846 static inline bool hasMultiPassIO();
847
848
849 //
850 // Registry methods
851 //
853 static bool isRegistered() { return GridBase::isRegistered(Grid::gridType()); }
855 static void registerGrid()
856 {
857 GridBase::registerGrid(Grid::gridType(), Grid::factory);
858 if (!tree::internal::LeafBufferFlags<ValueType>::IsAtomic) {
859 OPENVDB_LOG_WARN("delayed loading of grids of type " << Grid::gridType()
860 << " might not be threadsafe on this platform");
861 }
862 }
864 static void unregisterGrid() { GridBase::unregisterGrid(Grid::gridType()); }
865
866
867 private:
869 static GridBase::Ptr factory() { return Grid::create(); }
870
871 TreePtrType mTree;
872 }; // class Grid
873
874
876
877
885 template<typename GridType>
886 inline typename GridType::Ptr
887 gridPtrCast(const GridBase::Ptr& grid)
888 {
889 return GridBase::grid<GridType>(grid);
890 }
891
892
901 template<typename GridType>
902 inline typename GridType::ConstPtr
903 gridConstPtrCast(const GridBase::ConstPtr& grid)
904 {
905 return GridBase::constGrid<GridType>(grid);
906 }
907
908
910
911
918 template<typename GridType>
919 inline typename GridType::Ptr
920 deepCopyTypedGrid(const GridBase::ConstPtr& grid)
921 {
922 if (!grid || !grid->isType<GridType>()) return typename GridType::Ptr();
923 return gridPtrCast<GridType>(grid->deepCopyGrid());
924 }
925
926
927 template<typename GridType>
928 inline typename GridType::Ptr
929 deepCopyTypedGrid(const GridBase& grid)
930 {
931 if (!grid.isType<GridType>()) return typename GridType::Ptr();
932 return gridPtrCast<GridType>(grid.deepCopyGrid());
933 }
935
936
938
939
941 template<typename _TreeType>
944 struct TreeAdapter
945 {
946 using TreeType = _TreeType;
947 using NonConstTreeType = typename std::remove_const<TreeType>::type;
948 using TreePtrType = typename TreeType::Ptr;
949 using ConstTreePtrType = typename TreeType::ConstPtr;
950 using NonConstTreePtrType = typename NonConstTreeType::Ptr;
951 using GridType = Grid<TreeType>;
952 using NonConstGridType = Grid<NonConstTreeType>;
953 using GridPtrType = typename GridType::Ptr;
954 using NonConstGridPtrType = typename NonConstGridType::Ptr;
955 using ConstGridPtrType = typename GridType::ConstPtr;
956 using ValueType = typename TreeType::ValueType;
957 using AccessorType = typename tree::ValueAccessor<TreeType>;
958 using ConstAccessorType = typename tree::ValueAccessor<const TreeType>;
959 using NonConstAccessorType = typename tree::ValueAccessor<NonConstTreeType>;
960
961 static TreeType& tree(TreeType& t) { return t; }
962 static TreeType& tree(GridType& g) { return g.tree(); }
963 static const TreeType& tree(const TreeType& t) { return t; }
964 static const TreeType& tree(const GridType& g) { return g.tree(); }
965 static const TreeType& constTree(TreeType& t) { return t; }
966 static const TreeType& constTree(GridType& g) { return g.constTree(); }
967 static const TreeType& constTree(const TreeType& t) { return t; }
968 static const TreeType& constTree(const GridType& g) { return g.constTree(); }
969 };
970
971
973 template<typename _TreeType>
974 struct TreeAdapter<Grid<_TreeType> >
975 {
976 using TreeType = _TreeType;
977 using NonConstTreeType = typename std::remove_const<TreeType>::type;
978 using TreePtrType = typename TreeType::Ptr;
979 using ConstTreePtrType = typename TreeType::ConstPtr;
980 using NonConstTreePtrType = typename NonConstTreeType::Ptr;
981 using GridType = Grid<TreeType>;
982 using NonConstGridType = Grid<NonConstTreeType>;
983 using GridPtrType = typename GridType::Ptr;
984 using NonConstGridPtrType = typename NonConstGridType::Ptr;
985 using ConstGridPtrType = typename GridType::ConstPtr;
986 using ValueType = typename TreeType::ValueType;
987 using AccessorType = typename tree::ValueAccessor<TreeType>;
988 using ConstAccessorType = typename tree::ValueAccessor<const TreeType>;
989 using NonConstAccessorType = typename tree::ValueAccessor<NonConstTreeType>;
990
991 static TreeType& tree(TreeType& t) { return t; }
992 static TreeType& tree(GridType& g) { return g.tree(); }
993 static const TreeType& tree(const TreeType& t) { return t; }
994 static const TreeType& tree(const GridType& g) { return g.tree(); }
995 static const TreeType& constTree(TreeType& t) { return t; }
996 static const TreeType& constTree(GridType& g) { return g.constTree(); }
997 static const TreeType& constTree(const TreeType& t) { return t; }
998 static const TreeType& constTree(const GridType& g) { return g.constTree(); }
999 };
1000
1002 template<typename _TreeType>
1003 struct TreeAdapter<tree::ValueAccessor<_TreeType> >
1004 {
1005 using TreeType = _TreeType;
1006 using NonConstTreeType = typename std::remove_const<TreeType>::type;
1007 using TreePtrType = typename TreeType::Ptr;
1008 using ConstTreePtrType = typename TreeType::ConstPtr;
1009 using NonConstTreePtrType = typename NonConstTreeType::Ptr;
1010 using GridType = Grid<TreeType>;
1011 using NonConstGridType = Grid<NonConstTreeType>;
1012 using GridPtrType = typename GridType::Ptr;
1013 using NonConstGridPtrType = typename NonConstGridType::Ptr;
1014 using ConstGridPtrType = typename GridType::ConstPtr;
1015 using ValueType = typename TreeType::ValueType;
1016 using AccessorType = typename tree::ValueAccessor<TreeType>;
1017 using ConstAccessorType = typename tree::ValueAccessor<const TreeType>;
1018 using NonConstAccessorType = typename tree::ValueAccessor<NonConstTreeType>;
1019
1020 static TreeType& tree(TreeType& t) { return t; }
1021 static TreeType& tree(GridType& g) { return g.tree(); }
1022 static TreeType& tree(AccessorType& a) { return a.tree(); }
1023 static const TreeType& tree(const TreeType& t) { return t; }
1024 static const TreeType& tree(const GridType& g) { return g.tree(); }
1025 static const TreeType& tree(const AccessorType& a) { return a.tree(); }
1026 static const TreeType& constTree(TreeType& t) { return t; }
1027 static const TreeType& constTree(GridType& g) { return g.constTree(); }
1028 static const TreeType& constTree(const TreeType& t) { return t; }
1029 static const TreeType& constTree(const GridType& g) { return g.constTree(); }
1030 };
1031
1033
1034
1036
1037
1043 template<typename LeafNodeType>
1044 struct HasMultiPassIO {
1045 static const bool value = std::is_base_of<io::MultiPass, LeafNodeType>::value;
1046 };
1047
1048 // Partial specialization for Tree types
1049 template<typename RootNodeType>
1050 struct HasMultiPassIO<tree::Tree<RootNodeType>> {
1051 // A tree is multi-pass if its (root node's) leaf node type is multi-pass.
1052 static const bool value = HasMultiPassIO<typename RootNodeType::LeafNodeType>::value;
1053 };
1054
1055 // Partial specialization for Grid types
1056 template<typename TreeType>
1057 struct HasMultiPassIO<Grid<TreeType>> {
1058 // A grid is multi-pass if its tree's leaf node type is multi-pass.
1059 static const bool value = HasMultiPassIO<typename TreeType::LeafNodeType>::value;
1060 };
1061
1062
1064
1065
1066 template<typename GridType>
1067 inline typename GridType::Ptr
1068 GridBase::grid(const GridBase::Ptr& grid)
1069 {
1070 // The string comparison on type names is slower than a dynamic pointer cast, but
1071 // it is safer when pointers cross DSO boundaries, as they do in many Houdini nodes.
1072 if (grid && grid->type() == GridType::gridType()) {
1073 return StaticPtrCast<GridType>(grid);
1074 }
1075 return typename GridType::Ptr();
1076 }
1077
1078
1079 template<typename GridType>
1080 inline typename GridType::ConstPtr
1081 GridBase::grid(const GridBase::ConstPtr& grid)
1082 {
1083 return ConstPtrCast<const GridType>(
1084 GridBase::grid<GridType>(ConstPtrCast<GridBase>(grid)));
1085 }
1086
1087
1088 template<typename GridType>
1089 inline typename GridType::ConstPtr
1090 GridBase::constGrid(const GridBase::Ptr& grid)
1091 {
1092 return ConstPtrCast<const GridType>(GridBase::grid<GridType>(grid));
1093 }
1094
1095
1096 template<typename GridType>
1097 inline typename GridType::ConstPtr
1098 GridBase::constGrid(const GridBase::ConstPtr& grid)
1099 {
1100 return ConstPtrCast<const GridType>(
1101 GridBase::grid<GridType>(ConstPtrCast<GridBase>(grid)));
1102 }
1103
1104
1105 inline TreeBase::Ptr
1106 GridBase::baseTreePtr()
1107 {
1108 return ConstPtrCast<TreeBase>(this->constBaseTreePtr());
1109 }
1110
1111
1112 inline void
1113 GridBase::setTransform(math::Transform::Ptr xform)
1114 {
1115 if (!xform) OPENVDB_THROW(ValueError, "Transform pointer is null");
1116 mTransform = xform;
1117 }
1118
1119
1121
1122
1123 template<typename TreeT>
1124 inline Grid<TreeT>::Grid(): mTree(new TreeType)
1125 {
1126 }
1127
1128
1129 template<typename TreeT>
1130 inline Grid<TreeT>::Grid(const ValueType &background): mTree(new TreeType(background))
1131 {
1132 }
1133
1134
1135 template<typename TreeT>
1136 inline Grid<TreeT>::Grid(TreePtrType tree): mTree(tree)
1137 {
1138 if (!tree) OPENVDB_THROW(ValueError, "Tree pointer is null");
1139 }
1140
1141
1142 template<typename TreeT>
1143 inline Grid<TreeT>::Grid(const Grid& other):
1144 GridBase(other),
1145 mTree(StaticPtrCast<TreeType>(other.mTree->copy()))
1146 {
1147 }
1148
1149
1150 template<typename TreeT>
1151 template<typename OtherTreeType>
1152 inline Grid<TreeT>::Grid(const Grid<OtherTreeType>& other):
1153 GridBase(other),
1154 mTree(new TreeType(other.constTree()))
1155 {
1156 }
1157
1158
1159 #if OPENVDB_ABI_VERSION_NUMBER <= 3
1160 template<typename TreeT>
1161 inline Grid<TreeT>::Grid(const Grid& other, ShallowCopy):
1162 GridBase(other, ShallowCopy()),
1163 mTree(other.mTree)
1164 {
1165 }
1166 #else
1167 template<typename TreeT>
1168 inline Grid<TreeT>::Grid(Grid& other, ShallowCopy):
1169 GridBase(other),
1170 mTree(other.mTree)
1171 {
1172 }
1173 #endif
1174
1175
1176 template<typename TreeT>
1177 inline Grid<TreeT>::Grid(const GridBase& other):
1178 GridBase(other),
1179 mTree(new TreeType)
1180 {
1181 }
1182
1183
1184 //static
1185 template<typename TreeT>
1186 inline typename Grid<TreeT>::Ptr
1187 Grid<TreeT>::create()
1188 {
1189 return Grid::create(zeroVal<ValueType>());
1190 }
1191
1192
1193 //static
1194 template<typename TreeT>
1195 inline typename Grid<TreeT>::Ptr
1196 Grid<TreeT>::create(const ValueType& background)
1197 {
1198 return Ptr(new Grid(background));
1199 }
1200
1201
1202 //static
1203 template<typename TreeT>
1204 inline typename Grid<TreeT>::Ptr
1205 Grid<TreeT>::create(TreePtrType tree)
1206 {
1207 return Ptr(new Grid(tree));
1208 }
1209
1210
1211 //static
1212 template<typename TreeT>
1213 inline typename Grid<TreeT>::Ptr
1214 Grid<TreeT>::create(const GridBase& other)
1215 {
1216 return Ptr(new Grid(other));
1217 }
1218
1219
1221
1222
1223 #if OPENVDB_ABI_VERSION_NUMBER <= 3
1224
1225 template<typename TreeT>
1226 inline typename Grid<TreeT>::Ptr
1227 Grid<TreeT>::copy(CopyPolicy treePolicy) const
1228 {
1229 Ptr ret;
1230 switch (treePolicy) {
1231 case CP_NEW:
1232 ret.reset(new Grid(*this, ShallowCopy()));
1233 ret->newTree();
1234 break;
1235 case CP_COPY:
1236 ret.reset(new Grid(*this));
1237 break;
1238 case CP_SHARE:
1239 ret.reset(new Grid(*this, ShallowCopy()));
1240 break;
1241 }
1242 return ret;
1243 }
1244
1245
1246 template<typename TreeT>
1247 inline GridBase::Ptr
1248 Grid<TreeT>::copyGrid(CopyPolicy treePolicy) const
1249 {
1250 return this->copy(treePolicy);
1251 }
1252
1253 #else // if OPENVDB_ABI_VERSION_NUMBER > 3
1254
1255 template<typename TreeT>
1256 inline typename Grid<TreeT>::ConstPtr
1257 Grid<TreeT>::copy() const
1258 {
1259 return ConstPtr{new Grid{*const_cast<Grid*>(this), ShallowCopy{}}};
1260 }
1261
1262 template<typename TreeT>
1263 inline typename Grid<TreeT>::Ptr
1264 Grid<TreeT>::copy()
1265 {
1266 return Ptr{new Grid{*this, ShallowCopy{}}};
1267 }
1268
1269
1270 template<typename TreeT>
1271 inline typename Grid<TreeT>::Ptr
1272 Grid<TreeT>::copyWithNewTree() const
1273 {
1274 Ptr result{new Grid{*const_cast<Grid*>(this), ShallowCopy{}}};
1275 result->newTree();
1276 return result;
1277 }
1278
1279
1280 template<typename TreeT>
1281 inline GridBase::Ptr
1282 Grid<TreeT>::copyGrid()
1283 {
1284 return this->copy();
1285 }
1286
1287 template<typename TreeT>
1288 inline GridBase::ConstPtr
1289 Grid<TreeT>::copyGrid() const
1290 {
1291 return this->copy();
1292 }
1293
1294
1295 template<typename TreeT>
1296 inline GridBase::Ptr
1297 Grid<TreeT>::copyGridWithNewTree() const
1298 {
1299 return this->copyWithNewTree();
1300 }
1301
1302 #endif
1303
1304
1306
1307
1308 template<typename TreeT>
1309 inline void
1310 Grid<TreeT>::setTree(TreeBase::Ptr tree)
1311 {
1312 if (!tree) OPENVDB_THROW(ValueError, "Tree pointer is null");
1313 if (tree->type() != TreeType::treeType()) {
1314 OPENVDB_THROW(TypeError, "Cannot assign a tree of type "
1315 + tree->type() + " to a grid of type " + this->type());
1316 }
1317 mTree = StaticPtrCast<TreeType>(tree);
1318 }
1319
1320
1321 template<typename TreeT>
1322 inline void
1323 Grid<TreeT>::newTree()
1324 {
1325 mTree.reset(new TreeType(this->background()));
1326 }
1327
1328
1330
1331
1332 template<typename TreeT>
1333 inline void
1334 Grid<TreeT>::sparseFill(const CoordBBox& bbox, const ValueType& value, bool active)
1335 {
1336 tree().sparseFill(bbox, value, active);
1337 }
1338
1339
1340 template<typename TreeT>
1341 inline void
1342 Grid<TreeT>::fill(const CoordBBox& bbox, const ValueType& value, bool active)
1343 {
1344 this->sparseFill(bbox, value, active);
1345 }
1346
1347 template<typename TreeT>
1348 inline void
1349 Grid<TreeT>::denseFill(const CoordBBox& bbox, const ValueType& value, bool active)
1350 {
1351 tree().denseFill(bbox, value, active);
1352 }
1353
1354 template<typename TreeT>
1355 inline void
1356 Grid<TreeT>::pruneGrid(float tolerance)
1357 {
1358 this->tree().prune(ValueType(zeroVal<ValueType>() + tolerance));
1359 }
1360
1361 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1362 template<typename TreeT>
1363 inline void
1364 Grid<TreeT>::clip(const CoordBBox& bbox)
1365 {
1366 tree().clip(bbox);
1367 }
1368 #endif
1369
1370
1371 template<typename TreeT>
1372 inline void
1373 Grid<TreeT>::merge(Grid& other, MergePolicy policy)
1374 {
1375 tree().merge(other.tree(), policy);
1376 }
1377
1378
1379 template<typename TreeT>
1380 template<typename OtherTreeType>
1381 inline void
1382 Grid<TreeT>::topologyUnion(const Grid<OtherTreeType>& other)
1383 {
1384 tree().topologyUnion(other.tree());
1385 }
1386
1387
1388 template<typename TreeT>
1389 template<typename OtherTreeType>
1390 inline void
1391 Grid<TreeT>::topologyIntersection(const Grid<OtherTreeType>& other)
1392 {
1393 tree().topologyIntersection(other.tree());
1394 }
1395
1396
1397 template<typename TreeT>
1398 template<typename OtherTreeType>
1399 inline void
1400 Grid<TreeT>::topologyDifference(const Grid<OtherTreeType>& other)
1401 {
1402 tree().topologyDifference(other.tree());
1403 }
1404
1405
1407
1408
1409 template<typename TreeT>
1410 inline void
1411 Grid<TreeT>::evalMinMax(ValueType& minVal, ValueType& maxVal) const
1412 {
1413 tree().evalMinMax(minVal, maxVal);
1414 }
1415
1416
1417 template<typename TreeT>
1418 inline CoordBBox
1419 Grid<TreeT>::evalActiveVoxelBoundingBox() const
1420 {
1421 CoordBBox bbox;
1422 tree().evalActiveVoxelBoundingBox(bbox);
1423 return bbox;
1424 }
1425
1426
1427 template<typename TreeT>
1428 inline Coord
1429 Grid<TreeT>::evalActiveVoxelDim() const
1430 {
1431 Coord dim;
1432 const bool nonempty = tree().evalActiveVoxelDim(dim);
1433 return (nonempty ? dim : Coord());
1434 }
1435
1436
1438
1439
1442
1443 template<typename TreeT>
1444 inline void
1445 Grid<TreeT>::readTopology(std::istream& is)
1446 {
1447 tree().readTopology(is, saveFloatAsHalf());
1448 }
1449
1450
1451 template<typename TreeT>
1452 inline void
1453 Grid<TreeT>::writeTopology(std::ostream& os) const
1454 {
1455 tree().writeTopology(os, saveFloatAsHalf());
1456 }
1457
1458
1459 template<typename TreeT>
1460 inline void
1461 Grid<TreeT>::readBuffers(std::istream& is)
1462 {
1463 if (!hasMultiPassIO() || (io::getFormatVersion(is) < OPENVDB_FILE_VERSION_MULTIPASS_IO)) {
1464 tree().readBuffers(is, saveFloatAsHalf());
1465 } else {
1466 uint16_t numPasses = 1;
1467 is.read(reinterpret_cast<char*>(&numPasses), sizeof(uint16_t));
1468 const io::StreamMetadata::Ptr meta = io::getStreamMetadataPtr(is);
1469 assert(bool(meta));
1470 for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1471 uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1472 meta->setPass(pass);
1473 tree().readBuffers(is, saveFloatAsHalf());
1474 }
1475 }
1476 }
1477
1478
1479 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1480
1483 template<typename TreeT>
1484 inline void
1485 Grid<TreeT>::readBuffers(std::istream& is, const CoordBBox& bbox)
1486 {
1487 if (!hasMultiPassIO() || (io::getFormatVersion(is) < OPENVDB_FILE_VERSION_MULTIPASS_IO)) {
1488 tree().readBuffers(is, bbox, saveFloatAsHalf());
1489 } else {
1490 uint16_t numPasses = 1;
1491 is.read(reinterpret_cast<char*>(&numPasses), sizeof(uint16_t));
1492 const io::StreamMetadata::Ptr meta = io::getStreamMetadataPtr(is);
1493 assert(bool(meta));
1494 for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1495 uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1496 meta->setPass(pass);
1497 tree().readBuffers(is, saveFloatAsHalf());
1498 }
1499 // Cannot clip inside readBuffers() when using multiple passes,
1500 // so instead clip afterwards.
1501 tree().clip(bbox);
1502 }
1503 }
1504
1505
1506 template<typename TreeT>
1507 inline void
1508 Grid<TreeT>::readNonresidentBuffers() const
1509 {
1510 tree().readNonresidentBuffers();
1511 }
1512
1513 #endif
1514
1515
1516 template<typename TreeT>
1517 inline void
1518 Grid<TreeT>::writeBuffers(std::ostream& os) const
1519 {
1520 if (!hasMultiPassIO()) {
1521 tree().writeBuffers(os, saveFloatAsHalf());
1522 } else {
1523 // Determine how many leaf buffer passes are required for this grid
1524 const io::StreamMetadata::Ptr meta = io::getStreamMetadataPtr(os);
1525 assert(bool(meta));
1526 uint16_t numPasses = 1;
1527 meta->setCountingPasses(true);
1528 meta->setPass(0);
1529 tree().writeBuffers(os, saveFloatAsHalf());
1530 numPasses = static_cast<uint16_t>(meta->pass());
1531 os.write(reinterpret_cast<const char*>(&numPasses), sizeof(uint16_t));
1532 meta->setCountingPasses(false);
1533
1534 // Save out the data blocks of the grid.
1535 for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1536 uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1537 meta->setPass(pass);
1538 tree().writeBuffers(os, saveFloatAsHalf());
1539 }
1540 }
1541 }
1542
1543
1544 //static
1545 template<typename TreeT>
1546 inline bool
1547 Grid<TreeT>::hasMultiPassIO()
1548 {
1549 return HasMultiPassIO<Grid>::value;
1550 }
1551
1552
1553 template<typename TreeT>
1554 inline void
1555 Grid<TreeT>::print(std::ostream& os, int verboseLevel) const
1556 {
1557 tree().print(os, verboseLevel);
1558
1559 if (metaCount() > 0) {
1560 os << "Additional metadata:" << std::endl;
1561 for (ConstMetaIterator it = beginMeta(), end = endMeta(); it != end; ++it) {
1562 os << " " << it->first;
1563 if (it->second) {
1564 const std::string value = it->second->str();
1565 if (!value.empty()) os << ": " << value;
1566 }
1567 os << "\n";
1568 }
1569 }
1570
1571 os << "Transform:" << std::endl;
1572 transform().print(os, /*indent=*/" ");
1573 os << std::endl;
1574 }
1575
1576
1578
1579
1580 template<typename GridType>
1581 inline typename GridType::Ptr
1582 createGrid(const typename GridType::ValueType& background)
1583 {
1584 return GridType::create(background);
1585 }
1586
1587
1588 template<typename GridType>
1589 inline typename GridType::Ptr
1590 createGrid()
1591 {
1592 return GridType::create();
1593 }
1594
1595
1596 template<typename TreePtrType>
1597 inline typename Grid<typename TreePtrType::element_type>::Ptr
1598 createGrid(TreePtrType tree)
1599 {
1600 using TreeType = typename TreePtrType::element_type;
1601 return Grid<TreeType>::create(tree);
1602 }
1603
1604
1605 template<typename GridType>
1606 typename GridType::Ptr
1607 createLevelSet(Real voxelSize, Real halfWidth)
1608 {
1609 using ValueType = typename GridType::ValueType;
1610
1611 // GridType::ValueType is required to be a floating-point scalar.
1612 static_assert(std::is_floating_point<ValueType>::value,
1613 "level-set grids must be floating-point-valued");
1614
1615 typename GridType::Ptr grid = GridType::create(
1616 /*background=*/static_cast<ValueType>(voxelSize * halfWidth));
1617 grid->setTransform(math::Transform::createLinearTransform(voxelSize));
1618 grid->setGridClass(GRID_LEVEL_SET);
1619 return grid;
1620 }
1621
1622 } // namespace OPENVDB_VERSION_NAME
1623 } // namespace openvdb
1624
1625 #endif // OPENVDB_GRID_HAS_BEEN_INCLUDED
1626
1627 // Copyright (c) 2012-2018 DreamWorks Animation LLC
1628 // All rights reserved. This software is distributed under the
1629 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
openvdb::v5_2::tree::TreeBase::ConstPtr
SharedPtr< const TreeBase > ConstPtr
Definition: Tree.h:66
openvdb::v5_2::Grid::activeVoxelCount
Index64 activeVoxelCount() const override
Return the number of active voxels.
Definition: Grid.h:771
openvdb::v5_2::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:903
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::constTree
static const TreeType & constTree(GridType &g)
Definition: Grid.h:996
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::GridPtrType
typename GridType::Ptr GridPtrType
Definition: Grid.h:983
openvdb::v5_2::GridBase::META_GRID_CLASS
static const char *const META_GRID_CLASS
Definition: Grid.h:291
openvdb::v5_2::Grid::setTree
void setTree(TreeBase::Ptr) override
Associate the given tree with this grid, in place of its existing tree.
Definition: Grid.h:1310
openvdb::v5_2::math::CoordBBox
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:264
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static TreeType & tree(AccessorType &a)
Definition: Grid.h:1022
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::AccessorType
typename tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:987
OPENVDB_API
#define OPENVDB_API
Helper macros for defining library symbol visibility.
Definition: Platform.h:194
openvdb::v5_2::GridCPtrSetIter
GridCPtrSet::iterator GridCPtrSetIter
Definition: Grid.h:453
openvdb::v5_2::TreeAdapter::constTree
static const TreeType & constTree(GridType &g)
Definition: Grid.h:966
openvdb::v5_2::GridBase::META_FILE_COMPRESSION
static const char *const META_FILE_COMPRESSION
Definition: Grid.h:299
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::tree
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:993
openvdb::v5_2::GridPtrSet
std::set< GridBase::Ptr > GridPtrSet
Definition: Grid.h:447
openvdb::v5_2::Real
double Real
Definition: Types.h:67
openvdb::v5_2::Grid::newTree
void newTree() override
Associate a new, empty tree with this grid, in place of its existing tree.
Definition: Grid.h:1323
openvdb::v5_2::GridCPtrSet
std::set< GridBase::ConstPtr > GridCPtrSet
Definition: Grid.h:452
openvdb::v5_2::io::getGridClass
OPENVDB_API uint32_t getGridClass(std::ios_base &)
Return the class (GRID_LEVEL_SET, GRID_UNKNOWN, etc.) of the grid currently being read from or writte...
Types.h
openvdb::v5_2::GridBase::baseTreePtr
TreeBase::ConstPtr baseTreePtr() const
Return a pointer to this grid&#39;s tree, which might be shared with other grids. The pointer is guarante...
Definition: Grid.h:176
openvdb::v5_2::GridBase::isType
bool isType() const
Return true if this grid is of the same type as the template parameter.
Definition: Grid.h:157
openvdb::v5_2::TreeAdapter::tree
static TreeType & tree(TreeType &t)
Definition: Grid.h:961
openvdb::v5_2::Grid::ValueConverter
ValueConverter<T>::Type is the type of a grid having the same hierarchy as this grid but a different ...
Definition: Grid.h:530
openvdb::v5_2::GridBase::META_VECTOR_TYPE
static const char *const META_VECTOR_TYPE
Definition: Grid.h:296
openvdb::v5_2::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:1297
openvdb::v5_2::TreeAdapter::constTree
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:965
MetaMap.h
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::GridPtrType
typename GridType::Ptr GridPtrType
Definition: Grid.h:1012
openvdb::v5_2::Grid::clear
void clear() override
Empty this grid, so that all voxels become inactive background voxels.
Definition: Grid.h:632
openvdb::v5_2::TreeAdapter::tree
static TreeType & tree(GridType &g)
Definition: Grid.h:962
openvdb::v5_2::Grid::beginValueOff
ValueOffCIter beginValueOff() const
Return an iterator over all of this grid&#39;s inactive values (tile and voxel).
Definition: Grid.h:671
openvdb::v5_2::GridBase::indexToWorld
Vec3d indexToWorld(const Coord &ijk) const
Apply this grid&#39;s transform to the given coordinates.
Definition: Grid.h:368
openvdb::v5_2::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:1373
openvdb::v5_2::Grid::ValueType
typename _TreeType::ValueType ValueType
Definition: Grid.h:508
openvdb::v5_2::Grid::beginValueAll
ValueAllCIter beginValueAll() const
Return an iterator over all of this grid&#39;s values (tile and voxel).
Definition: Grid.h:677
openvdb::v5_2::GridBase::readTransform
void readTransform(std::istream &is)
Read in the transform for this grid.
Definition: Grid.h:400
openvdb::v5_2::io::getFormatVersion
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
openvdb::v5_2::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:1068
openvdb::v5_2::TreeAdapter::NonConstGridPtrType
typename NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:954
openvdb::v5_2::math::BBox< Vec3d >
openvdb::v5_2::math::Transform::Ptr
SharedPtr< Transform > Ptr
Definition: Transform.h:69
openvdb::v5_2::TreeBase
tree::TreeBase TreeBase
Definition: Grid.h:53
openvdb::v5_2::Grid::ConstTreePtrType
typename _TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:507
OPENVDB_THROW
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:109
openvdb::v5_2::TreeAdapter::AccessorType
typename tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:957
openvdb::v5_2::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:1445
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::ConstGridPtrType
typename GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:985
openvdb::v5_2::Grid::cbeginValueAll
ValueAllCIter cbeginValueAll() const
Return an iterator over all of this grid&#39;s values (tile and voxel).
Definition: Grid.h:678
openvdb::v5_2::math::Coord
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:51
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::constTree
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:997
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::NonConstAccessorType
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:989
openvdb::v5_2::Name
std::string Name
Definition: Name.h:44
openvdb::v5_2::Grid::readNonresidentBuffers
void readNonresidentBuffers() const override
Read all of this grid&#39;s data buffers that are not yet resident in memory (because delayed loading is ...
Definition: Grid.h:1508
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::ConstGridPtrType
typename GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:1014
openvdb::v5_2::GridBase::registerGrid
static void registerGrid(const Name &type, GridFactory)
Register a grid type along with a factory function.
openvdb::v5_2::TypeError
Definition: Exceptions.h:91
openvdb::v5_2::GridNamePred::GridNamePred
GridNamePred(const Name &_name)
Definition: Grid.h:461
openvdb::v5_2::GridNamePred::name
Name name
Definition: Grid.h:463
openvdb::v5_2::GridBase::setTransform
void setTransform(math::Transform::Ptr)
Associate the given transform with this grid, in place of its existing transform. ...
Definition: Grid.h:1113
openvdb::v5_2::HasMultiPassIO
Metafunction that specifies whether a given leaf node, tree, or grid type requires multiple passes to...
Definition: Grid.h:1044
openvdb::v5_2::SharedPtr
std::shared_ptr< T > SharedPtr
Definition: Types.h:139
openvdb::v5_2::Grid::constBaseTreePtr
TreeBase::ConstPtr constBaseTreePtr() const override
Return a pointer to this grid&#39;s tree, which might be shared with other grids. The pointer is guarante...
Definition: Grid.h:791
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstAccessorType
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:1018
openvdb::v5_2::Grid::ConstPtr
SharedPtr< const Grid > ConstPtr
Definition: Grid.h:503
openvdb::v5_2::Grid::constTreePtr
ConstTreePtrType constTreePtr() const
Return a pointer to this grid&#39;s tree, which might be shared with other grids. The pointer is guarante...
Definition: Grid.h:790
openvdb::v5_2::deepCopyTypedGrid
GridType::Ptr deepCopyTypedGrid(const GridBase &grid)
Return a pointer to a deep copy of the given grid, provided that the grid&#39;s concrete type is GridType...
Definition: Grid.h:929
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::ConstAccessorType
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:988
openvdb::v5_2::GridPtrVecCIter
GridPtrVec::const_iterator GridPtrVecCIter
Definition: Grid.h:439
openvdb::v5_2::Grid::Accessor
typename tree::ValueAccessor< _TreeType, true > Accessor
Definition: Grid.h:518
openvdb::v5_2::TreeAdapter::tree
static const TreeType & tree(const GridType &g)
Definition: Grid.h:964
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static const TreeType & tree(const GridType &g)
Definition: Grid.h:1024
openvdb::v5_2::Grid::getAccessor
Accessor getAccessor()
Return an accessor that provides random read and write access to this grid&#39;s voxels. The accessor is safe in the sense that it is registered by the tree of this grid.
Definition: Grid.h:637
openvdb::v5_2::GridBase::constGrid
static GridType::ConstPtr constGrid(const GridBase::Ptr &)
Return the result of downcasting a GridBase pointer to a Grid pointer of the specified type...
Definition: Grid.h:1090
openvdb::v5_2::Grid::constTree
const TreeType & constTree() const
Return a reference to this grid&#39;s tree, which might be shared with other grids.
Definition: Grid.h:800
openvdb::v5_2::MetaMap
Container that maps names (strings) to values of arbitrary types.
Definition: MetaMap.h:46
openvdb::v5_2::GridBase::hasUniformVoxels
bool hasUniformVoxels() const
Return true if the voxels in world space are uniformly sized cubes.
Definition: Grid.h:364
Transform.h
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::ConstTreePtrType
typename TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:1008
openvdb::v5_2::TreeAdapter::ValueType
typename TreeType::ValueType ValueType
Definition: Grid.h:956
openvdb::v5_2::Grid::ConstAccessor
typename tree::ValueAccessor< const _TreeType, true > ConstAccessor
Definition: Grid.h:519
openvdb::v5_2::Grid::evalMinMax
void evalMinMax(ValueType &minVal, ValueType &maxVal) const
Return the minimum and maximum active values in this grid.
Definition: Grid.h:1411
io.h
openvdb::v5_2::Grid::deepCopyGrid
GridBase::Ptr deepCopyGrid() const override
Return a new grid whose metadata, transform and tree are deep copies of this grid&#39;s.
Definition: Grid.h:609
openvdb::v5_2::GridBase::transform
const math::Transform & transform() const
Return a reference to this grid&#39;s transform, which might be shared with other grids.
Definition: Grid.h:348
openvdb::v5_2::Grid::ConstUnsafeAccessor
typename tree::ValueAccessor< const _TreeType, false > ConstUnsafeAccessor
Definition: Grid.h:521
openvdb::v5_2::createGrid
GridType::Ptr createGrid(const typename GridType::ValueType &background)
Create a new grid of type GridType with a given background value.
Definition: Grid.h:1582
openvdb::v5_2::GridBase::isRegistered
static bool isRegistered(const Name &type)
Return true if the given grid type name is registered.
logging.h
openvdb::v5_2::tree::TreeBase
Base class for typed trees.
Definition: Tree.h:62
openvdb::v5_2::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:1547
openvdb::v5_2::tree::internal::LeafBufferFlags
Definition: LeafBuffer.h:67
openvdb::v5_2::Grid::print
void print(std::ostream &=std::cout, int verboseLevel=1) const override
Output a human-readable description of this grid.
Definition: Grid.h:1555
openvdb::v5_2::Grid::getConstAccessor
ConstAccessor getConstAccessor() const
Return an accessor that provides random read-only access to this grid&#39;s voxels.
Definition: Grid.h:650
openvdb::v5_2::GRID_LEVEL_SET
Definition: Types.h:277
openvdb::v5_2::GridBase::GridFactory
Ptr(*)() GridFactory
Definition: Grid.h:110
Tree.h
openvdb::v5_2::tree::ValueAccessor
Definition: ValueAccessor.h:220
openvdb::v5_2::LEVEL_SET_HALF_WIDTH
static const Real LEVEL_SET_HALF_WIDTH
Definition: Types.h:283
openvdb::v5_2::TreeAdapter::NonConstTreeType
typename std::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:947
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:1029
openvdb::v5_2::GridPtrVecPtr
SharedPtr< GridPtrVec > GridPtrVecPtr
Definition: Grid.h:440
openvdb::v5_2::Grid::background
const ValueType & background() const
Return this grid&#39;s background value.
Definition: Grid.h:627
openvdb::v5_2::Grid::isRegistered
static bool isRegistered()
Return true if this grid type is registered.
Definition: Grid.h:853
openvdb::v5_2::GridNamePred::operator()
bool operator()(const GridBase::ConstPtr &g) const
Definition: Grid.h:462
openvdb::v5_2::GridNamePred
Predicate functor that returns true for grids that have a specified name.
Definition: Grid.h:459
openvdb::v5_2::TreeAdapter::ConstAccessorType
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:958
openvdb::v5_2::Grid::BuildType
typename _TreeType::BuildType BuildType
Definition: Grid.h:509
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::ValueType
typename TreeType::ValueType ValueType
Definition: Grid.h:1015
openvdb::v5_2::Grid::readBuffers
void readBuffers(std::istream &) override
Read all data buffers for this grid.
Definition: Grid.h:1461
openvdb::v5_2::GridBase::META_GRID_CREATOR
static const char *const META_GRID_CREATOR
Definition: Grid.h:292
openvdb::v5_2::math::Transform::createLinearTransform
static Transform::Ptr createLinearTransform(double voxelSize=1.0)
Create and return a shared pointer to a new transform.
openvdb::v5_2::Grid::getUnsafeAccessor
UnsafeAccessor getUnsafeAccessor()
Return an accessor that provides random read and write access to this grid&#39;s voxels. The accessor is unsafe in the sense that it is not registered by the tree of this grid. In some rare cases this can give a performance advantage over a registered accessor but it is unsafe if the tree topology is modified.
Definition: Grid.h:646
openvdb::v5_2::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:1349
openvdb::v5_2::GridBase::ConstPtr
SharedPtr< const GridBase > ConstPtr
Definition: Grid.h:108
openvdb::v5_2::Grid::registerGrid
static void registerGrid()
Register this grid type along with a factory function.
Definition: Grid.h:855
openvdb::v5_2::Grid::type
Name type() const override
Return the name of this grid&#39;s type.
Definition: Grid.h:613
openvdb::v5_2::Grid::gridType
static Name gridType()
Return the name of this type of grid.
Definition: Grid.h:615
openvdb::v5_2::Grid::ValueOnCIter
typename _TreeType::ValueOnCIter ValueOnCIter
Definition: Grid.h:512
openvdb::v5_2::Grid::ValueAllCIter
typename _TreeType::ValueAllCIter ValueAllCIter
Definition: Grid.h:516
Exceptions.h
openvdb::v5_2::math::Vec3d
Vec3< double > Vec3d
Definition: Vec3.h:679
openvdb::v5_2::TreeAdapter::TreePtrType
typename TreeType::Ptr TreePtrType
Definition: Grid.h:948
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::ConstAccessorType
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:1017
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::NonConstTreePtrType
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:980
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::constTree
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:998
openvdb::v5_2::GridPtrVecIter
GridPtrVec::iterator GridPtrVecIter
Definition: Grid.h:438
openvdb::v5_2::Grid::valueType
Name valueType() const override
Return the name of the type of a voxel&#39;s value (e.g., "float" or "vec3d").
Definition: Grid.h:622
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::ConstTreePtrType
typename TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:979
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstTreeType
typename std::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:1006
openvdb::v5_2::TreeAdapter::tree
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:963
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const TreeType & constTree(GridType &g)
Definition: Grid.h:1027
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstGridPtrType
typename NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:1013
openvdb::v5_2::GridPtrSetCIter
GridPtrSet::const_iterator GridPtrSetCIter
Definition: Grid.h:449
openvdb::v5_2::ValueError
Definition: Exceptions.h:92
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static const TreeType & tree(const AccessorType &a)
Definition: Grid.h:1025
openvdb::v5_2::Grid::TreePtrType
typename _TreeType::Ptr TreePtrType
Definition: Grid.h:506
OPENVDB_LOG_WARN
#define OPENVDB_LOG_WARN(message)
Log a warning message of the form &#39;someVar << "some text" << ...&#39;.
Definition: logging.h:280
openvdb::v5_2::ShallowCopy
Tag dispatch class that distinguishes shallow copy constructors from deep copy constructors.
Definition: Types.h:515
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::ValueType
typename TreeType::ValueType ValueType
Definition: Grid.h:986
openvdb::v5_2::findGridByName
GridPtrT findGridByName(const std::map< KeyT, GridPtrT > &container, const Name &name)
Return the first grid in the given map whose name is name.
Definition: Grid.h:480
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::tree
static const TreeType & tree(const GridType &g)
Definition: Grid.h:994
openvdb::v5_2::Grid::writeBuffers
void writeBuffers(std::ostream &) const override
Write out all data buffers for this grid.
Definition: Grid.h:1518
openvdb::v5_2::Grid::cbeginValueOn
ValueOnCIter cbeginValueOn() const
Return an iterator over all of this grid&#39;s active values (tile and voxel).
Definition: Grid.h:666
openvdb::v5_2::tools::clip
GridType::Ptr clip(const GridType &grid, const BBoxd &bbox, bool keepInterior=true)
Clip the given grid against a world-space bounding box and return a new grid containing the result...
Definition: Clip.h:375
openvdb::v5_2::GridPtrSetPtr
SharedPtr< GridPtrSet > GridPtrSetPtr
Definition: Grid.h:450
openvdb::v5_2::Grid::Ptr
SharedPtr< Grid > Ptr
Definition: Grid.h:502
openvdb::v5_2::GridClass
GridClass
Definition: Types.h:275
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static TreeType & tree(TreeType &t)
Definition: Grid.h:1020
openvdb::v5_2::GridCPtrVecCIter
GridCPtrVec::const_iterator GridCPtrVecCIter
Definition: Grid.h:444
openvdb::v5_2::GridBase::META_FILE_MEM_BYTES
static const char *const META_FILE_MEM_BYTES
Definition: Grid.h:300
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::constTree
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:995
openvdb::v5_2::math::Transform
Definition: Transform.h:66
openvdb::v5_2::Grid::evalActiveVoxelBoundingBox
CoordBBox evalActiveVoxelBoundingBox() const override
Return the axis-aligned bounding box of all active voxels.
Definition: Grid.h:1419
openvdb
Definition: Exceptions.h:40
openvdb::v5_2::Grid::topologyUnion
void topologyUnion(const Grid< OtherTreeType > &other)
Union this grid&#39;s set of active values with the active values of the other grid, whose value type may...
Definition: Grid.h:1382
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::TreeType
_TreeType TreeType
Definition: Grid.h:1005
openvdb::v5_2::GridBase::META_FILE_BBOX_MAX
static const char *const META_FILE_BBOX_MAX
Definition: Grid.h:298
openvdb::v5_2::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:1607
openvdb::v5_2::GridBase::META_SAVE_HALF_FLOAT
static const char *const META_SAVE_HALF_FLOAT
Definition: Grid.h:294
openvdb::v5_2::TreeAdapter::constTree
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:968
openvdb::v5_2::Grid::memUsage
Index64 memUsage() const override
Definition: Grid.h:779
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::NonConstTreeType
typename std::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:977
openvdb::v5_2::GridBase::deepCopyGrid
virtual GridBase::Ptr deepCopyGrid() const =0
Return a new grid whose metadata, transform and tree are deep copies of this grid&#39;s.
openvdb::v5_2::GridPtrSetIter
GridPtrSet::iterator GridPtrSetIter
Definition: Grid.h:448
openvdb::v5_2::VecType
VecType
Definition: Types.h:305
openvdb::v5_2::Grid::create
static Ptr create()
Return a new grid with background value zero.
Definition: Grid.h:1187
openvdb::v5_2::TreeAdapter::ConstGridPtrType
typename GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:955
openvdb::v5_2::GridBase::GridBase
GridBase()
Initialize with an identity linear transform.
Definition: Grid.h:410
openvdb::v5_2::GridBase
Abstract base class for typed grids.
Definition: Grid.h:104
openvdb::v5_2::Grid::evalActiveVoxelDim
Coord evalActiveVoxelDim() const override
Return the dimensions of the axis-aligned bounding box of all active voxels.
Definition: Grid.h:1429
openvdb::v5_2::MetaMap::ConstMetaIterator
MetadataMap::const_iterator ConstMetaIterator
Definition: MetaMap.h:55
openvdb::v5_2::Grid::unregisterGrid
static void unregisterGrid()
Remove this grid type from the registry.
Definition: Grid.h:864
openvdb::v5_2::GridBase::writeTransform
void writeTransform(std::ostream &os) const
Write out the transform for this grid.
Definition: Grid.h:402
openvdb::v5_2::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:887
openvdb::v5_2::MetaMap::Ptr
SharedPtr< MetaMap > Ptr
Definition: MetaMap.h:49
openvdb::v5_2::Grid::Grid
Grid()
Construct a new grid with background value zero.
Definition: Grid.h:1124
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::tree
static TreeType & tree(GridType &g)
Definition: Grid.h:992
openvdb::v5_2::Grid::beginValueOn
ValueOnCIter beginValueOn() const
Return an iterator over all of this grid&#39;s active values (tile and voxel).
Definition: Grid.h:665
openvdb::v5_2::Index64
uint64_t Index64
Definition: Types.h:60
openvdb::v5_2::GridCPtrVecIter
GridCPtrVec::iterator GridCPtrVecIter
Definition: Grid.h:443
openvdb::v5_2::MergePolicy
MergePolicy
Definition: Types.h:328
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::NonConstGridPtrType
typename NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:984
openvdb::v5_2::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::v5_2::GridBase::META_GRID_NAME
static const char *const META_GRID_NAME
Definition: Grid.h:293
openvdb::v5_2::Grid::ValueOffIter
typename _TreeType::ValueOffIter ValueOffIter
Definition: Grid.h:513
openvdb::v5_2::TreeAdapter::NonConstTreePtrType
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:950
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::TreePtrType
typename TreeType::Ptr TreePtrType
Definition: Grid.h:1007
openvdb::v5_2::TreeAdapter::ConstTreePtrType
typename TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:949
openvdb::v5_2::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:171
openvdb::v5_2::GridBase::transformPtr
math::Transform::ConstPtr transformPtr() const
Return a pointer to this grid&#39;s transform, which might be shared with other grids.
Definition: Grid.h:339
openvdb::v5_2::OPENVDB_FILE_VERSION_MULTIPASS_IO
Definition: version.h:232
openvdb::v5_2::Grid::clip
void clip(const CoordBBox &) override
Clip this grid to the given index-space bounding box.
Definition: Grid.h:1364
openvdb::v5_2::GridBase::~GridBase
~GridBase() override
Definition: Grid.h:113
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::TreeType
_TreeType TreeType
Definition: Grid.h:976
openvdb::v5_2::GridBase::META_FILE_BBOX_MIN
static const char *const META_FILE_BBOX_MIN
Definition: Grid.h:297
openvdb::v5_2::GridBase::baseTreePtr
TreeBase::Ptr baseTreePtr()
Return a pointer to this grid&#39;s tree, which might be shared with other grids. The pointer is guarante...
Definition: Grid.h:1106
openvdb::v5_2::GridBase::constTransform
const math::Transform & constTransform() const
Return a reference to this grid&#39;s transform, which might be shared with other grids.
Definition: Grid.h:349
openvdb::v5_2::io::setGridClass
OPENVDB_API void setGridClass(std::ios_base &, uint32_t)
Associate with the given stream the class (GRID_LEVEL_SET, GRID_UNKNOWN, etc.) of the grid currently ...
openvdb::v5_2::GridBase::unregisterGrid
static void unregisterGrid(const Name &type)
Remove a grid type from the registry.
openvdb::v5_2::tree::TreeBase::Ptr
SharedPtr< TreeBase > Ptr
Definition: Tree.h:65
openvdb::v5_2::GridPtrVec
std::vector< GridBase::Ptr > GridPtrVec
Definition: Grid.h:437
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::tree
static TreeType & tree(TreeType &t)
Definition: Grid.h:991
openvdb::v5_2::TreeAdapter::NonConstAccessorType
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:959
openvdb::v5_2::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:1453
openvdb::v5_2::GridBase::voxelSize
Vec3d voxelSize() const
Return the size of this grid&#39;s voxels.
Definition: Grid.h:359
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::AccessorType
typename tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:1016
openvdb::v5_2::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:1272
openvdb::v5_2::GridBase::constTransformPtr
math::Transform::ConstPtr constTransformPtr() const
Return a pointer to this grid&#39;s transform, which might be shared with other grids.
Definition: Grid.h:340
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:1023
openvdb::v5_2::GridCPtrVecPtr
SharedPtr< GridCPtrVec > GridCPtrVecPtr
Definition: Grid.h:445
openvdb::v5_2::MERGE_ACTIVE_STATES
Definition: Types.h:329
openvdb::v5_2::GridCPtrSetPtr
SharedPtr< GridCPtrSet > GridCPtrSetPtr
Definition: Grid.h:455
openvdb::v5_2::Grid::copyGrid
GridBase::Ptr copyGrid() override
Return a new grid of the same type as this grid whose metadata and transform are deep copies of this ...
Definition: Grid.h:1282
openvdb::v5_2::Grid::treePtr
ConstTreePtrType treePtr() const
Return a pointer to this grid&#39;s tree, which might be shared with other grids. The pointer is guarante...
Definition: Grid.h:789
openvdb::v5_2::GridBase::META_IS_LOCAL_SPACE
static const char *const META_IS_LOCAL_SPACE
Definition: Grid.h:295
openvdb::v5_2::createGrid
Grid< typename TreePtrType::element_type >::Ptr createGrid(TreePtrType)
Create a new grid of the appropriate type that wraps the given tree.
Definition: Grid.h:1598
openvdb::v5_2::GridCPtrSetCIter
GridCPtrSet::const_iterator GridCPtrSetCIter
Definition: Grid.h:454
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:1028
openvdb::v5_2::TreeAdapter::TreeType
_TreeType TreeType
Definition: Grid.h:946
openvdb::v5_2::Grid
Container class that associates a tree with a transform and metadata.
Definition: Grid.h:55
openvdb::v5_2::GridCPtrVec
std::vector< GridBase::ConstPtr > GridCPtrVec
Definition: Grid.h:442
openvdb::v5_2::TreeAdapter< Grid< _TreeType > >::TreePtrType
typename TreeType::Ptr TreePtrType
Definition: Grid.h:978
openvdb::v5_2::GridBase::GridBase
GridBase(const GridBase &other)
Deep copy another grid&#39;s metadata and transform.
Definition: Grid.h:413
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
openvdb::v5_2::Grid::topologyIntersection
void topologyIntersection(const Grid< OtherTreeType > &other)
Intersect this grid&#39;s set of active values with the active values of the other grid, whose value type may be different.
Definition: Grid.h:1391
openvdb::v5_2::Grid::pruneGrid
void pruneGrid(float tolerance=0.0) override
Reduce the memory footprint of this grid by increasing its sparseness.
Definition: Grid.h:1356
openvdb::v5_2::TreeAdapter::constTree
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:967
openvdb::v5_2::GridBase::constBaseTree
const TreeBase & constBaseTree() const
Return a reference to this grid&#39;s tree, which might be shared with other grids.
Definition: Grid.h:187
openvdb::v5_2::GridBase::Ptr
SharedPtr< GridBase > Ptr
Definition: Grid.h:107
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static TreeType & tree(GridType &g)
Definition: Grid.h:1021
openvdb::v5_2::Grid::cbeginValueOff
ValueOffCIter cbeginValueOff() const
Return an iterator over all of this grid&#39;s inactive values (tile and voxel).
Definition: Grid.h:672
openvdb::v5_2::Grid::ValueAllIter
typename _TreeType::ValueAllIter ValueAllIter
Definition: Grid.h:515
openvdb::v5_2::Grid::TreeType
_TreeType TreeType
Definition: Grid.h:505
openvdb::v5_2::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:1334
openvdb::v5_2::Grid::tree
TreeType & tree()
Return a reference to this grid&#39;s tree, which might be shared with other grids.
Definition: Grid.h:798
openvdb::v5_2::GridBase::baseTree
const TreeBase & baseTree() const
Return a reference to this grid&#39;s tree, which might be shared with other grids.
Definition: Grid.h:186
openvdb::v5_2::GridBase::META_FILE_VOXEL_COUNT
static const char *const META_FILE_VOXEL_COUNT
Definition: Grid.h:301
openvdb::v5_2::math::Transform::ConstPtr
SharedPtr< const Transform > ConstPtr
Definition: Transform.h:70
openvdb::v5_2::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:1264
openvdb::v5_2::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:944
openvdb::v5_2::Grid::tree
const TreeType & tree() const
Return a reference to this grid&#39;s tree, which might be shared with other grids.
Definition: Grid.h:799
openvdb::v5_2::Grid::ValueOffCIter
typename _TreeType::ValueOffCIter ValueOffCIter
Definition: Grid.h:514
openvdb::v5_2::GridBase::voxelSize
Vec3d voxelSize(const Vec3d &xyz) const
Return the size of this grid&#39;s voxel at position (x, y, z).
Definition: Grid.h:362
openvdb::v5_2::Grid::empty
bool empty() const override
Return true if this grid contains only inactive background voxels.
Definition: Grid.h:630
openvdb::v5_2::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:1342
openvdb::v5_2::Grid::~Grid
~Grid() override
Definition: Grid.h:574
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:1026
Name.h
openvdb::v5_2::Grid::topologyDifference
void topologyDifference(const Grid< OtherTreeType > &other)
Difference this grid&#39;s set of active values with the active values of the other grid, whose value type may be different.
Definition: Grid.h:1400
openvdb::v5_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstTreePtrType
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:1009
openvdb::v5_2::Grid::UnsafeAccessor
typename tree::ValueAccessor< _TreeType, false > UnsafeAccessor
Definition: Grid.h:520
openvdb::v5_2::Grid::ValueOnIter
typename _TreeType::ValueOnIter ValueOnIter
Definition: Grid.h:511
openvdb::v5_2::TreeAdapter::GridPtrType
typename GridType::Ptr GridPtrType
Definition: Grid.h:953
openvdb::v5_2::io::StreamMetadata::Ptr
SharedPtr< StreamMetadata > Ptr
Definition: io.h:59