31 #ifndef OPENVDB_GRID_HAS_BEEN_INCLUDED
32 #define OPENVDB_GRID_HAS_BEEN_INCLUDED
37 #include <boost/static_assert.hpp>
38 #include <boost/type_traits/remove_const.hpp>
39 #include <boost/type_traits/is_floating_point.hpp>
40 #include <openvdb/Types.h>
41 #include <openvdb/util/Name.h>
42 #include <openvdb/math/Transform.h>
43 #include <openvdb/tree/Tree.h>
44 #include <openvdb/metadata/MetaMap.h>
45 #include <openvdb/Exceptions.h>
54 template<
typename>
class Grid;
61 template<
typename Gr
idType>
62 inline typename GridType::Ptr
createGrid(
const typename GridType::ValueType& background);
68 template<
typename Gr
idType>
76 template<
typename TreePtrType>
94 template<
typename Gr
idType>
106 typedef boost::shared_ptr<GridBase>
Ptr;
107 typedef boost::shared_ptr<const GridBase>
ConstPtr;
109 typedef Ptr (*GridFactory)();
129 static bool isRegistered(
const Name &type);
132 static void clearRegistry();
139 virtual Name type()
const = 0;
141 virtual Name valueType()
const = 0;
144 template<
typename Gr
idType>
145 bool isType()
const {
return (this->type() == GridType::gridType()); }
148 template<
typename Gr
idType>
152 template<
typename Gr
idType>
154 template<
typename Gr
idType>
155 static typename GridType::ConstPtr constGrid(
const GridBase::Ptr&);
156 template<
typename Gr
idType>
169 TreeBase& baseTree() {
return const_cast<TreeBase&
>(this->constBaseTree()); }
186 virtual void newTree() = 0;
189 virtual bool empty()
const = 0;
191 virtual void clear() = 0;
198 virtual void pruneGrid(
float tolerance = 0.0) = 0;
205 std::string getName()
const;
207 void setName(
const std::string&);
210 std::string getCreator()
const;
212 void setCreator(
const std::string&);
216 bool saveFloatAsHalf()
const;
217 void setSaveFloatAsHalf(
bool);
224 void clearGridClass();
227 static std::string gridClassToString(
GridClass);
229 static std::string gridClassToMenuName(
GridClass);
233 static GridClass stringToGridClass(
const std::string&);
242 void clearVectorType();
245 static std::string vecTypeToString(
VecType);
248 static std::string vecTypeExamples(
VecType);
251 static std::string vecTypeDescription(
VecType);
252 static VecType stringToVecType(
const std::string&);
257 bool isInWorldSpace()
const;
259 void setIsInWorldSpace(
bool);
282 virtual Index64 activeVoxelCount()
const = 0;
286 virtual CoordBBox evalActiveVoxelBoundingBox()
const = 0;
289 virtual Coord evalActiveVoxelDim()
const = 0;
292 virtual Index64 memUsage()
const = 0;
298 void addStatsMetadata();
340 Vec3d indexToWorld(
const Vec3d& xyz)
const {
return transform().indexToWorld(xyz); }
344 Vec3d worldToIndex(
const Vec3d& xyz)
const {
return transform().worldToIndex(xyz); }
353 virtual void readTopology(std::istream&) = 0;
356 virtual void writeTopology(std::ostream&)
const = 0;
359 virtual void readBuffers(std::istream&) = 0;
361 virtual void writeBuffers(std::ostream&)
const = 0;
369 virtual void print(std::ostream& = std::cout,
int verboseLevel = 1)
const = 0;
374 GridBase(): mTransform(math::Transform::createLinearTransform()) {}
383 static void registerGrid(
const Name& type, GridFactory);
385 static void unregisterGrid(
const Name& type);
426 template<
typename Gr
idPtrContainerT>
427 inline typename GridPtrContainerT::value_type
430 typedef typename GridPtrContainerT::value_type GridPtrT;
431 typename GridPtrContainerT::const_iterator it =
432 std::find_if(container.begin(), container.end(),
GridNamePred(name));
433 return (it == container.end() ? GridPtrT() : *it);
437 template<
typename KeyT,
typename Gr
idPtrT>
441 typedef std::map<KeyT, GridPtrT> GridPtrMapT;
442 for (
typename GridPtrMapT::const_iterator it = container.begin(), end = container.end();
445 const GridPtrT& grid = it->second;
446 if (grid && grid->getName() == name)
return grid;
457 template<
typename _TreeType>
461 typedef boost::shared_ptr<Grid>
Ptr;
485 template<
typename OtherValueType>
530 Ptr deepCopy()
const {
return Ptr(
new Grid(*
this)); }
536 virtual Name type()
const {
return this->gridType(); }
553 virtual bool empty()
const {
return tree().empty(); }
555 virtual void clear() { tree().clear(); }
560 ConstAccessor getAccessor()
const {
return ConstAccessor(tree()); }
566 ValueOnIter beginValueOn() {
return tree().beginValueOn(); }
572 ValueOffIter beginValueOff() {
return tree().beginValueOff(); }
578 ValueAllIter beginValueAll() {
return tree().beginValueAll(); }
585 void evalMinMax(ValueType& minVal, ValueType& maxVal)
const;
595 void fill(
const CoordBBox& bbox,
const ValueType& value,
bool active =
true);
611 void signedFloodFill(
const ValueType& outside,
const ValueType& inside);
617 void prune(
const ValueType& tolerance = zeroVal<ValueType>()) { tree().prune(tolerance); }
619 virtual void pruneGrid(
float tolerance = 0.0);
641 template<
typename OtherTreeType>
657 template<
typename OtherTreeType>
660 tree().topologyIntersection(other.
tree());
671 virtual CoordBBox evalActiveVoxelBoundingBox()
const;
673 virtual Coord evalActiveVoxelDim()
const;
684 TreePtrType treePtr() {
return mTree; }
692 TreeType& tree() {
return *mTree; }
710 virtual void newTree();
718 virtual void readTopology(std::istream&);
721 virtual void writeTopology(std::ostream&)
const;
724 virtual void readBuffers(std::istream&);
726 virtual void writeBuffers(std::ostream&)
const;
729 virtual void print(std::ostream& = std::cout,
int verboseLevel = 1)
const;
764 template<
typename Gr
idType>
765 inline typename GridType::Ptr
768 return GridBase::grid<GridType>(grid);
780 template<
typename Gr
idType>
781 inline typename GridType::ConstPtr
784 return GridBase::constGrid<GridType>(grid);
797 template<
typename Gr
idType>
798 inline typename GridType::Ptr
801 if (!grid || !grid->isType<GridType>())
return typename GridType::Ptr();
802 return gridPtrCast<GridType>(grid->deepCopyGrid());
806 template<
typename Gr
idType>
807 inline typename GridType::Ptr
810 if (!grid.
isType<GridType>())
return typename GridType::Ptr();
820 template<
typename _TreeType>
852 template<
typename _TreeType>
881 template<
typename _TreeType>
917 template<
typename Gr
idType>
918 inline typename GridType::Ptr
923 if (grid && grid->type() == GridType::gridType()) {
924 return boost::static_pointer_cast<GridType>(grid);
926 return typename GridType::Ptr();
930 template<
typename Gr
idType>
931 inline typename GridType::ConstPtr
934 return boost::const_pointer_cast<
const GridType>(
935 GridBase::grid<GridType>(boost::const_pointer_cast<
GridBase>(grid)));
939 template<
typename Gr
idType>
940 inline typename GridType::ConstPtr
943 return boost::const_pointer_cast<
const GridType>(GridBase::grid<GridType>(grid));
947 template<
typename Gr
idType>
948 inline typename GridType::ConstPtr
951 return boost::const_pointer_cast<
const GridType>(
952 GridBase::grid<GridType>(boost::const_pointer_cast<
GridBase>(grid)));
959 return boost::const_pointer_cast<
TreeBase>(this->constBaseTreePtr());
974 template<
typename TreeT>
980 template<
typename TreeT>
986 template<
typename TreeT>
993 template<
typename TreeT>
996 mTree(boost::static_pointer_cast<
TreeType>(other.mTree->copy()))
1001 template<
typename TreeT>
1009 template<
typename TreeT>
1018 template<
typename TreeT>
1027 template<
typename TreeT>
1031 return Ptr(
new Grid(background));
1036 template<
typename TreeT>
1045 template<
typename TreeT>
1056 template<
typename TreeT>
1061 switch (treePolicy) {
1067 ret.reset(
new Grid(*
this));
1077 template<
typename TreeT>
1081 return this->copy(treePolicy);
1088 template<
typename TreeT>
1093 if (tree->type() != TreeType::treeType()) {
1095 + tree->type() +
" to a grid of type " + this->type());
1097 mTree = boost::static_pointer_cast<
TreeType>(tree);
1101 template<
typename TreeT>
1105 mTree.reset(
new TreeType(this->background()));
1109 template<
typename TreeT>
1113 tree().fill(bbox, value, active);
1117 template<
typename TreeT>
1121 tree().signedFloodFill(outside, inside);
1125 template<
typename TreeT>
1129 this->prune(
ValueType(zeroVal<ValueType>() + tolerance));
1133 template<
typename TreeT>
1137 tree().merge(other.
tree(), policy);
1141 template<
typename TreeT>
1145 tree().evalMinMax(minVal, maxVal);
1149 template<
typename TreeT>
1154 tree().evalActiveVoxelBoundingBox(bbox);
1159 template<
typename TreeT>
1164 const bool nonempty = tree().evalActiveVoxelDim(dim);
1165 return (nonempty ? dim : Coord());
1175 template<
typename TreeT>
1179 tree().readTopology(is, saveFloatAsHalf());
1183 template<
typename TreeT>
1187 tree().writeTopology(os, saveFloatAsHalf());
1191 template<
typename TreeT>
1195 tree().readBuffers(is, saveFloatAsHalf());
1199 template<
typename TreeT>
1203 tree().writeBuffers(os, saveFloatAsHalf());
1207 template<
typename TreeT>
1211 tree().print(os, verboseLevel);
1213 if (metaCount() > 0) {
1214 os <<
"Additional metadata:" << std::endl;
1216 os <<
" " << it->first;
1218 const std::string value = it->second->str();
1219 if (!value.empty()) os <<
": " << value;
1225 os <<
"Transform:" << std::endl;
1226 transform().print(os,
" ");
1234 template<
typename Gr
idType>
1235 inline typename GridType::Ptr
1238 return GridType::create(background);
1242 template<
typename Gr
idType>
1243 inline typename GridType::Ptr
1246 return GridType::create();
1250 template<
typename TreePtrType>
1254 typedef typename TreePtrType::element_type TreeType;
1259 template<
typename Gr
idType>
1260 typename GridType::Ptr
1263 typedef typename GridType::ValueType ValueType;
1266 BOOST_STATIC_ASSERT(boost::is_floating_point<ValueType>::value);
1268 typename GridType::Ptr grid = GridType::create(
1269 static_cast<ValueType>(voxelSize * halfWidth));
1278 #endif // OPENVDB_GRID_HAS_BEEN_INCLUDED
void setBackground(const ValueType &val)
Replace this grid's background value.
Definition: Grid.h:550
CopyPolicy
Definition: Types.h:338
boost::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:885
void evalMinMax(ValueType &minVal, ValueType &maxVal) const
Return the minimum and maximum active values in this grid.
Definition: Grid.h:1143
Predicate functor that returns true for grids that have a specified name.
Definition: Grid.h:418
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:782
static TreeType & tree(GridType &g)
Definition: Grid.h:841
NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:833
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:874
boost::shared_ptr< const TreeBase > ConstPtr
Definition: Tree.h:68
std::vector< GridBase::ConstPtr > GridCPtrVec
Definition: Grid.h:401
_TreeType TreeType
Definition: Grid.h:464
GridPtrSet::const_iterator GridPtrSetCIter
Definition: Grid.h:408
This adapter allows code that is templated on a Tree type to accept either a Tree type or a Grid type...
Definition: Grid.h:823
ValueAllCIter cbeginValueAll() const
Return an iterator over all of this grid's values (tile and voxel).
Definition: Grid.h:581
OPENVDB_IMPORT void setGridClass(std::ios_base &, uint32_t)
Associate with the given stream the class (GRID_LEVEL_SET, GRID_UNKNOWN, etc.) of the grid currently ...
virtual void pruneGrid(float tolerance=0.0)
Reduce the memory footprint of this grid by increasing its sparseness.
Definition: Grid.h:1127
void merge(Grid &other, MergePolicy policy=MERGE_ACTIVE_STATES)
Efficiently merge another grid into this grid using one of several schemes.
Definition: Grid.h:1135
static void registerGrid(const Name &type, GridFactory)
Register a grid type along with a factory function.
virtual Name type() const
Return the name of this grid's type.
Definition: Grid.h:536
GridNamePred(const Name &name)
Definition: Grid.h:420
bool operator()(const GridBase::ConstPtr &g) const
Definition: Grid.h:421
Grid()
Construct a new grid with background value zero.
Definition: Grid.h:975
std::vector< GridBase::Ptr > GridPtrVec
Definition: Grid.h:396
tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:838
boost::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:856
ValueAllCIter beginValueAll() const
Return an iterator over all of this grid's values (tile and voxel).
Definition: Grid.h:580
virtual void clear()
Empty this grid, so that all voxels become inactive background voxels.
Definition: Grid.h:555
_TreeType::ValueAllCIter ValueAllCIter
Definition: Grid.h:477
tree::ValueAccessor< _TreeType > Accessor
Definition: Grid.h:469
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:766
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:164
static const char *const META_VECTOR_TYPE
Definition: Grid.h:270
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:97
TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:887
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:846
const math::Transform & transform() const
Return a reference to this grid's transform, which might be shared with other grids.
Definition: Grid.h:322
static void registerGrid()
Register this grid type along with a factory function.
Definition: Grid.h:738
GridType::Ptr GridPtrType
Definition: Grid.h:832
const ValueType & background() const
Return this grid's background value.
Definition: Grid.h:548
math::Transform::ConstPtr constTransformPtr() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition: Grid.h:314
TreeType::Ptr TreePtrType
Definition: Grid.h:827
tree::TreeBase TreeBase
Definition: Grid.h:52
virtual Index64 activeVoxelCount() const
Return the number of active voxels.
Definition: Grid.h:669
TreeType & tree()
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:696
double Real
Definition: Types.h:62
static TreeType & tree(AccessorType &a)
Definition: Grid.h:901
TreeType::Ptr TreePtrType
Definition: Grid.h:886
GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:893
tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:896
static const char *const META_GRID_CLASS
Definition: Grid.h:265
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:919
boost::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:826
static TreeType & tree(TreeType &t)
Definition: Grid.h:840
static TreeType & tree(TreeType &t)
Definition: Grid.h:870
static void unregisterGrid()
Remove this grid type from the registry.
Definition: Grid.h:740
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:1261
void setTransform(math::Transform::Ptr)
Associate the given transform with this grid, in place of its existing transform. ...
Definition: Grid.h:964
virtual void writeTopology(std::ostream &) const
Write the grid topology to a stream. This will write only the grid structure, not the actual data buf...
Definition: Grid.h:1185
static const char *const META_IS_LOCAL_SPACE
Definition: Grid.h:269
GridType::Ptr GridPtrType
Definition: Grid.h:862
GridType::Ptr GridPtrType
Definition: Grid.h:891
TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:858
const TreeType & tree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:697
static Ptr create()
Return a new grid with background value zero.
Definition: Grid.h:1020
std::set< GridBase::Ptr > GridPtrSet
Definition: Grid.h:406
GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:834
virtual GridBase::Ptr copyGrid(CopyPolicy treePolicy=CP_SHARE) const
Return a new grid of the same type as this grid and whose metadata and transform are deep copies of t...
Definition: Grid.h:1079
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:905
static bool isRegistered(const Name &type)
Return true if the given grid type name is registered.
GridPtrSet::iterator GridPtrSetIter
Definition: Grid.h:407
ValueOffCIter beginValueOff() const
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition: Grid.h:574
_TreeType::ValueAllIter ValueAllIter
Definition: Grid.h:476
tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:866
tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:897
Grid< NonConstTreeType > NonConstGridType
Definition: Grid.h:890
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:687
boost::shared_ptr< GridCPtrVec > GridCPtrVecPtr
Definition: Grid.h:404
virtual ~Grid()
Definition: Grid.h:518
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:688
Name name
Definition: Grid.h:422
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:1111
NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:888
TreeType::ValueType ValueType
Definition: Grid.h:894
virtual void writeBuffers(std::ostream &) const
Write out all data buffers for this grid.
Definition: Grid.h:1201
std::string Name
Definition: Name.h:44
Abstract base class for typed grids.
Definition: Grid.h:103
virtual GridBase::Ptr deepCopyGrid() const
Return a new grid whose metadata, transform and tree are deep copies of this grid's.
Definition: Grid.h:532
NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:863
_TreeType::ValueOnIter ValueOnIter
Definition: Grid.h:472
tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:895
boost::shared_ptr< Grid > Ptr
Definition: Grid.h:461
std::set< GridBase::ConstPtr > GridCPtrSet
Definition: Grid.h:411
tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:868
GridBase(const GridBase &other, ShallowCopy)
Copy another grid's metadata but share its transform.
Definition: Grid.h:380
tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:867
#define OPENVDB_VERSION_NAME
Definition: version.h:45
static const char *const META_FILE_VOXEL_COUNT
Definition: Grid.h:275
static const char *const META_FILE_COMPRESSION
Definition: Grid.h:273
Vec3d voxelSize() const
Return the size of this grid's voxels.
Definition: Grid.h:333
void signedFloodFill()
Set the values of all inactive voxels and tiles of a narrow-band level set from the signs of the acti...
Definition: Grid.h:602
static const TreeType & tree(const GridType &g)
Definition: Grid.h:873
virtual TreeBase::ConstPtr constBaseTreePtr() const
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition: Grid.h:689
static bool isRegistered()
Return true if this grid type is registered.
Definition: Grid.h:736
virtual Name valueType() const
Return the name of the type of a voxel's value (e.g., "float" or "vec3d").
Definition: Grid.h:545
virtual void setTree(TreeBase::Ptr)
Associate the given tree with this grid, in place of its existing tree.
Definition: Grid.h:1090
Grid< typename TreeType::template ValueConverter< OtherValueType >::Type > Type
Definition: Grid.h:487
static Name gridType()
Return the name of this type of grid.
Definition: Grid.h:538
void topologyIntersection(const Grid< OtherTreeType > &other)
Intersects this tree's set of active values with the active values of the other tree, whose ValueType may be different.
Definition: Grid.h:658
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:847
static const TreeType & constTree(GridType &g)
Definition: Grid.h:845
TreeType::ValueType ValueType
Definition: Grid.h:865
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:842
TreeType::ValueType ValueType
Definition: Grid.h:835
TreeType::Ptr TreePtrType
Definition: Grid.h:857
NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:892
virtual void newTree()
Associate a new, empty tree with this grid, in place of its existing tree.
Definition: Grid.h:1103
virtual void readBuffers(std::istream &)
Read all data buffers for this grid.
Definition: Grid.h:1193
virtual Coord evalActiveVoxelDim() const
Return the dimensions of the axis-aligned bounding box of all active voxels.
Definition: Grid.h:1161
GridBase()
Initialize with an identity linear transform.
Definition: Grid.h:374
static const char *const META_FILE_BBOX_MAX
Definition: Grid.h:272
ValueOnCIter cbeginValueOn() const
Return an iterator over all of this grid's active values (tile and voxel).
Definition: Grid.h:569
_TreeType::ValueOffCIter ValueOffCIter
Definition: Grid.h:475
VecType
Definition: Types.h:165
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:872
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:907
ValueOffCIter cbeginValueOff() const
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition: Grid.h:575
_TreeType TreeType
Definition: Grid.h:825
static const char *const META_FILE_BBOX_MIN
Definition: Grid.h:271
GridCPtrVec::const_iterator GridCPtrVecCIter
Definition: Grid.h:403
Accessor getAccessor()
Return an accessor that provides random read and write access to this grid's voxels.
Definition: Grid.h:558
Vec3< double > Vec3d
Definition: Vec3.h:605
virtual void readTopology(std::istream &)
Read the grid topology from a stream. This will read only the grid structure, not the actual data buf...
Definition: Grid.h:1177
virtual bool empty() const
Return true if this grid contains only inactive background voxels.
Definition: Grid.h:553
virtual GridBase::Ptr deepCopyGrid() const =0
Return a new grid whose metadata, transform and tree are deep copies of this grid's.
boost::shared_ptr< const Grid > ConstPtr
Definition: Grid.h:462
Definition: ValueAccessor.h:173
GridCPtrSet::const_iterator GridCPtrSetCIter
Definition: Grid.h:413
tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:837
static TreeType & tree(GridType &g)
Definition: Grid.h:900
virtual CoordBBox evalActiveVoxelBoundingBox() const
Return the axis-aligned bounding box of all active voxels.
Definition: Grid.h:1151
static TreeType & tree(TreeType &t)
Definition: Grid.h:899
_TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:466
Grid< TreeType > GridType
Definition: Grid.h:860
tree::ValueAccessor< const _TreeType > ConstAccessor
Definition: Grid.h:470
static const char *const META_SAVE_HALF_FLOAT
Definition: Grid.h:268
boost::shared_ptr< GridCPtrSet > GridCPtrSetPtr
Definition: Grid.h:414
static void unregisterGrid(const Name &type)
Remove a grid type from the registry.
static const char *const META_FILE_MEM_BYTES
Definition: Grid.h:274
boost::shared_ptr< TreeBase > Ptr
Definition: Tree.h:67
void prune(const ValueType &tolerance=zeroVal< ValueType >())
Reduce the memory footprint of this grid by increasing its sparseness either losslessly (tolerance = ...
Definition: Grid.h:617
_TreeType::ValueOnCIter ValueOnCIter
Definition: Grid.h:473
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:902
static const Real LEVEL_SET_HALF_WIDTH
Definition: Types.h:143
GridPtrVec::iterator GridPtrVecIter
Definition: Grid.h:397
TreeType & tree() const
Return a reference to the tree associated with this accessor.
Definition: ValueAccessor.h:117
static const TreeType & tree(const GridType &g)
Definition: Grid.h:903
boost::shared_ptr< const GridBase > ConstPtr
Definition: Grid.h:107
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:957
OPENVDB_IMPORT uint32_t getGridClass(std::ios_base &)
Return the class (GRID_LEVEL_SET, GRID_UNKNOWN, etc.) of the grid currently being read from or writte...
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:908
MergePolicy
Definition: Types.h:188
GridCPtrVec::iterator GridCPtrVecIter
Definition: Grid.h:402
Definition: Exceptions.h:88
static const TreeType & tree(const GridType &g)
Definition: Grid.h:843
Grid< NonConstTreeType > NonConstGridType
Definition: Grid.h:861
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:844
static TreeType & tree(GridType &g)
Definition: Grid.h:871
Ptr copy(CopyPolicy treePolicy=CP_SHARE) const
Return a new grid of the same type as this grid and whose metadata and transform are deep copies of t...
Definition: Grid.h:1058
Container class that associates a tree with a transform and metadata.
Definition: Grid.h:54
boost::shared_ptr< GridPtrVec > GridPtrVecPtr
Definition: Grid.h:399
GridPtrVec::const_iterator GridPtrVecCIter
Definition: Grid.h:398
GridBase(const GridBase &other)
Deep copy another grid's metadata and transform.
Definition: Grid.h:377
const TreeType & constTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:698
GridClass
Definition: Types.h:135
static const char *const META_GRID_CREATOR
Definition: Grid.h:266
static const TreeType & tree(const AccessorType &a)
Definition: Grid.h:904
GridType::Ptr deepCopyTypedGrid(const GridBase::ConstPtr &grid)
Return a pointer to a deep copy of the given grid, provided that the grid's concrete type is GridType...
Definition: Grid.h:799
void writeTransform(std::ostream &os) const
Write out the transform for this grid.
Definition: Grid.h:366
GridCPtrSet::iterator GridCPtrSetIter
Definition: Grid.h:412
_TreeType::Ptr TreePtrType
Definition: Grid.h:465
ValueOnCIter beginValueOn() const
Return an iterator over all of this grid's active values (tile and voxel).
Definition: Grid.h:568
Vec3d voxelSize(const Vec3d &xyz) const
Return the size of this grid's voxel at position (x, y, z).
Definition: Grid.h:336
boost::shared_ptr< GridPtrSet > GridPtrSetPtr
Definition: Grid.h:409
virtual void print(std::ostream &=std::cout, int verboseLevel=1) const
Output a human-readable description of this grid.
Definition: Grid.h:1209
TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:828
_TreeType TreeType
Definition: Grid.h:855
math::Transform::ConstPtr transformPtr() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition: Grid.h:313
static const TreeType & constTree(GridType &g)
Definition: Grid.h:906
Definition: Exceptions.h:87
NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:829
bool isType() const
Return true if this grid is of the same type as the template parameter.
Definition: Grid.h:145
NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:859
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:56
Grid< TreeType > GridType
Definition: Grid.h:830
_TreeType::ValueOffIter ValueOffIter
Definition: Grid.h:474
static const TreeType & constTree(GridType &g)
Definition: Grid.h:875
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:877
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:876
uint64_t Index64
Definition: Types.h:55
const math::Transform & constTransform() const
Return a reference to this grid's transform, which might be shared with other grids.
Definition: Grid.h:323
Vec3d indexToWorld(const Coord &ijk) const
Apply this grid's transform to the given coordinates.
Definition: Grid.h:342
GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:864
const TreeBase & constBaseTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:175
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:642
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:941
GridType::Ptr createGrid(const typename GridType::ValueType &background)
Create a new grid of type GridType with a given background value.
Definition: Grid.h:1236
_TreeType::ValueType ValueType
Definition: Grid.h:467
bool hasUniformVoxels() const
Return true if the voxels in world space are uniformly sized cubes.
Definition: Grid.h:338
virtual ~GridBase()
Definition: Grid.h:112
boost::shared_ptr< GridBase > Ptr
Definition: Grid.h:106
Grid< TreeType > GridType
Definition: Grid.h:889
ValueConverter<T>::Type is the type of a grid having the same hierarchy as this grid but a different ...
Definition: Grid.h:486
Grid< NonConstTreeType > NonConstGridType
Definition: Grid.h:831
GridPtrContainerT::value_type findGridByName(const GridPtrContainerT &container, const Name &name)
Return the first grid in the given container whose name is name.
Definition: Grid.h:428
const TreeBase & baseTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:174
ConstAccessor getConstAccessor() const
Return an accessor that provides random read-only access to this grid's voxels.
Definition: Grid.h:562
tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:836
static const char *const META_GRID_NAME
Definition: Grid.h:267
virtual Index64 memUsage() const
Definition: Grid.h:677
void readTransform(std::istream &is)
Read in the transform for this grid.
Definition: Grid.h:364
Base class for typed trees.
Definition: Tree.h:64
_TreeType TreeType
Definition: Grid.h:884