This class provides the public API for intersecting a ray with a generic (e.g. density) volume.
More...
#include <openvdb/tools/RayIntersector.h>
template<typename GridT, int NodeLevel = GridT::TreeType::RootNodeType::ChildNodeType::LEVEL, typename RayT = math::Ray<Real>>
class openvdb::v12_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:
iter.setIndexRay(ray);
iter.setWorldRay(ray);
double t0=0, t1=0;
while ( inter.march(t0, t1) ) {
}}
using RealType = typename RayT::RealType |
using RootType = typename GridT::TreeType::RootNodeType |
Grid constructor.
- Parameters
-
grid | Generic grid to intersect rays against. |
dilationCount | The 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
-
RuntimeError | if the voxels of the grid are not uniform or the grid is empty. |
Grid and BBox constructor.
- Parameters
-
grid | Generic grid to intersect rays against. |
bbox | The 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
-
RuntimeError | if the voxels of the grid are not uniform or the grid is empty. |
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).
Return a const reference to the BBOX of the grid.
Return the floating-point index position along the current index ray at the specified time.
Return the floating-point world position along the current index ray at the specified time.
const GridT& grid |
( |
| ) |
const |
|
inline |
Return a const reference to the input grid.
void hits |
( |
ListType & |
list | ) |
|
|
inline |
Generates a list of hits along the ray.
- Parameters
-
list | List 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>.
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
-
t0 | If the return value > 0 this is the time of the first hit of an active tile or leaf. |
t1 | If 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!
void print |
( |
std::ostream & |
os = std::cout , |
|
|
int |
verboseLevel = 1 |
|
) |
| |
|
inline |
Print bbox, statistics, memory usage and other information.
- Parameters
-
os | a stream to which to write textual information |
verboseLevel | 1: print bbox only; 2: include boolean tree statistics; 3: include memory usage |
bool setIndexRay |
( |
const RayT & |
iRay | ) |
|
|
inline |
Return false
if the index ray misses the bbox of the grid.
- Parameters
-
iRay | Ray 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
-
wRay | Ray 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.
const TreeT& tree |
( |
| ) |
const |
|
inline |
Return a const reference to the (potentially dilated) bool tree used to accelerate the ray marching.