OpenVDB: Grid.h Source File

OpenVDB 8.0.0

Grid.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3
4 #ifndef OPENVDB_GRID_HAS_BEEN_INCLUDED
5 #define OPENVDB_GRID_HAS_BEEN_INCLUDED
6
7 #include "Exceptions.h"
8 #include "MetaMap.h"
9 #include "Types.h"
10 #include "io/io.h"
11 #include "math/Transform.h"
12 #include "tree/Tree.h"
13 #include "util/logging.h"
14 #include "util/Name.h"
15 #include <cassert>
16 #include <iostream>
17 #include <set>
18 #include <type_traits>
19 #include <vector>
20
21
22 namespace openvdb {
23 OPENVDB_USE_VERSION_NAMESPACE
24 namespace OPENVDB_VERSION_NAME {
25
26 using TreeBase = tree::TreeBase;
27
28 template<typename> class Grid; // forward declaration
29
30
35 template<typename GridType>
36 inline typename GridType::Ptr createGrid(const typename GridType::ValueType& background);
37
38
42 template<typename GridType>
43 inline typename GridType::Ptr createGrid();
44
45
50 template<typename TreePtrType>
51 inline typename Grid<typename TreePtrType::element_type>::Ptr createGrid(TreePtrType);
52
53
68 template<typename GridType>
69 typename GridType::Ptr createLevelSet(
70 Real voxelSize = 1.0, Real halfWidth = LEVEL_SET_HALF_WIDTH);
71
72
74
75
77 class OPENVDB_API GridBase: public MetaMap
78 {
79 public:
80 using Ptr = SharedPtr<GridBase>;
81 using ConstPtr = SharedPtr<const GridBase>;
82
83 using GridFactory = Ptr (*)();
84
85
86 ~GridBase() override {}
87
88
91
94 virtual GridBase::Ptr copyGrid() = 0;
97 virtual GridBase::ConstPtr copyGrid() const = 0;
100 virtual GridBase::Ptr copyGridWithNewTree() const = 0;
101
102 #if OPENVDB_ABI_VERSION_NUMBER >= 7
103 virtual GridBase::ConstPtr copyGridReplacingMetadata(const MetaMap& meta) const = 0;
110 virtual GridBase::ConstPtr copyGridReplacingTransform(math::Transform::Ptr xform) const = 0;
114 virtual GridBase::ConstPtr copyGridReplacingMetadataAndTransform(const MetaMap& meta,
115 math::Transform::Ptr xform) const = 0;
116 #endif
117
119 virtual GridBase::Ptr deepCopyGrid() const = 0;
120
122
123
126
128 static Ptr createGrid(const Name& type);
129
131 static bool isRegistered(const Name &type);
132
134 static void clearRegistry();
135
137
140
142 virtual Name type() const = 0;
144 virtual Name valueType() const = 0;
145
147 template<typename GridType>
148 bool isType() const { return (this->type() == GridType::gridType()); }
149
151
153 template<typename GridType>
156 static typename GridType::Ptr grid(const GridBase::Ptr&);
157 template<typename GridType>
158 static typename GridType::ConstPtr grid(const GridBase::ConstPtr&);
159 template<typename GridType>
160 static typename GridType::ConstPtr constGrid(const GridBase::Ptr&);
161 template<typename GridType>
162 static typename GridType::ConstPtr constGrid(const GridBase::ConstPtr&);
164
167
170 TreeBase::Ptr baseTreePtr();
173 TreeBase::ConstPtr baseTreePtr() const { return this->constBaseTreePtr(); }
176 virtual TreeBase::ConstPtr constBaseTreePtr() const = 0;
177
178 #if OPENVDB_ABI_VERSION_NUMBER >= 8
179 virtual bool isTreeUnique() const = 0;
181 #endif
182
187 TreeBase& baseTree() { return const_cast<TreeBase&>(this->constBaseTree()); }
192 const TreeBase& baseTree() const { return this->constBaseTree(); }
197 const TreeBase& constBaseTree() const { return *(this->constBaseTreePtr()); }
198
205 virtual void setTree(TreeBase::Ptr) = 0;
206
208 virtual void newTree() = 0;
209
211
213 virtual bool empty() const = 0;
215 virtual void clear() = 0;
216
217
220
226 virtual void pruneGrid(float tolerance = 0.0) = 0;
227
232 void clipGrid(const BBoxd&);
233
238 virtual void clip(const CoordBBox&) = 0;
239
241
266 template<typename GridTypeListT, typename OpT> inline bool apply(OpT&) const;
267 template<typename GridTypeListT, typename OpT> inline bool apply(OpT&);
268 template<typename GridTypeListT, typename OpT> inline bool apply(const OpT&) const;
269 template<typename GridTypeListT, typename OpT> inline bool apply(const OpT&);
271
274
276 std::string getName() const;
278 void setName(const std::string&);
279
281 std::string getCreator() const;
283 void setCreator(const std::string&);
284
287 bool saveFloatAsHalf() const;
288 void setSaveFloatAsHalf(bool);
289
293 GridClass getGridClass() const;
297 void setGridClass(GridClass);
299 void clearGridClass();
300
302
304 static std::string gridClassToString(GridClass);
306 static std::string gridClassToMenuName(GridClass);
311 static GridClass stringToGridClass(const std::string&);
312
315
319 VecType getVectorType() const;
323 void setVectorType(VecType);
325 void clearVectorType();
326
328
330 static std::string vecTypeToString(VecType);
333 static std::string vecTypeExamples(VecType);
336 static std::string vecTypeDescription(VecType);
337 static VecType stringToVecType(const std::string&);
338
341
345 bool isInWorldSpace() const;
347 void setIsInWorldSpace(bool);
348
350
351 // Standard metadata field names
352 // (These fields should normally not be accessed directly, but rather
353 // via the accessor methods above, when available.)
354 // Note: Visual C++ requires these declarations to be separate statements.
355 static const char* const META_GRID_CLASS;
356 static const char* const META_GRID_CREATOR;
357 static const char* const META_GRID_NAME;
358 static const char* const META_SAVE_HALF_FLOAT;
359 static const char* const META_IS_LOCAL_SPACE;
360 static const char* const META_VECTOR_TYPE;
361 static const char* const META_FILE_BBOX_MIN;
362 static const char* const META_FILE_BBOX_MAX;
363 static const char* const META_FILE_COMPRESSION;
364 static const char* const META_FILE_MEM_BYTES;
365 static const char* const META_FILE_VOXEL_COUNT;
366 static const char* const META_FILE_DELAYED_LOAD;
367
368
371
373 virtual Index64 activeVoxelCount() const = 0;
374
377 virtual CoordBBox evalActiveVoxelBoundingBox() const = 0;
378
380 virtual Coord evalActiveVoxelDim() const = 0;
381
383 virtual Index64 memUsage() const = 0;
384
389 void addStatsMetadata();
395 MetaMap::Ptr getStatsMetadata() const;
396
398
399
402
404 math::Transform::Ptr transformPtr() { return mTransform; }
407 math::Transform::ConstPtr transformPtr() const { return mTransform; }
408 math::Transform::ConstPtr constTransformPtr() const { return mTransform; }
410
411 math::Transform& transform() { return *mTransform; }
416 const math::Transform& transform() const { return *mTransform; }
417 const math::Transform& constTransform() const { return *mTransform; }
419
421
424
431 void setTransform(math::Transform::Ptr);
432
434 Vec3d voxelSize() const { return transform().voxelSize(); }
437 Vec3d voxelSize(const Vec3d& xyz) const { return transform().voxelSize(xyz); }
439 bool hasUniformVoxels() const { return mTransform->hasUniformScale(); }
441 Vec3d indexToWorld(const Vec3d& xyz) const { return transform().indexToWorld(xyz); }
443 Vec3d indexToWorld(const Coord& ijk) const { return transform().indexToWorld(ijk); }
445 Vec3d worldToIndex(const Vec3d& xyz) const { return transform().worldToIndex(xyz); }
446
448
449
452
455 virtual void readTopology(std::istream&) = 0;
458 virtual void writeTopology(std::ostream&) const = 0;
459
461 virtual void readBuffers(std::istream&) = 0;
463 virtual void readBuffers(std::istream&, const CoordBBox&) = 0;
469 virtual void readNonresidentBuffers() const = 0;
471 virtual void writeBuffers(std::ostream&) const = 0;
472
474 void readTransform(std::istream& is) { transform().read(is); }
476 void writeTransform(std::ostream& os) const { transform().write(os); }
477
479 virtual void print(std::ostream& = std::cout, int verboseLevel = 1) const = 0;
480
482
483
484 protected:
486 GridBase(): mTransform(math::Transform::createLinearTransform()) {}
487
488 #if OPENVDB_ABI_VERSION_NUMBER >= 7
489 GridBase(const MetaMap& meta, math::Transform::Ptr xform);
492 #endif
493
495 GridBase(const GridBase& other): MetaMap(other), mTransform(other.mTransform->copy()) {}
496
498 GridBase(GridBase& other, ShallowCopy): MetaMap(other), mTransform(other.mTransform) {}
499
501 static void registerGrid(const Name& type, GridFactory);
503 static void unregisterGrid(const Name& type);
504
505
506 private:
507 math::Transform::Ptr mTransform;
508 }; // class GridBase
509
510
512
513
514 using GridPtrVec = std::vector<GridBase::Ptr>;
515 using GridPtrVecIter = GridPtrVec::iterator;
516 using GridPtrVecCIter = GridPtrVec::const_iterator;
517 using GridPtrVecPtr = SharedPtr<GridPtrVec>;
518
519 using GridCPtrVec = std::vector<GridBase::ConstPtr>;
520 using GridCPtrVecIter = GridCPtrVec::iterator;
521 using GridCPtrVecCIter = GridCPtrVec::const_iterator;
522 using GridCPtrVecPtr = SharedPtr<GridCPtrVec>;
523
524 using GridPtrSet = std::set<GridBase::Ptr>;
525 using GridPtrSetIter = GridPtrSet::iterator;
526 using GridPtrSetCIter = GridPtrSet::const_iterator;
527 using GridPtrSetPtr = SharedPtr<GridPtrSet>;
528
529 using GridCPtrSet = std::set<GridBase::ConstPtr>;
530 using GridCPtrSetIter = GridCPtrSet::iterator;
531 using GridCPtrSetCIter = GridCPtrSet::const_iterator;
532 using GridCPtrSetPtr = SharedPtr<GridCPtrSet>;
533
534
536 struct OPENVDB_API GridNamePred
537 {
538 GridNamePred(const Name& _name): name(_name) {}
539 bool operator()(const GridBase::ConstPtr& g) const { return g && g->getName() == name; }
540 Name name;
541 };
542
544 template<typename GridPtrContainerT>
545 inline typename GridPtrContainerT::value_type
546 findGridByName(const GridPtrContainerT& container, const Name& name)
547 {
548 using GridPtrT = typename GridPtrContainerT::value_type;
549 typename GridPtrContainerT::const_iterator it =
550 std::find_if(container.begin(), container.end(), GridNamePred(name));
551 return (it == container.end() ? GridPtrT() : *it);
552 }
553
555 template<typename KeyT, typename GridPtrT>
556 inline GridPtrT
557 findGridByName(const std::map<KeyT, GridPtrT>& container, const Name& name)
558 {
559 using GridPtrMapT = std::map<KeyT, GridPtrT>;
560 for (typename GridPtrMapT::const_iterator it = container.begin(), end = container.end();
561 it != end; ++it)
562 {
563 const GridPtrT& grid = it->second;
564 if (grid && grid->getName() == name) return grid;
565 }
566 return GridPtrT();
567 }
569
570
572
573
575 template<typename _TreeType>
576 class Grid: public GridBase
577 {
578 public:
579 using Ptr = SharedPtr<Grid>;
580 using ConstPtr = SharedPtr<const Grid>;
581
582 using TreeType = _TreeType;
583 using TreePtrType = typename _TreeType::Ptr;
584 using ConstTreePtrType = typename _TreeType::ConstPtr;
585 using ValueType = typename _TreeType::ValueType;
586 using BuildType = typename _TreeType::BuildType;
587
588 using ValueOnIter = typename _TreeType::ValueOnIter;
589 using ValueOnCIter = typename _TreeType::ValueOnCIter;
590 using ValueOffIter = typename _TreeType::ValueOffIter;
591 using ValueOffCIter = typename _TreeType::ValueOffCIter;
592 using ValueAllIter = typename _TreeType::ValueAllIter;
593 using ValueAllCIter = typename _TreeType::ValueAllCIter;
594
595 using Accessor = typename tree::ValueAccessor<_TreeType, true>;
596 using ConstAccessor = typename tree::ValueAccessor<const _TreeType, true>;
597 using UnsafeAccessor = typename tree::ValueAccessor<_TreeType, false>;
598 using ConstUnsafeAccessor = typename tree::ValueAccessor<const _TreeType, false>;
599
606 template<typename OtherValueType>
607 struct ValueConverter {
608 using Type = Grid<typename TreeType::template ValueConverter<OtherValueType>::Type>;
609 };
610
612 static Ptr create(const ValueType& background);
614 static Ptr create();
617 static Ptr create(TreePtrType);
620 static Ptr create(const GridBase& other);
621
622
624 Grid();
626 explicit Grid(const ValueType& background);
630 explicit Grid(TreePtrType);
632 Grid(const Grid&);
638 template<typename OtherTreeType>
639 explicit Grid(const Grid<OtherTreeType>&);
641 Grid(Grid&, ShallowCopy);
644 explicit Grid(const GridBase&);
645
646 ~Grid() override {}
647
649 Grid& operator=(const Grid&) = delete;
650
653
656 Ptr copy();
659 ConstPtr copy() const;
662 Ptr copyWithNewTree() const;
663
666 GridBase::Ptr copyGrid() override;
669 GridBase::ConstPtr copyGrid() const override;
672 GridBase::Ptr copyGridWithNewTree() const override;
674
677
678 #if OPENVDB_ABI_VERSION_NUMBER >= 7
679 ConstPtr copyReplacingMetadata(const MetaMap& meta) const;
686 ConstPtr copyReplacingTransform(math::Transform::Ptr xform) const;
690 ConstPtr copyReplacingMetadataAndTransform(const MetaMap& meta,
691 math::Transform::Ptr xform) const;
692
695 GridBase::ConstPtr copyGridReplacingMetadata(const MetaMap& meta) const override;
700 GridBase::ConstPtr copyGridReplacingTransform(math::Transform::Ptr xform) const override;
704 GridBase::ConstPtr copyGridReplacingMetadataAndTransform(const MetaMap& meta,
705 math::Transform::Ptr xform) const override;
706 #endif
707
709 Ptr deepCopy() const { return Ptr(new Grid(*this)); }
711 GridBase::Ptr deepCopyGrid() const override { return this->deepCopy(); }
712
714
715
717 Name type() const override { return this->gridType(); }
719 static Name gridType() { return TreeType::treeType(); }
720
722 Name valueType() const override { return tree().valueType(); }
723
724
727
730 const ValueType& background() const { return mTree->background(); }
731
733 bool empty() const override { return tree().empty(); }
735 void clear() override { tree().clear(); }
736
740 Accessor getAccessor() { return Accessor(tree()); }
748 UnsafeAccessor getUnsafeAccessor() { return UnsafeAccessor(tree()); }
750 ConstAccessor getAccessor() const { return ConstAccessor(tree()); }
752 ConstAccessor getConstAccessor() const { return ConstAccessor(tree()); }
760 ConstUnsafeAccessor getConstUnsafeAccessor() const { return ConstUnsafeAccessor(tree()); }
761
763 ValueOnIter beginValueOn() { return tree().beginValueOn(); }
765 ValueOnCIter beginValueOn() const { return tree().cbeginValueOn(); }
767 ValueOnCIter cbeginValueOn() const { return tree().cbeginValueOn(); }
769 ValueOffIter beginValueOff() { return tree().beginValueOff(); }
771 ValueOffCIter beginValueOff() const { return tree().cbeginValueOff(); }
773 ValueOffCIter cbeginValueOff() const { return tree().cbeginValueOff(); }
775 ValueAllIter beginValueAll() { return tree().beginValueAll(); }
777 ValueAllCIter beginValueAll() const { return tree().cbeginValueAll(); }
779 ValueAllCIter cbeginValueAll() const { return tree().cbeginValueAll(); }
780
782
785
794 void sparseFill(const CoordBBox& bbox, const ValueType& value, bool active = true);
803 void fill(const CoordBBox& bbox, const ValueType& value, bool active = true);
804
811 void denseFill(const CoordBBox& bbox, const ValueType& value, bool active = true);
812
814 void pruneGrid(float tolerance = 0.0) override;
815
820 void clip(const CoordBBox&) override;
821
827 void merge(Grid& other, MergePolicy policy = MERGE_ACTIVE_STATES);
828
842 template<typename OtherTreeType>
843 void topologyUnion(const Grid<OtherTreeType>& other);
844
857 template<typename OtherTreeType>
858 void topologyIntersection(const Grid<OtherTreeType>& other);
859
870 template<typename OtherTreeType>
871 void topologyDifference(const Grid<OtherTreeType>& other);
872
874
877
879 Index64 activeVoxelCount() const override { return tree().activeVoxelCount(); }
881 CoordBBox evalActiveVoxelBoundingBox() const override;
883 Coord evalActiveVoxelDim() const override;
885 void evalMinMax(ValueType& minVal, ValueType& maxVal) const;
886
889 Index64 memUsage() const override { return tree().memUsage(); }
890
892
893
896
898 TreePtrType treePtr() { return mTree; }
901 ConstTreePtrType treePtr() const { return mTree; }
902 ConstTreePtrType constTreePtr() const { return mTree; }
903 TreeBase::ConstPtr constBaseTreePtr() const override { return mTree; }
905 #if OPENVDB_ABI_VERSION_NUMBER >= 8
908 bool isTreeUnique() const final;
909 #else
910 bool isTreeUnique() const;
911 #endif
912
913 TreeType& tree() { return *mTree; }
918 const TreeType& tree() const { return *mTree; }
919 const TreeType& constTree() const { return *mTree; }
921
923
926
932 void setTree(TreeBase::Ptr) override;
933
936 void newTree() override;
937
939
940
943
946 void readTopology(std::istream&) override;
949 void writeTopology(std::ostream&) const override;
950
952 void readBuffers(std::istream&) override;
954 void readBuffers(std::istream&, const CoordBBox&) override;
960 void readNonresidentBuffers() const override;
962 void writeBuffers(std::ostream&) const override;
963
965 void print(std::ostream& = std::cout, int verboseLevel = 1) const override;
966
968
972 static inline bool hasMultiPassIO();
973
974
977
979 static bool isRegistered() { return GridBase::isRegistered(Grid::gridType()); }
981 static void registerGrid()
982 {
983 GridBase::registerGrid(Grid::gridType(), Grid::factory);
984 if (!tree::internal::LeafBufferFlags<ValueType>::IsAtomic) {
985 OPENVDB_LOG_WARN("delayed loading of grids of type " << Grid::gridType()
986 << " might not be threadsafe on this platform");
987 }
988 }
990 static void unregisterGrid() { GridBase::unregisterGrid(Grid::gridType()); }
991
993
994
995 private:
996 #if OPENVDB_ABI_VERSION_NUMBER >= 7
997 Grid(TreePtrType tree, const MetaMap& meta, math::Transform::Ptr xform);
999 #endif
1000
1002 static GridBase::Ptr factory() { return Grid::create(); }
1003
1004 TreePtrType mTree;
1005 }; // class Grid
1006
1007
1009
1010
1018 template<typename GridType>
1019 inline typename GridType::Ptr
1020 gridPtrCast(const GridBase::Ptr& grid)
1021 {
1022 return GridBase::grid<GridType>(grid);
1023 }
1024
1025
1034 template<typename GridType>
1035 inline typename GridType::ConstPtr
1036 gridConstPtrCast(const GridBase::ConstPtr& grid)
1037 {
1038 return GridBase::constGrid<GridType>(grid);
1039 }
1040
1041
1043
1044
1051 template<typename GridType>
1052 inline typename GridType::Ptr
1053 deepCopyTypedGrid(const GridBase::ConstPtr& grid)
1054 {
1055 if (!grid || !grid->isType<GridType>()) return typename GridType::Ptr();
1056 return gridPtrCast<GridType>(grid->deepCopyGrid());
1057 }
1058
1059
1060 template<typename GridType>
1061 inline typename GridType::Ptr
1062 deepCopyTypedGrid(const GridBase& grid)
1063 {
1064 if (!grid.isType<GridType>()) return typename GridType::Ptr();
1065 return gridPtrCast<GridType>(grid.deepCopyGrid());
1066 }
1068
1069
1071
1072
1074 template<typename _TreeType>
1077 struct TreeAdapter
1078 {
1079 using TreeType = _TreeType;
1080 using NonConstTreeType = typename std::remove_const<TreeType>::type;
1081 using TreePtrType = typename TreeType::Ptr;
1082 using ConstTreePtrType = typename TreeType::ConstPtr;
1083 using NonConstTreePtrType = typename NonConstTreeType::Ptr;
1084 using GridType = Grid<TreeType>;
1085 using NonConstGridType = Grid<NonConstTreeType>;
1086 using GridPtrType = typename GridType::Ptr;
1087 using NonConstGridPtrType = typename NonConstGridType::Ptr;
1088 using ConstGridPtrType = typename GridType::ConstPtr;
1089 using ValueType = typename TreeType::ValueType;
1090 using AccessorType = typename tree::ValueAccessor<TreeType>;
1091 using ConstAccessorType = typename tree::ValueAccessor<const TreeType>;
1092 using NonConstAccessorType = typename tree::ValueAccessor<NonConstTreeType>;
1093
1094 static TreeType& tree(TreeType& t) { return t; }
1095 static TreeType& tree(GridType& g) { return g.tree(); }
1096 static const TreeType& tree(const TreeType& t) { return t; }
1097 static const TreeType& tree(const GridType& g) { return g.tree(); }
1098 static const TreeType& constTree(TreeType& t) { return t; }
1099 static const TreeType& constTree(GridType& g) { return g.constTree(); }
1100 static const TreeType& constTree(const TreeType& t) { return t; }
1101 static const TreeType& constTree(const GridType& g) { return g.constTree(); }
1102 };
1103
1104
1106 template<typename _TreeType>
1107 struct TreeAdapter<Grid<_TreeType> >
1108 {
1109 using TreeType = _TreeType;
1110 using NonConstTreeType = typename std::remove_const<TreeType>::type;
1111 using TreePtrType = typename TreeType::Ptr;
1112 using ConstTreePtrType = typename TreeType::ConstPtr;
1113 using NonConstTreePtrType = typename NonConstTreeType::Ptr;
1114 using GridType = Grid<TreeType>;
1115 using NonConstGridType = Grid<NonConstTreeType>;
1116 using GridPtrType = typename GridType::Ptr;
1117 using NonConstGridPtrType = typename NonConstGridType::Ptr;
1118 using ConstGridPtrType = typename GridType::ConstPtr;
1119 using ValueType = typename TreeType::ValueType;
1120 using AccessorType = typename tree::ValueAccessor<TreeType>;
1121 using ConstAccessorType = typename tree::ValueAccessor<const TreeType>;
1122 using NonConstAccessorType = typename tree::ValueAccessor<NonConstTreeType>;
1123
1124 static TreeType& tree(TreeType& t) { return t; }
1125 static TreeType& tree(GridType& g) { return g.tree(); }
1126 static const TreeType& tree(const TreeType& t) { return t; }
1127 static const TreeType& tree(const GridType& g) { return g.tree(); }
1128 static const TreeType& constTree(TreeType& t) { return t; }
1129 static const TreeType& constTree(GridType& g) { return g.constTree(); }
1130 static const TreeType& constTree(const TreeType& t) { return t; }
1131 static const TreeType& constTree(const GridType& g) { return g.constTree(); }
1132 };
1133
1135 template<typename _TreeType>
1136 struct TreeAdapter<tree::ValueAccessor<_TreeType> >
1137 {
1138 using TreeType = _TreeType;
1139 using NonConstTreeType = typename std::remove_const<TreeType>::type;
1140 using TreePtrType = typename TreeType::Ptr;
1141 using ConstTreePtrType = typename TreeType::ConstPtr;
1142 using NonConstTreePtrType = typename NonConstTreeType::Ptr;
1143 using GridType = Grid<TreeType>;
1144 using NonConstGridType = Grid<NonConstTreeType>;
1145 using GridPtrType = typename GridType::Ptr;
1146 using NonConstGridPtrType = typename NonConstGridType::Ptr;
1147 using ConstGridPtrType = typename GridType::ConstPtr;
1148 using ValueType = typename TreeType::ValueType;
1149 using AccessorType = typename tree::ValueAccessor<TreeType>;
1150 using ConstAccessorType = typename tree::ValueAccessor<const TreeType>;
1151 using NonConstAccessorType = typename tree::ValueAccessor<NonConstTreeType>;
1152
1153 static TreeType& tree(TreeType& t) { return t; }
1154 static TreeType& tree(GridType& g) { return g.tree(); }
1155 static TreeType& tree(AccessorType& a) { return a.tree(); }
1156 static const TreeType& tree(const TreeType& t) { return t; }
1157 static const TreeType& tree(const GridType& g) { return g.tree(); }
1158 static const TreeType& tree(const AccessorType& a) { return a.tree(); }
1159 static const TreeType& constTree(TreeType& t) { return t; }
1160 static const TreeType& constTree(GridType& g) { return g.constTree(); }
1161 static const TreeType& constTree(const TreeType& t) { return t; }
1162 static const TreeType& constTree(const GridType& g) { return g.constTree(); }
1163 };
1164
1166
1167
1169
1170
1176 template<typename LeafNodeType>
1177 struct HasMultiPassIO {
1178 static const bool value = std::is_base_of<io::MultiPass, LeafNodeType>::value;
1179 };
1180
1181 // Partial specialization for Tree types
1182 template<typename RootNodeType>
1183 struct HasMultiPassIO<tree::Tree<RootNodeType>> {
1184 // A tree is multi-pass if its (root node's) leaf node type is multi-pass.
1185 static const bool value = HasMultiPassIO<typename RootNodeType::LeafNodeType>::value;
1186 };
1187
1188 // Partial specialization for Grid types
1189 template<typename TreeType>
1190 struct HasMultiPassIO<Grid<TreeType>> {
1191 // A grid is multi-pass if its tree's leaf node type is multi-pass.
1192 static const bool value = HasMultiPassIO<typename TreeType::LeafNodeType>::value;
1193 };
1194
1195
1197
1198 #if OPENVDB_ABI_VERSION_NUMBER >= 7
1199 inline GridBase::GridBase(const MetaMap& meta, math::Transform::Ptr xform)
1200 : MetaMap(meta)
1201 , mTransform(xform)
1202 {
1203 if (!xform) OPENVDB_THROW(ValueError, "Transform pointer is null");
1204 }
1205 #endif
1206
1207 template<typename GridType>
1208 inline typename GridType::Ptr
1209 GridBase::grid(const GridBase::Ptr& grid)
1210 {
1211 // The string comparison on type names is slower than a dynamic pointer cast, but
1212 // it is safer when pointers cross DSO boundaries, as they do in many Houdini nodes.
1213 if (grid && grid->type() == GridType::gridType()) {
1214 return StaticPtrCast<GridType>(grid);
1215 }
1216 return typename GridType::Ptr();
1217 }
1218
1219
1220 template<typename GridType>
1221 inline typename GridType::ConstPtr
1222 GridBase::grid(const GridBase::ConstPtr& grid)
1223 {
1224 return ConstPtrCast<const GridType>(
1225 GridBase::grid<GridType>(ConstPtrCast<GridBase>(grid)));
1226 }
1227
1228
1229 template<typename GridType>
1230 inline typename GridType::ConstPtr
1231 GridBase::constGrid(const GridBase::Ptr& grid)
1232 {
1233 return ConstPtrCast<const GridType>(GridBase::grid<GridType>(grid));
1234 }
1235
1236
1237 template<typename GridType>
1238 inline typename GridType::ConstPtr
1239 GridBase::constGrid(const GridBase::ConstPtr& grid)
1240 {
1241 return ConstPtrCast<const GridType>(
1242 GridBase::grid<GridType>(ConstPtrCast<GridBase>(grid)));
1243 }
1244
1245
1246 inline TreeBase::Ptr
1247 GridBase::baseTreePtr()
1248 {
1249 return ConstPtrCast<TreeBase>(this->constBaseTreePtr());
1250 }
1251
1252
1253 inline void
1254 GridBase::setTransform(math::Transform::Ptr xform)
1255 {
1256 if (!xform) OPENVDB_THROW(ValueError, "Transform pointer is null");
1257 mTransform = xform;
1258 }
1259
1260
1262
1263
1264 template<typename TreeT>
1265 inline Grid<TreeT>::Grid(): mTree(new TreeType)
1266 {
1267 }
1268
1269
1270 template<typename TreeT>
1271 inline Grid<TreeT>::Grid(const ValueType &background): mTree(new TreeType(background))
1272 {
1273 }
1274
1275
1276 template<typename TreeT>
1277 inline Grid<TreeT>::Grid(TreePtrType tree): mTree(tree)
1278 {
1279 if (!tree) OPENVDB_THROW(ValueError, "Tree pointer is null");
1280 }
1281
1282
1283 #if OPENVDB_ABI_VERSION_NUMBER >= 7
1284 template<typename TreeT>
1285 inline Grid<TreeT>::Grid(TreePtrType tree, const MetaMap& meta, math::Transform::Ptr xform):
1286 GridBase(meta, xform),
1287 mTree(tree)
1288 {
1289 if (!tree) OPENVDB_THROW(ValueError, "Tree pointer is null");
1290 }
1291 #endif
1292
1293
1294 template<typename TreeT>
1295 inline Grid<TreeT>::Grid(const Grid& other):
1296 GridBase(other),
1297 mTree(StaticPtrCast<TreeType>(other.mTree->copy()))
1298 {
1299 }
1300
1301
1302 template<typename TreeT>
1303 template<typename OtherTreeType>
1304 inline Grid<TreeT>::Grid(const Grid<OtherTreeType>& other):
1305 GridBase(other),
1306 mTree(new TreeType(other.constTree()))
1307 {
1308 }
1309
1310
1311 template<typename TreeT>
1312 inline Grid<TreeT>::Grid(Grid& other, ShallowCopy):
1313 GridBase(other),
1314 mTree(other.mTree)
1315 {
1316 }
1317
1318
1319 template<typename TreeT>
1320 inline Grid<TreeT>::Grid(const GridBase& other):
1321 GridBase(other),
1322 mTree(new TreeType)
1323 {
1324 }
1325
1326
1327 //static
1328 template<typename TreeT>
1329 inline typename Grid<TreeT>::Ptr
1330 Grid<TreeT>::create()
1331 {
1332 return Grid::create(zeroVal<ValueType>());
1333 }
1334
1335
1336 //static
1337 template<typename TreeT>
1338 inline typename Grid<TreeT>::Ptr
1339 Grid<TreeT>::create(const ValueType& background)
1340 {
1341 return Ptr(new Grid(background));
1342 }
1343
1344
1345 //static
1346 template<typename TreeT>
1347 inline typename Grid<TreeT>::Ptr
1348 Grid<TreeT>::create(TreePtrType tree)
1349 {
1350 return Ptr(new Grid(tree));
1351 }
1352
1353
1354 //static
1355 template<typename TreeT>
1356 inline typename Grid<TreeT>::Ptr
1357 Grid<TreeT>::create(const GridBase& other)
1358 {
1359 return Ptr(new Grid(other));
1360 }
1361
1362
1364
1365
1366 template<typename TreeT>
1367 inline typename Grid<TreeT>::ConstPtr
1368 Grid<TreeT>::copy() const
1369 {
1370 return ConstPtr{new Grid{*const_cast<Grid*>(this), ShallowCopy{}}};
1371 }
1372
1373
1374 #if OPENVDB_ABI_VERSION_NUMBER >= 7
1375 template<typename TreeT>
1376 inline typename Grid<TreeT>::ConstPtr
1377 Grid<TreeT>::copyReplacingMetadata(const MetaMap& meta) const
1378 {
1379 math::Transform::Ptr transformPtr = ConstPtrCast<math::Transform>(
1380 this->constTransformPtr());
1381 TreePtrType treePtr = ConstPtrCast<TreeT>(this->constTreePtr());
1382 return ConstPtr{new Grid<TreeT>{treePtr, meta, transformPtr}};
1383 }
1384
1385 template<typename TreeT>
1386 inline typename Grid<TreeT>::ConstPtr
1387 Grid<TreeT>::copyReplacingTransform(math::Transform::Ptr xform) const
1388 {
1389 return this->copyReplacingMetadataAndTransform(*this, xform);
1390 }
1391
1392 template<typename TreeT>
1393 inline typename Grid<TreeT>::ConstPtr
1394 Grid<TreeT>::copyReplacingMetadataAndTransform(const MetaMap& meta,
1395 math::Transform::Ptr xform) const
1396 {
1397 TreePtrType treePtr = ConstPtrCast<TreeT>(this->constTreePtr());
1398 return ConstPtr{new Grid<TreeT>{treePtr, meta, xform}};
1399 }
1400 #endif
1401
1402
1403 template<typename TreeT>
1404 inline typename Grid<TreeT>::Ptr
1405 Grid<TreeT>::copy()
1406 {
1407 return Ptr{new Grid{*this, ShallowCopy{}}};
1408 }
1409
1410
1411 template<typename TreeT>
1412 inline typename Grid<TreeT>::Ptr
1413 Grid<TreeT>::copyWithNewTree() const
1414 {
1415 Ptr result{new Grid{*const_cast<Grid*>(this), ShallowCopy{}}};
1416 result->newTree();
1417 return result;
1418 }
1419
1420
1421 template<typename TreeT>
1422 inline GridBase::Ptr
1423 Grid<TreeT>::copyGrid()
1424 {
1425 return this->copy();
1426 }
1427
1428 template<typename TreeT>
1429 inline GridBase::ConstPtr
1430 Grid<TreeT>::copyGrid() const
1431 {
1432 return this->copy();
1433 }
1434
1435 #if OPENVDB_ABI_VERSION_NUMBER >= 7
1436 template<typename TreeT>
1437 inline GridBase::ConstPtr
1438 Grid<TreeT>::copyGridReplacingMetadata(const MetaMap& meta) const
1439 {
1440 return this->copyReplacingMetadata(meta);
1441 }
1442
1443 template<typename TreeT>
1444 inline GridBase::ConstPtr
1445 Grid<TreeT>::copyGridReplacingTransform(math::Transform::Ptr xform) const
1446 {
1447 return this->copyReplacingTransform(xform);
1448 }
1449
1450 template<typename TreeT>
1451 inline GridBase::ConstPtr
1452 Grid<TreeT>::copyGridReplacingMetadataAndTransform(const MetaMap& meta,
1453 math::Transform::Ptr xform) const
1454 {
1455 return this->copyReplacingMetadataAndTransform(meta, xform);
1456 }
1457 #endif
1458
1459 template<typename TreeT>
1460 inline GridBase::Ptr
1461 Grid<TreeT>::copyGridWithNewTree() const
1462 {
1463 return this->copyWithNewTree();
1464 }
1465
1466
1468
1469
1470 template<typename TreeT>
1471 inline bool
1472 Grid<TreeT>::isTreeUnique() const
1473 {
1474 return mTree.use_count() == 1;
1475 }
1476
1477
1478 template<typename TreeT>
1479 inline void
1480 Grid<TreeT>::setTree(TreeBase::Ptr tree)
1481 {
1482 if (!tree) OPENVDB_THROW(ValueError, "Tree pointer is null");
1483 if (tree->type() != TreeType::treeType()) {
1484 OPENVDB_THROW(TypeError, "Cannot assign a tree of type "
1485 + tree->type() + " to a grid of type " + this->type());
1486 }
1487 mTree = StaticPtrCast<TreeType>(tree);
1488 }
1489
1490
1491 template<typename TreeT>
1492 inline void
1493 Grid<TreeT>::newTree()
1494 {
1495 mTree.reset(new TreeType(this->background()));
1496 }
1497
1498
1500
1501
1502 template<typename TreeT>
1503 inline void
1504 Grid<TreeT>::sparseFill(const CoordBBox& bbox, const ValueType& value, bool active)
1505 {
1506 tree().sparseFill(bbox, value, active);
1507 }
1508
1509
1510 template<typename TreeT>
1511 inline void
1512 Grid<TreeT>::fill(const CoordBBox& bbox, const ValueType& value, bool active)
1513 {
1514 this->sparseFill(bbox, value, active);
1515 }
1516
1517 template<typename TreeT>
1518 inline void
1519 Grid<TreeT>::denseFill(const CoordBBox& bbox, const ValueType& value, bool active)
1520 {
1521 tree().denseFill(bbox, value, active);
1522 }
1523
1524 template<typename TreeT>
1525 inline void
1526 Grid<TreeT>::pruneGrid(float tolerance)
1527 {
1528 const auto value = math::cwiseAdd(zeroVal<ValueType>(), tolerance);
1529 this->tree().prune(static_cast<ValueType>(value));
1530 }
1531
1532 template<typename TreeT>
1533 inline void
1534 Grid<TreeT>::clip(const CoordBBox& bbox)
1535 {
1536 tree().clip(bbox);
1537 }
1538
1539 template<typename TreeT>
1540 inline void
1541 Grid<TreeT>::merge(Grid& other, MergePolicy policy)
1542 {
1543 tree().merge(other.tree(), policy);
1544 }
1545
1546
1547 template<typename TreeT>
1548 template<typename OtherTreeType>
1549 inline void
1550 Grid<TreeT>::topologyUnion(const Grid<OtherTreeType>& other)
1551 {
1552 tree().topologyUnion(other.tree());
1553 }
1554
1555
1556 template<typename TreeT>
1557 template<typename OtherTreeType>
1558 inline void
1559 Grid<TreeT>::topologyIntersection(const Grid<OtherTreeType>& other)
1560 {
1561 tree().topologyIntersection(other.tree());
1562 }
1563
1564
1565 template<typename TreeT>
1566 template<typename OtherTreeType>
1567 inline void
1568 Grid<TreeT>::topologyDifference(const Grid<OtherTreeType>& other)
1569 {
1570 tree().topologyDifference(other.tree());
1571 }
1572
1573
1575
1576
1577 template<typename TreeT>
1578 inline void
1579 Grid<TreeT>::evalMinMax(ValueType& minVal, ValueType& maxVal) const
1580 {
1581 tree().evalMinMax(minVal, maxVal);
1582 }
1583
1584
1585 template<typename TreeT>
1586 inline CoordBBox
1587 Grid<TreeT>::evalActiveVoxelBoundingBox() const
1588 {
1589 CoordBBox bbox;
1590 tree().evalActiveVoxelBoundingBox(bbox);
1591 return bbox;
1592 }
1593
1594
1595 template<typename TreeT>
1596 inline Coord
1597 Grid<TreeT>::evalActiveVoxelDim() const
1598 {
1599 Coord dim;
1600 const bool nonempty = tree().evalActiveVoxelDim(dim);
1601 return (nonempty ? dim : Coord());
1602 }
1603
1604
1606
1607
1610
1611 template<typename TreeT>
1612 inline void
1613 Grid<TreeT>::readTopology(std::istream& is)
1614 {
1615 tree().readTopology(is, saveFloatAsHalf());
1616 }
1617
1618
1619 template<typename TreeT>
1620 inline void
1621 Grid<TreeT>::writeTopology(std::ostream& os) const
1622 {
1623 tree().writeTopology(os, saveFloatAsHalf());
1624 }
1625
1626
1627 template<typename TreeT>
1628 inline void
1629 Grid<TreeT>::readBuffers(std::istream& is)
1630 {
1631 if (!hasMultiPassIO() || (io::getFormatVersion(is) < OPENVDB_FILE_VERSION_MULTIPASS_IO)) {
1632 tree().readBuffers(is, saveFloatAsHalf());
1633 } else {
1634 uint16_t numPasses = 1;
1635 is.read(reinterpret_cast<char*>(&numPasses), sizeof(uint16_t));
1636 const io::StreamMetadata::Ptr meta = io::getStreamMetadataPtr(is);
1637 assert(bool(meta));
1638 for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1639 uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1640 meta->setPass(pass);
1641 tree().readBuffers(is, saveFloatAsHalf());
1642 }
1643 }
1644 }
1645
1646
1649 template<typename TreeT>
1650 inline void
1651 Grid<TreeT>::readBuffers(std::istream& is, const CoordBBox& bbox)
1652 {
1653 if (!hasMultiPassIO() || (io::getFormatVersion(is) < OPENVDB_FILE_VERSION_MULTIPASS_IO)) {
1654 tree().readBuffers(is, bbox, saveFloatAsHalf());
1655 } else {
1656 uint16_t numPasses = 1;
1657 is.read(reinterpret_cast<char*>(&numPasses), sizeof(uint16_t));
1658 const io::StreamMetadata::Ptr meta = io::getStreamMetadataPtr(is);
1659 assert(bool(meta));
1660 for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1661 uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1662 meta->setPass(pass);
1663 tree().readBuffers(is, saveFloatAsHalf());
1664 }
1665 // Cannot clip inside readBuffers() when using multiple passes,
1666 // so instead clip afterwards.
1667 tree().clip(bbox);
1668 }
1669 }
1670
1671
1672 template<typename TreeT>
1673 inline void
1674 Grid<TreeT>::readNonresidentBuffers() const
1675 {
1676 tree().readNonresidentBuffers();
1677 }
1678
1679
1680 template<typename TreeT>
1681 inline void
1682 Grid<TreeT>::writeBuffers(std::ostream& os) const
1683 {
1684 if (!hasMultiPassIO()) {
1685 tree().writeBuffers(os, saveFloatAsHalf());
1686 } else {
1687 // Determine how many leaf buffer passes are required for this grid
1688 const io::StreamMetadata::Ptr meta = io::getStreamMetadataPtr(os);
1689 assert(bool(meta));
1690 uint16_t numPasses = 1;
1691 meta->setCountingPasses(true);
1692 meta->setPass(0);
1693 tree().writeBuffers(os, saveFloatAsHalf());
1694 numPasses = static_cast<uint16_t>(meta->pass());
1695 os.write(reinterpret_cast<const char*>(&numPasses), sizeof(uint16_t));
1696 meta->setCountingPasses(false);
1697
1698 // Save out the data blocks of the grid.
1699 for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1700 uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1701 meta->setPass(pass);
1702 tree().writeBuffers(os, saveFloatAsHalf());
1703 }
1704 }
1705 }
1706
1707
1708 //static
1709 template<typename TreeT>
1710 inline bool
1711 Grid<TreeT>::hasMultiPassIO()
1712 {
1713 return HasMultiPassIO<Grid>::value;
1714 }
1715
1716
1717 template<typename TreeT>
1718 inline void
1719 Grid<TreeT>::print(std::ostream& os, int verboseLevel) const
1720 {
1721 tree().print(os, verboseLevel);
1722
1723 if (metaCount() > 0) {
1724 os << "Additional metadata:" << std::endl;
1725 for (ConstMetaIterator it = beginMeta(), end = endMeta(); it != end; ++it) {
1726 os << " " << it->first;
1727 if (it->second) {
1728 const std::string value = it->second->str();
1729 if (!value.empty()) os << ": " << value;
1730 }
1731 os << "\n";
1732 }
1733 }
1734
1735 os << "Transform:" << std::endl;
1736 transform().print(os, /*indent=*/" ");
1737 os << std::endl;
1738 }
1739
1740
1742
1743
1744 template<typename GridType>
1745 inline typename GridType::Ptr
1746 createGrid(const typename GridType::ValueType& background)
1747 {
1748 return GridType::create(background);
1749 }
1750
1751
1752 template<typename GridType>
1753 inline typename GridType::Ptr
1754 createGrid()
1755 {
1756 return GridType::create();
1757 }
1758
1759
1760 template<typename TreePtrType>
1761 inline typename Grid<typename TreePtrType::element_type>::Ptr
1762 createGrid(TreePtrType tree)
1763 {
1764 using TreeType = typename TreePtrType::element_type;
1765 return Grid<TreeType>::create(tree);
1766 }
1767
1768
1769 template<typename GridType>
1770 typename GridType::Ptr
1771 createLevelSet(Real voxelSize, Real halfWidth)
1772 {
1773 using ValueType = typename GridType::ValueType;
1774
1775 // GridType::ValueType is required to be a floating-point scalar.
1776 static_assert(std::is_floating_point<ValueType>::value,
1777 "level-set grids must be floating-point-valued");
1778
1779 typename GridType::Ptr grid = GridType::create(
1780 /*background=*/static_cast<ValueType>(voxelSize * halfWidth));
1781 grid->setTransform(math::Transform::createLinearTransform(voxelSize));
1782 grid->setGridClass(GRID_LEVEL_SET);
1783 return grid;
1784 }
1785
1786
1788
1789
1790 namespace internal {
1791
1793 template<typename OpT, typename GridBaseT, typename T, typename ...Ts>
1794 struct GridApplyImpl { static bool apply(GridBaseT&, OpT&) { return false; } };
1795
1796 // Partial specialization for (nonempty) TypeLists
1798 template<typename OpT, typename GridBaseT, typename GridT, typename ...GridTs>
1799 struct GridApplyImpl<OpT, GridBaseT, TypeList<GridT, GridTs...>>
1800 {
1801 static bool apply(GridBaseT& grid, OpT& op)
1802 {
1803 if (grid.template isType<GridT>()) {
1804 op(static_cast<typename CopyConstness<GridBaseT, GridT>::Type&>(grid));
1805 return true;
1806 }
1807 return GridApplyImpl<OpT, GridBaseT, TypeList<GridTs...>>::apply(grid, op);
1808 }
1809 };
1810
1811 } // namespace internal
1812
1813
1814 template<typename GridTypeListT, typename OpT>
1815 inline bool
1816 GridBase::apply(OpT& op) const
1817 {
1818 return internal::GridApplyImpl<OpT, const GridBase, GridTypeListT>::apply(*this, op);
1819 }
1820
1821 template<typename GridTypeListT, typename OpT>
1822 inline bool
1823 GridBase::apply(OpT& op)
1824 {
1825 return internal::GridApplyImpl<OpT, GridBase, GridTypeListT>::apply(*this, op);
1826 }
1827
1828 template<typename GridTypeListT, typename OpT>
1829 inline bool
1830 GridBase::apply(const OpT& op) const
1831 {
1832 return internal::GridApplyImpl<const OpT, const GridBase, GridTypeListT>::apply(*this, op);
1833 }
1834
1835 template<typename GridTypeListT, typename OpT>
1836 inline bool
1837 GridBase::apply(const OpT& op)
1838 {
1839 return internal::GridApplyImpl<const OpT, GridBase, GridTypeListT>::apply(*this, op);
1840 }
1841
1842 } // namespace OPENVDB_VERSION_NAME
1843 } // namespace openvdb
1844
1845 #endif // OPENVDB_GRID_HAS_BEEN_INCLUDED
openvdb::v8_2::Grid::beginValueAll
ValueAllIter beginValueAll()
Return an iterator over all of this grid's values (tile and voxel).
Definition: Grid.h:775
openvdb::v8_2::GridBase::memUsage
virtual Index64 memUsage() const =0
Return the number of bytes of memory used by this grid.
openvdb::v8_2::GridBase::ConstPtr
SharedPtr< const GridBase > ConstPtr
Definition: Grid.h:81
openvdb::v8_2::Grid::operator=
Grid & operator=(const Grid &)=delete
Disallow assignment, since it wouldn't be obvious whether the copy is deep or shallow.
openvdb::v8_2::GridBase::META_FILE_DELAYED_LOAD
static const char *const META_FILE_DELAYED_LOAD
Definition: Grid.h:366
openvdb::v8_2::GridBase::writeTransform
void writeTransform(std::ostream &os) const
Write out the transform for this grid.
Definition: Grid.h:476
openvdb::v8_2::Grid::beginValueOff
ValueOffCIter beginValueOff() const
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition: Grid.h:771
openvdb::v8_2::Grid::setTree
void setTree(TreeBase::Ptr) override
Associate the given tree with this grid, in place of its existing tree.
Definition: Grid.h:1480
openvdb::v8_2::GridBase::META_GRID_CREATOR
static const char *const META_GRID_CREATOR
Definition: Grid.h:356
openvdb::v8_2::Grid::ValueOnCIter
typename _TreeType::ValueOnCIter ValueOnCIter
Definition: Grid.h:589
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::NonConstTreeType
typename std::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:1110
Types.h
Consolidated llvm types for most supported types.
openvdb::v8_2::GridNamePred
Predicate functor that returns true for grids that have a specified name.
Definition: Grid.h:537
openvdb::v8_2::TreeBase
tree::TreeBase TreeBase
Definition: Grid.h:26
openvdb::v8_2::TreeAdapter::NonConstGridPtrType
typename NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:1087
openvdb::v8_2::Grid::beginValueOn
ValueOnCIter beginValueOn() const
Return an iterator over all of this grid's active values (tile and voxel).
Definition: Grid.h:765
openvdb::v8_2::TreeAdapter::ValueType
typename TreeType::ValueType ValueType
Definition: Grid.h:1089
openvdb::v8_2::Grid::ValueOffIter
typename _TreeType::ValueOffIter ValueOffIter
Definition: Grid.h:590
openvdb::v8_2::math::Coord
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:26
openvdb::v8_2::GridBase::copyGridReplacingMetadataAndTransform
virtual GridBase::ConstPtr copyGridReplacingMetadataAndTransform(const MetaMap &meta, math::Transform::Ptr xform) const =0
Return a new grid of the same type as this grid whose tree is shared with this grid and whose transfo...
openvdb::v8_2::MERGE_ACTIVE_STATES
@ MERGE_ACTIVE_STATES
Definition: openvdb/Types.h:367
openvdb::v8_2::GridBase::~GridBase
~GridBase() override
Definition: Grid.h:86
openvdb::v8_2::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:1247
openvdb::v8_2::GridBase::clipGrid
void clipGrid(const BBoxd &)
Clip this grid to the given world-space bounding box.
openvdb::v8_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:1461
openvdb::v8_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: openvdb/Types.h:124
openvdb::v8_2::GridBase::clip
virtual void clip(const CoordBBox &)=0
Clip this grid to the given index-space bounding box.
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static const TreeType & tree(const GridType &g)
Definition: Grid.h:1157
openvdb::v8_2::Grid::ValueOnIter
typename _TreeType::ValueOnIter ValueOnIter
Definition: Grid.h:588
openvdb::v8_2::Grid::memUsage
Index64 memUsage() const override
Definition: Grid.h:889
openvdb::v8_2::GridBase::vecTypeToString
static std::string vecTypeToString(VecType)
Return the metadata string value for the given type of vector data.
openvdb::v8_2::TreeAdapter::TreeType
_TreeType TreeType
Definition: Grid.h:1079
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static TreeType & tree(AccessorType &a)
Definition: Grid.h:1155
openvdb::v8_2::Grid::copyReplacingMetadata
ConstPtr copyReplacingMetadata(const MetaMap &meta) const
Return a new grid of the same type as this grid whose tree and transform is shared with this grid and...
Definition: Grid.h:1377
openvdb::v8_2::GridBase::unregisterGrid
static void unregisterGrid(const Name &type)
Remove a grid type from the registry.
openvdb::v8_2::GridBase::print
virtual void print(std::ostream &=std::cout, int verboseLevel=1) const =0
Output a human-readable description of this grid.
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::ConstTreePtrType
typename TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:1141
openvdb::v8_2::Grid::ValueAllCIter
typename _TreeType::ValueAllCIter ValueAllCIter
Definition: Grid.h:593
openvdb::v8_2::ShallowCopy
Tag dispatch class that distinguishes shallow copy constructors from deep copy constructors.
Definition: openvdb/Types.h:539
openvdb::v8_2::TreeAdapter::tree
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:1096
openvdb::v8_2::TreeAdapter::ConstGridPtrType
typename GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:1088
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::ConstTreePtrType
typename TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:1112
openvdb::v8_2::TreeAdapter::GridPtrType
typename GridType::Ptr GridPtrType
Definition: Grid.h:1086
openvdb::v8_2::math::Transform::Ptr
SharedPtr< Transform > Ptr
Definition: Transform.h:42
openvdb::v8_2::Grid::activeVoxelCount
Index64 activeVoxelCount() const override
Return the number of active voxels.
Definition: Grid.h:879
openvdb::v8_2::VecType
VecType
Definition: openvdb/Types.h:343
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::tree
static const TreeType & tree(const GridType &g)
Definition: Grid.h:1127
openvdb::v8_2::GridBase::clearGridClass
void clearGridClass()
Remove the setting specifying the class of this grid's volumetric data.
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::AccessorType
typename tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:1149
openvdb::v8_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:1078
openvdb::v8_2::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:1816
openvdb::v8_2::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:408
openvdb::v8_2::Grid::beginValueAll
ValueAllCIter beginValueAll() const
Return an iterator over all of this grid's values (tile and voxel).
Definition: Grid.h:777
openvdb::v8_2::TreeAdapter::NonConstTreeType
typename std::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:1080
openvdb::v8_2::GridBase::copyGridReplacingTransform
virtual GridBase::ConstPtr copyGridReplacingTransform(math::Transform::Ptr xform) const =0
Return a new grid of the same type as this grid whose tree is shared with this grid,...
openvdb::v8_2::GridBase::clear
virtual void clear()=0
Empty this grid, setting all voxels to the background.
openvdb::v8_2::Grid::copyGridReplacingMetadata
GridBase::ConstPtr copyGridReplacingMetadata(const MetaMap &meta) const override
Return a new grid of the same type as this grid whose tree and transform is shared with this grid and...
Definition: Grid.h:1438
openvdb::v8_2::MergePolicy
MergePolicy
Definition: openvdb/Types.h:366
openvdb::v8_2::tree::TreeBase::Ptr
SharedPtr< TreeBase > Ptr
Definition: Tree.h:38
openvdb::v8_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:1771
openvdb::v8_2::GridBase::META_FILE_BBOX_MAX
static const char *const META_FILE_BBOX_MAX
Definition: Grid.h:362
openvdb::v8_2::Grid::copyGridReplacingMetadataAndTransform
GridBase::ConstPtr copyGridReplacingMetadataAndTransform(const MetaMap &meta, math::Transform::Ptr xform) const override
Return a new grid of the same type as this grid whose tree is shared with this grid and whose transfo...
Definition: Grid.h:1452
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::TreePtrType
typename TreeType::Ptr TreePtrType
Definition: Grid.h:1111
openvdb::v8_2::math::cwiseAdd
Mat3< Type1 > cwiseAdd(const Mat3< Type1 > &m, const Type2 s)
Definition: Mat3.h:820
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::GridPtrType
typename GridType::Ptr GridPtrType
Definition: Grid.h:1145
Transform.h
openvdb::v8_2::GridBase::META_SAVE_HALF_FLOAT
static const char *const META_SAVE_HALF_FLOAT
Definition: Grid.h:358
openvdb::v8_2::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::v8_2::TreeAdapter< Grid< _TreeType > >::constTree
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:1128
openvdb::v8_2::GridBase::GridBase
GridBase()
Initialize with an identity linear transform.
Definition: Grid.h:486
openvdb::v8_2::GridBase::getCreator
std::string getCreator() const
Return the user-specified description of this grid's creator.
openvdb::v8_2::math::Transform::ConstPtr
SharedPtr< const Transform > ConstPtr
Definition: Transform.h:43
openvdb::v8_2::tree::TreeBase::ConstPtr
SharedPtr< const TreeBase > ConstPtr
Definition: Tree.h:39
openvdb::v8_2::GridBase::addStatsMetadata
void addStatsMetadata()
Add metadata to this grid comprising the current values of statistics like the active voxel count and...
openvdb::v8_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:1719
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::ConstAccessorType
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:1150
openvdb::v8_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:607
openvdb::v8_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:1541
openvdb::v8_2::GridBase::setTree
virtual void setTree(TreeBase::Ptr)=0
Associate the given tree with this grid, in place of its existing tree.
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::ValueType
typename TreeType::ValueType ValueType
Definition: Grid.h:1148
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstTreeType
typename std::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:1139
openvdb::v8_2::io::getFormatVersion
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
openvdb::v8_2::GridBase::empty
virtual bool empty() const =0
Return true if this grid contains only background voxels.
openvdb::v8_2::GridBase::GridBase
GridBase(GridBase &other, ShallowCopy)
Copy another grid's metadata but share its transform.
Definition: Grid.h:498
openvdb::v8_2::GridBase::META_GRID_NAME
static const char *const META_GRID_NAME
Definition: Grid.h:357
openvdb::v8_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:557
openvdb::v8_2::GridBase::clearVectorType
void clearVectorType()
Remove the setting specifying the type of vector data stored in this grid.
openvdb::v8_2::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:407
openvdb::v8_2::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:1550
openvdb::v8_2::GridBase::META_FILE_VOXEL_COUNT
static const char *const META_FILE_VOXEL_COUNT
Definition: Grid.h:365
openvdb::v8_2::Grid::copyReplacingMetadataAndTransform
ConstPtr copyReplacingMetadataAndTransform(const MetaMap &meta, math::Transform::Ptr xform) const
Return a new grid of the same type as this grid whose tree is shared with this grid and whose transfo...
Definition: Grid.h:1394
openvdb::v8_2::GridBase::baseTree
const TreeBase & baseTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:192
openvdb::v8_2::Grid::BuildType
typename _TreeType::BuildType BuildType
Definition: Grid.h:586
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::constTree
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:1131
openvdb::v8_2::Grid::ValueAllIter
typename _TreeType::ValueAllIter ValueAllIter
Definition: Grid.h:592
openvdb::v8_2::GridBase::META_FILE_BBOX_MIN
static const char *const META_FILE_BBOX_MIN
Definition: Grid.h:361
openvdb::v8_2::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:901
openvdb::v8_2::TreeAdapter::TreePtrType
typename TreeType::Ptr TreePtrType
Definition: Grid.h:1081
openvdb::v8_2::Grid::ValueOffCIter
typename _TreeType::ValueOffCIter ValueOffCIter
Definition: Grid.h:591
openvdb::v8_2::Grid::Grid
Grid()
Construct a new grid with background value zero.
Definition: Grid.h:1265
openvdb::v8_2::GridPtrSet
std::set< GridBase::Ptr > GridPtrSet
Definition: Grid.h:524
openvdb::v8_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:1519
openvdb::v8_2::GridBase::constTransform
const math::Transform & constTransform() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition: Grid.h:417
openvdb::v8_2::GridCPtrSetCIter
GridCPtrSet::const_iterator GridCPtrSetCIter
Definition: Grid.h:531
openvdb::v8_2::GridBase::getVectorType
VecType getVectorType() const
Return the type of vector data (invariant, covariant, etc.) stored in this grid, assuming that this g...
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::tree
static TreeType & tree(GridType &g)
Definition: Grid.h:1125
OPENVDB_THROW
#define OPENVDB_THROW(exception, message)
Definition: openvdb/Exceptions.h:74
openvdb::v8_2::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:903
openvdb::v8_2::GridCPtrSet
std::set< GridBase::ConstPtr > GridCPtrSet
Definition: Grid.h:529
Name.h
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::ConstGridPtrType
typename GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:1118
openvdb::v8_2::GridBase::copyGridWithNewTree
virtual GridBase::Ptr copyGridWithNewTree() const =0
Return a new grid of the same type as this grid whose metadata and transform are deep copies of this ...
openvdb::v8_2::Grid::evalMinMax
void evalMinMax(ValueType &minVal, ValueType &maxVal) const
Return the minimum and maximum active values in this grid.
Definition: Grid.h:1579
openvdb::v8_2::Grid::cbeginValueAll
ValueAllCIter cbeginValueAll() const
Return an iterator over all of this grid's values (tile and voxel).
Definition: Grid.h:779
openvdb::v8_2::Grid::cbeginValueOff
ValueOffCIter cbeginValueOff() const
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition: Grid.h:773
openvdb::v8_2::MetaMap
Container that maps names (strings) to values of arbitrary types.
Definition: MetaMap.h:20
openvdb::v8_2::GridPtrSetPtr
SharedPtr< GridPtrSet > GridPtrSetPtr
Definition: Grid.h:527
openvdb::v8_2::GridBase
Abstract base class for typed grids.
Definition: Grid.h:78
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::ValueType
typename TreeType::ValueType ValueType
Definition: Grid.h:1119
openvdb::v8_2::Grid::getAccessor
Accessor getAccessor()
Return an accessor that provides random read and write access to this grid's voxels.
Definition: Grid.h:740
openvdb::v8_2::GridBase::evalActiveVoxelDim
virtual Coord evalActiveVoxelDim() const =0
Return the dimensions of the axis-aligned bounding box of all active voxels.
openvdb::v8_2::GridBase::voxelSize
Vec3d voxelSize() const
Return the size of this grid's voxels.
Definition: Grid.h:434
openvdb::v8_2::Grid::background
const ValueType & background() const
Return this grid's background value.
Definition: Grid.h:730
openvdb::v8_2::GridBase::copyGrid
virtual GridBase::ConstPtr copyGrid() const =0
Return a new grid of the same type as this grid whose metadata is a deep copy of this grid's and whos...
openvdb::v8_2::GridBase::clearRegistry
static void clearRegistry()
Clear the grid type registry.
openvdb::v8_2::io::StreamMetadata::Ptr
SharedPtr< StreamMetadata > Ptr
Definition: io.h:33
openvdb::v8_2::GridBase::createGrid
static Ptr createGrid(const Name &type)
Create a new grid of the given (registered) type.
openvdb_houdini::Grid
openvdb::GridBase Grid
Definition: openvdb_houdini/openvdb_houdini/Utils.h:33
MetaMap.h
openvdb::v8_2::TypeList
A list of types (not necessarily unique)
Definition: TypeList.h:366
openvdb::v8_2::GridBase::worldToIndex
Vec3d worldToIndex(const Vec3d &xyz) const
Apply the inverse of this grid's transform to the given coordinates.
Definition: Grid.h:445
openvdb::v8_2::TreeAdapter::tree
static TreeType & tree(GridType &g)
Definition: Grid.h:1095
openvdb::v8_2::GRID_LEVEL_SET
@ GRID_LEVEL_SET
Definition: openvdb/Types.h:315
openvdb::v8_2::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:722
openvdb::v8_2::TypeError
Definition: openvdb/Exceptions.h:64
openvdb::v8_2::Grid::Accessor
typename tree::ValueAccessor< _TreeType, true > Accessor
Definition: Grid.h:595
OPENVDB_API
#define OPENVDB_API
Helper macros for defining library symbol visibility.
Definition: Platform.h:208
openvdb::v8_2::Grid::tree
TreeType & tree()
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:917
openvdb::v8_2::GridBase::META_GRID_CLASS
static const char *const META_GRID_CLASS
Definition: Grid.h:355
openvdb::v8_2::GridBase::setGridClass
void setGridClass(GridClass)
Specify the class of volumetric data (level set, fog volume, etc.) that is stored in this grid.
openvdb::v8_2::GridBase::META_FILE_COMPRESSION
static const char *const META_FILE_COMPRESSION
Definition: Grid.h:363
openvdb::v8_2::Grid::ConstUnsafeAccessor
typename tree::ValueAccessor< const _TreeType, false > ConstUnsafeAccessor
Definition: Grid.h:598
openvdb::v8_2::Grid::deepCopy
Ptr deepCopy() const
Return a new grid whose metadata, transform and tree are deep copies of this grid's.
Definition: Grid.h:709
openvdb::v8_2::Grid::isRegistered
static bool isRegistered()
Return true if this grid type is registered.
Definition: Grid.h:979
openvdb::v8_2::GridBase::setVectorType
void setVectorType(VecType)
Specify the type of vector data (invariant, covariant, etc.) stored in this grid, assuming that this ...
openvdb::v8_2::GridPtrVecPtr
SharedPtr< GridPtrVec > GridPtrVecPtr
Definition: Grid.h:517
openvdb::v8_2::GridBase::vecTypeExamples
static std::string vecTypeExamples(VecType)
openvdb::v8_2::GridBase::META_IS_LOCAL_SPACE
static const char *const META_IS_LOCAL_SPACE
Definition: Grid.h:359
openvdb::v8_2::GridBase::type
virtual Name type() const =0
Return the name of this grid's type.
openvdb::v8_2::GridCPtrVec
std::vector< GridBase::ConstPtr > GridCPtrVec
Definition: Grid.h:519
openvdb::v8_2::Grid::ConstAccessor
typename tree::ValueAccessor< const _TreeType, true > ConstAccessor
Definition: Grid.h:596
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::constTree
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:1130
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::TreeType
_TreeType TreeType
Definition: Grid.h:1109
openvdb::v8_2::Grid::copyReplacingTransform
ConstPtr copyReplacingTransform(math::Transform::Ptr xform) const
Return a new grid of the same type as this grid whose tree is shared with this grid,...
Definition: Grid.h:1387
openvdb::v8_2::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:173
openvdb::v8_2::TreeAdapter::tree
static const TreeType & tree(const GridType &g)
Definition: Grid.h:1097
openvdb::v8_2::Grid::beginValueOff
ValueOffIter beginValueOff()
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition: Grid.h:769
openvdb::v8_2::Grid::newTree
void newTree() override
Associate a new, empty tree with this grid, in place of its existing tree.
Definition: Grid.h:1493
openvdb::v8_2::Grid::empty
bool empty() const override
Return true if this grid contains only inactive background voxels.
Definition: Grid.h:733
openvdb::v8_2::GridBase::gridClassToString
static std::string gridClassToString(GridClass)
Return the metadata string value for the given class of volumetric data.
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::constTree
static const TreeType & constTree(GridType &g)
Definition: Grid.h:1129
openvdb::v8_2::GridBase::readBuffers
virtual void readBuffers(std::istream &, const CoordBBox &)=0
Read all of this grid's data buffers that intersect the given index-space bounding box.
openvdb::v8_2::Grid::ValueType
typename _TreeType::ValueType ValueType
Definition: Grid.h:585
openvdb::v8_2::GridBase::baseTree
TreeBase & baseTree()
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:187
openvdb::v8_2::Grid::isTreeUnique
bool isTreeUnique() const final
Return true if tree is not shared with another grid.
Definition: Grid.h:1472
openvdb::v8_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:1711
openvdb::v8_2::GridBase::GridBase
GridBase(const GridBase &other)
Deep copy another grid's metadata and transform.
Definition: Grid.h:495
openvdb::v8_2::GridBase::setName
void setName(const std::string &)
Specify a name for this grid.
openvdb::v8_2::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:1568
openvdb::v8_2::Grid::getAccessor
ConstAccessor getAccessor() const
Return an accessor that provides random read-only access to this grid's voxels.
Definition: Grid.h:750
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:1162
openvdb::v8_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:1746
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const TreeType & constTree(GridType &g)
Definition: Grid.h:1160
openvdb::v8_2::GridBase::getName
std::string getName() const
Return this grid's user-specified name.
openvdb::v8_2::GridCPtrVecPtr
SharedPtr< GridCPtrVec > GridCPtrVecPtr
Definition: Grid.h:522
openvdb::v8_2::Grid::tree
const TreeType & tree() const
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition: Grid.h:918
openvdb::v8_2::GridBase::indexToWorld
Vec3d indexToWorld(const Coord &ijk) const
Apply this grid's transform to the given coordinates.
Definition: Grid.h:443
openvdb::v8_2::Grid::TreeType
_TreeType TreeType
Definition: Grid.h:582
openvdb::v8_2::GridBase::constBaseTree
const TreeBase & constBaseTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:197
openvdb::v8_2::GridCPtrSetPtr
SharedPtr< GridCPtrSet > GridCPtrSetPtr
Definition: Grid.h:532
openvdb::v8_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:1036
openvdb::v8_2::Grid::clear
void clear() override
Empty this grid, so that all voxels become inactive background voxels.
Definition: Grid.h:735
openvdb::v8_2::GridBase::stringToGridClass
static GridClass stringToGridClass(const std::string &)
Return the class of volumetric data specified by the given string.
openvdb::v8_2::GridBase::vecTypeDescription
static std::string vecTypeDescription(VecType)
Return a string describing how the given type of vector data is affected by transformations (e....
openvdb::v8_2::GridBase::Ptr
SharedPtr< GridBase > Ptr
Definition: Grid.h:80
openvdb::v8_2::GridBase::pruneGrid
virtual void pruneGrid(float tolerance=0.0)=0
Reduce the memory footprint of this grid by increasing its sparseness either losslessly (tolerance = ...
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:1161
openvdb::v8_2::ValueError
Definition: openvdb/Exceptions.h:65
openvdb::v8_2::SharedPtr
std::shared_ptr< T > SharedPtr
Definition: openvdb/Types.h:92
openvdb::v8_2::GridPtrSetCIter
GridPtrSet::const_iterator GridPtrSetCIter
Definition: Grid.h:526
openvdb::v8_2::TreeAdapter::constTree
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:1100
openvdb::v8_2::GridPtrSetIter
GridPtrSet::iterator GridPtrSetIter
Definition: Grid.h:525
openvdb::v8_2::Real
double Real
Definition: openvdb/Types.h:38
openvdb::v8_2::GridNamePred::GridNamePred
GridNamePred(const Name &_name)
Definition: Grid.h:538
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstAccessorType
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:1151
openvdb::v8_2::TreeAdapter::constTree
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:1101
openvdb::v8_2::Grid::ConstTreePtrType
typename _TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:584
openvdb::v8_2::math::BBox< Vec3d >
openvdb::v8_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:1413
openvdb::v8_2::HasMultiPassIO
Metafunction that specifies whether a given leaf node, tree, or grid type requires multiple passes to...
Definition: Grid.h:1177
openvdb::v8_2::GridBase::voxelSize
Vec3d voxelSize(const Vec3d &xyz) const
Return the size of this grid's voxel at position (x, y, z).
Definition: Grid.h:437
openvdb::v8_2::Grid::beginValueOn
ValueOnIter beginValueOn()
Return an iterator over all of this grid's active values (tile and voxel).
Definition: Grid.h:763
openvdb::v8_2::GridBase::activeVoxelCount
virtual Index64 activeVoxelCount() const =0
Return the number of active voxels.
openvdb::v8_2::Grid::readBuffers
void readBuffers(std::istream &) override
Read all data buffers for this grid.
Definition: Grid.h:1629
openvdb::v8_2::Grid::copyGridReplacingTransform
GridBase::ConstPtr copyGridReplacingTransform(math::Transform::Ptr xform) const override
Return a new grid of the same type as this grid whose tree is shared with this grid,...
Definition: Grid.h:1445
openvdb::v8_2::LEVEL_SET_HALF_WIDTH
static const Real LEVEL_SET_HALF_WIDTH
Definition: openvdb/Types.h:321
openvdb::v8_2::TreeAdapter::NonConstAccessorType
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:1092
openvdb::v8_2::TreeAdapter::constTree
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:1098
openvdb::v8_2::GridBase::readBuffers
virtual void readBuffers(std::istream &)=0
Read all data buffers for this grid.
openvdb::v8_2::GridBase::registerGrid
static void registerGrid(const Name &type, GridFactory)
Register a grid type along with a factory function.
openvdb::v8_2::GridNamePred::operator()
bool operator()(const GridBase::ConstPtr &g) const
Definition: Grid.h:539
openvdb::v8_2::Grid::ConstPtr
SharedPtr< const Grid > ConstPtr
Definition: Grid.h:580
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::tree
static TreeType & tree(TreeType &t)
Definition: Grid.h:1124
openvdb::v8_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:1020
openvdb::v8_2::TreeAdapter::constTree
static const TreeType & constTree(GridType &g)
Definition: Grid.h:1099
openvdb::v8_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:1512
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::tree
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:1126
openvdb::v8_2::TreeAdapter::AccessorType
typename tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:1090
openvdb::v8_2::GridCPtrSetIter
GridCPtrSet::iterator GridCPtrSetIter
Definition: Grid.h:530
openvdb::v8_2::GridBase::readNonresidentBuffers
virtual void readNonresidentBuffers() const =0
Read all of this grid's data buffers that are not yet resident in memory (because delayed loading is ...
openvdb::v8_2::tree::TreeBase
Base class for typed trees.
Definition: Tree.h:36
openvdb::v8_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:1613
openvdb::v8_2::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:902
openvdb::v8_2::GridPtrVec
std::vector< GridBase::Ptr > GridPtrVec
Definition: Grid.h:514
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static TreeType & tree(TreeType &t)
Definition: Grid.h:1153
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:1159
openvdb::v8_2::GridBase::copyGrid
virtual GridBase::Ptr copyGrid()=0
Return a new grid of the same type as this grid whose metadata is a deep copy of this grid's and whos...
openvdb::v8_2::GridBase::constBaseTreePtr
virtual TreeBase::ConstPtr constBaseTreePtr() const =0
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:153
openvdb::v8_2::GridCPtrVecCIter
GridCPtrVec::const_iterator GridCPtrVecCIter
Definition: Grid.h:521
openvdb::v8_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:1762
openvdb::v8_2::math::Vec3d
Vec3< double > Vec3d
Definition: Vec3.h:668
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::NonConstTreePtrType
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:1113
openvdb::v8_2::GridBase::isType
bool isType() const
Return true if this grid is of the same type as the template parameter.
Definition: Grid.h:148
openvdb::v8_2::Grid::Ptr
SharedPtr< Grid > Ptr
Definition: Grid.h:579
openvdb::v8_2::Grid::create
static Ptr create()
Return a new grid with background value zero.
Definition: Grid.h:1330
openvdb::v8_2::GridCPtrVecIter
GridCPtrVec::iterator GridCPtrVecIter
Definition: Grid.h:520
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::TreeType
_TreeType TreeType
Definition: Grid.h:1138
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::TreePtrType
typename TreeType::Ptr TreePtrType
Definition: Grid.h:1140
openvdb::v8_2::GridBase::setSaveFloatAsHalf
void setSaveFloatAsHalf(bool)
Return this grid's user-specified name.
openvdb::v8_2::GridBase::isRegistered
static bool isRegistered(const Name &type)
Return true if the given grid type name is registered.
openvdb::v8_2::GridBase::META_VECTOR_TYPE
static const char *const META_VECTOR_TYPE
Definition: Grid.h:360
openvdb::v8_2::GridClass
GridClass
Definition: openvdb/Types.h:313
Tree.h
openvdb::v8_2::GridBase::evalActiveVoxelBoundingBox
virtual CoordBBox evalActiveVoxelBoundingBox() const =0
openvdb::v8_2::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:1559
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstTreePtrType
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:1142
openvdb::v8_2::GridBase::valueType
virtual Name valueType() const =0
Return the name of the type of a voxel's value (e.g., "float" or "vec3d").
openvdb::v8_2::GridBase::GridFactory
Ptr(*)() GridFactory
Definition: Grid.h:83
openvdb::v8_2::GridBase::getGridClass
GridClass getGridClass() const
Return the class of volumetric data (level set, fog volume, etc.) that is stored in this grid.
openvdb::v8_2::math::Transform
Definition: Transform.h:40
openvdb::v8_2::math::Transform::createLinearTransform
static Transform::Ptr createLinearTransform(double voxelSize=1.0)
Create and return a shared pointer to a new transform.
openvdb::v8_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:1621
openvdb::v8_2::GridBase::readTransform
void readTransform(std::istream &is)
Read in the transform for this grid.
Definition: Grid.h:474
openvdb::v8_2::TreeAdapter::ConstAccessorType
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:1091
openvdb::v8_2::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:711
openvdb::v8_2::GridBase::indexToWorld
Vec3d indexToWorld(const Vec3d &xyz) const
Apply this grid's transform to the given coordinates.
Definition: Grid.h:441
openvdb::v8_2::GridBase::getStatsMetadata
MetaMap::Ptr getStatsMetadata() const
Return a new MetaMap containing just the metadata that was added to this grid with addStatsMetadata.
openvdb::v8_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::v8_2::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:1423
openvdb::v8_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:1209
logging.h
io.h
openvdb::v8_2::Grid::clip
void clip(const CoordBBox &) override
Clip this grid to the given index-space bounding box.
Definition: Grid.h:1534
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::GridPtrType
typename GridType::Ptr GridPtrType
Definition: Grid.h:1116
openvdb::v8_2::GridBase::isInWorldSpace
bool isInWorldSpace() const
openvdb::v8_2::TreeAdapter::NonConstTreePtrType
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:1083
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstGridPtrType
typename NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:1146
openvdb::v8_2::TreeAdapter::tree
static TreeType & tree(TreeType &t)
Definition: Grid.h:1094
openvdb::v8_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:348
openvdb::v8_2::Grid::getUnsafeAccessor
UnsafeAccessor getUnsafeAccessor()
Return an unsafe accessor that provides random read and write access to this grid's voxels.
Definition: Grid.h:748
openvdb::v8_2::Grid::getConstAccessor
ConstAccessor getConstAccessor() const
Return an accessor that provides random read-only access to this grid's voxels.
Definition: Grid.h:752
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static TreeType & tree(GridType &g)
Definition: Grid.h:1154
openvdb::v8_2::GridPtrVecIter
GridPtrVec::iterator GridPtrVecIter
Definition: Grid.h:515
openvdb::v8_2::Index64
uint64_t Index64
Definition: openvdb/Types.h:31
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:101
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:1156
openvdb::v8_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:1405
openvdb::v8_2::GridNamePred::name
Name name
Definition: Grid.h:540
openvdb::v8_2::MetaMap::Ptr
SharedPtr< MetaMap > Ptr
Definition: MetaMap.h:22
openvdb::v8_2::Grid::evalActiveVoxelBoundingBox
CoordBBox evalActiveVoxelBoundingBox() const override
Return the axis-aligned bounding box of all active voxels.
Definition: Grid.h:1587
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::NonConstGridPtrType
typename NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:1117
openvdb::v8_2::math::CoordBBox
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:249
openvdb::v8_2::GridBase::newTree
virtual void newTree()=0
Set a new tree with the same background value as the previous tree.
openvdb::v8_2::GridBase::setTransform
void setTransform(math::Transform::Ptr)
Associate the given transform with this grid, in place of its existing transform.
Definition: Grid.h:1254
openvdb::v8_2::GridBase::setIsInWorldSpace
void setIsInWorldSpace(bool)
Specify whether this grid's voxel values are in world space or in local space.
openvdb::v8_2::Grid::gridType
static Name gridType()
Return the name of this type of grid.
Definition: Grid.h:719
openvdb::v8_2::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:1674
openvdb::v8_2::GridBase::writeBuffers
virtual void writeBuffers(std::ostream &) const =0
Write out all data buffers for this grid.
openvdb::v8_2::Grid::constTree
const TreeType & constTree() const
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition: Grid.h:919
openvdb::v8_2::Grid::type
Name type() const override
Return the name of this grid's type.
Definition: Grid.h:717
openvdb::v8_2::GridBase::saveFloatAsHalf
bool saveFloatAsHalf() const
Return true if this grid should be written out with floating-point voxel values (including components...
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::NonConstAccessorType
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:1122
openvdb::v8_2::Grid::pruneGrid
void pruneGrid(float tolerance=0.0) override
Reduce the memory footprint of this grid by increasing its sparseness.
Definition: Grid.h:1526
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::AccessorType
typename tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:1120
Exceptions.h
OpenVDB AX Exceptions.
openvdb::v8_2::GridBase::hasUniformVoxels
bool hasUniformVoxels() const
Return true if the voxels in world space are uniformly sized cubes.
Definition: Grid.h:439
openvdb::v8_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:1504
openvdb
Definition: openvdb/Exceptions.h:13
openvdb::v8_2::GridBase::constGrid
static GridType::ConstPtr constGrid(const GridBase::Ptr &)
Definition: Grid.h:1231
openvdb::v8_2::TreeAdapter< Grid< _TreeType > >::ConstAccessorType
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:1121
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static const TreeType & tree(const AccessorType &a)
Definition: Grid.h:1158
openvdb::v8_2::Grid::registerGrid
static void registerGrid()
Register this grid type along with a factory function.
Definition: Grid.h:981
openvdb::v8_2::tree::ValueAccessor
Definition: ValueAccessor.h:183
openvdb::v8_2::Grid::getConstUnsafeAccessor
ConstUnsafeAccessor getConstUnsafeAccessor() const
Return an unsafe accessor that provides random read-only access to this grid's voxels.
Definition: Grid.h:760
openvdb::v8_2::GridBase::stringToVecType
static VecType stringToVecType(const std::string &)
openvdb::v8_2::Grid::unregisterGrid
static void unregisterGrid()
Remove this grid type from the registry.
Definition: Grid.h:990
openvdb::v8_2::GridBase::transform
const math::Transform & transform() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition: Grid.h:416
openvdb::v8_2::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:1062
openvdb::v8_2::GridBase::META_FILE_MEM_BYTES
static const char *const META_FILE_MEM_BYTES
Definition: Grid.h:364
openvdb::v8_2::tree::internal::LeafBufferFlags
Definition: LeafBuffer.h:41
openvdb::v8_2::Grid::cbeginValueOn
ValueOnCIter cbeginValueOn() const
Return an iterator over all of this grid's active values (tile and voxel).
Definition: Grid.h:767
openvdb::v8_2::Grid::~Grid
~Grid() override
Definition: Grid.h:646
openvdb::v8_2::GridBase::setCreator
void setCreator(const std::string &)
Provide a description of this grid's creator.
openvdb::v8_2::Grid
Container class that associates a tree with a transform and metadata.
Definition: Grid.h:577
openvdb::v8_2::TreeAdapter::ConstTreePtrType
typename TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:1082
openvdb::v8_2::CopyConstness::Type
typename std::remove_const< ToType >::type Type
Definition: openvdb/Types.h:299
openvdb::v8_2::GridBase::writeTopology
virtual void writeTopology(std::ostream &) const =0
Write the grid topology to a stream. This will write only the grid structure, not the actual data buf...
openvdb::v8_2::GridPtrVecCIter
GridPtrVec::const_iterator GridPtrVecCIter
Definition: Grid.h:516
openvdb::v8_2::GridBase::gridClassToMenuName
static std::string gridClassToMenuName(GridClass)
Return a formatted string version of the grid class.
openvdb::v8_2::Grid::writeBuffers
void writeBuffers(std::ostream &) const override
Write out all data buffers for this grid.
Definition: Grid.h:1682
openvdb::v8_2::Name
std::string Name
Definition: Name.h:17
openvdb::v8_2::Grid::evalActiveVoxelDim
Coord evalActiveVoxelDim() const override
Return the dimensions of the axis-aligned bounding box of all active voxels.
Definition: Grid.h:1597
openvdb::v8_2::Grid::UnsafeAccessor
typename tree::ValueAccessor< _TreeType, false > UnsafeAccessor
Definition: Grid.h:597
openvdb::v8_2::GridBase::readTopology
virtual void readTopology(std::istream &)=0
Read the grid topology from a stream. This will read only the grid structure, not the actual data buf...
openvdb::v8_2::ax::ast::print
void print(const ast::Node &node, const bool numberStatements=true, std::ostream &os=std::cout, const char *indent=" ")
Writes a descriptive printout of a Node hierarchy into a target stream.
openvdb::v8_2::OPENVDB_FILE_VERSION_MULTIPASS_IO
@ OPENVDB_FILE_VERSION_MULTIPASS_IO
Definition: version.h:197
openvdb::v8_2::Grid::TreePtrType
typename _TreeType::Ptr TreePtrType
Definition: Grid.h:583
OPENVDB_LOG_WARN
#define OPENVDB_LOG_WARN(message)
Log a warning message of the form 'someVar << "some text" << ...'.
Definition: logging.h:253
openvdb::v8_2::TreeAdapter< tree::ValueAccessor< _TreeType > >::ConstGridPtrType
typename GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:1147