4 #ifndef OPENVDB_GRID_HAS_BEEN_INCLUDED 5 #define OPENVDB_GRID_HAS_BEEN_INCLUDED 18 #include <type_traits> 28 template<
typename>
class Grid;
35 template<
typename Gr
idType>
36 inline typename GridType::Ptr
createGrid(
const typename GridType::ValueType& background);
42 template<
typename Gr
idType>
50 template<
typename TreePtrType>
68 template<
typename Gr
idType>
83 using GridFactory =
Ptr (*)();
129 static bool isRegistered(
const Name &type);
132 static void clearRegistry();
140 virtual Name type()
const = 0;
142 virtual Name valueType()
const = 0;
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>
158 static typename GridType::ConstPtr constGrid(
const GridBase::Ptr&);
159 template<
typename Gr
idType>
176 #if OPENVDB_ABI_VERSION_NUMBER >= 8 178 virtual bool isTreeUnique()
const = 0;
206 virtual void newTree() = 0;
211 virtual bool empty()
const = 0;
213 virtual void clear() = 0;
224 virtual void pruneGrid(
float tolerance = 0.0) = 0;
230 void clipGrid(
const BBoxd&);
264 template<
typename Gr
idTypeListT,
typename OpT>
inline bool apply(OpT&)
const;
265 template<
typename Gr
idTypeListT,
typename OpT>
inline bool apply(OpT&);
266 template<
typename Gr
idTypeListT,
typename OpT>
inline bool apply(
const OpT&)
const;
267 template<
typename Gr
idTypeListT,
typename OpT>
inline bool apply(
const OpT&);
274 std::string getName()
const;
276 void setName(
const std::string&);
279 std::string getCreator()
const;
281 void setCreator(
const std::string&);
285 bool saveFloatAsHalf()
const;
286 void setSaveFloatAsHalf(
bool);
297 void clearGridClass();
302 static std::string gridClassToString(
GridClass);
304 static std::string gridClassToMenuName(
GridClass);
309 static GridClass stringToGridClass(
const std::string&);
323 void clearVectorType();
328 static std::string vecTypeToString(
VecType);
331 static std::string vecTypeExamples(
VecType);
334 static std::string vecTypeDescription(
VecType);
335 static VecType stringToVecType(
const std::string&);
343 bool isInWorldSpace()
const;
345 void setIsInWorldSpace(
bool);
371 virtual Index64 activeVoxelCount()
const = 0;
375 virtual CoordBBox evalActiveVoxelBoundingBox()
const = 0;
378 virtual Coord evalActiveVoxelDim()
const = 0;
387 void addStatsMetadata();
432 Vec3d
voxelSize()
const {
return transform().voxelSize(); }
435 Vec3d
voxelSize(
const Vec3d& xyz)
const {
return transform().voxelSize(xyz); }
439 Vec3d
indexToWorld(
const Vec3d& xyz)
const {
return transform().indexToWorld(xyz); }
441 Vec3d
indexToWorld(
const Coord& ijk)
const {
return transform().indexToWorld(ijk); }
443 Vec3d
worldToIndex(
const Vec3d& xyz)
const {
return transform().worldToIndex(xyz); }
453 virtual void readTopology(std::istream&) = 0;
456 virtual void writeTopology(std::ostream&)
const = 0;
459 virtual void readBuffers(std::istream&) = 0;
461 virtual void readBuffers(std::istream&,
const CoordBBox&) = 0;
467 virtual void readNonresidentBuffers()
const = 0;
469 virtual void writeBuffers(std::ostream&)
const = 0;
477 virtual void print(std::ostream& = std::cout,
int verboseLevel = 1)
const = 0;
484 GridBase(): mTransform(math::Transform::createLinearTransform()) {}
497 static void registerGrid(
const Name& type, GridFactory);
499 static void unregisterGrid(
const Name& type);
540 template<
typename Gr
idPtrContainerT>
541 inline typename GridPtrContainerT::value_type
544 using GridPtrT =
typename GridPtrContainerT::value_type;
545 typename GridPtrContainerT::const_iterator it =
546 std::find_if(container.begin(), container.end(),
GridNamePred(name));
547 return (it == container.end() ? GridPtrT() : *it);
551 template<
typename KeyT,
typename Gr
idPtrT>
555 using GridPtrMapT = std::map<KeyT, GridPtrT>;
556 for (
typename GridPtrMapT::const_iterator it = container.begin(), end = container.end();
559 const GridPtrT& grid = it->second;
560 if (grid && grid->getName() == name)
return grid;
571 template<
typename _TreeType>
602 template<
typename OtherValueType>
634 template<
typename OtherTreeType>
645 Grid& operator=(
const Grid&) =
delete;
658 Ptr copyWithNewTree()
const;
711 Name type()
const override {
return this->gridType(); }
727 bool empty()
const override {
return tree().empty(); }
729 void clear()
override { tree().clear(); }
808 void pruneGrid(
float tolerance = 0.0)
override;
836 template<
typename OtherTreeType>
851 template<
typename OtherTreeType>
864 template<
typename OtherTreeType>
875 CoordBBox evalActiveVoxelBoundingBox()
const override;
877 Coord evalActiveVoxelDim()
const override;
880 tools::minMax(grid->tree()). Use threaded = false for serial execution")
903 #if OPENVDB_ABI_VERSION_NUMBER >= 8 904 bool isTreeUnique()
const final;
906 bool isTreeUnique()
const;
932 void newTree()
override;
942 void readTopology(std::istream&)
override;
945 void writeTopology(std::ostream&)
const override;
948 void readBuffers(std::istream&)
override;
950 void readBuffers(std::istream&,
const CoordBBox&)
override;
956 void readNonresidentBuffers()
const override;
958 void writeBuffers(std::ostream&)
const override;
961 void print(std::ostream& = std::cout,
int verboseLevel = 1)
const override;
968 static inline bool hasMultiPassIO();
1005 template<
typename Gr
idType>
1006 inline typename GridType::Ptr
1009 return GridBase::grid<GridType>(grid);
1021 template<
typename Gr
idType>
1022 inline typename GridType::ConstPtr
1025 return GridBase::constGrid<GridType>(grid);
1038 template<
typename Gr
idType>
1039 inline typename GridType::Ptr
1042 if (!grid || !grid->isType<
GridType>())
return typename GridType::Ptr();
1043 return gridPtrCast<GridType>(grid->deepCopyGrid());
1047 template<
typename Gr
idType>
1048 inline typename GridType::Ptr
1063 template<
typename _TreeType>
1093 template<
typename _TreeType>
1122 template<
typename _TreeType>
1163 template<
typename LeafNodeType>
1169 template<
typename RootNodeType>
1176 template<
typename TreeType>
1192 template<
typename Gr
idType>
1193 inline typename GridType::Ptr
1198 if (grid && grid->type() == GridType::gridType()) {
1199 return StaticPtrCast<GridType>(
grid);
1201 return typename GridType::Ptr();
1205 template<
typename Gr
idType>
1206 inline typename GridType::ConstPtr
1209 return ConstPtrCast<const GridType>(
1210 GridBase::grid<GridType>(ConstPtrCast<GridBase>(
grid)));
1214 template<
typename Gr
idType>
1215 inline typename GridType::ConstPtr
1218 return ConstPtrCast<const GridType>(GridBase::grid<GridType>(
grid));
1222 template<
typename Gr
idType>
1223 inline typename GridType::ConstPtr
1226 return ConstPtrCast<const GridType>(
1227 GridBase::grid<GridType>(ConstPtrCast<GridBase>(
grid)));
1249 template<
typename TreeT>
1255 template<
typename TreeT>
1261 template<
typename TreeT>
1268 template<
typename TreeT>
1277 template<
typename TreeT>
1285 template<
typename TreeT>
1286 template<
typename OtherTreeType>
1294 template<
typename TreeT>
1302 template<
typename TreeT>
1311 template<
typename TreeT>
1320 template<
typename TreeT>
1324 return Ptr(
new Grid(background));
1329 template<
typename TreeT>
1338 template<
typename TreeT>
1349 template<
typename TreeT>
1357 template<
typename TreeT>
1367 template<
typename TreeT>
1374 template<
typename TreeT>
1384 template<
typename TreeT>
1392 template<
typename TreeT>
1402 template<
typename TreeT>
1406 return this->
copy();
1409 template<
typename TreeT>
1413 return this->
copy();
1416 template<
typename TreeT>
1423 template<
typename TreeT>
1430 template<
typename TreeT>
1438 template<
typename TreeT>
1449 template<
typename TreeT>
1453 return mTree.use_count() == 1;
1457 template<
typename TreeT>
1462 if (tree->type() != TreeType::treeType()) {
1464 + tree->type() +
" to a grid of type " + this->
type());
1466 mTree = StaticPtrCast<TreeType>(
tree);
1470 template<
typename TreeT>
1481 template<
typename TreeT>
1485 tree().sparseFill(bbox, value, active);
1489 template<
typename TreeT>
1496 template<
typename TreeT>
1500 tree().denseFill(bbox, value, active);
1503 template<
typename TreeT>
1508 this->
tree().prune(static_cast<ValueType>(
value));
1511 template<
typename TreeT>
1518 template<
typename TreeT>
1522 tree().merge(other.
tree(), policy);
1526 template<
typename TreeT>
1527 template<
typename OtherTreeType>
1531 tree().topologyUnion(other.
tree());
1535 template<
typename TreeT>
1536 template<
typename OtherTreeType>
1540 tree().topologyIntersection(other.
tree());
1544 template<
typename TreeT>
1545 template<
typename OtherTreeType>
1549 tree().topologyDifference(other.
tree());
1556 template<
typename TreeT>
1561 tree().evalMinMax(minVal, maxVal);
1566 template<
typename TreeT>
1571 tree().evalActiveVoxelBoundingBox(bbox);
1576 template<
typename TreeT>
1581 const bool nonempty =
tree().evalActiveVoxelDim(dim);
1582 return (nonempty ? dim : Coord());
1592 template<
typename TreeT>
1600 template<
typename TreeT>
1608 template<
typename TreeT>
1615 uint16_t numPasses = 1;
1616 is.read(reinterpret_cast<char*>(&numPasses),
sizeof(uint16_t));
1619 for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1620 uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1621 meta->setPass(pass);
1630 template<
typename TreeT>
1637 uint16_t numPasses = 1;
1638 is.read(reinterpret_cast<char*>(&numPasses),
sizeof(uint16_t));
1641 for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1642 uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1643 meta->setPass(pass);
1653 template<
typename TreeT>
1657 tree().readNonresidentBuffers();
1661 template<
typename TreeT>
1671 uint16_t numPasses = 1;
1672 meta->setCountingPasses(
true);
1675 numPasses =
static_cast<uint16_t
>(meta->pass());
1676 os.write(reinterpret_cast<const char*>(&numPasses),
sizeof(uint16_t));
1677 meta->setCountingPasses(
false);
1680 for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1681 uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1682 meta->setPass(pass);
1690 template<
typename TreeT>
1698 template<
typename TreeT>
1702 tree().print(os, verboseLevel);
1705 os <<
"Additional metadata:" << std::endl;
1707 os <<
" " << it->first;
1709 const std::string
value = it->second->str();
1710 if (!value.empty()) os <<
": " << value;
1716 os <<
"Transform:" << std::endl;
1725 template<
typename Gr
idType>
1726 inline typename GridType::Ptr
1729 return GridType::create(background);
1733 template<
typename Gr
idType>
1734 inline typename GridType::Ptr
1737 return GridType::create();
1741 template<
typename TreePtrType>
1745 using TreeType =
typename TreePtrType::element_type;
1750 template<
typename Gr
idType>
1751 typename GridType::Ptr
1754 using ValueType =
typename GridType::ValueType;
1758 "level-set grids must be floating-point-valued");
1760 typename GridType::Ptr
grid = GridType::create(
1761 static_cast<ValueType>(voxelSize * halfWidth));
1771 template<
typename Gr
idTypeListT,
typename OpT>
1775 return GridTypeListT::template apply<OpT&, const GridBase>(std::ref(op), *
this);
1778 template<
typename Gr
idTypeListT,
typename OpT>
1782 return GridTypeListT::template apply<OpT&, GridBase>(std::ref(op), *
this);
1785 template<
typename Gr
idTypeListT,
typename OpT>
1789 return GridTypeListT::template apply<const OpT&, const GridBase>(std::ref(op), *
this);
1792 template<
typename Gr
idTypeListT,
typename OpT>
1796 return GridTypeListT::template apply<const OpT&, GridBase>(std::ref(op), *
this);
1803 #endif // OPENVDB_GRID_HAS_BEEN_INCLUDED void evalMinMax(ValueType &minVal, ValueType &maxVal) const
Return the minimum and maximum active values in this grid.
Definition: Grid.h:1558
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:1149
void merge(Grid &other, MergePolicy policy=MERGE_ACTIVE_STATES)
Efficiently merge another grid into this grid using one of several schemes.
Definition: Grid.h:1520
typename tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:1107
typename _TreeType::ValueType ValueType
Definition: Grid.h:581
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:1602
bool isType() const
Return true if this grid is of the same type as the template parameter.
Definition: Grid.h:146
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:1483
GridBase(GridBase &other, ShallowCopy)
Copy another grid's metadata but share its transform.
Definition: Grid.h:494
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
math::Transform::Ptr transformPtr()
Return a pointer to this grid's transform, which might be shared with other grids.
Definition: Grid.h:404
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:1023
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:1386
std::vector< GridBase::ConstPtr > GridCPtrVec
Definition: Grid.h:515
bool saveFloatAsHalf() const
Return true if this grid should be written out with floating-point voxel values (including components...
typename _TreeType::ValueOffCIter ValueOffCIter
Definition: Grid.h:587
typename TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:1069
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:1440
Vec3d indexToWorld(const Coord &ijk) const
Apply this grid's transform to the given coordinates.
Definition: Grid.h:441
const TreeBase & baseTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:190
typename tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:1136
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:1491
~Grid() override
Definition: Grid.h:642
ValueOnCIter beginValueOn() const
Return an iterator over all of this grid's active values (tile and voxel).
Definition: Grid.h:759
Name name
Definition: Grid.h:536
typename GridType::Ptr GridPtrType
Definition: Grid.h:1132
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:74
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:1085
void setTransform(math::Transform::Ptr)
Associate the given transform with this grid, in place of its existing transform. ...
Definition: Grid.h:1239
ValueAllCIter beginValueAll() const
Return an iterator over all of this grid's values (tile and voxel).
Definition: Grid.h:771
typename tree::ValueAccessor< _TreeType, false > UnsafeAccessor
Definition: Grid.h:593
ValueAllCIter cbeginValueAll() const
Return an iterator over all of this grid's values (tile and voxel).
Definition: Grid.h:773
static Name gridType()
Return the name of this type of grid.
Definition: Grid.h:713
static TreeType & tree(GridType &g)
Definition: Grid.h:1082
ValueOffCIter beginValueOff() const
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition: Grid.h:765
GridNamePred(const Name &_name)
Definition: Grid.h:534
void writeTransform(std::ostream &os) const
Write out the transform for this grid.
Definition: Grid.h:474
const math::Transform & transform() const
Return a reference to this grid's transform, which might be shared with other grids.
Definition: Grid.h:414
Base class for typed trees.
Definition: Tree.h:36
GridCPtrVec::const_iterator GridCPtrVecCIter
Definition: Grid.h:517
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:1404
Name valueType() const override
Return the name of the type of a voxel's value (e.g., "float" or "vec3d").
Definition: Grid.h:716
GridBase::Ptr deepCopyGrid() const override
Return a new grid whose metadata, transform and tree are deep copies of this grid's.
Definition: Grid.h:705
typename NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:1074
static Ptr createGrid(const Name &type)
Create a new grid of the given (registered) type.
static const char *const META_FILE_VOXEL_COUNT
Definition: Grid.h:363
SharedPtr< GridCPtrSet > GridCPtrSetPtr
Definition: Grid.h:528
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:1087
GridPtrSet::iterator GridPtrSetIter
Definition: Grid.h:521
static const char *const META_GRID_CLASS
Definition: Grid.h:353
static TreeType & tree(GridType &g)
Definition: Grid.h:1141
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:898
typename _TreeType::Ptr TreePtrType
Definition: Grid.h:579
static const TreeType & tree(const GridType &g)
Definition: Grid.h:1144
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:1773
typename TreeType::ValueType ValueType
Definition: Grid.h:1076
typename std::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:1097
_TreeType TreeType
Definition: Grid.h:1066
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:1088
Metafunction that specifies whether a given leaf node, tree, or grid type requires multiple passes to...
Definition: Grid.h:1164
Definition: Exceptions.h:64
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:897
typename _TreeType::ValueAllIter ValueAllIter
Definition: Grid.h:588
Index64 activeVoxelCount() const override
Return the number of active voxels.
Definition: Grid.h:873
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:1376
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:1232
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:1100
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
SharedPtr< const GridBase > ConstPtr
Definition: Grid.h:81
virtual GridBase::Ptr deepCopyGrid() const =0
Return a new grid whose metadata, transform and tree are deep copies of this grid's.
typename TreeType::Ptr TreePtrType
Definition: Grid.h:1098
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 const char *const META_VECTOR_TYPE
Definition: Grid.h:358
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
void readBuffers(std::istream &) override
Read all data buffers for this grid.
Definition: Grid.h:1610
Definition: Exceptions.h:65
Mat3< Type1 > cwiseAdd(const Mat3< Type1 > &m, const Type2 s)
Definition: Mat3.h:820
typename _TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:580
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:1547
ValueAllIter beginValueAll()
Return an iterator over all of this grid's values (tile and voxel).
Definition: Grid.h:769
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:1752
VecType
Definition: Types.h:444
GridPtrSet::const_iterator GridPtrSetCIter
Definition: Grid.h:522
static void unregisterGrid()
Remove this grid type from the registry.
Definition: Grid.h:979
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:1418
typename _TreeType::ValueAllCIter ValueAllCIter
Definition: Grid.h:589
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:553
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, whose metadata is a deep copy of this grid's and whose transform is provided as an argument.
Definition: Grid.h:1369
ValueOnCIter cbeginValueOn() const
Return an iterator over all of this grid's active values (tile and voxel).
Definition: Grid.h:761
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:1394
ConstAccessor getConstAccessor() const
Return an accessor that provides random read-only access to this grid's voxels.
Definition: Grid.h:746
Tag dispatch class that distinguishes shallow copy constructors from deep copy constructors.
Definition: Types.h:641
Vec3d worldToIndex(const Vec3d &xyz) const
Apply the inverse of this grid's transform to the given coordinates.
Definition: Grid.h:443
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:1118
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:1143
GridClass
Definition: Types.h:414
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:1146
GridCPtrSet::iterator GridCPtrSetIter
Definition: Grid.h:526
Abstract base class for typed grids.
Definition: Grid.h:77
typename GridType::Ptr GridPtrType
Definition: Grid.h:1073
Vec3d voxelSize() const
Return the size of this grid's voxels.
Definition: Grid.h:432
static const Real LEVEL_SET_HALF_WIDTH
Definition: Types.h:422
void newTree() override
Associate a new, empty tree with this grid, in place of its existing tree.
Definition: Grid.h:1472
_TreeType TreeType
Definition: Grid.h:1125
BBox< Coord > CoordBBox
Definition: NanoVDB.h:1658
typename tree::ValueAccessor< _TreeType, true > Accessor
Definition: Grid.h:591
static const TreeType & tree(const GridType &g)
Definition: Grid.h:1114
static const char *const META_FILE_COMPRESSION
Definition: Grid.h:361
static const TreeType & constTree(GridType &g)
Definition: Grid.h:1147
tree::TreeBase TreeBase
Definition: Grid.h:26
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:1007
ConstAccessor getAccessor() const
Return an accessor that provides random read-only access to this grid's voxels.
Definition: Grid.h:744
GridCPtrSet::const_iterator GridCPtrSetCIter
Definition: Grid.h:527
GridPtrVec::iterator GridPtrVecIter
Definition: Grid.h:511
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:1129
static const TreeType & constTree(GridType &g)
Definition: Grid.h:1086
CoordBBox evalActiveVoxelBoundingBox() const override
Return the axis-aligned bounding box of all active voxels.
Definition: Grid.h:1568
Coord evalActiveVoxelDim() const override
Return the dimensions of the axis-aligned bounding box of all active voxels.
Definition: Grid.h:1578
static const char *const META_GRID_NAME
Definition: Grid.h:355
ValueOffCIter cbeginValueOff() const
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition: Grid.h:767
openvdb::GridBase Grid
Definition: Utils.h:34
static bool hasMultiPassIO()
Return true if grids of this type require multiple I/O passes to read and write data buffers...
Definition: Grid.h:1692
Definition: ValueAccessor.h:182
TreeBase & baseTree()
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:185
static TreeType & tree(TreeType &t)
Definition: Grid.h:1111
typename GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:1134
std::pair< ValueT, ValueT > evalMinMax(const PointDataTreeT &points, const std::string &attribute, const FilterT &filter=NullFilter())
Evaluates the minimum and maximum values of a point attribute.
Definition: PointStatistics.h:697
ValueOffIter beginValueOff()
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition: Grid.h:763
typename std::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:1067
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:1049
static const char *const META_IS_LOCAL_SPACE
Definition: Grid.h:357
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:1113
bool operator()(const GridBase::ConstPtr &g) const
Definition: Grid.h:535
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:1078
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, whose metadata is a deep copy of this grid's and whose transform is provided as an argument.
Definition: Grid.h:1425
bool hasUniformVoxels() const
Return true if the voxels in world space are uniformly sized cubes.
Definition: Grid.h:437
typename _TreeType::BuildType BuildType
Definition: Grid.h:582
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:1594
typename NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:1133
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:1498
static void registerGrid()
Register this grid type along with a factory function.
Definition: Grid.h:977
Grid()
Construct a new grid with background value zero.
Definition: Grid.h:1250
static const char *const META_FILE_BBOX_MIN
Definition: Grid.h:359
Definition: Exceptions.h:13
void pruneGrid(float tolerance=0.0) override
Reduce the memory footprint of this grid by increasing its sparseness.
Definition: Grid.h:1505
static const TreeType & tree(const AccessorType &a)
Definition: Grid.h:1145
static void registerGrid(const Name &type, GridFactory)
Register a grid type along with a factory function.
SharedPtr< TreeBase > Ptr
Definition: Tree.h:39
typename TreeType::ValueType ValueType
Definition: Grid.h:1135
void print(std::ostream &=std::cout, int verboseLevel=1) const override
Output a human-readable description of this grid.
Definition: Grid.h:1700
ValueT value
Definition: GridBuilder.h:1287
typename TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:1128
const TreeBase & constBaseTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:195
TreePtrType treePtr()
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition: Grid.h:896
const TreeType & tree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:914
Predicate functor that returns true for grids that have a specified name.
Definition: Grid.h:532
typename GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:1075
ConstUnsafeAccessor getConstUnsafeAccessor() const
Return an unsafe accessor that provides random read-only access to this grid's voxels.
Definition: Grid.h:754
static TreeType & tree(TreeType &t)
Definition: Grid.h:1140
GridBase(const GridBase &other)
Deep copy another grid's metadata and transform.
Definition: Grid.h:491
typename tree::ValueAccessor< const _TreeType, false > ConstUnsafeAccessor
Definition: Grid.h:594
Grid< typename TreePtrType::element_type >::Ptr createGrid(TreePtrType)
Create a new grid of the appropriate type that wraps the given tree.
Definition: Grid.h:1743
typename TreeType::Ptr TreePtrType
Definition: Grid.h:1127
typename std::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:1126
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:1655
typename NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:1104
static const TreeType & tree(const GridType &g)
Definition: Grid.h:1084
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:1079
GridPtrVec::const_iterator GridPtrVecCIter
Definition: Grid.h:512
Container class that associates a tree with a transform and metadata.
Definition: Grid.h:28
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:1216
void writeBuffers(std::ostream &) const override
Write out all data buffers for this grid.
Definition: Grid.h:1663
_TreeType TreeType
Definition: Grid.h:1096
ValueConverter<T>::Type is the type of a grid having the same hierarchy as this grid but a different ...
Definition: Grid.h:603
typename _TreeType::ValueOnIter ValueOnIter
Definition: Grid.h:584
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:1529
OPENVDB_API uint32_t getGridClass(std::ios_base &)
Return the class (GRID_LEVEL_SET, GRID_UNKNOWN, etc.) of the grid currently being read from or writte...
static bool isRegistered()
Return true if this grid type is registered.
Definition: Grid.h:975
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:1117
ValueOnIter beginValueOn()
Return an iterator over all of this grid's active values (tile and voxel).
Definition: Grid.h:757
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:1137
const math::Transform & constTransform() const
Return a reference to this grid's transform, which might be shared with other grids.
Definition: Grid.h:415
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:1432
const ValueType & background() const
Return this grid's background value.
Definition: Grid.h:724
GridType
List of types that are currently supported by NanoVDB.
Definition: NanoVDB.h:216
GridCPtrVec::iterator GridCPtrVecIter
Definition: Grid.h:516
typename TreeType::Ptr TreePtrType
Definition: Grid.h:1068
UnsafeAccessor getUnsafeAccessor()
Return an unsafe accessor that provides random read and write access to this grid's voxels...
Definition: Grid.h:742
MergePolicy
Definition: Types.h:467
math::Transform & transform()
Return a reference to this grid's transform, which might be shared with other grids.
Definition: Grid.h:413
bool empty() const override
Return true if this grid contains only inactive background voxels.
Definition: Grid.h:727
OPENVDB_AX_API void print(const ast::Node &node, const bool numberStatements=true, std::ostream &os=std::cout, const char *indent=" ")
Writes a descriptive printout of a Node hierarchy into a target stream.
static bool isRegistered(const Name &type)
Return true if the given grid type name is registered.
typename _TreeType::ValueOnCIter ValueOnCIter
Definition: Grid.h:585
SharedPtr< GridCPtrVec > GridCPtrVecPtr
Definition: Grid.h:518
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:899
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:1083
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:1538
std::set< GridBase::ConstPtr > GridCPtrSet
Definition: Grid.h:525
typename _TreeType::ValueOffIter ValueOffIter
Definition: Grid.h:586
SharedPtr< GridPtrVec > GridPtrVecPtr
Definition: Grid.h:513
void clear() override
Empty this grid, so that all voxels become inactive background voxels.
Definition: Grid.h:729
static const char *const META_FILE_MEM_BYTES
Definition: Grid.h:362
static const char *const META_FILE_BBOX_MAX
Definition: Grid.h:360
Vec3d indexToWorld(const Vec3d &xyz) const
Apply this grid's transform to the given coordinates.
Definition: Grid.h:439
Index64 memUsage() const override
Definition: Grid.h:885
_TreeType TreeType
Definition: Grid.h:578
void clip(const CoordBBox &) override
Clip this grid to the given index-space bounding box.
Definition: Grid.h:1513
std::set< GridBase::Ptr > GridPtrSet
Definition: Grid.h:520
TreeType & tree()
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:913
GridBase()
Initialize with an identity linear transform.
Definition: Grid.h:484
typename TreeType::ValueType ValueType
Definition: Grid.h:1106
SharedPtr< GridPtrSet > GridPtrSetPtr
Definition: Grid.h:523
OPENVDB_API SharedPtr< StreamMetadata > getStreamMetadataPtr(std::ios_base &)
Return a shared pointer to an object that stores metadata (file format, compression scheme...
Vec3d voxelSize(const Vec3d &xyz) const
Return the size of this grid's voxel at position (x, y, z).
Definition: Grid.h:435
~GridBase() override
Definition: Grid.h:86
const TreeType & constTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:915
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:1109
Ptr deepCopy() const
Return a new grid whose metadata, transform and tree are deep copies of this grid's.
Definition: Grid.h:703
OPENVDB_API void setGridClass(std::ios_base &, uint32_t)
Associate with the given stream the class (GRID_LEVEL_SET, GRID_UNKNOWN, etc.) of the grid currently ...
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:1148
SharedPtr< Grid > Ptr
Definition: Grid.h:575
math::Transform::ConstPtr constTransformPtr() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition: Grid.h:406
static const TreeType & constTree(GridType &g)
Definition: Grid.h:1116
typename TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:1099
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:1359
Definition: version.h.in:249
static void unregisterGrid(const Name &type)
Remove a grid type from the registry.
std::shared_ptr< T > SharedPtr
Definition: Types.h:114
static const char *const META_FILE_DELAYED_LOAD
Definition: Grid.h:364
std::string Name
Definition: Name.h:17
typename GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:1105
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
typename tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:1077
void readTransform(std::istream &is)
Read in the transform for this grid.
Definition: Grid.h:472
void setTree(TreeBase::Ptr) override
Associate the given tree with this grid, in place of its existing tree.
Definition: Grid.h:1459
SharedPtr< const TreeBase > ConstPtr
Definition: Tree.h:40
static Ptr create()
Return a new grid with background value zero.
Definition: Grid.h:1313
This adapter allows code that is templated on a Tree type to accept either a Tree type or a Grid type...
Definition: Grid.h:1064
SharedPtr< GridBase > Ptr
Definition: Grid.h:80
static TreeType & tree(GridType &g)
Definition: Grid.h:1112
SharedPtr< const Grid > ConstPtr
Definition: Grid.h:576
math::Transform::ConstPtr transformPtr() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition: Grid.h:405
Name type() const override
Return the name of this grid's type.
Definition: Grid.h:711
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:1115
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:1108
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:1070
static TreeType & tree(AccessorType &a)
Definition: Grid.h:1142
Accessor getAccessor()
Return an accessor that provides random read and write access to this grid's voxels.
Definition: Grid.h:734
uint64_t Index64
Definition: Types.h:53
static TreeType & tree(TreeType &t)
Definition: Grid.h:1081
bool isTreeUnique() const final
Return true if tree is not shared with another grid.
Definition: Grid.h:1451
static const char *const META_SAVE_HALF_FLOAT
Definition: Grid.h:356
std::vector< GridBase::Ptr > GridPtrVec
Definition: Grid.h:510
static const char *const META_GRID_CREATOR
Definition: Grid.h:354
typename tree::ValueAccessor< const _TreeType, true > ConstAccessor
Definition: Grid.h:592
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202
typename GridType::Ptr GridPtrType
Definition: Grid.h:1103
double Real
Definition: Types.h:60
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:1138
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:1194