OpenVDB 13.0.0

Loading...
Searching...
No Matches
Dense< ValueT, Layout > Class Template Reference

Dense is a simple dense grid API used by the CopyToDense and CopyFromDense classes defined below. More...

`#include <openvdb/tools/Dense.h>`

Inheritance diagram for Dense< ValueT, Layout >:

## Public Types
using | ValueType = ValueT
using | BaseT = DenseBase<ValueT, Layout>
using | Ptr = SharedPtr<Dense>
using | ConstPtr = SharedPtr<const Dense>

## Public Member Functions
| Dense (const CoordBBox &bbox)
| Construct a dense grid with a given range of coordinates.
| Dense (const CoordBBox &bbox, const ValueT &value)
| Construct a dense grid with a given range of coordinates and initial value.
| Dense (const CoordBBox &bbox, ValueT *data)
| Construct a dense grid that wraps an external array.
| Dense (const Coord &dim, const Coord &min=Coord(0))
| Construct a dense grid with a given origin and dimensions.
ValueT * | data ()
| Return a raw pointer to this grid's value array.
const ValueT * | data () const
| Return a raw pointer to this grid's value array.
const CoordBBox & | bbox () const
| Return the bounding box of the signed index domain of this grid.
const Coord & | origin () const
| Return the grid's origin in index coordinates.
Index64 | valueCount () const
| Return the number of voxels contained in this grid.
void | setValue (size_t offset, const ValueT &value)
| Set the value of the voxel at the given array offset.
const ValueT & | getValue (size_t offset) const
| Return a const reference to the value of the voxel at the given array offset.
ValueT & | getValue (size_t offset)
| Return a non-const reference to the value of the voxel at the given array offset.
void | setValue (size_t i, size_t j, size_t k, const ValueT &value)
| Set the value of the voxel at unsigned index coordinates (i, j, k).
const ValueT & | getValue (size_t i, size_t j, size_t k) const
| Return a const reference to the value of the voxel at unsigned index coordinates (i, j, k).
ValueT & | getValue (size_t i, size_t j, size_t k)
| Return a non-const reference to the value of the voxel at unsigned index coordinates (i, j, k).
void | setValue (const Coord &xyz, const ValueT &value)
| Set the value of the voxel at the given signed coordinates.
const ValueT & | getValue (const Coord &xyz) const
| Return a const reference to the value of the voxel at the given signed coordinates.
ValueT & | getValue (const Coord &xyz)
| Return a non-const reference to the value of the voxel at the given signed coordinates.
void | fill (const ValueT &value)
| Fill this grid with a constant value.
size_t | coordToOffset (const Coord &xyz) const
| Return the linear offset into this grid's value array given by the specified signed coordinates, i.e., coordinates in the space of this grid's bounding box.
Coord | offsetToCoord (size_t n) const
| Return the global coordinate corresponding to the specified linear offset.
Index64 | memUsage () const
| Return the memory footprint of this Dense grid in bytes.
void | print (const std::string &name="", std::ostream &os=std::cout) const
| Output a human-readable description of this grid to the specified stream.
size_t | coordToOffset (size_t i, size_t j, size_t k) const
| Return the linear offset into this grid's value array given by unsigned coordinates (i, j, k), i.e., coordinates relative to the origin of this grid's bounding box.
Coord | offsetToLocalCoord (size_t n) const
| Return the local coordinate corresponding to the specified linear offset.
size_t | xStride () const
| Return the stride of the array in the x direction ( = dimY*dimZ).
size_t | yStride () const
| Return the stride of the array in the y direction ( = dimZ).

## Static Public Member Functions
static MemoryLayout | memoryLayout ()
| Return the memory layout for this grid (see above for definitions).
static size_t | zStride ()
| Return the stride of the array in the z direction ( = 1).

## Protected Attributes
const CoordBBox | mBBox
const size_t | mY
const size_t | mX

## Detailed Description

template<typename ValueT, MemoryLayout Layout = LayoutZYX>
class openvdb::v13_0::tools::Dense< ValueT, Layout >

Dense is a simple dense grid API used by the CopyToDense and CopyFromDense classes defined below.

Use the Dense class to efficiently produce a dense in-memory representation of an OpenVDB grid. However, be aware that a dense grid could have a memory footprint that is orders of magnitude larger than the sparse grid from which it originates.

Note
  This class can be used as a simple wrapper for existing dense grid classes if they provide access to the raw data array.
  This implementation allows for the 3D memory layout to be defined by the MemoryLayout template parameter (see above for definition). The default memory layout is ZYX since that's the layout used by OpenVDB grids.

## Member Typedef Documentation

## ◆ BaseT

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

using BaseT = DenseBase<ValueT, Layout>

## ◆ ConstPtr

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

using ConstPtr = SharedPtr<const Dense>

## ◆ Ptr

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

using Ptr = SharedPtr<Dense>

## ◆ ValueType

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

using ValueType = ValueT

## Constructor & Destructor Documentation

## ◆ Dense() [1/4]

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

Dense | ( | const CoordBBox & | bbox | ) |
| inline

Construct a dense grid with a given range of coordinates.

Parameters

  bbox | the bounding box of the (signed) coordinate range of this grid

Exceptions

  ValueError | if the bounding box is empty.

Note
  The min and max coordinates of the bounding box are inclusive.

## ◆ Dense() [2/4]

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

Dense | ( | const CoordBBox & | bbox,
|  | const ValueT & | value )
| inline

Construct a dense grid with a given range of coordinates and initial value.

Parameters

  bbox | the bounding box of the (signed) coordinate range of this grid
  value | the initial value of the grid.

Exceptions

  ValueError | if the bounding box is empty.

Note
  The min and max coordinates of the bounding box are inclusive.

## ◆ Dense() [3/4]

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

Dense | ( | const CoordBBox & | bbox,
|  | ValueT * | data )
| inline

Construct a dense grid that wraps an external array.

Parameters

  bbox | the bounding box of the (signed) coordinate range of this grid
  data | a raw C-style array whose size is commensurate with the coordinate domain of bbox

Note
  The data array is assumed to have a stride of one in the z direction.

Exceptions

  ValueError | if the bounding box is empty.

Note
  The min and max coordinates of the bounding box are inclusive.

## ◆ Dense() [4/4]

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

Dense | ( | const Coord & | dim,
|  | const Coord & | min = Coord(0) )
| inline

Construct a dense grid with a given origin and dimensions.

Parameters

  dim | the desired dimensions of the grid
  min | the signed coordinates of the first voxel in the dense grid

Exceptions

  ValueError | if any of the dimensions are zero.

Note
  The min coordinate is inclusive, and the max coordinate will be min + dim - 1.

## Member Function Documentation

## ◆ bbox()

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

const CoordBBox & bbox | ( |  | ) | const
| inline

Return the bounding box of the signed index domain of this grid.

Note
  This method is required by both CopyToDense and CopyFromDense.

## ◆ coordToOffset() [1/2]

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

size_t coordToOffset | ( | const Coord & | xyz | ) | const
| inline

Return the linear offset into this grid's value array given by the specified signed coordinates, i.e., coordinates in the space of this grid's bounding box.

Note
  This method reflects the fact that we assume the same layout of values as an OpenVDB grid, i.e., the fastest coordinate is z.

## ◆ coordToOffset() [2/2]

template<typename ValueT>

size_t coordToOffset | ( | size_t | i,
|  | size_t | j,
|  | size_t | k ) const
| inline inherited

Return the linear offset into this grid's value array given by unsigned coordinates (i, j, k), i.e., coordinates relative to the origin of this grid's bounding box.

Warning
  The input coordinates are assume to be relative to the grid's origin, i.e. minimum of its index bounding box!

## ◆ data() [1/2]

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

ValueT * data | ( |  | ) |
| inline

Return a raw pointer to this grid's value array.

Note
  This method is required by CopyToDense.

## ◆ data() [2/2]

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

const ValueT * data | ( |  | ) | const
| inline

Return a raw pointer to this grid's value array.

Note
  This method is required by CopyFromDense.

## ◆ fill()

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

void fill | ( | const ValueT & | value | ) |
| inline

Fill this grid with a constant value.

## ◆ getValue() [1/6]

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

ValueT & getValue | ( | const Coord & | xyz | ) |
| inline

Return a non-const reference to the value of the voxel at the given signed coordinates.

Note
  This is slower than using either an array offset or unsigned index coordinates.

## ◆ getValue() [2/6]

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

const ValueT & getValue | ( | const Coord & | xyz | ) | const
| inline

Return a const reference to the value of the voxel at the given signed coordinates.

Note
  This is slower than using either an array offset or unsigned index coordinates.

## ◆ getValue() [3/6]

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

ValueT & getValue | ( | size_t | i,
|  | size_t | j,
|  | size_t | k )
| inline

Return a non-const reference to the value of the voxel at unsigned index coordinates (i, j, k).

Note
  This is somewhat slower than using an array offset.

## ◆ getValue() [4/6]

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

const ValueT & getValue | ( | size_t | i,
|  | size_t | j,
|  | size_t | k ) const
| inline

Return a const reference to the value of the voxel at unsigned index coordinates (i, j, k).

Note
  This is somewhat slower than using an array offset.

## ◆ getValue() [5/6]

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

ValueT & getValue | ( | size_t | offset | ) |
| inline

Return a non-const reference to the value of the voxel at the given array offset.

## ◆ getValue() [6/6]

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

const ValueT & getValue | ( | size_t | offset | ) | const
| inline

Return a const reference to the value of the voxel at the given array offset.

## ◆ memoryLayout()

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

MemoryLayout memoryLayout | ( |  | ) |
| inline static

Return the memory layout for this grid (see above for definitions).

## ◆ memUsage()

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

Index64 memUsage | ( |  | ) | const
| inline

Return the memory footprint of this Dense grid in bytes.

## ◆ offsetToCoord()

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

Coord offsetToCoord | ( | size_t | n | ) | const
| inline

Return the global coordinate corresponding to the specified linear offset.

## ◆ offsetToLocalCoord()

template<typename ValueT>

Coord offsetToLocalCoord | ( | size_t | n | ) | const
| inline inherited

Return the local coordinate corresponding to the specified linear offset.

Warning
  The returned coordinate is relative to the origin of this grid's bounding box so add dense.origin() to get absolute coordinates.

## ◆ origin()

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

const Coord & origin | ( |  | ) | const
| inline

Return the grid's origin in index coordinates.

## ◆ print()

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

void print | ( | const std::string & | name = "",
|  | std::ostream & | os = std::cout ) const
| inline

Output a human-readable description of this grid to the specified stream.

## ◆ setValue() [1/3]

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

void setValue | ( | const Coord & | xyz,
|  | const ValueT & | value )
| inline

Set the value of the voxel at the given signed coordinates.

Note
  This is slower than using either an array offset or unsigned index coordinates.

## ◆ setValue() [2/3]

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

void setValue | ( | size_t | i,
|  | size_t | j,
|  | size_t | k,
|  | const ValueT & | value )
| inline

Set the value of the voxel at unsigned index coordinates (i, j, k).

Note
  This is somewhat slower than using an array offset.

## ◆ setValue() [3/3]

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

void setValue | ( | size_t | offset,
|  | const ValueT & | value )
| inline

Set the value of the voxel at the given array offset.

## ◆ valueCount()

template<typename ValueT, MemoryLayout Layout = LayoutZYX>

Index64 valueCount | ( |  | ) | const
| inline

Return the number of voxels contained in this grid.

## ◆ xStride()

template<typename ValueT>

size_t xStride | ( |  | ) | const
| inline inherited

Return the stride of the array in the x direction ( = dimY*dimZ).

Note
  This method is required by both CopyToDense and CopyFromDense.

## ◆ yStride()

template<typename ValueT>

size_t yStride | ( |  | ) | const
| inline inherited

Return the stride of the array in the y direction ( = dimZ).

Note
  This method is required by both CopyToDense and CopyFromDense.

## ◆ zStride()

template<typename ValueT>

size_t zStride | ( |  | ) |
| inline static inherited

Return the stride of the array in the z direction ( = 1).

Note
  This method is required by both CopyToDense and CopyFromDense.

## Member Data Documentation

## ◆ mBBox

template<typename ValueT>

const CoordBBox mBBox
| protected inherited

## ◆ mX

template<typename ValueT>

const size_t mX
| protected inherited

## ◆ mY

template<typename ValueT>

const size_t mY
| protected inherited