4#ifndef OPENVDB_GRID_HAS_BEEN_INCLUDED
5#define OPENVDB_GRID_HAS_BEEN_INCLUDED
28template<
typename>
class Grid;
35template<
typename Gr
idType>
36inline typename GridType::Ptr
createGrid(
const typename GridType::ValueType& background);
42template<
typename Gr
idType>
50template<
typename TreePtrType>
68template<
typename Gr
idType>
145 template<
typename Gr
idType>
146 bool isType()
const {
return (this->
type() == GridType::gridType()); }
153 template<
typename Gr
idType>
155 template<
typename Gr
idType>
157 template<
typename Gr
idType>
159 template<
typename Gr
idType>
262 template<
typename Gr
idTypeListT,
typename OpT>
inline bool apply(OpT&)
const;
263 template<
typename Gr
idTypeListT,
typename OpT>
inline bool apply(OpT&);
264 template<
typename Gr
idTypeListT,
typename OpT>
inline bool apply(
const OpT&)
const;
265 template<
typename Gr
idTypeListT,
typename OpT>
inline bool apply(
const OpT&);
475 virtual void print(std::ostream& = std::cout,
int verboseLevel = 1)
const = 0;
538template<
typename Gr
idPtrContainerT>
539inline typename GridPtrContainerT::value_type
542 using GridPtrT =
typename GridPtrContainerT::value_type;
543 typename GridPtrContainerT::const_iterator it =
544 std::find_if(container.begin(), container.end(),
GridNamePred(name));
545 return (it == container.end() ? GridPtrT() : *it);
549template<
typename KeyT,
typename Gr
idPtrT>
553 using GridPtrMapT = std::map<KeyT, GridPtrT>;
554 for (
typename GridPtrMapT::const_iterator it = container.begin(), end = container.end();
557 const GridPtrT& grid = it->second;
558 if (grid && grid->getName() == name)
return grid;
569template<
typename _TreeType>
600 template<
typename OtherValueType>
632 template<
typename OtherTreeType>
834 template<
typename OtherTreeType>
849 template<
typename OtherTreeType>
862 template<
typename OtherTreeType>
878tools::minMax(grid->tree()). Use threaded = false for serial execution")
956 void print(std::ostream& = std::cout,
int verboseLevel = 1)
const override;
1000template<
typename Gr
idType>
1001inline typename GridType::Ptr
1016template<
typename Gr
idType>
1017inline typename GridType::ConstPtr
1033template<
typename Gr
idType>
1034inline typename GridType::Ptr
1037 if (!grid || !grid->isType<GridType>())
return typename GridType::Ptr();
1042template<
typename Gr
idType>
1043inline typename GridType::Ptr
1046 if (!grid.
isType<GridType>())
return typename GridType::Ptr();
1058template<
typename _TreeType>
1088template<
typename _TreeType>
1117template<
typename _TreeType>
1146template<
typename _TreeType>
1193template<
typename LeafNodeType>
1195 static const bool value = std::is_base_of<io::MultiPass, LeafNodeType>::value;
1199template<
typename RootNodeType>
1206template<
typename TreeType>
1222template<
typename Gr
idType>
1223inline typename GridType::Ptr
1228 if (
grid &&
grid->type() == GridType::gridType()) {
1231 return typename GridType::Ptr();
1235template<
typename Gr
idType>
1236inline typename GridType::ConstPtr
1244template<
typename Gr
idType>
1245inline typename GridType::ConstPtr
1252template<
typename Gr
idType>
1253inline typename GridType::ConstPtr
1279template<
typename TreeT>
1285template<
typename TreeT>
1291template<
typename TreeT>
1298template<
typename TreeT>
1307template<
typename TreeT>
1315template<
typename TreeT>
1316template<
typename OtherTreeType>
1324template<
typename TreeT>
1332template<
typename TreeT>
1341template<
typename TreeT>
1350template<
typename TreeT>
1359template<
typename TreeT>
1368template<
typename TreeT>
1379template<
typename TreeT>
1387template<
typename TreeT>
1397template<
typename TreeT>
1404template<
typename TreeT>
1414template<
typename TreeT>
1422template<
typename TreeT>
1432template<
typename TreeT>
1436 return this->
copy();
1439template<
typename TreeT>
1443 return this->
copy();
1446template<
typename TreeT>
1453template<
typename TreeT>
1460template<
typename TreeT>
1468template<
typename TreeT>
1479template<
typename TreeT>
1483 return mTree.use_count() == 1;
1487template<
typename TreeT>
1492 if (
tree->type() != TreeType::treeType()) {
1494 +
tree->type() +
" to a grid of type " + this->type());
1500template<
typename TreeT>
1511template<
typename TreeT>
1515 tree().sparseFill(bbox, value, active);
1519template<
typename TreeT>
1526template<
typename TreeT>
1530 tree().denseFill(bbox, value, active);
1533template<
typename TreeT>
1538 this->tree().prune(
static_cast<ValueType>(value));
1541template<
typename TreeT>
1548template<
typename TreeT>
1552 tree().merge(other.
tree(), policy);
1556template<
typename TreeT>
1557template<
typename OtherTreeType>
1561 tree().topologyUnion(other.
tree());
1565template<
typename TreeT>
1566template<
typename OtherTreeType>
1570 tree().topologyIntersection(other.
tree());
1574template<
typename TreeT>
1575template<
typename OtherTreeType>
1579 tree().topologyDifference(other.
tree());
1586template<
typename TreeT>
1591 tree().evalMinMax(minVal, maxVal);
1596template<
typename TreeT>
1601 tree().evalActiveVoxelBoundingBox(bbox);
1606template<
typename TreeT>
1611 const bool nonempty =
tree().evalActiveVoxelDim(dim);
1612 return (nonempty ? dim :
Coord());
1622template<
typename TreeT>
1630template<
typename TreeT>
1638template<
typename TreeT>
1645 uint16_t numPasses = 1;
1646 is.read(
reinterpret_cast<char*
>(&numPasses),
sizeof(uint16_t));
1649 for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1650 uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1651 meta->setPass(pass);
1660template<
typename TreeT>
1667 uint16_t numPasses = 1;
1668 is.read(
reinterpret_cast<char*
>(&numPasses),
sizeof(uint16_t));
1671 for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1672 uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1673 meta->setPass(pass);
1683template<
typename TreeT>
1687 tree().readNonresidentBuffers();
1691template<
typename TreeT>
1701 uint16_t numPasses = 1;
1702 meta->setCountingPasses(
true);
1705 numPasses =
static_cast<uint16_t
>(meta->pass());
1706 os.write(
reinterpret_cast<const char*
>(&numPasses),
sizeof(uint16_t));
1707 meta->setCountingPasses(
false);
1710 for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1711 uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1712 meta->setPass(pass);
1720template<
typename TreeT>
1728template<
typename TreeT>
1732 tree().print(os, verboseLevel);
1735 os <<
"Additional metadata:" << std::endl;
1737 os <<
" " << it->first;
1739 const std::string value = it->second->str();
1740 if (!value.empty()) os <<
": " << value;
1746 os <<
"Transform:" << std::endl;
1755template<
typename Gr
idType>
1756inline typename GridType::Ptr
1759 return GridType::create(background);
1763template<
typename Gr
idType>
1764inline typename GridType::Ptr
1767 return GridType::create();
1771template<
typename TreePtrType>
1775 using TreeType =
typename TreePtrType::element_type;
1780template<
typename Gr
idType>
1781typename GridType::Ptr
1784 using ValueType =
typename GridType::ValueType;
1787 static_assert(std::is_floating_point<ValueType>::value,
1788 "level-set grids must be floating-point-valued");
1790 typename GridType::Ptr grid = GridType::create(
1791 static_cast<ValueType
>(voxelSize * halfWidth));
1801template<
typename Gr
idTypeListT,
typename OpT>
1808template<
typename Gr
idTypeListT,
typename OpT>
1815template<
typename Gr
idTypeListT,
typename OpT>
1822template<
typename Gr
idTypeListT,
typename OpT>
#define OPENVDB_ASSERT(X)
Definition Assert.h:41
Abstract base class for typed grids.
Definition Grid.h:78
virtual Name valueType() const =0
Return the name of the type of a voxel's value (e.g., "float" or "vec3d").
virtual GridBase::Ptr copyGrid()=0
Return a new grid of the same type as this grid whose metadata is a deep copy of this grid's and whos...
virtual GridBase::ConstPtr copyGridReplacingMetadataAndTransform(const MetaMap &meta, math::Transform::Ptr xform) const =0
Return a new grid of the same type as this grid whose tree is shared with this grid and whose transfo...
virtual GridBase::ConstPtr copyGridReplacingMetadata(const MetaMap &meta) const =0
Return a new grid of the same type as this grid whose tree and transform is shared with this grid and...
static const char *const META_FILE_MEM_BYTES
Definition Grid.h:360
Ptr(*)() GridFactory
Definition Grid.h:83
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:1224
static const char *const META_FILE_BBOX_MAX
Definition Grid.h:358
virtual void readBuffers(std::istream &)=0
Read all data buffers for this grid.
virtual void writeBuffers(std::ostream &) const =0
Write out all data buffers for this grid.
static std::string gridClassToMenuName(GridClass)
Return a formatted string version of the grid class.
bool hasUniformVoxels() const
Return true if the voxels in world space are uniformly sized cubes.
Definition Grid.h:435
math::Transform::ConstPtr constTransformPtr() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition Grid.h:404
void setSaveFloatAsHalf(bool)
Return this grid's user-specified name.
~GridBase() override
Definition Grid.h:86
virtual GridBase::ConstPtr copyGridReplacingTransform(math::Transform::Ptr xform) const =0
Return a new grid of the same type as this grid whose tree is shared with this grid,...
Vec3d indexToWorld(const Coord &ijk) const
Apply this grid's transform to the given coordinates.
Definition Grid.h:439
Vec3d voxelSize() const
Return the size of this grid's voxels.
Definition Grid.h:430
static std::string vecTypeDescription(VecType)
Return a string describing how the given type of vector data is affected by transformations (e....
const math::Transform & constTransform() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition Grid.h:413
void setName(const std::string &)
Specify a name for this grid.
static const char *const META_FILE_DELAYED_LOAD
Definition Grid.h:362
bool apply(const OpT &) const
If this grid resolves to one of the listed grid types, invoke the given functor on the resolved grid.
Definition Grid.h:1817
Vec3d indexToWorld(const Vec3d &xyz) const
Apply this grid's transform to the given coordinates.
Definition Grid.h:437
void clearGridClass()
Remove the setting specifying the class of this grid's volumetric data.
virtual bool isTreeUnique() const =0
Return true if tree is not shared with another grid.
bool isType() const
Return true if this grid is of the same type as the template parameter.
Definition Grid.h:146
static std::string vecTypeToString(VecType)
Return the metadata string value for the given type of vector data.
static const char *const META_IS_LOCAL_SPACE
Definition Grid.h:355
Vec3d worldToIndex(const Vec3d &xyz) const
Apply the inverse of this grid's transform to the given coordinates.
Definition Grid.h:441
SharedPtr< const GridBase > ConstPtr
Definition Grid.h:81
virtual GridBase::Ptr copyGridWithNewTree() const =0
Return a new grid of the same type as this grid whose metadata and transform are deep copies of this ...
math::Transform & transform()
Return a reference to this grid's transform, which might be shared with other grids.
Definition Grid.h:411
GridBase(GridBase &other, ShallowCopy)
Copy another grid's metadata but share its transform.
Definition Grid.h:492
static const char *const META_SAVE_HALF_FLOAT
Definition Grid.h:354
static GridType::ConstPtr constGrid(const GridBase::ConstPtr &)
Definition Grid.h:1254
bool apply(OpT &)
If this grid resolves to one of the listed grid types, invoke the given functor on the resolved grid.
Definition Grid.h:1810
virtual void clear()=0
Empty this grid, setting all voxels to the background.
void setGridClass(GridClass)
Specify the class of volumetric data (level set, fog volume, etc.) that is stored in this grid.
virtual void writeTopology(std::ostream &) const =0
Write the grid topology to a stream. This will write only the grid structure, not the actual data buf...
static GridType::ConstPtr grid(const GridBase::ConstPtr &)
Definition Grid.h:1237
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:171
void addStatsMetadata()
Add metadata to this grid comprising the current values of statistics like the active voxel count and...
const TreeBase & baseTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition Grid.h:188
void clearVectorType()
Remove the setting specifying the type of vector data stored in this grid.
virtual void newTree()=0
Set a new tree with the same background value as the previous tree.
static const char *const META_FILE_COMPRESSION
Definition Grid.h:359
virtual TreeBase::ConstPtr constBaseTreePtr() const =0
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
static std::string vecTypeExamples(VecType)
void clipGrid(const BBoxd &)
Clip this grid to the given world-space bounding box.
virtual CoordBBox evalActiveVoxelBoundingBox() const =0
static const char *const META_FILE_BBOX_MIN
Definition Grid.h:357
virtual Index64 memUsage() const =0
Return the number of bytes of memory used by this grid.
void setVectorType(VecType)
Specify the type of vector data (invariant, covariant, etc.) stored in this grid, assuming that this ...
virtual Index64 activeVoxelCount() const =0
Return the number of active voxels.
static bool isRegistered(const Name &type)
Return true if the given grid type name is registered.
Vec3d voxelSize(const Vec3d &xyz) const
Return the size of this grid's voxel at position (x, y, z).
Definition Grid.h:433
std::string getName() const
Return this grid's user-specified name.
bool apply(const OpT &)
If this grid resolves to one of the listed grid types, invoke the given functor on the resolved grid.
Definition Grid.h:1824
virtual void print(std::ostream &=std::cout, int verboseLevel=1) const =0
Output a human-readable description of this grid.
void setTransform(math::Transform::Ptr)
Associate the given transform with this grid, in place of its existing transform.
Definition Grid.h:1269
virtual void pruneGrid(float tolerance=0.0)=0
Reduce the memory footprint of this grid by increasing its sparseness either losslessly (tolerance = ...
bool apply(OpT &) const
If this grid resolves to one of the listed grid types, invoke the given functor on the resolved grid.
Definition Grid.h:1803
static GridType::ConstPtr constGrid(const GridBase::Ptr &)
Definition Grid.h:1246
GridClass getGridClass() const
Return the class of volumetric data (level set, fog volume, etc.) that is stored in this grid.
static VecType stringToVecType(const std::string &)
static void unregisterGrid(const Name &type)
Remove a grid type from the registry.
virtual void readNonresidentBuffers() const =0
Read all of this grid's data buffers that are not yet resident in memory (because delayed loading is ...
static const char *const META_GRID_CREATOR
Definition Grid.h:352
void readTransform(std::istream &is)
Read in the transform for this grid.
Definition Grid.h:470
static const char *const META_GRID_NAME
Definition Grid.h:353
static const char *const META_GRID_CLASS
Definition Grid.h:351
GridBase(const GridBase &other)
Deep copy another grid's metadata and transform.
Definition Grid.h:489
math::Transform::Ptr transformPtr()
Return a pointer to this grid's transform, which might be shared with other grids.
Definition Grid.h:402
static const char *const META_VECTOR_TYPE
Definition Grid.h:356
static GridClass stringToGridClass(const std::string &)
Return the class of volumetric data specified by the given string.
virtual Coord evalActiveVoxelDim() const =0
Return the dimensions of the axis-aligned bounding box of all active voxels.
void setCreator(const std::string &)
Provide a description of this grid's creator.
bool saveFloatAsHalf() const
Return true if this grid should be written out with floating-point voxel values (including components...
MetaMap::Ptr getStatsMetadata() const
Return a new MetaMap containing just the metadata that was added to this grid with addStatsMetadata.
const math::Transform & transform() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition Grid.h:412
static std::string gridClassToString(GridClass)
Return the metadata string value for the given class of volumetric data.
virtual void clip(const CoordBBox &)=0
Clip this grid to the given index-space bounding box.
virtual Name type() const =0
Return the name of this grid's type.
TreeBase & baseTree()
Return a reference to this grid's tree, which might be shared with other grids.
Definition Grid.h:183
virtual void readTopology(std::istream &)=0
Read the grid topology from a stream. This will read only the grid structure, not the actual data buf...
virtual void readBuffers(std::istream &, const CoordBBox &)=0
Read all of this grid's data buffers that intersect the given index-space bounding box.
const TreeBase & constBaseTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition Grid.h:193
static void clearRegistry()
Clear the grid type registry.
std::string getCreator() const
Return the user-specified description of this grid's creator.
void writeTransform(std::ostream &os) const
Write out the transform for this grid.
Definition Grid.h:472
VecType getVectorType() const
Return the type of vector data (invariant, covariant, etc.) stored in this grid, assuming that this g...
static Ptr createGrid(const Name &type)
Create a new grid of the given (registered) type.
SharedPtr< GridBase > Ptr
Definition Grid.h:80
static void registerGrid(const Name &type, GridFactory)
Register a grid type along with a factory function.
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:1262
virtual bool empty() const =0
Return true if this grid contains only background voxels.
static const char *const META_FILE_VOXEL_COUNT
Definition Grid.h:361
virtual void setTree(TreeBase::Ptr)=0
Associate the given tree with this grid, in place of its existing tree.
virtual GridBase::Ptr deepCopyGrid() const =0
Return a new grid whose metadata, transform and tree are deep copies of this grid's.
virtual GridBase::ConstPtr copyGrid() const =0
Return a new grid of the same type as this grid whose metadata is a deep copy of this grid's and whos...
GridBase()
Initialize with an identity linear transform.
Definition Grid.h:482
bool isInWorldSpace() const
math::Transform::ConstPtr transformPtr() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition Grid.h:403
void setIsInWorldSpace(bool)
Specify whether this grid's voxel values are in world space or in local space.
Container class that associates a tree with a transform and metadata.
Definition Grid.h:571
const TreeType & tree() const
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition Grid.h:909
typename _TreeType::Ptr TreePtrType
Definition Grid.h:577
Grid()
Construct a new grid with background value zero.
Definition Grid.h:1280
typename _TreeType::ValueOffCIter ValueOffCIter
Definition Grid.h:585
void evalMinMax(ValueType &minVal, ValueType &maxVal) const
bool empty() const override
Return true if this grid contains only inactive background voxels.
Definition Grid.h:725
typename _TreeType::ValueOffIter ValueOffIter
Definition Grid.h:584
TreeType & tree()
Definition Grid.h:908
void topologyIntersection(const Grid< OtherTreeType > &other)
Intersect this grid's set of active values with the active values of the other grid,...
Definition Grid.h:1568
ValueOffCIter cbeginValueOff() const
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition Grid.h:765
void readBuffers(std::istream &) override
Read all data buffers for this grid.
Definition Grid.h:1640
static Name gridType()
Definition Grid.h:711
Index64 memUsage() const override
Definition Grid.h:883
void writeBuffers(std::ostream &) const override
Write out all data buffers for this grid.
Definition Grid.h:1693
static bool hasMultiPassIO()
Return true if grids of this type require multiple I/O passes to read and write data buffers.
Definition Grid.h:1722
ConstPtr copyReplacingTransform(math::Transform::Ptr xform) const
Return a new grid of the same type as this grid whose tree is shared with this grid,...
Definition Grid.h:1399
Grid(const Grid &)
Deep copy another grid's metadata, transform and tree.
Definition Grid.h:1308
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:1416
bool isTreeUnique() const final
Return true if tree is not shared with another grid.
Definition Grid.h:1481
void pruneGrid(float tolerance=0.0) override
Reduce the memory footprint of this grid by increasing its sparseness.
Definition Grid.h:1535
static Ptr create(const ValueType &background)
Return a new grid with the given background value.
Definition Grid.h:1352
void readBuffers(std::istream &, const CoordBBox &) override
Read all of this grid's data buffers that intersect the given index-space bounding box.
Definition Grid.h:1662
static Ptr create(const GridBase &other)
Return a new, empty grid with the same transform and metadata as the given grid and with background v...
Definition Grid.h:1370
void clip(const CoordBBox &) override
Clip this grid to the given index-space bounding box.
Definition Grid.h:1543
ValueAllCIter cbeginValueAll() const
Return an iterator over all of this grid's values (tile and voxel).
Definition Grid.h:771
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:896
Grid(Grid &, ShallowCopy)
Deep copy another grid's metadata and transform, but share its tree.
Definition Grid.h:1325
Coord evalActiveVoxelDim() const override
Return the dimensions of the axis-aligned bounding box of all active voxels.
Definition Grid.h:1608
ValueOnCIter beginValueOn() const
Return an iterator over all of this grid's active values (tile and voxel).
Definition Grid.h:757
void setTree(TreeBase::Ptr) override
Associate the given tree with this grid, in place of its existing tree.
Definition Grid.h:1489
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:1424
Grid(const ValueType &background)
Construct a new grid with the given background value.
Definition Grid.h:1286
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:1470
typename _TreeType::Accessor Accessor
Definition Grid.h:589
~Grid() override
Definition Grid.h:640
Name type() const override
Return the name of this grid's type.
Definition Grid.h:709
void print(std::ostream &=std::cout, int verboseLevel=1) const override
Output a human-readable description of this grid.
Definition Grid.h:1730
GridBase::ConstPtr copyGridReplacingMetadata(const MetaMap &meta) const override
Return a new grid of the same type as this grid whose tree and transform is shared with this grid and...
Definition Grid.h:1448
typename _TreeType::ValueAllCIter ValueAllCIter
Definition Grid.h:587
Index64 activeVoxelCount() const override
Return the number of active voxels.
Definition Grid.h:871
ConstAccessor getAccessor() const
Return an accessor that provides random read-only access to this grid's voxels.
Definition Grid.h:742
GridBase::Ptr deepCopyGrid() const override
Return a new grid whose metadata, transform and tree are deep copies of this grid's.
Definition Grid.h:703
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:1521
ValueOffCIter beginValueOff() const
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition Grid.h:763
UnsafeAccessor getUnsafeAccessor()
Return an unsafe accessor that provides random read and write access to this grid's voxels.
Definition Grid.h:740
GridBase::Ptr copyGrid() override
Return a new grid of the same type as this grid whose metadata is a deep copy of this grid's and whos...
Definition Grid.h:1434
typename _TreeType::ValueType ValueType
Definition Grid.h:579
typename _TreeType::ConstPtr ConstTreePtrType
Definition Grid.h:578
ConstPtr copy() const
Return a new grid of the same type as this grid whose metadata and transform are deep copies of this ...
Definition Grid.h:1381
ValueOnIter beginValueOn()
Return an iterator over all of this grid's active values (tile and voxel).
Definition Grid.h:755
typename _TreeType::ValueOnCIter ValueOnCIter
Definition Grid.h:583
SharedPtr< const Grid > ConstPtr
Definition Grid.h:574
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:1624
static void registerGrid()
Register this grid type along with a factory function.
Definition Grid.h:972
ValueOnCIter cbeginValueOn() const
Return an iterator over all of this grid's active values (tile and voxel).
Definition Grid.h:759
typename _TreeType::UnsafeAccessor UnsafeAccessor
Definition Grid.h:591
ConstPtr copyReplacingMetadataAndTransform(const MetaMap &meta, math::Transform::Ptr xform) const
Return a new grid of the same type as this grid whose tree is shared with this grid and whose transfo...
Definition Grid.h:1406
static bool isRegistered()
Return true if this grid type is registered.
Definition Grid.h:970
typename _TreeType::ValueOnIter ValueOnIter
Definition Grid.h:582
typename _TreeType::ConstAccessor ConstAccessor
Definition Grid.h:590
void readNonresidentBuffers() const override
Read all of this grid's data buffers that are not yet resident in memory (because delayed loading is ...
Definition Grid.h:1685
GridBase::ConstPtr copyGridReplacingMetadataAndTransform(const MetaMap &meta, math::Transform::Ptr xform) const override
Return a new grid of the same type as this grid whose tree is shared with this grid and whose transfo...
Definition Grid.h:1462
typename _TreeType::ConstUnsafeAccessor ConstUnsafeAccessor
Definition Grid.h:592
typename _TreeType::BuildType BuildType
Definition Grid.h:580
ConstAccessor getConstAccessor() const
Return an accessor that provides random read-only access to this grid's voxels.
Definition Grid.h:744
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:1528
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:895
void topologyDifference(const Grid< OtherTreeType > &other)
Difference this grid's set of active values with the active values of the other grid,...
Definition Grid.h:1577
TreeBase::ConstPtr constBaseTreePtr() const override
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition Grid.h:897
Grid(TreePtrType)
Construct a new grid that shares the given tree and associates with it an identity linear transform.
Definition Grid.h:1292
GridBase::ConstPtr copyGridReplacingTransform(math::Transform::Ptr xform) const override
Return a new grid of the same type as this grid whose tree is shared with this grid,...
Definition Grid.h:1455
CoordBBox evalActiveVoxelBoundingBox() const override
Return the axis-aligned bounding box of all active voxels.
Definition Grid.h:1598
Ptr deepCopy() const
Return a new grid whose metadata, transform and tree are deep copies of this grid's.
Definition Grid.h:701
const ValueType & background() const
Definition Grid.h:722
GridBase::ConstPtr copyGrid() const override
Return a new grid of the same type as this grid whose metadata is a deep copy of this grid's and whos...
Definition Grid.h:1441
ValueOffIter beginValueOff()
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition Grid.h:761
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:1513
TreePtrType treePtr()
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition Grid.h:894
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:1632
void merge(Grid &other, MergePolicy policy=MERGE_ACTIVE_STATES)
Efficiently merge another grid into this grid using one of several schemes.
Definition Grid.h:1550
static void unregisterGrid()
Remove this grid type from the registry.
Definition Grid.h:974
ConstPtr copyReplacingMetadata(const MetaMap &meta) const
Return a new grid of the same type as this grid whose tree and transform is shared with this grid and...
Definition Grid.h:1389
typename _TreeType::ValueAllIter ValueAllIter
Definition Grid.h:586
_TreeType TreeType
Definition Grid.h:576
Name valueType() const override
Return the name of the type of a voxel's value (e.g., "float" or "vec3d").
Definition Grid.h:714
void clear() override
Empty this grid, so that all voxels become inactive background voxels.
Definition Grid.h:727
Grid(const GridBase &)
Deep copy another grid's metadata and transform, but construct a new tree with background value zero.
Definition Grid.h:1333
const TreeType & constTree() const
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition Grid.h:910
ValueAllCIter beginValueAll() const
Return an iterator over all of this grid's values (tile and voxel).
Definition Grid.h:769
void newTree() override
Associate a new, empty tree with this grid, in place of its existing tree.
Definition Grid.h:1502
Grid & operator=(const Grid &)=delete
Disallow assignment, since it wouldn't be obvious whether the copy is deep or shallow.
ConstUnsafeAccessor getConstUnsafeAccessor() const
Return an unsafe accessor that provides random read-only access to this grid's voxels.
Definition Grid.h:752
static Ptr create(TreePtrType)
Return a new grid that contains the given tree.
Definition Grid.h:1361
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:1559
SharedPtr< Grid > Ptr
Definition Grid.h:573
Accessor getAccessor()
Return an accessor that provides random read and write access to this grid's voxels.
Definition Grid.h:732
ValueAllIter beginValueAll()
Return an iterator over all of this grid's values (tile and voxel).
Definition Grid.h:767
static Ptr create()
Return a new grid with background value zero.
Definition Grid.h:1343
Grid(const Grid< OtherTreeType > &)
Deep copy the metadata, transform and tree of another grid whose tree configuration is the same as th...
Definition Grid.h:1317
Tag dispatch class that distinguishes shallow copy constructors from deep copy constructors.
Definition Types.h:680
Definition Exceptions.h:64
Definition Exceptions.h:65
Axis-aligned bounding box of signed integer coordinates.
Definition Coord.h:252
Signed (x, y, z) 32-bit integer coordinates.
Definition Coord.h:26
Base class for typed trees.
Definition Tree.h:38
SharedPtr< TreeBase > Ptr
Definition Tree.h:40
SharedPtr< const TreeBase > ConstPtr
Definition Tree.h:41
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
OPENVDB_API SharedPtr< StreamMetadata > getStreamMetadataPtr(std::ios_base &)
Return a shared pointer to an object that stores metadata (file format, compression scheme,...
Vec3< double > Vec3d
Definition Vec3.h:665
auto cwiseAdd(const math::Vec3< math::half > &v, const float s)
Definition Types.h:694
Definition PointDataGrid.h:170
ValueAccessorImpl< TreeType, IsSafe, MutexType, openvdb::make_index_sequence< CacheLevels > > ValueAccessor
Default alias for a ValueAccessor. This is simply a helper alias for the generic definition but takes...
Definition ValueAccessor.h:86
std::string Name
Definition Name.h:19
static const Real LEVEL_SET_HALF_WIDTH
Definition Types.h:461
GridPtrVec::const_iterator GridPtrVecCIter
Definition Grid.h:510
std::vector< GridBase::Ptr > GridPtrVec
Definition Grid.h:508
SharedPtr< GridPtrSet > GridPtrSetPtr
Definition Grid.h:521
GridCPtrSet::iterator GridCPtrSetIter
Definition Grid.h:524
SharedPtr< GridCPtrSet > GridCPtrSetPtr
Definition Grid.h:526
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:1018
double Real
Definition Types.h:60
GridClass
Definition Types.h:453
@ GRID_LEVEL_SET
Definition Types.h:455
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:1002
std::set< GridBase::ConstPtr > GridCPtrSet
Definition Grid.h:523
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:540
std::set< GridBase::Ptr > GridPtrSet
Definition Grid.h:518
SharedPtr< GridCPtrVec > GridCPtrVecPtr
Definition Grid.h:516
GridCPtrVec::iterator GridCPtrVecIter
Definition Grid.h:514
constexpr T zeroVal()
Return the value of type T that corresponds to zero.
Definition Math.h:70
@ OPENVDB_FILE_VERSION_MULTIPASS_IO
Definition version.h.in:265
SharedPtr< GridPtrVec > GridPtrVecPtr
Definition Grid.h:511
GridCPtrVec::const_iterator GridCPtrVecCIter
Definition Grid.h:515
GridPtrSet::iterator GridPtrSetIter
Definition Grid.h:519
SharedPtr< T > ConstPtrCast(const SharedPtr< U > &ptr)
Return a new shared pointer that points to the same object as the given pointer but with possibly dif...
Definition Types.h:126
GridCPtrSet::const_iterator GridCPtrSetCIter
Definition Grid.h:525
math::BBox< Vec3d > BBoxd
Definition Types.h:84
GridPtrSet::const_iterator GridPtrSetCIter
Definition Grid.h:520
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:1782
GridType::Ptr createGrid(const typename GridType::ValueType &background)
Create a new grid of type GridType with a given background value.
Definition Grid.h:1757
uint64_t Index64
Definition Types.h:53
tree::TreeBase TreeBase
Definition Grid.h:26
GridPtrVec::iterator GridPtrVecIter
Definition Grid.h:509
std::shared_ptr< T > SharedPtr
Definition Types.h:114
MergePolicy
Definition Types.h:506
@ MERGE_ACTIVE_STATES
Definition Types.h:507
VecType
Definition Types.h:483
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:146
std::vector< GridBase::ConstPtr > GridCPtrVec
Definition Grid.h:513
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:1035
GridType::Ptr createGrid()
Create a new grid of type GridType with background value zero.
Definition Grid.h:1765
Definition Exceptions.h:13
#define OPENVDB_THROW(exception, message)
Definition Exceptions.h:74
Predicate functor that returns true for grids that have a specified name.
Definition Grid.h:531
Name name
Definition Grid.h:534
GridNamePred(const Name &_name)
Definition Grid.h:532
bool operator()(const GridBase::ConstPtr &g) const
Definition Grid.h:533
ValueConverter<T>::Type is the type of a grid having the same hierarchy as this grid but a different ...
Definition Grid.h:601
Grid< typename TreeType::template ValueConverter< OtherValueType >::Type > Type
Definition Grid.h:602
static const bool value
Definition Grid.h:1209
static const bool value
Definition Grid.h:1202
Metafunction that specifies whether a given leaf node, tree, or grid type requires multiple passes to...
Definition Grid.h:1194
static const bool value
Definition Grid.h:1195
static const NonConstTreeType & constTree(NonConstTreeType &t)
Definition Grid.h:1110
Grid< TreeType > GridType
Definition Grid.h:1096
typename std::remove_const< TreeType >::type NonConstTreeType
Definition Grid.h:1092
static const NonConstTreeType & constTree(const NonConstGridType &g)
Definition Grid.h:1113
typename TreeType::ValueType ValueType
Definition Grid.h:1101
static const NonConstTreeType & constTree(const NonConstTreeType &t)
Definition Grid.h:1112
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition Grid.h:1104
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition Grid.h:1103
static const NonConstTreeType & tree(const NonConstGridType &g)
Definition Grid.h:1109
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition Grid.h:1095
typename TreeType::ConstPtr ConstTreePtrType
Definition Grid.h:1094
static NonConstTreeType & tree(NonConstTreeType &t)
Definition Grid.h:1106
static NonConstTreeType & tree(NonConstGridType &g)
Definition Grid.h:1107
typename GridType::Ptr GridPtrType
Definition Grid.h:1098
static const NonConstTreeType & constTree(NonConstGridType &g)
Definition Grid.h:1111
Grid< NonConstTreeType > NonConstGridType
Definition Grid.h:1097
typename GridType::ConstPtr ConstGridPtrType
Definition Grid.h:1100
typename TreeType::Ptr TreePtrType
Definition Grid.h:1093
static const NonConstTreeType & tree(const NonConstTreeType &t)
Definition Grid.h:1108
_TreeType TreeType
Definition Grid.h:1091
typename NonConstGridType::Ptr NonConstGridPtrType
Definition Grid.h:1099
typename tree::ValueAccessor< TreeType > AccessorType
Definition Grid.h:1102
static const NonConstTreeType & constTree(NonConstTreeType &t)
Definition Grid.h:1139
Grid< TreeType > GridType
Definition Grid.h:1125
typename std::remove_const< TreeType >::type NonConstTreeType
Definition Grid.h:1121
static const NonConstTreeType & constTree(const NonConstGridType &g)
Definition Grid.h:1142
typename TreeType::ValueType ValueType
Definition Grid.h:1130
static const NonConstTreeType & constTree(const NonConstTreeType &t)
Definition Grid.h:1141
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition Grid.h:1133
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition Grid.h:1132
static const NonConstTreeType & tree(const NonConstGridType &g)
Definition Grid.h:1138
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition Grid.h:1124
typename TreeType::ConstPtr ConstTreePtrType
Definition Grid.h:1123
static NonConstTreeType & tree(NonConstTreeType &t)
Definition Grid.h:1135
static NonConstTreeType & tree(NonConstGridType &g)
Definition Grid.h:1136
typename GridType::Ptr GridPtrType
Definition Grid.h:1127
static const NonConstTreeType & constTree(NonConstGridType &g)
Definition Grid.h:1140
Grid< NonConstTreeType > NonConstGridType
Definition Grid.h:1126
typename GridType::ConstPtr ConstGridPtrType
Definition Grid.h:1129
typename TreeType::Ptr TreePtrType
Definition Grid.h:1122
static const NonConstTreeType & tree(const NonConstTreeType &t)
Definition Grid.h:1137
_TreeType TreeType
Definition Grid.h:1120
typename NonConstGridType::Ptr NonConstGridPtrType
Definition Grid.h:1128
typename tree::ValueAccessor< TreeType > AccessorType
Definition Grid.h:1131
static const NonConstTreeType & constTree(NonConstTreeType &t)
Definition Grid.h:1172
static NonConstTreeType & tree(NonConstAccessorType &a)
Definition Grid.h:1166
typename std::remove_const< TreeType >::type NonConstTreeType
Definition Grid.h:1150
typename tree::ValueAccessor< const NonConstTreeType > ConstAccessorType
Definition Grid.h:1161
static const NonConstTreeType & constTree(NonConstAccessorType &a)
Definition Grid.h:1174
static const NonConstTreeType & constTree(const NonConstGridType &g)
Definition Grid.h:1177
typename TreeType::ValueType ValueType
Definition Grid.h:1159
static const NonConstTreeType & constTree(const ConstAccessorType &a)
Definition Grid.h:1179
static const NonConstTreeType & constTree(const NonConstTreeType &t)
Definition Grid.h:1176
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition Grid.h:1162
static const NonConstTreeType & tree(const ConstAccessorType &a)
Definition Grid.h:1171
static const NonConstTreeType & tree(const NonConstGridType &g)
Definition Grid.h:1169
static const NonConstTreeType & tree(const NonConstAccessorType &a)
Definition Grid.h:1170
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition Grid.h:1153
typename TreeType::ConstPtr ConstTreePtrType
Definition Grid.h:1152
static NonConstTreeType & tree(NonConstTreeType &t)
Definition Grid.h:1164
static NonConstTreeType & tree(NonConstGridType &g)
Definition Grid.h:1165
static const NonConstTreeType & tree(ConstAccessorType &a)
Definition Grid.h:1167
typename GridType::Ptr GridPtrType
Definition Grid.h:1156
static const NonConstTreeType & constTree(NonConstGridType &g)
Definition Grid.h:1173
static const NonConstTreeType & constTree(const NonConstAccessorType &a)
Definition Grid.h:1178
Grid< NonConstTreeType > NonConstGridType
Definition Grid.h:1155
typename GridType::ConstPtr ConstGridPtrType
Definition Grid.h:1158
typename TreeType::Ptr TreePtrType
Definition Grid.h:1151
static const NonConstTreeType & tree(const NonConstTreeType &t)
Definition Grid.h:1168
_TreeType TreeType
Definition Grid.h:1149
Grid< NonConstTreeType > GridType
Definition Grid.h:1154
typename NonConstGridType::Ptr NonConstGridPtrType
Definition Grid.h:1157
static const NonConstTreeType & constTree(ConstAccessorType &a)
Definition Grid.h:1175
typename tree::ValueAccessor< TreeType > AccessorType
Definition Grid.h:1160
This adapter allows code that is templated on a Tree type to accept either a Tree type or a Grid type...
Definition Grid.h:1060
static const NonConstTreeType & constTree(NonConstTreeType &t)
Definition Grid.h:1080
typename std::remove_const< TreeType >::type NonConstTreeType
Definition Grid.h:1062
static const NonConstTreeType & constTree(const NonConstGridType &g)
Definition Grid.h:1083
typename TreeType::ValueType ValueType
Definition Grid.h:1071
static const NonConstTreeType & constTree(const NonConstTreeType &t)
Definition Grid.h:1082
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition Grid.h:1074
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition Grid.h:1073
static const NonConstTreeType & tree(const NonConstGridType &g)
Definition Grid.h:1079
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition Grid.h:1065
typename TreeType::ConstPtr ConstTreePtrType
Definition Grid.h:1064
static NonConstTreeType & tree(NonConstTreeType &t)
Definition Grid.h:1076
static NonConstTreeType & tree(NonConstGridType &g)
Definition Grid.h:1077
typename GridType::Ptr GridPtrType
Definition Grid.h:1068
static const NonConstTreeType & constTree(NonConstGridType &g)
Definition Grid.h:1081
Grid< NonConstTreeType > NonConstGridType
Definition Grid.h:1067
typename GridType::ConstPtr ConstGridPtrType
Definition Grid.h:1070
typename TreeType::Ptr TreePtrType
Definition Grid.h:1063
static const NonConstTreeType & tree(const NonConstTreeType &t)
Definition Grid.h:1078
_TreeType TreeType
Definition Grid.h:1061
Grid< NonConstTreeType > GridType
Definition Grid.h:1066
typename NonConstGridType::Ptr NonConstGridPtrType
Definition Grid.h:1069
typename tree::ValueAccessor< TreeType > AccessorType
Definition Grid.h:1072
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:218