RTI
-
namespace double_down
-
class RayTracingInterface
- #include <RTI.hpp>
Interface for constructing BVH’s, firing rays, and performing point containment checks.
Public Functions
-
RayTracingInterface(moab::Interface *mbi)
Constructor taking a MOAB interface pointer. A GeomTopoTool will be created internally for this instance.
- Parameters
mbi – Pointer to a moab::Interface.
Constructor taking a GeomTopoTool shared pointer.
- Parameters
gtt – Shared pointer to a moab::GeomTopoTool object.
-
inline RayTracingInterface()
Default constructor, both a MOAB instance and GeomTopoTool object will be created internally.
-
inline ~RayTracingInterface()
Destructor. Clears all storage and removes all Embree scenes and geometries.
-
moab::ErrorCode load_file(std::string filename)
Load a file to be used for the RTI.
- Parameters
filename – Path to the mesh file to load.
-
std::string git_sha() const
Returns the git sha used to compile the executable (if available).
-
moab::ErrorCode init()
Initialize the RTI, building acceleration datastructures and internal storage. Assumes that the MOAB file is already open.
-
void shutdown()
Release all Embree scenes and device.
-
moab::ErrorCode point_in_volume(const moab::EntityHandle volume, const double xyz[3], int &result, const double *uvw, const moab::GeomQueryTool::RayHistory *history, double overlap_tol = 0.0)
Check location
xyzfor containment in the specifiedvolume. Performs a point containment query by firing a single ray and checking the dot product of the ray direction and the sense-adjusted normal of the triangle hit. Falls back onto RayTracingInterface::point_in_volume_slow() in ambiguous situations.- Parameters
volume – MOAB EntityHandle of the volume to check for containment.
xyz – Location to check.
result – Result of the query (1 if inside, 0 if outside).
uvw – Ray direction to use in the query (randomly generated if one is not provided).
history – RayHistory object, used to ?? if provided.
overlap_tol – Maximum distance tolerated for self-overlapping volumes.
-
moab::ErrorCode point_in_volume_slow(moab::EntityHandle volume, const double xyz[3], int &result)
A slower, robust method for point containment of location
xyzinvolume. This method fires infinitely long rays in opposing directions and collects all intersections along the ray. The number of exiting/entering intersections are used to determine the points containment in the volume.- Parameters
volume – MOAB EntityHandle of the volume to check for containment.
xyz – Location to check.
result – Result of the query (1 if inside, 0 if outside).
-
moab::ErrorCode poly_solid_angle(moab::EntityHandle face, const moab::CartVect &point, double &solid_angle)
Calculates the solid angle of a polygon,
face, with respect topoint. This method is adapted from “Point in Polyhedron Testing Using Spherical Polygons”, Paulo Cezar Pinto Carvalho and Paulo Roma Cavalcanti, Graphics Gems V, pg. 42. Original algorithm was described in “An Efficient Point In Polyhedron Algorithm”, Jeff Lane, Bob Magedson, and Mike Rarick, Computer Vision, Graphics, and Image Processing 26, pg. 118-225, 1984.- Parameters
face – MOAB EntityHandle for the face.
point – MOAB CartVect of the location to use fo the solid angle.
solid_angle – Solid angle of the polygon,
face, with respect topoint.
-
void boundary_case(moab::EntityHandle volume, int &result, double u, double v, double w, moab::EntityHandle facet, moab::EntityHandle surface)
-
moab::ErrorCode test_volume_boundary(const moab::EntityHandle volume, const moab::EntityHandle surface, const double xyz[3], const double uvw[3], int &result, const moab::GeomQueryTool::RayHistory *history = 0)
-
moab::ErrorCode ray_fire(const moab::EntityHandle volume, const double point[3], const double dir[3], moab::EntityHandle &next_surf, double &next_surf_dist, moab::GeomQueryTool::RayHistory *history = 0, double user_dist_limit = 0, int ray_orientation = 1, void *dum = NULL)
-
moab::ErrorCode get_obb(moab::EntityHandle volume, std::array<double, 3> ¢er, std::array<double, 3> &axis0, std::array<double, 3> &axis1, std::array<double, 3> &axis2)
Get the oriented bounding box for the specified
volume.- Parameters
volume – MOAB EntityHandle of the volume.
center – Coordinates for the center of the bounding box.
axis0 – Scaled vector from the center to the edge of the box along axis 0. (Always along x-axis)
axis1 – Scaled vector from the center to the edge of the box along axis 1. (Always along y-axis)
axis2 – Scaled vector from the center to the edge of the box along axis 2. (Always along z-axis)
-
moab::ErrorCode get_obb(moab::EntityHandle volume, double center[3], double axis0[3], double axis1[3], double axis2[3])
-
moab::ErrorCode get_bbox(moab::EntityHandle volume, std::array<double, 3> &llc, std::array<double, 3> &urc)
Get an axis-aligned bounding bos for the specified
volume.- Parameters
volume – MOAB EntityHandle of the volume.
llc – x,y,z coordinates for the lower left corner of the box.
urc – x,y,z coordinates for the upper right corner of the box.
-
moab::ErrorCode get_bbox(moab::EntityHandle volume, double llc[3], double urc[3])
Get an axis-aligned bounding bos for the specified
volume.- Parameters
volume – MOAB EntityHandle of the volume.
llc – x,y,z coordinates for the lower left corner of the box.
urc – x,y,z coordinates for the upper right corner of the box.
-
moab::ErrorCode get_vols(moab::Range &vols)
Get a MOAB Range of all the volumes in the RayTracingInterface.
- Parameters
vols – Set to the range of volumes in the RayTracingInterface.
-
void fire(moab::EntityHandle volume, RTCDRayHit &rayhit)
Wrapper call for firing a ray in Embree. Separate from the calls made in RayTracingInterface::ray_fire.
- Parameters
volume – MOAB EntityHandle of the volume.
-
moab::ErrorCode allocateTriangleBuffer(moab::EntityHandle volume)
Allocates space for triangle reference information for the volume.
- Parameters
volume – MOAB EntityHandle of the volume.
-
moab::ErrorCode createBVH(moab::EntityHandle volume)
Creates the BVH for the specified volume. In addition to creating the BVH using Embree, this function ensures that DblTri’s connecting the MOAB triangles to the user-defined geometry in Embree are allocated and stored for the volume.
- Parameters
volume – MOAB EntityHandle of the volume.
-
void deleteBVH(moab::EntityHandle volume)
Deletes the BVH for the volume if present.
- Parameters
volume – MOAB EntityHandle of the volume.
-
moab::ErrorCode closest_to_location(moab::EntityHandle volume, const double point[3], double &result, moab::EntityHandle *closest_surf = 0)
Finds the distance to the closest point on the
volumefrom a specified location,point.- Parameters
volume – MOAB EntityHandle of the volume.
point – x,y,z coordinates of the query location.
result – Set to the distance of the nearest point on the
volume.closest_surf – If provided, set to the MOAB EntityHandle of the nearest surface to
point.
-
void closest(moab::EntityHandle volume, const double loc[3], double &result, moab::EntityHandle *surface = 0, moab::EntityHandle *facet = 0)
Internal function for getting the closest intersection to
locon thevolume.- Parameters
volume – MOAB EntityHandle of the volume.
loc – x,y,z coordinates of the query location.
result – Set to the distance of the nearest location on the
volume.surface – If present, set to the MOAB EntityHandle of the nearest surface.
facet – If present, set to the MOAB EntityHandle of the triangle containing the nearest point.
-
moab::ErrorCode get_normal(moab::EntityHandle surface, const double loc[3], double angle[3], const moab::GeomQueryTool::RayHistory *history = 0)
Finds the normal of the nearest location on the provided
surface.- Parameters
surface – MOAB EntityHandle of the surface.
loc – x,y,z coordinates of the query location.
angle – u,v,w components of the direction unit vector.
history – If provided, the last facet in the history is used to determine the normal.
-
moab::ErrorCode measure_volume(moab::EntityHandle volume, double &result)
Returns the volume of the specified
volume.- Parameters
volume – MOAB EntityHandle of the volume.
result – Set to the size of the volume.
-
moab::ErrorCode measure_area(moab::EntityHandle surface, double &result)
Returns the surface of the specified
surface.- Parameters
surface – MOAB EntityHandle of the surface.
result – Set to the size of the surface.
-
bool has_bvh() const
Indicates whether or not acceleration data structures are present.
-
inline double get_numerical_precision()
Accessor for the numerical precision.
-
inline double get_overlap_thickness()
Accessor fo the allowed overlap thickness of self-intersecting volumes.
-
inline void set_numerical_precision(double val)
Sets the value of numerical precision.
- Parameters
val – New value for the numerical precision.
-
inline void set_overlap_thickness(double val)
Sets the value of overlap thickness.
- Parameters
val – New value for the overlap thickness.
-
inline std::shared_ptr<MBDirectAccess> direct_access_manager()
Accessor for the MBDirectAccess object.
Private Members
-
std::shared_ptr<MBDirectAccess> mdam
MBDirectAccess instance.
-
DblTriStorage buffer_storage
Per-volume storage for DblTri instances.
-
std::unordered_map<moab::EntityHandle, RTCScene> scene_map
Mapping from MOAB volume EntityHandle’s to Embree Scenes.
-
double numerical_precision = {1E-3}
Numerical precision for triangle intersections.
-
double overlap_thickness = {0.0}
Allowed overlap thickness for self-intersecting volumes.
-
RTCDevice g_device = {nullptr}
Embree device object.
-
class DblTriStorage
This class is used to manage storage of Dbltri objects for each volume.
Public Functions
-
inline bool is_storing(moab::EntityHandle vol)
Determine if a volume has DblTri objects being stored.
-
inline void store(moab::EntityHandle vol, std::vector<DblTri> &&buffer)
Store a set of DblTris for a volume.
-
inline std::vector<DblTri> &retrieve_buffer(moab::EntityHandle vol)
Retrieve the DblTri’s for the specified volume.
-
inline const std::vector<DblTri> &retrieve_buffer(moab::EntityHandle vol) const
Retrieve the DblTri’s for the specified volume.
-
inline void clear()
Clear all storage.
-
inline bool is_storing(moab::EntityHandle vol)
-
RayTracingInterface(moab::Interface *mbi)
-
class RayTracingInterface
DualRay
-
namespace double_down
-
-
struct RTCDHit : public RTCHit
- #include <ray.h>
Structure extending Embree’s RayHit to include a double precision version of the primitive normal
Subclassed by MBHit
Public Members
-
Vec3da dNg
Double precision version of the primitive normal.
-
Vec3da dNg
-
struct RTCDPointQuery : public RTCPointQuery
- #include <ray.h>
Structure extending Embree’s RTCPointQuery to include double precision values
-
struct RTCDRay : public RTCRay
- #include <ray.h>
Stucture that is an extension of Embree’s RTCRay with double precision versions of the origin, direction and intersection distance.
Subclassed by MBRay
Public Functions
-
inline void set_org(double o[3])
Set both the single and double precision versions of the ray origin.
-
inline void set_org(const double o[3])
Set both the single and double precision versions of the ray origin.
-
inline void set_org(const Vec3da &o)
Set both the single and double precision versions of the ray origin.
-
inline void set_dir(double o[3])
Set both the single and double precision versions of the ray direction.
-
inline void set_dir(const double o[3])
Set both the single and double precision versions of the ray direction.
-
inline void set_dir(const Vec3da &o)
Set both the single and double precision versions of the ray direction.
-
inline void set_len(double len)
Set both the single and double precision versions of the ray length.
Public Members
-
RayFireType rf_type
Enum indicating the type of query this ray is used for.
-
Vec3da dorg
-
Vec3da ddir
double precision versions of the origin and ray direction
-
double dtfar
double precision version of the ray length
-
inline void set_org(double o[3])
-
struct RTCDHit : public RTCHit
MOABRay
Functions
-
double dot_prod(RTCDRay ray)
-
void count_hits(MBRayAccumulate *ray)
-
void MBDblTriIntersectFunc(RTCIntersectFunctionNArguments *args)
-
struct MBHit : public double_down::RTCDHit
- #include <MOABRay.h>
Extension of the single/double precision ray hit to include MOAB handles
Public Functions
-
inline MBHit()
-
inline MBHit()
-
struct MBRay : public double_down::RTCDRay
- #include <MOABRay.h>
Extension of the single/couble precision ray to include an orientation and RayHistory
Subclassed by MBRayAccumulate
Public Functions
-
inline MBRay()
-
inline MBRay()
-
struct MBRayHit
- #include <MOABRay.h>
Struct combining the MBRay and MBHit into a struct that can be passed to Embree’s rtcIntersect
Public Functions
-
inline double dot_prod()
Compute the dot product of the ray direction and triangle normal for the current hit.
-
inline double dot_prod()
-
struct MBRayAccumulate : public MBRay
- #include <MOABRay.h>
Extension of the MOAB ray to accumulate all triangle hits for robust point containment checks
Public Functions
-
inline MBRayAccumulate()
-
inline MBRayAccumulate()
-
struct MBRayHitAccumulate
- #include <MOABRay.h>
Struct combining MBRayAccumulate and MBHit that can be passed to Embree’s rtcIntersect
Public Functions
-
inline double dot_prod()
-
inline double dot_prod()
MBDirectAccess
-
class MBDirectAccess
- #include <MOABDirectAccess.h>
Class to manage direct access of triangle connectivity and coordinates
Public Functions
-
MBDirectAccess(Interface *mbi)
-
void setup()
Initialize internal structures.
-
void clear()
Reset internal data structures, but maintain MOAB isntance.
-
void update()
Update internal data structures to account for changes in the MOAB instance.
-
inline bool accessible(EntityHandle tri)
Check that a triangle is part of the managed coordinates here.
-
inline std::array<moab::CartVect, 3> get_mb_coords(const EntityHandle &tri)
Get the coordinates of a triangle as MOAB CartVect’s.
-
inline std::array<Vec3da, 3> get_coords(const EntityHandle &tri)
Get the coordinates of a triangle as Vec3da’s.
-
inline int n_elements()
return the number of elements being managed
-
inline int n_vertices()
return the number of vertices being managed
-
inline int stride()
return the stride between elements in the coordinate arrays
Private Members
-
Interface *mbi = {nullptr}
MOAB instance for the managed data.
-
int num_elements_ = {-1}
Number of elements in the manager.
-
int num_vertices_ = {-1}
Number of vertices in the manager.
-
int element_stride_ = {-1}
Number of vertices used by each element.
-
std::vector<std::pair<EntityHandle, size_t>> first_elements_
Pairs of first element and length pairs for contiguous blocks of memory.
-
std::vector<const EntityHandle*> vconn_
Storage array(s) for the connectivity array.
-
std::vector<double*> tx_
Storage array(s) for vertex x coordinates.
-
std::vector<double*> ty_
Storage array(s) for vertex y coordinates.
-
std::vector<double*> tz_
Storage array(s) for vertex z coordinates.
-
MBDirectAccess(Interface *mbi)
-
namespace moab
Double Precision Primitives & Intersection Functions
-
namespace double_down
Functions
-
inline RTCBounds DblTriBounds(MBDirectAccess *mdam, moab::EntityHandle tri_handle, double bump_val = 5e-03)
Function returning the extended bounds of a double precision MOAB triangle.
-
void DblTriBounds(const RTCBoundsFunctionArguments *args)
Function returning the extended bounds of a double precision MOAB triangle.
-
void DblTriIntersectFunc(RTCIntersectFunctionNArguments *args)
Function for intersecting a ray with a double-precision triangle.
-
void DblTriOccludedFunc(RTCOccludedFunctionNArguments *args)
Function for intersecting a ray with a double-precision triangle.
-
bool DblTriPointQueryFunc(RTCPointQueryFunctionArguments *args)
Function for determining the closest point on a triangle to the ray origin.
-
struct DblTri
- #include <primitives.hpp>
Structure with triangle information used in Embree
-
struct UserData
- #include <primitives.hpp>
Structure for linking primitive data with surfaces
-
inline RTCBounds DblTriBounds(MBDirectAccess *mdam, moab::EntityHandle tri_handle, double bump_val = 5e-03)