OpenVDB  2.1.0
Public Types | Public Member Functions | Friends | List of all members
VolumeRayIntersector< GridT, NodeLevel, RayT > Class Template Reference

This class provides the public API for intersecting a ray with a generic (e.g. density) volume. More...

#include <RayIntersector.h>

Public Types

typedef GridT GridType
 
typedef RayT RayType
 
typedef RayT::RealType RealType
 
typedef GridT::TreeType TreeT
 

Public Member Functions

 BOOST_STATIC_ASSERT (NodeLevel >=0 &&NodeLevel< int(TreeT::DEPTH)-1)
 
 VolumeRayIntersector (const GridT &grid)
 Constructor. More...
 
bool setIndexRay (const RayT &iRay)
 Return false if the index ray misses the bbox of the grid. More...
 
bool setWorldRay (const RayT &wRay)
 Return false if the world ray misses the bbox of the grid. More...
 
int march (Real &t0, Real &t1)
 Return 0 if not hit was detected. A return value of 1 means it hit an active tile, and a return value of 2 means it hit a LeafNode. Only when a hit is detected are t0 and t1 updated with the corresponding entry and exit times along the INDEX ray! More...
 
Vec3R getIndexPos (Real time) const
 Return the floating-point index position along the current index ray at the specified time. More...
 
Vec3R getWorldPos (Real time) const
 Return the floating-point world position along the current index ray at the specified time. More...
 

Friends

template<typename , int >
struct VolumeHDDA
 

Detailed Description

template<typename GridT, int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
class openvdb::v2_1_0::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >

This class provides the public API for intersecting a ray with a generic (e.g. density) volume.

Internally it performs the actual hierarchical tree node traversal.

Warning
Use the (default) copy-constructor to make sure each computational thread has their own instance of this class. This is important since it contains a ValueAccessor that is not thread-safe and a CoordBBox of the active voxels that should not be re-computed for each thread. However copying is very efficient.
Example:
* // Create an instance for the master thread
* VolumeRayIntersector inter(grid);
* // For each additional thread use the copy contructor. This
* // amortizes the overhead of computing the bbox of the active voxels!
* VolumeRayIntersector inter2(inter);
* // Before each ray-traversal set the index ray.
* iter.setIndexRay(ray);
* // or world ray
* iter.setWorldRay(ray);
* // Now you can begin the ray-marching using consecutive calls to VolumeRayIntersector::march
* double t0=0, t1=0;// note the entry and exit times are with respect to the INDEX ray
* while ( int n = inter.march(t0, t1) ) {// perform line-integration between t0 and t1
* if (n == 1) {//hit a tile so the value between t0 and t1 is constant
* } else {//n == 2 so we hit a leaf node and the value between t0 and t1 is unknown
* }}
*

Member Typedef Documentation

typedef GridT GridType
typedef RayT RayType
typedef RayT::RealType RealType
typedef GridT::TreeType TreeT

Constructor & Destructor Documentation

VolumeRayIntersector ( const GridT &  grid)
inline

Constructor.

Parameters
gridGeneric grid to intersect rays against.
Warning
In the near future we will add support for grids with frustrum transforms.

Member Function Documentation

BOOST_STATIC_ASSERT ( )
Vec3R getIndexPos ( Real  time) const
inline

Return the floating-point index position along the current index ray at the specified time.

Vec3R getWorldPos ( Real  time) const
inline

Return the floating-point world position along the current index ray at the specified time.

int march ( Real t0,
Real t1 
)
inline

Return 0 if not hit was detected. A return value of 1 means it hit an active tile, and a return value of 2 means it hit a LeafNode. Only when a hit is detected are t0 and t1 updated with the corresponding entry and exit times along the INDEX ray!

Parameters
t0If the return value > 0 this is the time of the first hit.
t1If the return value > 0 this is the time of the second hit.
Warning
t0 and t1 are computed with repect to the ray represented in index space of the current grid, not world space!
bool setIndexRay ( const RayT &  iRay)
inline

Return false if the index ray misses the bbox of the grid.

Parameters
iRayRay represented in index space.
Warning
Call this method (or setWorldRay) before the ray traversal starts and use the return value to decide if further marching is required.
bool setWorldRay ( const RayT &  wRay)
inline

Return false if the world ray misses the bbox of the grid.

Parameters
wRayRay represented in world space.
Warning
Call this method (or setIndexRay) before the ray traversal starts and use the return value to decide if further marching is required.

Since hit times are computed with repect to the ray represented in index space of the current grid, it is recommended that either the client code uses getIndexPos to compute index position from hit times or alternatively keeps an instance of the index ray and instead uses setIndexRay to initialize the ray.

Friends And Related Function Documentation

friend struct VolumeHDDA
friend

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