OpenVDB: Grid.h Source File

OpenVDB 6.1.0

Grid.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2019 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
118
119 #if OPENVDB_ABI_VERSION_NUMBER <= 3
120 OPENVDB_DEPRECATED virtual GridBase::Ptr copyGrid(CopyPolicy treePolicy = CP_SHARE) const = 0;
124 #else
125 virtual GridBase::Ptr copyGrid() = 0;
130 virtual GridBase::ConstPtr copyGrid() const = 0;
133 virtual GridBase::Ptr copyGridWithNewTree() const = 0;
134 #endif
135 virtual GridBase::Ptr deepCopyGrid() const = 0;
137
139
140
143
145 static Ptr createGrid(const Name& type);
146
148 static bool isRegistered(const Name &type);
149
151 static void clearRegistry();
152
154
157
159 virtual Name type() const = 0;
161 virtual Name valueType() const = 0;
162
164 template<typename GridType>
165 bool isType() const { return (this->type() == GridType::gridType()); }
166
168
170 template<typename GridType>
173 static typename GridType::Ptr grid(const GridBase::Ptr&);
174 template<typename GridType>
175 static typename GridType::ConstPtr grid(const GridBase::ConstPtr&);
176 template<typename GridType>
177 static typename GridType::ConstPtr constGrid(const GridBase::Ptr&);
178 template<typename GridType>
179 static typename GridType::ConstPtr constGrid(const GridBase::ConstPtr&);
181
184
187 TreeBase::Ptr baseTreePtr();
190 TreeBase::ConstPtr baseTreePtr() const { return this->constBaseTreePtr(); }
193 virtual TreeBase::ConstPtr constBaseTreePtr() const = 0;
194
199 TreeBase& baseTree() { return const_cast<TreeBase&>(this->constBaseTree()); }
204 const TreeBase& baseTree() const { return this->constBaseTree(); }
209 const TreeBase& constBaseTree() const { return *(this->constBaseTreePtr()); }
210
217 virtual void setTree(TreeBase::Ptr) = 0;
218
220 virtual void newTree() = 0;
221
223
225 virtual bool empty() const = 0;
227 virtual void clear() = 0;
228
229
232
238 virtual void pruneGrid(float tolerance = 0.0) = 0;
239
240 #if OPENVDB_ABI_VERSION_NUMBER >= 3
241 void clipGrid(const BBoxd&);
246
251 virtual void clip(const CoordBBox&) = 0;
252 #endif
253
255
280 template<typename GridTypeListT, typename OpT> inline bool apply(OpT&) const;
281 template<typename GridTypeListT, typename OpT> inline bool apply(OpT&);
283
286
288 std::string getName() const;
290 void setName(const std::string&);
291
293 std::string getCreator() const;
295 void setCreator(const std::string&);
296
299 bool saveFloatAsHalf() const;
300 void setSaveFloatAsHalf(bool);
301
305 GridClass getGridClass() const;
309 void setGridClass(GridClass);
311 void clearGridClass();
312
314
316 static std::string gridClassToString(GridClass);
318 static std::string gridClassToMenuName(GridClass);
323 static GridClass stringToGridClass(const std::string&);
324
327
331 VecType getVectorType() const;
335 void setVectorType(VecType);
337 void clearVectorType();
338
340
342 static std::string vecTypeToString(VecType);
345 static std::string vecTypeExamples(VecType);
348 static std::string vecTypeDescription(VecType);
349 static VecType stringToVecType(const std::string&);
350
353
357 bool isInWorldSpace() const;
359 void setIsInWorldSpace(bool);
360
362
363 // Standard metadata field names
364 // (These fields should normally not be accessed directly, but rather
365 // via the accessor methods above, when available.)
366 // Note: Visual C++ requires these declarations to be separate statements.
367 static const char* const META_GRID_CLASS;
368 static const char* const META_GRID_CREATOR;
369 static const char* const META_GRID_NAME;
370 static const char* const META_SAVE_HALF_FLOAT;
371 static const char* const META_IS_LOCAL_SPACE;
372 static const char* const META_VECTOR_TYPE;
373 static const char* const META_FILE_BBOX_MIN;
374 static const char* const META_FILE_BBOX_MAX;
375 static const char* const META_FILE_COMPRESSION;
376 static const char* const META_FILE_MEM_BYTES;
377 static const char* const META_FILE_VOXEL_COUNT;
378
379
382
384 virtual Index64 activeVoxelCount() const = 0;
385
388 virtual CoordBBox evalActiveVoxelBoundingBox() const = 0;
389
391 virtual Coord evalActiveVoxelDim() const = 0;
392
394 virtual Index64 memUsage() const = 0;
395
400 void addStatsMetadata();
406 MetaMap::Ptr getStatsMetadata() const;
407
409
410
413
415 math::Transform::Ptr transformPtr() { return mTransform; }
418 math::Transform::ConstPtr transformPtr() const { return mTransform; }
419 math::Transform::ConstPtr constTransformPtr() const { return mTransform; }
421
422 math::Transform& transform() { return *mTransform; }
427 const math::Transform& transform() const { return *mTransform; }
428 const math::Transform& constTransform() const { return *mTransform; }
430
432
435
442 void setTransform(math::Transform::Ptr);
443
445 Vec3d voxelSize() const { return transform().voxelSize(); }
448 Vec3d voxelSize(const Vec3d& xyz) const { return transform().voxelSize(xyz); }
450 bool hasUniformVoxels() const { return mTransform->hasUniformScale(); }
452 Vec3d indexToWorld(const Vec3d& xyz) const { return transform().indexToWorld(xyz); }
454 Vec3d indexToWorld(const Coord& ijk) const { return transform().indexToWorld(ijk); }
456 Vec3d worldToIndex(const Vec3d& xyz) const { return transform().worldToIndex(xyz); }
457
459
460
463
466 virtual void readTopology(std::istream&) = 0;
469 virtual void writeTopology(std::ostream&) const = 0;
470
472 virtual void readBuffers(std::istream&) = 0;
473 #if OPENVDB_ABI_VERSION_NUMBER >= 3
474 virtual void readBuffers(std::istream&, const CoordBBox&) = 0;
481 virtual void readNonresidentBuffers() const = 0;
482 #endif
483 virtual void writeBuffers(std::ostream&) const = 0;
485
487 void readTransform(std::istream& is) { transform().read(is); }
489 void writeTransform(std::ostream& os) const { transform().write(os); }
490
492 virtual void print(std::ostream& = std::cout, int verboseLevel = 1) const = 0;
493
495
496
497 protected:
499 GridBase(): mTransform(math::Transform::createLinearTransform()) {}
500
502 GridBase(const GridBase& other): MetaMap(other), mTransform(other.mTransform->copy()) {}
503
504 #if OPENVDB_ABI_VERSION_NUMBER <= 3
505 OPENVDB_DEPRECATED GridBase(const GridBase& other, ShallowCopy): MetaMap(other), mTransform(other.mTransform) {}
508 #else
509 GridBase(GridBase& other, ShallowCopy): MetaMap(other), mTransform(other.mTransform) {}
511 #endif
512
514 static void registerGrid(const Name& type, GridFactory);
516 static void unregisterGrid(const Name& type);
517
518
519 private:
520 math::Transform::Ptr mTransform;
521 }; // class GridBase
522
523
525
526
527 using GridPtrVec = std::vector<GridBase::Ptr>;
528 using GridPtrVecIter = GridPtrVec::iterator;
529 using GridPtrVecCIter = GridPtrVec::const_iterator;
530 using GridPtrVecPtr = SharedPtr<GridPtrVec>;
531
532 using GridCPtrVec = std::vector<GridBase::ConstPtr>;
533 using GridCPtrVecIter = GridCPtrVec::iterator;
534 using GridCPtrVecCIter = GridCPtrVec::const_iterator;
535 using GridCPtrVecPtr = SharedPtr<GridCPtrVec>;
536
537 using GridPtrSet = std::set<GridBase::Ptr>;
538 using GridPtrSetIter = GridPtrSet::iterator;
539 using GridPtrSetCIter = GridPtrSet::const_iterator;
540 using GridPtrSetPtr = SharedPtr<GridPtrSet>;
541
542 using GridCPtrSet = std::set<GridBase::ConstPtr>;
543 using GridCPtrSetIter = GridCPtrSet::iterator;
544 using GridCPtrSetCIter = GridCPtrSet::const_iterator;
545 using GridCPtrSetPtr = SharedPtr<GridCPtrSet>;
546
547
549 struct OPENVDB_API GridNamePred
550 {
551 GridNamePred(const Name& _name): name(_name) {}
552 bool operator()(const GridBase::ConstPtr& g) const { return g && g->getName() == name; }
553 Name name;
554 };
555
557 template<typename GridPtrContainerT>
558 inline typename GridPtrContainerT::value_type
559 findGridByName(const GridPtrContainerT& container, const Name& name)
560 {
561 using GridPtrT = typename GridPtrContainerT::value_type;
562 typename GridPtrContainerT::const_iterator it =
563 std::find_if(container.begin(), container.end(), GridNamePred(name));
564 return (it == container.end() ? GridPtrT() : *it);
565 }
566
568 template<typename KeyT, typename GridPtrT>
569 inline GridPtrT
570 findGridByName(const std::map<KeyT, GridPtrT>& container, const Name& name)
571 {
572 using GridPtrMapT = std::map<KeyT, GridPtrT>;
573 for (typename GridPtrMapT::const_iterator it = container.begin(), end = container.end();
574 it != end; ++it)
575 {
576 const GridPtrT& grid = it->second;
577 if (grid && grid->getName() == name) return grid;
578 }
579 return GridPtrT();
580 }
582
583
585
586
588 template<typename _TreeType>
589 class Grid: public GridBase
590 {
591 public:
592 using Ptr = SharedPtr<Grid>;
593 using ConstPtr = SharedPtr<const Grid>;
594
595 using TreeType = _TreeType;
596 using TreePtrType = typename _TreeType::Ptr;
597 using ConstTreePtrType = typename _TreeType::ConstPtr;
598 using ValueType = typename _TreeType::ValueType;
599 using BuildType = typename _TreeType::BuildType;
600
601 using ValueOnIter = typename _TreeType::ValueOnIter;
602 using ValueOnCIter = typename _TreeType::ValueOnCIter;
603 using ValueOffIter = typename _TreeType::ValueOffIter;
604 using ValueOffCIter = typename _TreeType::ValueOffCIter;
605 using ValueAllIter = typename _TreeType::ValueAllIter;
606 using ValueAllCIter = typename _TreeType::ValueAllCIter;
607
608 using Accessor = typename tree::ValueAccessor<_TreeType, true>;
609 using ConstAccessor = typename tree::ValueAccessor<const _TreeType, true>;
610 using UnsafeAccessor = typename tree::ValueAccessor<_TreeType, false>;
611 using ConstUnsafeAccessor = typename tree::ValueAccessor<const _TreeType, false>;
612
619 template<typename OtherValueType>
620 struct ValueConverter {
621 using Type = Grid<typename TreeType::template ValueConverter<OtherValueType>::Type>;
622 };
623
625 static Ptr create(const ValueType& background);
627 static Ptr create();
630 static Ptr create(TreePtrType);
633 static Ptr create(const GridBase& other);
634
635
637 Grid();
639 explicit Grid(const ValueType& background);
643 explicit Grid(TreePtrType);
645 Grid(const Grid&);
651 template<typename OtherTreeType>
652 explicit Grid(const Grid<OtherTreeType>&);
653 #if OPENVDB_ABI_VERSION_NUMBER <= 3
654 OPENVDB_DEPRECATED Grid(const Grid&, ShallowCopy);
657 #else
658 Grid(Grid&, ShallowCopy);
660 #endif
661 explicit Grid(const GridBase&);
664
665 ~Grid() override {}
666
668 Grid& operator=(const Grid&) = delete;
669
670
671 #if OPENVDB_ABI_VERSION_NUMBER <= 3
672
673 OPENVDB_DEPRECATED Ptr copy(CopyPolicy treePolicy = CP_SHARE) const;
681 OPENVDB_DEPRECATED GridBase::Ptr copyGrid(CopyPolicy treePolicy = CP_SHARE) const override;
683 #else
684
685 Ptr copy();
688 ConstPtr copy() const;
690 Ptr copyWithNewTree() const;
693
694 GridBase::Ptr copyGrid() override;
695 GridBase::ConstPtr copyGrid() const override;
696 GridBase::Ptr copyGridWithNewTree() const override;
697 #endif
698
699 Ptr deepCopy() const { return Ptr(new Grid(*this)); }
701 GridBase::Ptr deepCopyGrid() const override { return this->deepCopy(); }
703
705 Name type() const override { return this->gridType(); }
707 static Name gridType() { return TreeType::treeType(); }
708
709
710 //
711 // Voxel access methods
712 //
714 Name valueType() const override { return tree().valueType(); }
715
719 const ValueType& background() const { return mTree->background(); }
720
722 bool empty() const override { return tree().empty(); }
724 void clear() override { tree().clear(); }
725
729 Accessor getAccessor() { return Accessor(tree()); }
738 UnsafeAccessor getUnsafeAccessor() { return UnsafeAccessor(tree()); }
740 ConstAccessor getAccessor() const { return ConstAccessor(tree()); }
742 ConstAccessor getConstAccessor() const { return ConstAccessor(tree()); }
744 ConstUnsafeAccessor getConstUnsafeAccessor() const { return ConstUnsafeAccessor(tree()); }
753
755 ValueOnIter beginValueOn() { return tree().beginValueOn(); }
757 ValueOnCIter beginValueOn() const { return tree().cbeginValueOn(); }
758 ValueOnCIter cbeginValueOn() const { return tree().cbeginValueOn(); }
760
761 ValueOffIter beginValueOff() { return tree().beginValueOff(); }
763 ValueOffCIter beginValueOff() const { return tree().cbeginValueOff(); }
764 ValueOffCIter cbeginValueOff() const { return tree().cbeginValueOff(); }
766
767 ValueAllIter beginValueAll() { return tree().beginValueAll(); }
769 ValueAllCIter beginValueAll() const { return tree().cbeginValueAll(); }
770 ValueAllCIter cbeginValueAll() const { return tree().cbeginValueAll(); }
772
774 void evalMinMax(ValueType& minVal, ValueType& maxVal) const;
775
777 void sparseFill(const CoordBBox& bbox, const ValueType& value, bool active = true);
786 void fill(const CoordBBox& bbox, const ValueType& value, bool active = true);
788
795 void denseFill(const CoordBBox& bbox, const ValueType& value, bool active = true);
796
798 void pruneGrid(float tolerance = 0.0) override;
799
800 #if OPENVDB_ABI_VERSION_NUMBER >= 3
801 void clip(const CoordBBox&) override;
806 #endif
807
813 void merge(Grid& other, MergePolicy policy = MERGE_ACTIVE_STATES);
814
828 template<typename OtherTreeType>
829 void topologyUnion(const Grid<OtherTreeType>& other);
830
843 template<typename OtherTreeType>
844 void topologyIntersection(const Grid<OtherTreeType>& other);
845
856 template<typename OtherTreeType>
857 void topologyDifference(const Grid<OtherTreeType>& other);
858
859 //
860 // Statistics
861 //
863 Index64 activeVoxelCount() const override { return tree().activeVoxelCount(); }
865 CoordBBox evalActiveVoxelBoundingBox() const override;
867 Coord evalActiveVoxelDim() const override;
868
871 Index64 memUsage() const override { return tree().memUsage(); }
872
873
874 //
875 // Tree methods
876 //
878 TreePtrType treePtr() { return mTree; }
881 ConstTreePtrType treePtr() const { return mTree; }
882 ConstTreePtrType constTreePtr() const { return mTree; }
883 TreeBase::ConstPtr constBaseTreePtr() const override { return mTree; }
885
886 TreeType& tree() { return *mTree; }
891 const TreeType& tree() const { return *mTree; }
892 const TreeType& constTree() const { return *mTree; }
894
900 void setTree(TreeBase::Ptr) override;
901
904 void newTree() override;
905
906
907 //
908 // I/O methods
909 //
912 void readTopology(std::istream&) override;
915 void writeTopology(std::ostream&) const override;
916
918 void readBuffers(std::istream&) override;
919 #if OPENVDB_ABI_VERSION_NUMBER >= 3
920 void readBuffers(std::istream&, const CoordBBox&) override;
927 void readNonresidentBuffers() const override;
928 #endif
929 void writeBuffers(std::ostream&) const override;
931
933 void print(std::ostream& = std::cout, int verboseLevel = 1) const override;
934
938 static inline bool hasMultiPassIO();
939
940
941 //
942 // Registry methods
943 //
945 static bool isRegistered() { return GridBase::isRegistered(Grid::gridType()); }
947 static void registerGrid()
948 {
949 GridBase::registerGrid(Grid::gridType(), Grid::factory);
950 if (!tree::internal::LeafBufferFlags<ValueType>::IsAtomic) {
951 OPENVDB_LOG_WARN("delayed loading of grids of type " << Grid::gridType()
952 << " might not be threadsafe on this platform");
953 }
954 }
956 static void unregisterGrid() { GridBase::unregisterGrid(Grid::gridType()); }
957
958
959 private:
961 static GridBase::Ptr factory() { return Grid::create(); }
962
963 TreePtrType mTree;
964 }; // class Grid
965
966
968
969
977 template<typename GridType>
978 inline typename GridType::Ptr
979 gridPtrCast(const GridBase::Ptr& grid)
980 {
981 return GridBase::grid<GridType>(grid);
982 }
983
984
993 template<typename GridType>
994 inline typename GridType::ConstPtr
995 gridConstPtrCast(const GridBase::ConstPtr& grid)
996 {
997 return GridBase::constGrid<GridType>(grid);
998 }
999
1000
1002
1003
1010 template<typename GridType>
1011 inline typename GridType::Ptr
1012 deepCopyTypedGrid(const GridBase::ConstPtr& grid)
1013 {
1014 if (!grid || !grid->isType<GridType>()) return typename GridType::Ptr();
1015 return gridPtrCast<GridType>(grid->deepCopyGrid());
1016 }
1017
1018
1019 template<typename GridType>
1020 inline typename GridType::Ptr
1021 deepCopyTypedGrid(const GridBase& grid)
1022 {
1023 if (!grid.isType<GridType>()) return typename GridType::Ptr();
1024 return gridPtrCast<GridType>(grid.deepCopyGrid());
1025 }
1027
1028
1030
1031
1033 template<typename _TreeType>
1036 struct TreeAdapter
1037 {
1038 using TreeType = _TreeType;
1039 using NonConstTreeType = typename std::remove_const<TreeType>::type;
1040 using TreePtrType = typename TreeType::Ptr;
1041 using ConstTreePtrType = typename TreeType::ConstPtr;
1042 using NonConstTreePtrType = typename NonConstTreeType::Ptr;
1043 using GridType = Grid<TreeType>;
1044 using NonConstGridType = Grid<NonConstTreeType>;
1045 using GridPtrType = typename GridType::Ptr;
1046 using NonConstGridPtrType = typename NonConstGridType::Ptr;
1047 using ConstGridPtrType = typename GridType::ConstPtr;
1048 using ValueType = typename TreeType::ValueType;
1049 using AccessorType = typename tree::ValueAccessor<TreeType>;
1050 using ConstAccessorType = typename tree::ValueAccessor<const TreeType>;
1051 using NonConstAccessorType = typename tree::ValueAccessor<NonConstTreeType>;
1052
1053 static TreeType& tree(TreeType& t) { return t; }
1054 static TreeType& tree(GridType& g) { return g.tree(); }
1055 static const TreeType& tree(const TreeType& t) { return t; }
1056 static const TreeType& tree(const GridType& g) { return g.tree(); }
1057 static const TreeType& constTree(TreeType& t) { return t; }
1058 static const TreeType& constTree(GridType& g) { return g.constTree(); }
1059 static const TreeType& constTree(const TreeType& t) { return t; }
1060 static const TreeType& constTree(const GridType& g) { return g.constTree(); }
1061 };
1062
1063
1065 template<typename _TreeType>
1066 struct TreeAdapter<Grid<_TreeType> >
1067 {
1068 using TreeType = _TreeType;
1069 using NonConstTreeType = typename std::remove_const<TreeType>::type;
1070 using TreePtrType = typename TreeType::Ptr;
1071 using ConstTreePtrType = typename TreeType::ConstPtr;
1072 using NonConstTreePtrType = typename NonConstTreeType::Ptr;
1073 using GridType = Grid<TreeType>;
1074 using NonConstGridType = Grid<NonConstTreeType>;
1075 using GridPtrType = typename GridType::Ptr;
1076 using NonConstGridPtrType = typename NonConstGridType::Ptr;
1077 using ConstGridPtrType = typename GridType::ConstPtr;
1078 using ValueType = typename TreeType::ValueType;
1079 using AccessorType = typename tree::ValueAccessor<TreeType>;
1080 using ConstAccessorType = typename tree::ValueAccessor<const TreeType>;
1081 using NonConstAccessorType = typename tree::ValueAccessor<NonConstTreeType>;
1082
1083 static TreeType& tree(TreeType& t) { return t; }
1084 static TreeType& tree(GridType& g) { return g.tree(); }
1085 static const TreeType& tree(const TreeType& t) { return t; }
1086 static const TreeType& tree(const GridType& g) { return g.tree(); }
1087 static const TreeType& constTree(TreeType& t) { return t; }
1088 static const TreeType& constTree(GridType& g) { return g.constTree(); }
1089 static const TreeType& constTree(const TreeType& t) { return t; }
1090 static const TreeType& constTree(const GridType& g) { return g.constTree(); }
1091 };
1092
1094 template<typename _TreeType>
1095 struct TreeAdapter<tree::ValueAccessor<_TreeType> >
1096 {
1097 using TreeType = _TreeType;
1098 using NonConstTreeType = typename std::remove_const<TreeType>::type;
1099 using TreePtrType = typename TreeType::Ptr;
1100 using ConstTreePtrType = typename TreeType::ConstPtr;
1101 using NonConstTreePtrType = typename NonConstTreeType::Ptr;
1102 using GridType = Grid<TreeType>;
1103 using NonConstGridType = Grid<NonConstTreeType>;
1104 using GridPtrType = typename GridType::Ptr;
1105 using NonConstGridPtrType = typename NonConstGridType::Ptr;
1106 using ConstGridPtrType = typename GridType::ConstPtr;
1107 using ValueType = typename TreeType::ValueType;
1108 using AccessorType = typename tree::ValueAccessor<TreeType>;
1109 using ConstAccessorType = typename tree::ValueAccessor<const TreeType>;
1110 using NonConstAccessorType = typename tree::ValueAccessor<NonConstTreeType>;
1111
1112 static TreeType& tree(TreeType& t) { return t; }
1113 static TreeType& tree(GridType& g) { return g.tree(); }
1114 static TreeType& tree(AccessorType& a) { return a.tree(); }
1115 static const TreeType& tree(const TreeType& t) { return t; }
1116 static const TreeType& tree(const GridType& g) { return g.tree(); }
1117 static const TreeType& tree(const AccessorType& a) { return a.tree(); }
1118 static const TreeType& constTree(TreeType& t) { return t; }
1119 static const TreeType& constTree(GridType& g) { return g.constTree(); }
1120 static const TreeType& constTree(const TreeType& t) { return t; }
1121 static const TreeType& constTree(const GridType& g) { return g.constTree(); }
1122 };
1123
1125
1126
1128
1129
1135 template<typename LeafNodeType>
1136 struct HasMultiPassIO {
1137 static const bool value = std::is_base_of<io::MultiPass, LeafNodeType>::value;
1138 };
1139
1140 // Partial specialization for Tree types
1141 template<typename RootNodeType>
1142 struct HasMultiPassIO<tree::Tree<RootNodeType>> {
1143 // A tree is multi-pass if its (root node's) leaf node type is multi-pass.
1144 static const bool value = HasMultiPassIO<typename RootNodeType::LeafNodeType>::value;
1145 };
1146
1147 // Partial specialization for Grid types
1148 template<typename TreeType>
1149 struct HasMultiPassIO<Grid<TreeType>> {
1150 // A grid is multi-pass if its tree's leaf node type is multi-pass.
1151 static const bool value = HasMultiPassIO<typename TreeType::LeafNodeType>::value;
1152 };
1153
1154
1156
1157
1158 template<typename GridType>
1159 inline typename GridType::Ptr
1160 GridBase::grid(const GridBase::Ptr& grid)
1161 {
1162 // The string comparison on type names is slower than a dynamic pointer cast, but
1163 // it is safer when pointers cross DSO boundaries, as they do in many Houdini nodes.
1164 if (grid && grid->type() == GridType::gridType()) {
1165 return StaticPtrCast<GridType>(grid);
1166 }
1167 return typename GridType::Ptr();
1168 }
1169
1170
1171 template<typename GridType>
1172 inline typename GridType::ConstPtr
1173 GridBase::grid(const GridBase::ConstPtr& grid)
1174 {
1175 return ConstPtrCast<const GridType>(
1176 GridBase::grid<GridType>(ConstPtrCast<GridBase>(grid)));
1177 }
1178
1179
1180 template<typename GridType>
1181 inline typename GridType::ConstPtr
1182 GridBase::constGrid(const GridBase::Ptr& grid)
1183 {
1184 return ConstPtrCast<const GridType>(GridBase::grid<GridType>(grid));
1185 }
1186
1187
1188 template<typename GridType>
1189 inline typename GridType::ConstPtr
1190 GridBase::constGrid(const GridBase::ConstPtr& grid)
1191 {
1192 return ConstPtrCast<const GridType>(
1193 GridBase::grid<GridType>(ConstPtrCast<GridBase>(grid)));
1194 }
1195
1196
1197 inline TreeBase::Ptr
1198 GridBase::baseTreePtr()
1199 {
1200 return ConstPtrCast<TreeBase>(this->constBaseTreePtr());
1201 }
1202
1203
1204 inline void
1205 GridBase::setTransform(math::Transform::Ptr xform)
1206 {
1207 if (!xform) OPENVDB_THROW(ValueError, "Transform pointer is null");
1208 mTransform = xform;
1209 }
1210
1211
1213
1214
1215 template<typename TreeT>
1216 inline Grid<TreeT>::Grid(): mTree(new TreeType)
1217 {
1218 }
1219
1220
1221 template<typename TreeT>
1222 inline Grid<TreeT>::Grid(const ValueType &background): mTree(new TreeType(background))
1223 {
1224 }
1225
1226
1227 template<typename TreeT>
1228 inline Grid<TreeT>::Grid(TreePtrType tree): mTree(tree)
1229 {
1230 if (!tree) OPENVDB_THROW(ValueError, "Tree pointer is null");
1231 }
1232
1233
1234 template<typename TreeT>
1235 inline Grid<TreeT>::Grid(const Grid& other):
1236 GridBase(other),
1237 mTree(StaticPtrCast<TreeType>(other.mTree->copy()))
1238 {
1239 }
1240
1241
1242 template<typename TreeT>
1243 template<typename OtherTreeType>
1244 inline Grid<TreeT>::Grid(const Grid<OtherTreeType>& other):
1245 GridBase(other),
1246 mTree(new TreeType(other.constTree()))
1247 {
1248 }
1249
1250
1251 #if OPENVDB_ABI_VERSION_NUMBER <= 3
1252 template<typename TreeT>
1253 inline Grid<TreeT>::Grid(const Grid& other, ShallowCopy):
1254 GridBase(other, ShallowCopy()),
1255 mTree(other.mTree)
1256 {
1257 }
1258 #else
1259 template<typename TreeT>
1260 inline Grid<TreeT>::Grid(Grid& other, ShallowCopy):
1261 GridBase(other),
1262 mTree(other.mTree)
1263 {
1264 }
1265 #endif
1266
1267
1268 template<typename TreeT>
1269 inline Grid<TreeT>::Grid(const GridBase& other):
1270 GridBase(other),
1271 mTree(new TreeType)
1272 {
1273 }
1274
1275
1276 //static
1277 template<typename TreeT>
1278 inline typename Grid<TreeT>::Ptr
1279 Grid<TreeT>::create()
1280 {
1281 return Grid::create(zeroVal<ValueType>());
1282 }
1283
1284
1285 //static
1286 template<typename TreeT>
1287 inline typename Grid<TreeT>::Ptr
1288 Grid<TreeT>::create(const ValueType& background)
1289 {
1290 return Ptr(new Grid(background));
1291 }
1292
1293
1294 //static
1295 template<typename TreeT>
1296 inline typename Grid<TreeT>::Ptr
1297 Grid<TreeT>::create(TreePtrType tree)
1298 {
1299 return Ptr(new Grid(tree));
1300 }
1301
1302
1303 //static
1304 template<typename TreeT>
1305 inline typename Grid<TreeT>::Ptr
1306 Grid<TreeT>::create(const GridBase& other)
1307 {
1308 return Ptr(new Grid(other));
1309 }
1310
1311
1313
1314
1315 #if OPENVDB_ABI_VERSION_NUMBER <= 3
1316
1317 template<typename TreeT>
1318 inline typename Grid<TreeT>::Ptr
1319 Grid<TreeT>::copy(CopyPolicy treePolicy) const
1320 {
1321 Ptr ret;
1322 switch (treePolicy) {
1323 case CP_NEW:
1324 ret.reset(new Grid(*this, ShallowCopy()));
1325 ret->newTree();
1326 break;
1327 case CP_COPY:
1328 ret.reset(new Grid(*this));
1329 break;
1330 case CP_SHARE:
1331 ret.reset(new Grid(*this, ShallowCopy()));
1332 break;
1333 }
1334 return ret;
1335 }
1336
1337
1338 template<typename TreeT>
1339 inline GridBase::Ptr
1340 Grid<TreeT>::copyGrid(CopyPolicy treePolicy) const
1341 {
1342 return this->copy(treePolicy);
1343 }
1344
1345 #else // if OPENVDB_ABI_VERSION_NUMBER > 3
1346
1347 template<typename TreeT>
1348 inline typename Grid<TreeT>::ConstPtr
1349 Grid<TreeT>::copy() const
1350 {
1351 return ConstPtr{new Grid{*const_cast<Grid*>(this), ShallowCopy{}}};
1352 }
1353
1354 template<typename TreeT>
1355 inline typename Grid<TreeT>::Ptr
1356 Grid<TreeT>::copy()
1357 {
1358 return Ptr{new Grid{*this, ShallowCopy{}}};
1359 }
1360
1361
1362 template<typename TreeT>
1363 inline typename Grid<TreeT>::Ptr
1364 Grid<TreeT>::copyWithNewTree() const
1365 {
1366 Ptr result{new Grid{*const_cast<Grid*>(this), ShallowCopy{}}};
1367 result->newTree();
1368 return result;
1369 }
1370
1371
1372 template<typename TreeT>
1373 inline GridBase::Ptr
1374 Grid<TreeT>::copyGrid()
1375 {
1376 return this->copy();
1377 }
1378
1379 template<typename TreeT>
1380 inline GridBase::ConstPtr
1381 Grid<TreeT>::copyGrid() const
1382 {
1383 return this->copy();
1384 }
1385
1386
1387 template<typename TreeT>
1388 inline GridBase::Ptr
1389 Grid<TreeT>::copyGridWithNewTree() const
1390 {
1391 return this->copyWithNewTree();
1392 }
1393
1394 #endif
1395
1396
1398
1399
1400 template<typename TreeT>
1401 inline void
1402 Grid<TreeT>::setTree(TreeBase::Ptr tree)
1403 {
1404 if (!tree) OPENVDB_THROW(ValueError, "Tree pointer is null");
1405 if (tree->type() != TreeType::treeType()) {
1406 OPENVDB_THROW(TypeError, "Cannot assign a tree of type "
1407 + tree->type() + " to a grid of type " + this->type());
1408 }
1409 mTree = StaticPtrCast<TreeType>(tree);
1410 }
1411
1412
1413 template<typename TreeT>
1414 inline void
1415 Grid<TreeT>::newTree()
1416 {
1417 mTree.reset(new TreeType(this->background()));
1418 }
1419
1420
1422
1423
1424 template<typename TreeT>
1425 inline void
1426 Grid<TreeT>::sparseFill(const CoordBBox& bbox, const ValueType& value, bool active)
1427 {
1428 tree().sparseFill(bbox, value, active);
1429 }
1430
1431
1432 template<typename TreeT>
1433 inline void
1434 Grid<TreeT>::fill(const CoordBBox& bbox, const ValueType& value, bool active)
1435 {
1436 this->sparseFill(bbox, value, active);
1437 }
1438
1439 template<typename TreeT>
1440 inline void
1441 Grid<TreeT>::denseFill(const CoordBBox& bbox, const ValueType& value, bool active)
1442 {
1443 tree().denseFill(bbox, value, active);
1444 }
1445
1446 template<typename TreeT>
1447 inline void
1448 Grid<TreeT>::pruneGrid(float tolerance)
1449 {
1450 OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
1451 const auto value = zeroVal<ValueType>() + tolerance;
1452 OPENVDB_NO_TYPE_CONVERSION_WARNING_END
1453 this->tree().prune(static_cast<ValueType>(value));
1454 }
1455
1456 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1457 template<typename TreeT>
1458 inline void
1459 Grid<TreeT>::clip(const CoordBBox& bbox)
1460 {
1461 tree().clip(bbox);
1462 }
1463 #endif
1464
1465
1466 template<typename TreeT>
1467 inline void
1468 Grid<TreeT>::merge(Grid& other, MergePolicy policy)
1469 {
1470 tree().merge(other.tree(), policy);
1471 }
1472
1473
1474 template<typename TreeT>
1475 template<typename OtherTreeType>
1476 inline void
1477 Grid<TreeT>::topologyUnion(const Grid<OtherTreeType>& other)
1478 {
1479 tree().topologyUnion(other.tree());
1480 }
1481
1482
1483 template<typename TreeT>
1484 template<typename OtherTreeType>
1485 inline void
1486 Grid<TreeT>::topologyIntersection(const Grid<OtherTreeType>& other)
1487 {
1488 tree().topologyIntersection(other.tree());
1489 }
1490
1491
1492 template<typename TreeT>
1493 template<typename OtherTreeType>
1494 inline void
1495 Grid<TreeT>::topologyDifference(const Grid<OtherTreeType>& other)
1496 {
1497 tree().topologyDifference(other.tree());
1498 }
1499
1500
1502
1503
1504 template<typename TreeT>
1505 inline void
1506 Grid<TreeT>::evalMinMax(ValueType& minVal, ValueType& maxVal) const
1507 {
1508 tree().evalMinMax(minVal, maxVal);
1509 }
1510
1511
1512 template<typename TreeT>
1513 inline CoordBBox
1514 Grid<TreeT>::evalActiveVoxelBoundingBox() const
1515 {
1516 CoordBBox bbox;
1517 tree().evalActiveVoxelBoundingBox(bbox);
1518 return bbox;
1519 }
1520
1521
1522 template<typename TreeT>
1523 inline Coord
1524 Grid<TreeT>::evalActiveVoxelDim() const
1525 {
1526 Coord dim;
1527 const bool nonempty = tree().evalActiveVoxelDim(dim);
1528 return (nonempty ? dim : Coord());
1529 }
1530
1531
1533
1534
1537
1538 template<typename TreeT>
1539 inline void
1540 Grid<TreeT>::readTopology(std::istream& is)
1541 {
1542 tree().readTopology(is, saveFloatAsHalf());
1543 }
1544
1545
1546 template<typename TreeT>
1547 inline void
1548 Grid<TreeT>::writeTopology(std::ostream& os) const
1549 {
1550 tree().writeTopology(os, saveFloatAsHalf());
1551 }
1552
1553
1554 template<typename TreeT>
1555 inline void
1556 Grid<TreeT>::readBuffers(std::istream& is)
1557 {
1558 if (!hasMultiPassIO() || (io::getFormatVersion(is) < OPENVDB_FILE_VERSION_MULTIPASS_IO)) {
1559 tree().readBuffers(is, saveFloatAsHalf());
1560 } else {
1561 uint16_t numPasses = 1;
1562 is.read(reinterpret_cast<char*>(&numPasses), sizeof(uint16_t));
1563 const io::StreamMetadata::Ptr meta = io::getStreamMetadataPtr(is);
1564 assert(bool(meta));
1565 for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1566 uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1567 meta->setPass(pass);
1568 tree().readBuffers(is, saveFloatAsHalf());
1569 }
1570 }
1571 }
1572
1573
1574 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1575
1578 template<typename TreeT>
1579 inline void
1580 Grid<TreeT>::readBuffers(std::istream& is, const CoordBBox& bbox)
1581 {
1582 if (!hasMultiPassIO() || (io::getFormatVersion(is) < OPENVDB_FILE_VERSION_MULTIPASS_IO)) {
1583 tree().readBuffers(is, bbox, saveFloatAsHalf());
1584 } else {
1585 uint16_t numPasses = 1;
1586 is.read(reinterpret_cast<char*>(&numPasses), sizeof(uint16_t));
1587 const io::StreamMetadata::Ptr meta = io::getStreamMetadataPtr(is);
1588 assert(bool(meta));
1589 for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1590 uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1591 meta->setPass(pass);
1592 tree().readBuffers(is, saveFloatAsHalf());
1593 }
1594 // Cannot clip inside readBuffers() when using multiple passes,
1595 // so instead clip afterwards.
1596 tree().clip(bbox);
1597 }
1598 }
1599
1600
1601 template<typename TreeT>
1602 inline void
1603 Grid<TreeT>::readNonresidentBuffers() const
1604 {
1605 tree().readNonresidentBuffers();
1606 }
1607
1608 #endif
1609
1610
1611 template<typename TreeT>
1612 inline void
1613 Grid<TreeT>::writeBuffers(std::ostream& os) const
1614 {
1615 if (!hasMultiPassIO()) {
1616 tree().writeBuffers(os, saveFloatAsHalf());
1617 } else {
1618 // Determine how many leaf buffer passes are required for this grid
1619 const io::StreamMetadata::Ptr meta = io::getStreamMetadataPtr(os);
1620 assert(bool(meta));
1621 uint16_t numPasses = 1;
1622 meta->setCountingPasses(true);
1623 meta->setPass(0);
1624 tree().writeBuffers(os, saveFloatAsHalf());
1625 numPasses = static_cast<uint16_t>(meta->pass());
1626 os.write(reinterpret_cast<const char*>(&numPasses), sizeof(uint16_t));
1627 meta->setCountingPasses(false);
1628
1629 // Save out the data blocks of the grid.
1630 for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1631 uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1632 meta->setPass(pass);
1633 tree().writeBuffers(os, saveFloatAsHalf());
1634 }
1635 }
1636 }
1637
1638
1639 //static
1640 template<typename TreeT>
1641 inline bool
1642 Grid<TreeT>::hasMultiPassIO()
1643 {
1644 return HasMultiPassIO<Grid>::value;
1645 }
1646
1647
1648 template<typename TreeT>
1649 inline void
1650 Grid<TreeT>::print(std::ostream& os, int verboseLevel) const
1651 {
1652 tree().print(os, verboseLevel);
1653
1654 if (metaCount() > 0) {
1655 os << "Additional metadata:" << std::endl;
1656 for (ConstMetaIterator it = beginMeta(), end = endMeta(); it != end; ++it) {
1657 os << " " << it->first;
1658 if (it->second) {
1659 const std::string value = it->second->str();
1660 if (!value.empty()) os << ": " << value;
1661 }
1662 os << "\n";
1663 }
1664 }
1665
1666 os << "Transform:" << std::endl;
1667 transform().print(os, /*indent=*/" ");
1668 os << std::endl;
1669 }
1670
1671
1673
1674
1675 template<typename GridType>
1676 inline typename GridType::Ptr
1677 createGrid(const typename GridType::ValueType& background)
1678 {
1679 return GridType::create(background);
1680 }
1681
1682
1683 template<typename GridType>
1684 inline typename GridType::Ptr
1685 createGrid()
1686 {
1687 return GridType::create();
1688 }
1689
1690
1691 template<typename TreePtrType>
1692 inline typename Grid<typename TreePtrType::element_type>::Ptr
1693 createGrid(TreePtrType tree)
1694 {
1695 using TreeType = typename TreePtrType::element_type;
1696 return Grid<TreeType>::create(tree);
1697 }
1698
1699
1700 template<typename GridType>
1701 typename GridType::Ptr
1702 createLevelSet(Real voxelSize, Real halfWidth)
1703 {
1704 using ValueType = typename GridType::ValueType;
1705
1706 // GridType::ValueType is required to be a floating-point scalar.
1707 static_assert(std::is_floating_point<ValueType>::value,
1708 "level-set grids must be floating-point-valued");
1709
1710 typename GridType::Ptr grid = GridType::create(
1711 /*background=*/static_cast<ValueType>(voxelSize * halfWidth));
1712 grid->setTransform(math::Transform::createLinearTransform(voxelSize));
1713 grid->setGridClass(GRID_LEVEL_SET);
1714 return grid;
1715 }
1716
1717
1719
1720
1721 namespace internal {
1722
1724 template<typename OpT, typename GridBaseT, typename T, typename ...Ts>
1725 struct GridApplyImpl { static bool apply(GridBaseT&, OpT&) { return false; } };
1726
1727 // Partial specialization for (nonempty) TypeLists
1729 template<typename OpT, typename GridBaseT, typename GridT, typename ...GridTs>
1730 struct GridApplyImpl<OpT, GridBaseT, TypeList<GridT, GridTs...>>
1731 {
1732 static bool apply(GridBaseT& grid, OpT& op)
1733 {
1734 if (grid.template isType<GridT>()) {
1735 op(static_cast<typename CopyConstness<GridBaseT, GridT>::Type&>(grid));
1736 return true;
1737 }
1738 return GridApplyImpl<OpT, GridBaseT, TypeList<GridTs...>>::apply(grid, op);
1739 }
1740 };
1741
1742 } // namespace internal
1743
1744
1745 template<typename GridTypeListT, typename OpT>
1746 inline bool
1747 GridBase::apply(OpT& op) const
1748 {
1749 return internal::GridApplyImpl<OpT, const GridBase, GridTypeListT>::apply(*this, op);
1750 }
1751
1752 template<typename GridTypeListT, typename OpT>
1753 inline bool
1754 GridBase::apply(OpT& op)
1755 {
1756 return internal::GridApplyImpl<OpT, GridBase, GridTypeListT>::apply(*this, op);
1757 }
1758
1759 } // namespace OPENVDB_VERSION_NAME
1760 } // namespace openvdb
1761
1762 #endif // OPENVDB_GRID_HAS_BEEN_INCLUDED
1763
1764 // Copyright (c) 2012-2019 DreamWorks Animation LLC
1765 // All rights reserved. This software is distributed under the
1766 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
openvdb::v6_1::GridBase::ConstPtr
SharedPtr< const GridBase > ConstPtr
Definition: Grid.h:108
openvdb::v6_1::Grid::create
static Ptr create()
Return a new grid with background value zero.
Definition: Grid.h:1279
openvdb::v6_1::Grid::beginValueOn
ValueOnCIter beginValueOn() const
Return an iterator over all of this grid's active values (tile and voxel).
Definition: Grid.h:757
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::GridPtrType
typename GridType::Ptr GridPtrType
Definition: Grid.h:1075
OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
#define OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
Bracket code with OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN/_END, to inhibit warnings about type conve...
Definition: Platform.h:223
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::ValueType
typename TreeType::ValueType ValueType
Definition: Grid.h:1107
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::AccessorType
typename tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:1079
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static const TreeType & tree(const AccessorType &a)
Definition: Grid.h:1117
OPENVDB_API
#define OPENVDB_API
Helper macros for defining library symbol visibility.
Definition: Platform.h:288
openvdb::v6_1::TreeAdapter::TreePtrType
typename TreeType::Ptr TreePtrType
Definition: Grid.h:1040
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstGridPtrType
typename NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:1105
openvdb::v6_1::GridBase::META_FILE_MEM_BYTES
static const char *const META_FILE_MEM_BYTES
Definition: Grid.h:376
openvdb::v6_1::TreeAdapter::ValueType
typename TreeType::ValueType ValueType
Definition: Grid.h:1048
Types.h
OPENVDB_DEPRECATED
#define OPENVDB_DEPRECATED
Definition: Platform.h:69
openvdb::v6_1::GridBase::hasUniformVoxels
bool hasUniformVoxels() const
Return true if the voxels in world space are uniformly sized cubes.
Definition: Grid.h:450
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::TreePtrType
typename TreeType::Ptr TreePtrType
Definition: Grid.h:1099
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static TreeType & tree(TreeType &t)
Definition: Grid.h:1112
openvdb::v6_1::math::Transform::createLinearTransform
static Transform::Ptr createLinearTransform(double voxelSize=1.0)
Create and return a shared pointer to a new transform.
openvdb::v6_1::TreeAdapter::TreeType
_TreeType TreeType
Definition: Grid.h:1038
openvdb::v6_1::TreeAdapter::NonConstTreePtrType
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:1042
openvdb::v6_1::GridBase::isRegistered
static bool isRegistered(const Name &type)
Return true if the given grid type name is registered.
openvdb::v6_1::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:1434
openvdb::v6_1::Grid::~Grid
~Grid() override
Definition: Grid.h:665
MetaMap.h
openvdb::v6_1::GridBase::META_SAVE_HALF_FLOAT
static const char *const META_SAVE_HALF_FLOAT
Definition: Grid.h:370
openvdb::v6_1::GridPtrVecCIter
GridPtrVec::const_iterator GridPtrVecCIter
Definition: Grid.h:529
openvdb::v6_1::Grid::TreePtrType
typename _TreeType::Ptr TreePtrType
Definition: Grid.h:596
openvdb::v6_1::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:1198
openvdb::v6_1::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:1374
openvdb::v6_1::Grid::cbeginValueAll
ValueAllCIter cbeginValueAll() const
Return an iterator over all of this grid's values (tile and voxel).
Definition: Grid.h:770
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::ConstTreePtrType
typename TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:1100
openvdb::v6_1::Grid::UnsafeAccessor
typename tree::ValueAccessor< _TreeType, false > UnsafeAccessor
Definition: Grid.h:610
openvdb::v6_1::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:1356
openvdb::v6_1::GridBase::unregisterGrid
static void unregisterGrid(const Name &type)
Remove a grid type from the registry.
openvdb::v6_1::Grid::ValueAllIter
typename _TreeType::ValueAllIter ValueAllIter
Definition: Grid.h:605
openvdb::v6_1::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:883
openvdb::v6_1::TreeAdapter::ConstAccessorType
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:1050
openvdb::v6_1::GridBase::META_GRID_NAME
static const char *const META_GRID_NAME
Definition: Grid.h:369
openvdb::v6_1::GridCPtrVecIter
GridCPtrVec::iterator GridCPtrVecIter
Definition: Grid.h:533
openvdb::v6_1::GridNamePred::GridNamePred
GridNamePred(const Name &_name)
Definition: Grid.h:551
openvdb::v6_1::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:1389
openvdb::v6_1::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:1693
OPENVDB_THROW
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:109
openvdb::v6_1::Grid::gridType
static Name gridType()
Return the name of this type of grid.
Definition: Grid.h:707
openvdb::v6_1::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:418
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::NonConstTreeType
typename std::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:1069
openvdb::v6_1::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:419
openvdb::v6_1::GridBase::~GridBase
~GridBase() override
Definition: Grid.h:113
openvdb::v6_1::GridCPtrVecPtr
SharedPtr< GridCPtrVec > GridCPtrVecPtr
Definition: Grid.h:535
openvdb::v6_1::GridBase::constTransform
const math::Transform & constTransform() const
Return a reference to this grid's transform, which might be shared with other grids.
Definition: Grid.h:428
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstTreeType
typename std::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:1098
openvdb::v6_1::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:379
openvdb::v6_1::tree::ValueAccessor
Definition: ValueAccessor.h:220
openvdb::v6_1::GridNamePred::operator()
bool operator()(const GridBase::ConstPtr &g) const
Definition: Grid.h:552
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::NonConstTreePtrType
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:1072
openvdb::v6_1::TreeAdapter::GridPtrType
typename GridType::Ptr GridPtrType
Definition: Grid.h:1045
openvdb::v6_1::Grid::memUsage
Index64 memUsage() const override
Definition: Grid.h:871
openvdb::v6_1::Grid::readBuffers
void readBuffers(std::istream &) override
Read all data buffers for this grid.
Definition: Grid.h:1556
openvdb::v6_1::ShallowCopy
Tag dispatch class that distinguishes shallow copy constructors from deep copy constructors.
Definition: Types.h:747
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::ConstAccessorType
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:1109
openvdb::v6_1::MetaMap::Ptr
SharedPtr< MetaMap > Ptr
Definition: MetaMap.h:49
openvdb::v6_1::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::v6_1::MergePolicy
MergePolicy
Definition: Types.h:555
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::TreePtrType
typename TreeType::Ptr TreePtrType
Definition: Grid.h:1070
openvdb::v6_1::io::getFormatVersion
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
openvdb::v6_1::GridPtrSetPtr
SharedPtr< GridPtrSet > GridPtrSetPtr
Definition: Grid.h:540
openvdb::v6_1::TreeAdapter::constTree
static const TreeType & constTree(GridType &g)
Definition: Grid.h:1058
openvdb::v6_1::TreeAdapter::NonConstGridPtrType
typename NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:1046
openvdb::v6_1::GridBase
Abstract base class for typed grids.
Definition: Grid.h:104
openvdb::v6_1::Grid::newTree
void newTree() override
Associate a new, empty tree with this grid, in place of its existing tree.
Definition: Grid.h:1415
Transform.h
openvdb::v6_1::math::BBox< Vec3d >
openvdb::v6_1::GridBase::META_FILE_BBOX_MIN
static const char *const META_FILE_BBOX_MIN
Definition: Grid.h:373
openvdb::v6_1::TreeAdapter::constTree
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:1059
openvdb::v6_1::TreeAdapter::ConstGridPtrType
typename GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:1047
io.h
openvdb::v6_1::GridBase::META_VECTOR_TYPE
static const char *const META_VECTOR_TYPE
Definition: Grid.h:372
openvdb::v6_1::Grid
Container class that associates a tree with a transform and metadata.
Definition: Grid.h:55
openvdb::v6_1::GridCPtrSet
std::set< GridBase::ConstPtr > GridCPtrSet
Definition: Grid.h:542
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:1120
logging.h
openvdb::v6_1::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:1495
openvdb::v6_1::TreeAdapter::NonConstTreeType
typename std::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:1039
openvdb::v6_1::SharedPtr
std::shared_ptr< T > SharedPtr
Definition: Types.h:139
openvdb::v6_1::GridBase::baseTree
const TreeBase & baseTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:204
openvdb::v6_1::GridPtrVecPtr
SharedPtr< GridPtrVec > GridPtrVecPtr
Definition: Grid.h:530
openvdb::v6_1::TreeAdapter::NonConstAccessorType
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:1051
openvdb::v6_1::Name
std::string Name
Definition: Name.h:44
OPENVDB_NO_TYPE_CONVERSION_WARNING_END
#define OPENVDB_NO_TYPE_CONVERSION_WARNING_END
Definition: Platform.h:224
openvdb::v6_1::Grid::ValueAllCIter
typename _TreeType::ValueAllCIter ValueAllCIter
Definition: Grid.h:606
openvdb::v6_1::GridBase::worldToIndex
Vec3d worldToIndex(const Vec3d &xyz) const
Apply the inverse of this grid's transform to the given coordinates.
Definition: Grid.h:456
Tree.h
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::constTree
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:1090
openvdb::v6_1::GridPtrSet
std::set< GridBase::Ptr > GridPtrSet
Definition: Grid.h:537
openvdb::v6_1::GridBase::META_FILE_COMPRESSION
static const char *const META_FILE_COMPRESSION
Definition: Grid.h:375
openvdb::v6_1::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:1642
openvdb::v6_1::GridBase::GridBase
GridBase(const GridBase &other)
Deep copy another grid's metadata and transform.
Definition: Grid.h:502
openvdb::v6_1::Grid::ConstTreePtrType
typename _TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:597
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::tree
static const TreeType & tree(const GridType &g)
Definition: Grid.h:1086
openvdb::v6_1::GridBase::constBaseTree
const TreeBase & constBaseTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:209
openvdb::v6_1::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:190
openvdb::v6_1::tree::internal::LeafBufferFlags
Definition: LeafBuffer.h:67
openvdb::v6_1::Grid::unregisterGrid
static void unregisterGrid()
Remove this grid type from the registry.
Definition: Grid.h:956
openvdb::v6_1::GridNamePred::name
Name name
Definition: Grid.h:553
openvdb::v6_1::Grid::Accessor
typename tree::ValueAccessor< _TreeType, true > Accessor
Definition: Grid.h:608
openvdb::v6_1::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:1548
openvdb::v6_1::math::Vec3d
Vec3< double > Vec3d
Definition: Vec3.h:689
openvdb::v6_1::GridBase::baseTree
TreeBase & baseTree()
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:199
openvdb::v6_1::Grid::evalActiveVoxelBoundingBox
CoordBBox evalActiveVoxelBoundingBox() const override
Return the axis-aligned bounding box of all active voxels.
Definition: Grid.h:1514
openvdb::v6_1::GridPtrVec
std::vector< GridBase::Ptr > GridPtrVec
Definition: Grid.h:527
openvdb::v6_1::GridBase::META_GRID_CLASS
static const char *const META_GRID_CLASS
Definition: Grid.h:367
openvdb::v6_1::Grid::print
void print(std::ostream &=std::cout, int verboseLevel=1) const override
Output a human-readable description of this grid.
Definition: Grid.h:1650
Exceptions.h
openvdb::v6_1::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:1540
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:1121
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstAccessorType
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:1110
openvdb::v6_1::GridBase::voxelSize
Vec3d voxelSize(const Vec3d &xyz) const
Return the size of this grid's voxel at position (x, y, z).
Definition: Grid.h:448
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:125
openvdb::v6_1::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:979
openvdb::v6_1::OPENVDB_FILE_VERSION_MULTIPASS_IO
Definition: version.h:221
openvdb::v6_1::CopyConstness::Type
typename std::remove_const< ToType >::type Type
Definition: Types.h:348
openvdb::v6_1::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:570
openvdb::v6_1::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:1747
openvdb::v6_1::Grid::BuildType
typename _TreeType::BuildType BuildType
Definition: Grid.h:599
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::tree
static TreeType & tree(TreeType &t)
Definition: Grid.h:1083
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::tree
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:1085
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static TreeType & tree(AccessorType &a)
Definition: Grid.h:1114
openvdb::v6_1::Grid::evalMinMax
void evalMinMax(ValueType &minVal, ValueType &maxVal) const
Return the minimum and maximum active values in this grid.
Definition: Grid.h:1506
openvdb::v6_1::Grid::cbeginValueOn
ValueOnCIter cbeginValueOn() const
Return an iterator over all of this grid's active values (tile and voxel).
Definition: Grid.h:758
OPENVDB_LOG_WARN
#define OPENVDB_LOG_WARN(message)
Log a warning message of the form 'someVar << "some text" << ...'.
Definition: logging.h:280
openvdb::v6_1::GridBase::META_IS_LOCAL_SPACE
static const char *const META_IS_LOCAL_SPACE
Definition: Grid.h:371
openvdb::v6_1::Index64
uint64_t Index64
Definition: Types.h:60
openvdb::v6_1::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:1603
openvdb::v6_1::GridBase::META_FILE_VOXEL_COUNT
static const char *const META_FILE_VOXEL_COUNT
Definition: Grid.h:377
openvdb::v6_1::createGrid
GridType::Ptr createGrid(const typename GridType::ValueType &background)
Create a new grid of type GridType with a given background value.
Definition: Grid.h:1677
openvdb::v6_1::MetaMap::ConstMetaIterator
MetadataMap::const_iterator ConstMetaIterator
Definition: MetaMap.h:55
openvdb::v6_1::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:1364
openvdb::v6_1::GridBase::indexToWorld
Vec3d indexToWorld(const Coord &ijk) const
Apply this grid's transform to the given coordinates.
Definition: Grid.h:454
openvdb::v6_1::TreeAdapter::constTree
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:1060
openvdb::v6_1::GridBase::registerGrid
static void registerGrid(const Name &type, GridFactory)
Register a grid type along with a factory function.
openvdb::v6_1::Real
double Real
Definition: Types.h:67
openvdb::v6_1::Grid::tree
const TreeType & tree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:891
openvdb::v6_1::GridBase::readTransform
void readTransform(std::istream &is)
Read in the transform for this grid.
Definition: Grid.h:487
openvdb::v6_1::Grid::registerGrid
static void registerGrid()
Register this grid type along with a factory function.
Definition: Grid.h:947
openvdb
Definition: Exceptions.h:40
openvdb::v6_1::Grid::Grid
Grid()
Construct a new grid with background value zero.
Definition: Grid.h:1216
openvdb::v6_1::GridBase::Ptr
SharedPtr< GridBase > Ptr
Definition: Grid.h:107
openvdb::v6_1::math::CoordBBox
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:271
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::AccessorType
typename tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:1108
openvdb::v6_1::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:1441
openvdb::v6_1::GridCPtrVec
std::vector< GridBase::ConstPtr > GridCPtrVec
Definition: Grid.h:532
openvdb::v6_1::tree::TreeBase::Ptr
SharedPtr< TreeBase > Ptr
Definition: Tree.h:65
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static TreeType & tree(GridType &g)
Definition: Grid.h:1113
openvdb::v6_1::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:995
openvdb::v6_1::GridCPtrSetPtr
SharedPtr< GridCPtrSet > GridCPtrSetPtr
Definition: Grid.h:545
openvdb::v6_1::GridPtrSetIter
GridPtrSet::iterator GridPtrSetIter
Definition: Grid.h:538
openvdb::v6_1::Grid::ValueConverter
ValueConverter<T>::Type is the type of a grid having the same hierarchy as this grid but a different ...
Definition: Grid.h:620
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::GridPtrType
typename GridType::Ptr GridPtrType
Definition: Grid.h:1104
openvdb::v6_1::Grid::constTree
const TreeType & constTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:892
openvdb::v6_1::Grid::pruneGrid
void pruneGrid(float tolerance=0.0) override
Reduce the memory footprint of this grid by increasing its sparseness.
Definition: Grid.h:1448
openvdb::v6_1::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:701
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::NonConstGridPtrType
typename NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:1076
openvdb::v6_1::Grid::ConstUnsafeAccessor
typename tree::ValueAccessor< const _TreeType, false > ConstUnsafeAccessor
Definition: Grid.h:611
openvdb::v6_1::math::Transform::Ptr
SharedPtr< Transform > Ptr
Definition: Transform.h:69
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::constTree
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:1089
openvdb::v6_1::io::StreamMetadata::Ptr
SharedPtr< StreamMetadata > Ptr
Definition: io.h:60
openvdb::v6_1::GridCPtrVecCIter
GridCPtrVec::const_iterator GridCPtrVecCIter
Definition: Grid.h:534
openvdb::v6_1::tree::TreeBase
Base class for typed trees.
Definition: Tree.h:62
openvdb::v6_1::GridNamePred
Predicate functor that returns true for grids that have a specified name.
Definition: Grid.h:549
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::TreeType
_TreeType TreeType
Definition: Grid.h:1068
openvdb::v6_1::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::v6_1::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:1182
openvdb::v6_1::math::Transform
Definition: Transform.h:66
openvdb::v6_1::Grid::background
const ValueType & background() const
Return this grid's background value.
Definition: Grid.h:719
openvdb::v6_1::Grid::isRegistered
static bool isRegistered()
Return true if this grid type is registered.
Definition: Grid.h:945
openvdb::v6_1::GridBase::META_GRID_CREATOR
static const char *const META_GRID_CREATOR
Definition: Grid.h:368
openvdb::v6_1::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:1160
openvdb::v6_1::TreeAdapter::ConstTreePtrType
typename TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:1041
openvdb::v6_1::Grid::getConstAccessor
ConstAccessor getConstAccessor() const
Return an accessor that provides random read-only access to this grid's voxels.
Definition: Grid.h:742
openvdb::v6_1::Grid::ValueOnIter
typename _TreeType::ValueOnIter ValueOnIter
Definition: Grid.h:601
openvdb::v6_1::math::Coord
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:52
openvdb::v6_1::Grid::getUnsafeAccessor
UnsafeAccessor getUnsafeAccessor()
Return an accessor that provides random read and write access to this grid's voxels....
Definition: Grid.h:738
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static const TreeType & tree(const GridType &g)
Definition: Grid.h:1116
openvdb::v6_1::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:1477
openvdb::v6_1::Grid::ValueOffIter
typename _TreeType::ValueOffIter ValueOffIter
Definition: Grid.h:603
openvdb::v6_1::Grid::cbeginValueOff
ValueOffCIter cbeginValueOff() const
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition: Grid.h:764
openvdb::v6_1::VecType
VecType
Definition: Types.h:532
openvdb::v6_1::GridPtrSetCIter
GridPtrSet::const_iterator GridPtrSetCIter
Definition: Grid.h:539
openvdb::v6_1::TreeAdapter::AccessorType
typename tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:1049
openvdb::v6_1::TreeAdapter::constTree
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:1057
openvdb::v6_1::TreeAdapter::tree
static const TreeType & tree(const GridType &g)
Definition: Grid.h:1056
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:1115
openvdb::v6_1::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::v6_1::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::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:1118
openvdb::v6_1::TreeAdapter::tree
static TreeType & tree(GridType &g)
Definition: Grid.h:1054
openvdb::v6_1::GridClass
GridClass
Definition: Types.h:502
openvdb::v6_1::math::Transform::ConstPtr
SharedPtr< const Transform > ConstPtr
Definition: Transform.h:70
openvdb::v6_1::GridBase::transform
const math::Transform & transform() const
Return a reference to this grid's transform, which might be shared with other grids.
Definition: Grid.h:427
openvdb::v6_1::Grid::clear
void clear() override
Empty this grid, so that all voxels become inactive background voxels.
Definition: Grid.h:724
openvdb::v6_1::TypeError
Definition: Exceptions.h:91
openvdb::v6_1::GridCPtrSetIter
GridCPtrSet::iterator GridCPtrSetIter
Definition: Grid.h:543
openvdb::v6_1::Grid::type
Name type() const override
Return the name of this grid's type.
Definition: Grid.h:705
openvdb::v6_1::Grid::activeVoxelCount
Index64 activeVoxelCount() const override
Return the number of active voxels.
Definition: Grid.h:863
openvdb::v6_1::GridBase::META_FILE_BBOX_MAX
static const char *const META_FILE_BBOX_MAX
Definition: Grid.h:374
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::ValueType
typename TreeType::ValueType ValueType
Definition: Grid.h:1078
openvdb::v6_1::LEVEL_SET_HALF_WIDTH
static const Real LEVEL_SET_HALF_WIDTH
Definition: Types.h:510
openvdb::v6_1::Grid::ValueOnCIter
typename _TreeType::ValueOnCIter ValueOnCIter
Definition: Grid.h:602
openvdb::v6_1::Grid::TreeType
_TreeType TreeType
Definition: Grid.h:595
openvdb::v6_1::Grid::tree
TreeType & tree()
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:890
openvdb::v6_1::Grid::setTree
void setTree(TreeBase::Ptr) override
Associate the given tree with this grid, in place of its existing tree.
Definition: Grid.h:1402
openvdb::v6_1::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:1486
openvdb::v6_1::GridBase::setTransform
void setTransform(math::Transform::Ptr)
Associate the given transform with this grid, in place of its existing transform.
Definition: Grid.h:1205
openvdb::v6_1::ValueError
Definition: Exceptions.h:92
openvdb::v6_1::TreeAdapter::tree
static TreeType & tree(TreeType &t)
Definition: Grid.h:1053
openvdb::v6_1::GridBase::GridBase
GridBase()
Initialize with an identity linear transform.
Definition: Grid.h:499
openvdb::v6_1::GridBase::GridFactory
Ptr(*)() GridFactory
Definition: Grid.h:110
openvdb::v6_1::GridBase::isType
bool isType() const
Return true if this grid is of the same type as the template parameter.
Definition: Grid.h:165
openvdb::v6_1::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:1702
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::NonConstAccessorType
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:1081
openvdb::v6_1::GridBase::writeTransform
void writeTransform(std::ostream &os) const
Write out the transform for this grid.
Definition: Grid.h:489
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:177
openvdb::v6_1::Grid::empty
bool empty() const override
Return true if this grid contains only inactive background voxels.
Definition: Grid.h:722
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstTreePtrType
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:1101
openvdb::v6_1::TypeList
A list of types (not necessarily unique)
Definition: Types.h:439
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::ConstTreePtrType
typename TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:1071
openvdb::v6_1::Grid::getAccessor
Accessor getAccessor()
Return an accessor that provides random read and write access to this grid's voxels....
Definition: Grid.h:729
openvdb::v6_1::Grid::clip
void clip(const CoordBBox &) override
Clip this grid to the given index-space bounding box.
Definition: Grid.h:1459
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::ConstGridPtrType
typename GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:1077
openvdb::v6_1::Grid::Ptr
SharedPtr< Grid > Ptr
Definition: Grid.h:592
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::constTree
static const TreeType & constTree(GridType &g)
Definition: Grid.h:1088
openvdb::v6_1::GridBase::indexToWorld
Vec3d indexToWorld(const Vec3d &xyz) const
Apply this grid's transform to the given coordinates.
Definition: Grid.h:452
openvdb::v6_1::TreeAdapter::tree
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:1055
openvdb::v6_1::Grid::beginValueAll
ValueAllCIter beginValueAll() const
Return an iterator over all of this grid's values (tile and voxel).
Definition: Grid.h:769
openvdb::v6_1::tree::TreeBase::ConstPtr
SharedPtr< const TreeBase > ConstPtr
Definition: Tree.h:66
openvdb::v6_1::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:881
openvdb::v6_1::Grid::ConstAccessor
typename tree::ValueAccessor< const _TreeType, true > ConstAccessor
Definition: Grid.h:609
openvdb::v6_1::Grid::ConstPtr
SharedPtr< const Grid > ConstPtr
Definition: Grid.h:593
openvdb::v6_1::deepCopyTypedGrid
GridType::Ptr deepCopyTypedGrid(const GridBase &grid)
Return a pointer to a deep copy of the given grid, provided that the grid's concrete type is GridType...
Definition: Grid.h:1021
openvdb::v6_1::GRID_LEVEL_SET
Definition: Types.h:504
openvdb::v6_1::Grid::writeBuffers
void writeBuffers(std::ostream &) const override
Write out all data buffers for this grid.
Definition: Grid.h:1613
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::TreeType
_TreeType TreeType
Definition: Grid.h:1097
openvdb::v6_1::Grid::beginValueOff
ValueOffCIter beginValueOff() const
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition: Grid.h:763
openvdb::v6_1::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::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const TreeType & constTree(GridType &g)
Definition: Grid.h:1119
openvdb::v6_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::ConstGridPtrType
typename GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:1106
openvdb::v6_1::TreeBase
tree::TreeBase TreeBase
Definition: Grid.h:53
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::constTree
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:1087
openvdb::v6_1::MetaMap
Container that maps names (strings) to values of arbitrary types.
Definition: MetaMap.h:46
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::ConstAccessorType
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:1080
openvdb::v6_1::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:1426
openvdb::v6_1::TreeAdapter< Grid< _TreeType > >::tree
static TreeType & tree(GridType &g)
Definition: Grid.h:1084
openvdb::v6_1::MERGE_ACTIVE_STATES
Definition: Types.h:556
openvdb::v6_1::Grid::evalActiveVoxelDim
Coord evalActiveVoxelDim() const override
Return the dimensions of the axis-aligned bounding box of all active voxels.
Definition: Grid.h:1524
openvdb::v6_1::GridCPtrSetCIter
GridCPtrSet::const_iterator GridCPtrSetCIter
Definition: Grid.h:544
openvdb::v6_1::GridPtrVecIter
GridPtrVec::iterator GridPtrVecIter
Definition: Grid.h:528
openvdb::v6_1::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:882
Name.h
openvdb::v6_1::GridBase::voxelSize
Vec3d voxelSize() const
Return the size of this grid's voxels.
Definition: Grid.h:445
openvdb::v6_1::Grid::ValueOffCIter
typename _TreeType::ValueOffCIter ValueOffCIter
Definition: Grid.h:604
openvdb::v6_1::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:1468
openvdb::v6_1::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:1036
openvdb::v6_1::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...
openvdb::v6_1::Grid::ValueType
typename _TreeType::ValueType ValueType
Definition: Grid.h:598
openvdb::v6_1::HasMultiPassIO
Metafunction that specifies whether a given leaf node, tree, or grid type requires multiple passes to...
Definition: Grid.h:1136