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>
517 template<
typename OtherTreeType>
537 Ptr deepCopy()
const {
return Ptr(
new Grid(*
this)); }
543 virtual Name type()
const {
return this->gridType(); }
560 virtual bool empty()
const {
return tree().empty(); }
562 virtual void clear() { tree().clear(); }
567 ConstAccessor getAccessor()
const {
return ConstAccessor(tree()); }
573 ValueOnIter beginValueOn() {
return tree().beginValueOn(); }
579 ValueOffIter beginValueOff() {
return tree().beginValueOff(); }
585 ValueAllIter beginValueAll() {
return tree().beginValueAll(); }
592 void evalMinMax(ValueType& minVal, ValueType& maxVal)
const;
602 void fill(
const CoordBBox& bbox,
const ValueType& value,
bool active =
true);
618 void signedFloodFill(
const ValueType& outside,
const ValueType& inside);
624 void prune(
const ValueType& tolerance = zeroVal<ValueType>()) { tree().prune(tolerance); }
626 virtual void pruneGrid(
float tolerance = 0.0);
648 template<
typename OtherTreeType>
663 template<
typename OtherTreeType>
676 template<
typename OtherTreeType>
685 virtual CoordBBox evalActiveVoxelBoundingBox()
const;
687 virtual Coord evalActiveVoxelDim()
const;
698 TreePtrType treePtr() {
return mTree; }
706 TreeType& tree() {
return *mTree; }
724 virtual void newTree();
732 virtual void readTopology(std::istream&);
735 virtual void writeTopology(std::ostream&)
const;
738 virtual void readBuffers(std::istream&);
740 virtual void writeBuffers(std::ostream&)
const;
743 virtual void print(std::ostream& = std::cout,
int verboseLevel = 1)
const;
778 template<
typename Gr
idType>
779 inline typename GridType::Ptr
782 return GridBase::grid<GridType>(grid);
794 template<
typename Gr
idType>
795 inline typename GridType::ConstPtr
798 return GridBase::constGrid<GridType>(grid);
811 template<
typename Gr
idType>
812 inline typename GridType::Ptr
815 if (!grid || !grid->isType<GridType>())
return typename GridType::Ptr();
816 return gridPtrCast<GridType>(grid->deepCopyGrid());
820 template<
typename Gr
idType>
821 inline typename GridType::Ptr
824 if (!grid.
isType<GridType>())
return typename GridType::Ptr();
834 template<
typename _TreeType>
866 template<
typename _TreeType>
895 template<
typename _TreeType>
931 template<
typename Gr
idType>
932 inline typename GridType::Ptr
937 if (grid && grid->type() == GridType::gridType()) {
938 return boost::static_pointer_cast<GridType>(grid);
940 return typename GridType::Ptr();
944 template<
typename Gr
idType>
945 inline typename GridType::ConstPtr
948 return boost::const_pointer_cast<
const GridType>(
949 GridBase::grid<GridType>(boost::const_pointer_cast<
GridBase>(grid)));
953 template<
typename Gr
idType>
954 inline typename GridType::ConstPtr
957 return boost::const_pointer_cast<
const GridType>(GridBase::grid<GridType>(grid));
961 template<
typename Gr
idType>
962 inline typename GridType::ConstPtr
965 return boost::const_pointer_cast<
const GridType>(
966 GridBase::grid<GridType>(boost::const_pointer_cast<
GridBase>(grid)));
973 return boost::const_pointer_cast<
TreeBase>(this->constBaseTreePtr());
988 template<
typename TreeT>
994 template<
typename TreeT>
1000 template<
typename TreeT>
1007 template<
typename TreeT>
1010 mTree(boost::static_pointer_cast<
TreeType>(other.mTree->copy()))
1015 template<
typename TreeT>
1016 template<
typename OtherTreeType>
1019 mTree(new
TreeType(other.constTree()))
1024 template<
typename TreeT>
1032 template<
typename TreeT>
1041 template<
typename TreeT>
1050 template<
typename TreeT>
1054 return Ptr(
new Grid(background));
1059 template<
typename TreeT>
1068 template<
typename TreeT>
1079 template<
typename TreeT>
1084 switch (treePolicy) {
1090 ret.reset(
new Grid(*
this));
1100 template<
typename TreeT>
1104 return this->copy(treePolicy);
1111 template<
typename TreeT>
1116 if (tree->type() != TreeType::treeType()) {
1118 + tree->type() +
" to a grid of type " + this->type());
1120 mTree = boost::static_pointer_cast<
TreeType>(tree);
1124 template<
typename TreeT>
1128 mTree.reset(
new TreeType(this->background()));
1135 template<
typename TreeT>
1139 tree().fill(bbox, value, active);
1143 template<
typename TreeT>
1147 tree().signedFloodFill(outside, inside);
1151 template<
typename TreeT>
1155 this->prune(
ValueType(zeroVal<ValueType>() + tolerance));
1159 template<
typename TreeT>
1163 tree().merge(other.
tree(), policy);
1167 template<
typename TreeT>
1168 template<
typename OtherTreeType>
1172 tree().topologyUnion(other.
tree());
1176 template<
typename TreeT>
1177 template<
typename OtherTreeType>
1181 tree().topologyIntersection(other.
tree());
1185 template<
typename TreeT>
1186 template<
typename OtherTreeType>
1190 tree().topologyDifference(other.
tree());
1197 template<
typename TreeT>
1201 tree().evalMinMax(minVal, maxVal);
1205 template<
typename TreeT>
1210 tree().evalActiveVoxelBoundingBox(bbox);
1215 template<
typename TreeT>
1220 const bool nonempty = tree().evalActiveVoxelDim(dim);
1221 return (nonempty ? dim : Coord());
1231 template<
typename TreeT>
1235 tree().readTopology(is, saveFloatAsHalf());
1239 template<
typename TreeT>
1243 tree().writeTopology(os, saveFloatAsHalf());
1247 template<
typename TreeT>
1251 tree().readBuffers(is, saveFloatAsHalf());
1255 template<
typename TreeT>
1259 tree().writeBuffers(os, saveFloatAsHalf());
1263 template<
typename TreeT>
1267 tree().print(os, verboseLevel);
1269 if (metaCount() > 0) {
1270 os <<
"Additional metadata:" << std::endl;
1272 os <<
" " << it->first;
1274 const std::string value = it->second->str();
1275 if (!value.empty()) os <<
": " << value;
1281 os <<
"Transform:" << std::endl;
1282 transform().print(os,
" ");
1290 template<
typename Gr
idType>
1291 inline typename GridType::Ptr
1294 return GridType::create(background);
1298 template<
typename Gr
idType>
1299 inline typename GridType::Ptr
1302 return GridType::create();
1306 template<
typename TreePtrType>
1310 typedef typename TreePtrType::element_type TreeType;
1315 template<
typename Gr
idType>
1316 typename GridType::Ptr
1319 typedef typename GridType::ValueType ValueType;
1322 BOOST_STATIC_ASSERT(boost::is_floating_point<ValueType>::value);
1324 typename GridType::Ptr grid = GridType::create(
1325 static_cast<ValueType>(voxelSize * halfWidth));
1334 #endif // OPENVDB_GRID_HAS_BEEN_INCLUDED
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:1170
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:933
static const char *const META_SAVE_HALF_FLOAT
Definition: Grid.h:268
tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:851
virtual void pruneGrid(float tolerance=0.0)
Reduce the memory footprint of this grid by increasing its sparseness.
Definition: Grid.h:1153
void setTransform(math::Transform::Ptr)
Associate the given transform with this grid, in place of its existing transform. ...
Definition: Grid.h:978
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:439
GridCPtrVec::const_iterator GridCPtrVecCIter
Definition: Grid.h:403
void evalMinMax(ValueType &minVal, ValueType &maxVal) const
Return the minimum and maximum active values in this grid.
Definition: Grid.h:1199
Name name
Definition: Grid.h:422
NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:906
ValueAllCIter beginValueAll() const
Return an iterator over all of this grid's values (tile and voxel).
Definition: Grid.h:587
virtual void clear()
Empty this grid, so that all voxels become inactive background voxels.
Definition: Grid.h:562
void setBackground(const ValueType &val)
Replace this grid's background value.
Definition: Grid.h:557
void merge(Grid &other, MergePolicy policy=MERGE_ACTIVE_STATES)
Efficiently merge another grid into this grid using one of several schemes.
Definition: Grid.h:1161
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:888
virtual Name type() const
Return the name of this grid's type.
Definition: Grid.h:543
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:856
TreeType::ValueType ValueType
Definition: Grid.h:849
boost::shared_ptr< const TreeBase > ConstPtr
Definition: Tree.h:68
GridType::Ptr deepCopyTypedGrid(const GridBase &grid)
Return a pointer to a deep copy of the given grid, provided that the grid's concrete type is GridType...
Definition: Grid.h:822
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...
math::Transform::ConstPtr transformPtr() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition: Grid.h:313
_TreeType TreeType
Definition: Grid.h:464
VecType
Definition: Types.h:198
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:796
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:921
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:780
boost::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:870
Grid()
Construct a new grid with background value zero.
Definition: Grid.h:989
void topologyDifference(const Grid< OtherTreeType > &other)
Difference this grid's set of active values with the active values of the other grid, whose value type may be different.
Definition: Grid.h:1188
GridPtrVec::iterator GridPtrVecIter
Definition: Grid.h:397
GridCPtrSet::const_iterator GridCPtrSetCIter
Definition: Grid.h:413
static const TreeType & tree(const GridType &g)
Definition: Grid.h:917
static TreeType & tree(GridType &g)
Definition: Grid.h:914
GridBase(const GridBase &other, ShallowCopy)
Copy another grid's metadata but share its transform.
Definition: Grid.h:380
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:97
ValueAllCIter cbeginValueAll() const
Return an iterator over all of this grid's values (tile and voxel).
Definition: Grid.h:588
static TreeType & tree(TreeType &t)
Definition: Grid.h:913
Vec3d voxelSize(const Vec3d &xyz) const
Return the size of this grid's voxel at position (x, y, z).
Definition: Grid.h:336
const TreeBase & constBaseTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:175
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:955
static const char *const META_FILE_COMPRESSION
Definition: Grid.h:273
ValueConverter::Type is the type of a grid having the same hierarchy as this grid but a different ...
Definition: Grid.h:486
bool hasUniformVoxels() const
Return true if the voxels in world space are uniformly sized cubes.
Definition: Grid.h:338
MergePolicy
Definition: Types.h:221
bool isType() const
Return true if this grid is of the same type as the template parameter.
Definition: Grid.h:145
static void registerGrid()
Register this grid type along with a factory function.
Definition: Grid.h:752
const ValueType & background() const
Return this grid's background value.
Definition: Grid.h:555
boost::shared_ptr< GridCPtrSet > GridCPtrSetPtr
Definition: Grid.h:414
_TreeType::ValueAllCIter ValueAllCIter
Definition: Grid.h:477
GridPtrVec::const_iterator GridPtrVecCIter
Definition: Grid.h:398
tree::ValueAccessor< _TreeType > Accessor
Definition: Grid.h:469
TreeType & tree()
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:710
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:916
static const Real LEVEL_SET_HALF_WIDTH
Definition: Types.h:176
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:1241
boost::shared_ptr< GridPtrSet > GridPtrSetPtr
Definition: Grid.h:409
virtual Index64 activeVoxelCount() const
Return the number of active voxels.
Definition: Grid.h:683
static const TreeType & constTree(GridType &g)
Definition: Grid.h:920
static TreeType & tree(TreeType &t)
Definition: Grid.h:884
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:922
GridCPtrVec::iterator GridCPtrVecIter
Definition: Grid.h:402
boost::shared_ptr< GridBase > Ptr
Definition: Grid.h:106
Definition: Exceptions.h:88
ValueOffCIter beginValueOff() const
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition: Grid.h:581
This adapter allows code that is templated on a Tree type to accept either a Tree type or a Grid type...
Definition: Grid.h:837
TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:872
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:701
static const char *const META_FILE_BBOX_MIN
Definition: Grid.h:271
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:702
boost::shared_ptr< GridPtrVec > GridPtrVecPtr
Definition: Grid.h:399
GridType::Ptr GridPtrType
Definition: Grid.h:876
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:1102
Grid< typename TreeType::template ValueConverter< OtherValueType >::Type > Type
Definition: Grid.h:487
Abstract base class for typed grids.
Definition: Grid.h:103
GridClass
Definition: Types.h:168
_TreeType::ValueOnIter ValueOnIter
Definition: Grid.h:472
boost::shared_ptr< Grid > Ptr
Definition: Grid.h:461
static const TreeType & tree(const GridType &g)
Definition: Grid.h:857
static const TreeType & constTree(TreeType &t)
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:711
static const TreeType & tree(const AccessorType &a)
Definition: Grid.h:918
static void unregisterGrid()
Remove this grid type from the registry.
Definition: Grid.h:754
GridCPtrSet::iterator GridCPtrSetIter
Definition: Grid.h:412
Grid< NonConstTreeType > NonConstGridType
Definition: Grid.h:845
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:971
Definition: ValueAccessor.h:173
GridType::Ptr createGrid(const typename GridType::ValueType &background)
Create a new grid of type GridType with a given background value.
Definition: Grid.h:1292
tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:880
static Ptr create()
Return a new grid with background value zero.
Definition: Grid.h:1043
Container class that associates a tree with a transform and metadata.
Definition: Grid.h:54
TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:842
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:1137
static const char *const META_VECTOR_TYPE
Definition: Grid.h:270
tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:882
Definition: Exceptions.h:87
NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:843
virtual void newTree()
Associate a new, empty tree with this grid, in place of its existing tree.
Definition: Grid.h:1126
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:703
uint64_t Index64
Definition: Types.h:56
#define OPENVDB_VERSION_NAME
Definition: version.h:45
virtual void setTree(TreeBase::Ptr)
Associate the given tree with this grid, in place of its existing tree.
Definition: Grid.h:1113
tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:881
virtual Coord evalActiveVoxelDim() const
Return the dimensions of the axis-aligned bounding box of all active voxels.
Definition: Grid.h:1217
virtual GridBase::Ptr deepCopyGrid() const
Return a new grid whose metadata, transform and tree are deep copies of this grid's.
Definition: Grid.h:539
NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:877
static const TreeType & tree(const GridType &g)
Definition: Grid.h:887
math::Transform::ConstPtr constTransformPtr() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition: Grid.h:314
Grid< TreeType > GridType
Definition: Grid.h:844
CopyPolicy
Definition: Types.h:372
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 ...
_TreeType::ValueAllIter ValueAllIter
Definition: Grid.h:476
NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:847
virtual ~Grid()
Definition: Grid.h:525
boost::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:899
boost::shared_ptr< const GridBase > ConstPtr
Definition: Grid.h:107
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:609
virtual void writeBuffers(std::ostream &) const
Write out all data buffers for this grid.
Definition: Grid.h:1257
TreeType::ValueType ValueType
Definition: Grid.h:879
virtual void readBuffers(std::istream &)
Read all data buffers for this grid.
Definition: Grid.h:1249
static bool isRegistered()
Return true if this grid type is registered.
Definition: Grid.h:750
virtual Name valueType() const
Return the name of the type of a voxel's value (e.g., "float" or "vec3d").
Definition: Grid.h:552
Grid< TreeType > GridType
Definition: Grid.h:903
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
Accessor getAccessor()
Return an accessor that provides random read and write access to this grid's voxels.
Definition: Grid.h:565
TreeType::Ptr TreePtrType
Definition: Grid.h:871
std::vector< GridBase::ConstPtr > GridCPtrVec
Definition: Grid.h:401
GridBase(const GridBase &other)
Deep copy another grid's metadata and transform.
Definition: Grid.h:377
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:1233
virtual bool empty() const
Return true if this grid contains only inactive background voxels.
Definition: Grid.h:560
Base class for typed trees.
Definition: Tree.h:64
static const char *const META_GRID_CLASS
Definition: Grid.h:265
_TreeType TreeType
Definition: Grid.h:898
static const char *const META_GRID_CREATOR
Definition: Grid.h:266
tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:852
const math::Transform & constTransform() const
Return a reference to this grid's transform, which might be shared with other grids.
Definition: Grid.h:323
void writeTransform(std::ostream &os) const
Write out the transform for this grid.
Definition: Grid.h:366
static const char *const META_IS_LOCAL_SPACE
Definition: Grid.h:269
static Name gridType()
Return the name of this type of grid.
Definition: Grid.h:545
tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:850
void topologyIntersection(const Grid< OtherTreeType > &other)
Intersect this grid's set of active values with the active values of the other grid, whose value type may be different.
Definition: Grid.h:1179
Predicate functor that returns true for grids that have a specified name.
Definition: Grid.h:418
ValueOnCIter cbeginValueOn() const
Return an iterator over all of this grid's active values (tile and voxel).
Definition: Grid.h:576
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:886
std::vector< GridBase::Ptr > GridPtrVec
Definition: Grid.h:396
ValueOffCIter cbeginValueOff() const
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition: Grid.h:582
TreeType::Ptr TreePtrType
Definition: Grid.h:841
const TreeBase & baseTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:174
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:624
void readTransform(std::istream &is)
Read in the transform for this grid.
Definition: Grid.h:364
_TreeType::ValueOffCIter ValueOffCIter
Definition: Grid.h:475
boost::shared_ptr< const Grid > ConstPtr
Definition: Grid.h:462
GridPtrSet::const_iterator GridPtrSetCIter
Definition: Grid.h:408
static TreeType & tree(GridType &g)
Definition: Grid.h:855
Grid< TreeType > GridType
Definition: Grid.h:874
tree::TreeBase TreeBase
Definition: Grid.h:52
Vec3d indexToWorld(const Coord &ijk) const
Apply this grid's transform to the given coordinates.
Definition: Grid.h:342
Vec3< double > Vec3d
Definition: Vec3.h:625
static TreeType & tree(AccessorType &a)
Definition: Grid.h:915
virtual ~GridBase()
Definition: Grid.h:112
boost::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:840
static TreeType & tree(TreeType &t)
Definition: Grid.h:854
Grid< typename TreePtrType::element_type >::Ptr createGrid(TreePtrType)
Create a new grid of the appropriate type that wraps the given tree.
Definition: Grid.h:1308
virtual CoordBBox evalActiveVoxelBoundingBox() const
Return the axis-aligned bounding box of all active voxels.
Definition: Grid.h:1207
Vec3d voxelSize() const
Return the size of this grid's voxels.
Definition: Grid.h:333
_TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:466
static const char *const META_GRID_NAME
Definition: Grid.h:267
GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:907
tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:910
TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:901
tree::ValueAccessor< const _TreeType > ConstAccessor
Definition: Grid.h:470
static bool isRegistered(const Name &type)
Return true if the given grid type name is registered.
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:1317
double Real
Definition: Types.h:63
_TreeType::ValueOnCIter ValueOnCIter
Definition: Grid.h:473
static TreeType & tree(GridType &g)
Definition: Grid.h:885
Grid< NonConstTreeType > NonConstGridType
Definition: Grid.h:875
GridType::Ptr GridPtrType
Definition: Grid.h:905
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:860
GridType::Ptr GridPtrType
Definition: Grid.h:846
GridBase()
Initialize with an identity linear transform.
Definition: Grid.h:374
_TreeType::Ptr TreePtrType
Definition: Grid.h:465
std::set< GridBase::Ptr > GridPtrSet
Definition: Grid.h:406
static const char *const META_FILE_BBOX_MAX
Definition: Grid.h:272
TreeType::Ptr TreePtrType
Definition: Grid.h:900
static const char *const META_FILE_VOXEL_COUNT
Definition: Grid.h:275
virtual void print(std::ostream &=std::cout, int verboseLevel=1) const
Output a human-readable description of this grid.
Definition: Grid.h:1265
TreeType & tree() const
Return a reference to the tree associated with this accessor.
Definition: ValueAccessor.h:117
GridPtrSet::iterator GridPtrSetIter
Definition: Grid.h:407
const math::Transform & transform() const
Return a reference to this grid's transform, which might be shared with other grids.
Definition: Grid.h:322
_TreeType::ValueOffIter ValueOffIter
Definition: Grid.h:474
_TreeType TreeType
Definition: Grid.h:869
boost::shared_ptr< GridCPtrVec > GridCPtrVecPtr
Definition: Grid.h:404
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:1081
static void registerGrid(const Name &type, GridFactory)
Register a grid type along with a factory function.
TreeType::ValueType ValueType
Definition: Grid.h:908
bool operator()(const GridBase::ConstPtr &g) const
Definition: Grid.h:421
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:67
const TreeType & constTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:712
GridNamePred(const Name &_name)
Definition: Grid.h:420
NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:873
static const TreeType & constTree(GridType &g)
Definition: Grid.h:889
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:890
std::set< GridBase::ConstPtr > GridCPtrSet
Definition: Grid.h:411
ConstAccessor getConstAccessor() const
Return an accessor that provides random read-only access to this grid's voxels.
Definition: Grid.h:569
ValueOnCIter beginValueOn() const
Return an iterator over all of this grid's active values (tile and voxel).
Definition: Grid.h:575
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:861
static const TreeType & constTree(GridType &g)
Definition: Grid.h:859
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:891
GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:878
virtual Index64 memUsage() const
Definition: Grid.h:691
_TreeType::ValueType ValueType
Definition: Grid.h:467
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:919
tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:911
Grid< NonConstTreeType > NonConstGridType
Definition: Grid.h:904
GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:848
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
NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:902
virtual GridBase::Ptr deepCopyGrid() const =0
Return a new grid whose metadata, transform and tree are deep copies of this grid's.
std::string Name
Definition: Name.h:44
tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:909
_TreeType TreeType
Definition: Grid.h:839