OpenVDB 5.1.0

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