OpenVDB  1.2.0
Public Types | Public Member Functions | List of all members
Dense< ValueT > Class Template Reference

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

#include <Dense.h>

Public Types

typedef ValueT ValueType
 

Public Member Functions

 Dense (const CoordBBox &bbox)
 Construct a dense grid with a given range of coordinates. More...
 
 Dense (const CoordBBox &bbox, const ValueT &value)
 Construct a dense grid with a given range of coordinates and initial value. More...
 
 Dense (const CoordBBox &bbox, ValueT *data)
 Construct a dense grid that wraps an external array. More...
 
 Dense (const Coord &dim, const Coord &min=Coord(0))
 Construct a dense grid with a given origin and dimensions. More...
 
ValueT * data ()
 Return a raw pointer to this grid's value array. More...
 
const ValueT * data () const
 Return a raw pointer to this grid's value array. More...
 
const CoordBBoxbbox () const
 Return the bounding box of the signed index domain of this grid. More...
 
size_t xStride () const
 Return the stride of the array in the x direction ( = dimY*dimZ). More...
 
size_t yStride () const
 Return the stride of the array in the y direction ( = dimZ). More...
 
size_t valueCount () const
 Return the number of voxels contained in this grid. More...
 
void setValue (size_t offset, const ValueT &value)
 Set the value of the voxel at the given array offset. More...
 
const ValueT & getValue (size_t offset) const
 Return the value of the voxel at the given array offset. More...
 
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). More...
 
const ValueT & getValue (size_t i, size_t j, size_t k) const
 Return the value of the voxel at unsigned index coordinates (i, j, k). More...
 
void setValue (const Coord &xyz, const ValueT &value)
 Set the value of the voxel at the given signed coordinates. More...
 
const ValueT & getValue (const Coord &xyz) const
 Return the value of the voxel at the given signed coordinates. More...
 
void fill (const ValueT &value)
 Fill this grid with a constant value. More...
 
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. More...
 
size_t coordToOffset (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. More...
 
Index64 memUsage () const
 

Detailed Description

template<typename ValueT>
class openvdb::v1_2_0::tools::Dense< ValueT >

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 corresponding 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 assumes a data layout where z is the fastest-changing index (because that is the layout used by OpenVDB grids).

Member Typedef Documentation

typedef ValueT ValueType

Constructor & Destructor Documentation

Dense ( const CoordBBox bbox)
inline

Construct a dense grid with a given range of coordinates.

Parameters
bboxthe bounding box of the (signed) coordinate range of this grid
Exceptions
ValueErrorif the bounding box is empty.
Dense ( const CoordBBox bbox,
const ValueT &  value 
)
inline

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

Parameters
bboxthe bounding box of the (signed) coordinate range of this grid
valuethe initial value of the grid.
Exceptions
ValueErrorif the bounding box is empty.
Dense ( const CoordBBox bbox,
ValueT *  data 
)
inline

Construct a dense grid that wraps an external array.

Parameters
bboxthe bounding box of the (signed) coordinate range of this grid
dataa 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
ValueErrorif the bounding box is empty.
Dense ( const Coord dim,
const Coord min = Coord(0) 
)
inline

Construct a dense grid with a given origin and dimensions.

Parameters
dimthe desired dimensions of the grid
minthe signed coordinates of the first voxel in the dense grid
Exceptions
ValueErrorif any of the dimensions are zero.

Member Function Documentation

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.
size_t coordToOffset ( size_t  i,
size_t  j,
size_t  k 
) const
inline

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.

Note
This method reflects the fact that we assume the same layout of values as an OpenVDB grid, i.e., the fastest coordinate is k.
size_t coordToOffset ( 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.
ValueT* data ( )
inline

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

Note
This method is required by CopyToDense.
const ValueT* data ( ) const
inline

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

Note
This method is required by CopyFromDense.
void fill ( const ValueT &  value)
inline

Fill this grid with a constant value.

const ValueT& getValue ( size_t  offset) const
inline

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

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

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

Note
This is somewhat slower than using an array offset.
const ValueT& getValue ( const Coord xyz) const
inline

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

Note
This is slower than using either an array offset or unsigned index coordinates.
Index64 memUsage ( ) const
inline
void setValue ( size_t  offset,
const ValueT &  value 
)
inline

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

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.
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.
size_t valueCount ( ) const
inline

Return the number of voxels contained in this grid.

size_t xStride ( ) const
inline

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

Note
This method is required by both CopyToDense and CopyFromDense.
size_t yStride ( ) const
inline

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

Note
This method is required by both CopyToDense and CopyFromDense.

The documentation for this class was generated from the following file: