HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
openvdb::OPENVDB_VERSION_NAME::tools::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::RootNodeType 
RootType
 
typedef tree::Tree< typename
RootType::template
ValueConverter< bool >::Type > 
TreeT
 

Public Member Functions

 HBOOST_STATIC_ASSERT (NodeLevel >=0 &&NodeLevel< int(TreeT::DEPTH)-1)
 
 VolumeRayIntersector (const GridT &grid, int dilationCount=0)
 Grid constructor. More...
 
 VolumeRayIntersector (const GridT &grid, const math::CoordBBox &bbox)
 Grid and BBox constructor. More...
 
 VolumeRayIntersector (const VolumeRayIntersector &other)
 Shallow copy constructor. More...
 
 ~VolumeRayIntersector ()
 Destructor. 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...
 
RayT::TimeSpan march ()
 
bool march (RealType &t0, RealType &t1)
 Return true if the ray intersects active values, i.e. either active voxels or tiles. Only when a hit is detected are t0 and t1 updated with the corresponding entry and exit times along the INDEX ray! More...
 
template<typename ListType >
void hits (ListType &list)
 Generates a list of hits along the ray. More...
 
Vec3R getIndexPos (RealType time) const
 Return the floating-point index position along the current index ray at the specified time. More...
 
Vec3R getWorldPos (RealType time) const
 Return the floating-point world position along the current index ray at the specified time. More...
 
RealType getWorldTime (RealType time) const
 
const GridT & grid () const
 Return a const reference to the input grid. More...
 
const TreeTtree () const
 Return a const reference to the (potentially dilated) bool tree used to accelerate the ray marching. More...
 
const math::CoordBBoxbbox () const
 Return a const reference to the BBOX of the grid. More...
 
void print (std::ostream &os=std::cout, int verboseLevel=1)
 Print bbox, statistics, memory usage and other information. More...
 

Detailed Description

template<typename GridT, int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
class openvdb::OPENVDB_VERSION_NAME::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
// For each additional thread use the copy constructor. 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 ( inter.march(t0, t1) ) {
// perform line-integration between t0 and t1
}}

Definition at line 303 of file RayIntersector.h.

Member Typedef Documentation

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

Definition at line 306 of file RayIntersector.h.

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

Definition at line 307 of file RayIntersector.h.

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

Definition at line 308 of file RayIntersector.h.

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

Definition at line 309 of file RayIntersector.h.

template<typename GridT , int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
typedef tree::Tree<typename RootType::template ValueConverter<bool>::Type> openvdb::OPENVDB_VERSION_NAME::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >::TreeT

Definition at line 310 of file RayIntersector.h.

Constructor & Destructor Documentation

template<typename GridT , int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
openvdb::OPENVDB_VERSION_NAME::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >::VolumeRayIntersector ( const GridT &  grid,
int  dilationCount = 0 
)
inline

Grid constructor.

Parameters
gridGeneric grid to intersect rays against.
dilationCountThe number of voxel dilations performed on (a boolean copy of) the input grid. This allows the intersector to account for the size of interpolation kernels in client code.
Exceptions
RuntimeErrorif the voxels of the grid are not uniform or the grid is empty.

Definition at line 322 of file RayIntersector.h.

template<typename GridT , int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
openvdb::OPENVDB_VERSION_NAME::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >::VolumeRayIntersector ( const GridT &  grid,
const math::CoordBBox bbox 
)
inline

Grid and BBox constructor.

Parameters
gridGeneric grid to intersect rays against.
bboxThe axis-aligned bounding-box in the index space of the grid.
Warning
It is assumed that bbox = (min, min + dim) where min denotes to the smallest grid coordinates and dim are the integer length of the bbox.
Exceptions
RuntimeErrorif the voxels of the grid are not uniform or the grid is empty.

Definition at line 351 of file RayIntersector.h.

template<typename GridT , int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
openvdb::OPENVDB_VERSION_NAME::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >::VolumeRayIntersector ( const VolumeRayIntersector< GridT, NodeLevel, RayT > &  other)
inline

Shallow copy constructor.

Warning
This copy constructor creates shallow copies of data members of the instance passed as the argument. For performance reasons we are not using shared pointers (their mutex-lock impairs multi-threading).

Definition at line 372 of file RayIntersector.h.

template<typename GridT , int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
openvdb::OPENVDB_VERSION_NAME::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >::~VolumeRayIntersector ( )
inline

Destructor.

Definition at line 384 of file RayIntersector.h.

Member Function Documentation

template<typename GridT , int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
const math::CoordBBox& openvdb::OPENVDB_VERSION_NAME::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >::bbox ( ) const
inline

Return a const reference to the BBOX of the grid.

Definition at line 478 of file RayIntersector.h.

template<typename GridT , int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
Vec3R openvdb::OPENVDB_VERSION_NAME::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >::getIndexPos ( RealType  time) const
inline

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

Definition at line 459 of file RayIntersector.h.

template<typename GridT , int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
Vec3R openvdb::OPENVDB_VERSION_NAME::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >::getWorldPos ( RealType  time) const
inline

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

Definition at line 463 of file RayIntersector.h.

template<typename GridT , int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
RealType openvdb::OPENVDB_VERSION_NAME::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >::getWorldTime ( RealType  time) const
inline

Definition at line 465 of file RayIntersector.h.

template<typename GridT , int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
const GridT& openvdb::OPENVDB_VERSION_NAME::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >::grid ( ) const
inline

Return a const reference to the input grid.

Definition at line 471 of file RayIntersector.h.

template<typename GridT , int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
openvdb::OPENVDB_VERSION_NAME::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >::HBOOST_STATIC_ASSERT ( )
template<typename GridT , int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
template<typename ListType >
void openvdb::OPENVDB_VERSION_NAME::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >::hits ( ListType &  list)
inline

Generates a list of hits along the ray.

Parameters
listList of hits represented as time spans.
Note
ListType is a list of RayType::TimeSpan and is required to have the two methods: clear() and push_back(). Thus, it could be std::vector<typename RayType::TimeSpan> or std::deque<typename RayType::TimeSpan>.

Definition at line 452 of file RayIntersector.h.

template<typename GridT , int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
RayT::TimeSpan openvdb::OPENVDB_VERSION_NAME::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >::march ( )
inline

Definition at line 415 of file RayIntersector.h.

template<typename GridT , int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
bool openvdb::OPENVDB_VERSION_NAME::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >::march ( RealType t0,
RealType t1 
)
inline

Return true if the ray intersects active values, i.e. either active voxels or tiles. Only when a hit is detected are t0 and t1 updated with the corresponding entry and exit times along the INDEX ray!

Note
Note that t0 and t1 are only resolved at the node level (e.g. a LeafNode with active voxels) as opposed to the individual active voxels.
Parameters
t0If the return value > 0 this is the time of the first hit of an active tile or leaf.
t1If the return value > t0 this is the time of the first hit (> t0) of an inactive tile or exit point of the BBOX for the leaf nodes.
Warning
t0 and t1 are computed with respect to the ray represented in index space of the current grid, not world space!

Definition at line 436 of file RayIntersector.h.

template<typename GridT , int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
void openvdb::OPENVDB_VERSION_NAME::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >::print ( std::ostream &  os = std::cout,
int  verboseLevel = 1 
)
inline

Print bbox, statistics, memory usage and other information.

Parameters
osa stream to which to write textual information
verboseLevel1: print bbox only; 2: include boolean tree statistics; 3: include memory usage

Definition at line 484 of file RayIntersector.h.

template<typename GridT , int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
bool openvdb::OPENVDB_VERSION_NAME::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >::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.

Definition at line 391 of file RayIntersector.h.

template<typename GridT , int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
bool openvdb::OPENVDB_VERSION_NAME::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >::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 respect 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.

Definition at line 410 of file RayIntersector.h.

template<typename GridT , int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
const TreeT& openvdb::OPENVDB_VERSION_NAME::tools::VolumeRayIntersector< GridT, NodeLevel, RayT >::tree ( ) const
inline

Return a const reference to the (potentially dilated) bool tree used to accelerate the ray marching.

Definition at line 475 of file RayIntersector.h.


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