triro 1.3.0
A Python Ray-Mesh Intersector in OptiX
Loading...
Searching...
No Matches
triro.ray.ray_optix.RayMeshIntersector Class Reference

A class for performing ray-mesh intersection tests using OptiX acceleration structure. More...

Collaboration diagram for triro.ray.ray_optix.RayMeshIntersector:

Public Member Functions

 __init__ (self, **kwargs)
 Initialize the RayMeshIntersector class.
 
 update_raw (self, Float32[torch.Tensor, "n 3"] vertices, Int32[torch.Tensor, "f 3"] faces)
 Update the raw mesh data.
 
Bool[torch.Tensor, "*b"] intersects_any (self, Float32[torch.Tensor, "*b 3"] origins, Float32[torch.Tensor, "*b 3"] directions)
 Check if any intersections occur for each ray.
 
Int32[torch.Tensor, "*b"] intersects_first (self, Float32[torch.Tensor, "*b 3"] origins, Float32[torch.Tensor, "*b 3"] directions)
 Find the index of the first intersection for each ray.
 
Tuple[ Float32[torch.Tensor, "h 3"], Int32[torch.Tensor, "h"], Int32[torch.Tensor, "h"]] intersects_location (self, Float32[torch.Tensor, "*b 3"] origins, Float32[torch.Tensor, "*b 3"] directions)
 Find the intersection location for each ray.
 
Int32[torch.Tensor, "*b 3"] intersects_count (self, Float32[torch.Tensor, "*b 3"] origins, Float32[torch.Tensor, "*b 3"] directions)
 Count the number of intersections for each ray.
 
( Tuple[ Int32[torch.Tensor, "h"], # hit triangle indices Int32[torch.Tensor, "h"], # ray indices Float32[torch.Tensor, "h 3"], # hit location]|Tuple[ Int32[torch.Tensor, "h"], Int32[torch.Tensor, "h"]] # hit triangle indices and ray indices) intersects_id (self, Float32[torch.Tensor, "*b 3"] origins, Float32[torch.Tensor, "*b 3"] directions, bool return_locations=False, bool multiple_hits=True)
 Find the intersection indices for each ray.
 
Bool[torch.Tensor, "*b 3"] contains_points (self, Float32[torch.Tensor, "*b 3"] points, Optional[Float32[torch.Tensor, "3"]] check_direction=None)
 Check if the points are contained within the mesh.
 

Public Attributes

( Tuple intersects_closest [ Bool[torch.Tensor, "*b"], # hit Bool[torch.Tensor, "*b"], # front Int32[torch.Tensor, "*b"], # triangle index Float32[torch.Tensor, "*b 3"], # intersect location Float32[torch.Tensor, "*b 2"], # uv]|Tuple[ Bool[torch.Tensor, "*b"], # hit Bool[torch.Tensor, "h"], # front Int32[torch.Tensor, "h"], # ray index Int32[torch.Tensor, "h"], # triangle index Float32[torch.Tensor, "h 3"], # intersect location Float32[torch.Tensor, "h 2"], # uv:])(self, Float32[torch.Tensor, "*b 3"] origins, Float32[torch.Tensor, "*b 3"] directions, bool stream_compaction=False)
 Find the closest intersection for each ray.
 
 mesh_vertices
 
 mesh_faces
 
 mesh_aabb
 
 as_wrapper
 

Detailed Description

A class for performing ray-mesh intersection tests using OptiX acceleration structure.

This class provides methods for checking if rays intersect with a mesh, finding the closest intersection, retrieving intersection locations, counting intersections, and more.

This class has similar functionality as the RayMeshIntersector class in trimesh.ray.

Parameters
kwargsKeyword arguments for initializing the intersector. Either 'mesh' or 'vertices' and 'faces' must be provided.

Definition at line 18 of file ray_optix.py.

Constructor & Destructor Documentation

◆ __init__()

triro.ray.ray_optix.RayMeshIntersector.__init__ (   self,
**  kwargs 
)

Initialize the RayMeshIntersector class.

Parameters
kwargsKeyword arguments for initializing the intersector. Either 'mesh' or 'vertices' and 'faces' must be provided.

Definition at line 24 of file ray_optix.py.

Member Function Documentation

◆ contains_points()

Bool[torch.Tensor, "*b 3"] triro.ray.ray_optix.RayMeshIntersector.contains_points (   self,
Float32[torch.Tensor, "*b 3"]  points,
Optional[Float32[torch.Tensor, "3"]]   check_direction = None 
)

Check if the points are contained within the mesh.

Parameters
points(Float32[torch.Tensor, "*b 3"]): The points to check.
check_direction(Optional[Float32[torch.Tensor, "3"]], optional): The direction to check. Defaults to None.
Returns
Bool[torch.Tensor, "*b 3"]: A boolean tensor indicating if each point is contained within the mesh.

Definition at line 231 of file ray_optix.py.

◆ intersects_any()

Bool[torch.Tensor, "*b"] triro.ray.ray_optix.RayMeshIntersector.intersects_any (   self,
Float32[torch.Tensor, "*b 3"]  origins,
Float32[torch.Tensor, "*b 3"]  directions 
)

Check if any intersections occur for each ray.

Parameters
origins(Float32[torch.Tensor, "*b 3"]): The origins of the rays.
directions(Float32[torch.Tensor, "*b 3"]): The directions of the rays.
Returns
Bool[torch.Tensor, "*b"]: A boolean tensor indicating if each ray intersects with the mesh.

Definition at line 77 of file ray_optix.py.

◆ intersects_count()

Int32[torch.Tensor, "*b 3"] triro.ray.ray_optix.RayMeshIntersector.intersects_count (   self,
Float32[torch.Tensor, "*b 3"]  origins,
Float32[torch.Tensor, "*b 3"]  directions 
)

Count the number of intersections for each ray.

Parameters
origins(Float32[torch.Tensor, "*b 3"]): The origins of the rays.
directions(Float32[torch.Tensor, "*b 3"]): The directions of the rays.
Returns
Int32[torch.Tensor, "*b 3"]: The number of intersections for each ray.

Definition at line 172 of file ray_optix.py.

◆ intersects_first()

Int32[torch.Tensor, "*b"] triro.ray.ray_optix.RayMeshIntersector.intersects_first (   self,
Float32[torch.Tensor, "*b 3"]  origins,
Float32[torch.Tensor, "*b 3"]  directions 
)

Find the index of the first intersection for each ray.

Parameters
origins(Float32[torch.Tensor, "*b 3"]): The origins of the rays.
directions(Float32[torch.Tensor, "*b 3"]): The directions of the rays.
Returns
Int32[torch.Tensor, "*b"]: The index of the first intersection for each ray.

Definition at line 90 of file ray_optix.py.

◆ intersects_id()

( Tuple[ Int32[torch.Tensor, "h"], # hit triangle indices Int32[torch.Tensor, "h"], # ray indices Float32[torch.Tensor, "h 3"], # hit location ] | Tuple[ Int32[torch.Tensor, "h"], Int32[torch.Tensor, "h"] ] # hit triangle indices and ray indices ) triro.ray.ray_optix.RayMeshIntersector.intersects_id (   self,
Float32[torch.Tensor, "*b 3"]  origins,
Float32[torch.Tensor, "*b 3"]  directions,
bool   return_locations = False,
bool   multiple_hits = True 
)

Find the intersection indices for each ray.

Parameters
origins(Float32[torch.Tensor, "*b 3"]): The origins of the rays.
directions(Float32[torch.Tensor, "*b 3"]): The directions of the rays.
return_locations(bool, optional): Whether to return the intersection locations. Defaults to False.
multiple_hits(bool, optional): Whether to allow multiple intersections per ray. Defaults to True.
Returns
Tuple: A tuple containing the following elements:
  • hit triangle indices (Int32[torch.Tensor, "h"]): The indices of the triangles that were hit by the rays.
  • ray indices (Int32[torch.Tensor, "h"]): The indices of the rays that had intersections.
  • hit location (Float32[torch.Tensor, "h 3"]): The 3D coordinates of the intersection points for each ray. (Only returned if return_locations is set to True)

Definition at line 191 of file ray_optix.py.

◆ intersects_location()

Tuple[ Float32[torch.Tensor, "h 3"], Int32[torch.Tensor, "h"], Int32[torch.Tensor, "h"] ] triro.ray.ray_optix.RayMeshIntersector.intersects_location (   self,
Float32[torch.Tensor, "*b 3"]  origins,
Float32[torch.Tensor, "*b 3"]  directions 
)

Find the intersection location for each ray.

Parameters
origins(Float32[torch.Tensor, "*b 3"]): The origins of the rays.
directions(Float32[torch.Tensor, "*b 3"]): The directions of the rays.
Returns
Tuple: A tuple containing the following elements:
  • intersection locations (Float32[torch.Tensor, "h 3"]): The 3D coordinates of the intersection points for each ray.
  • hit ray indices (Int32[torch.Tensor, "h"]): The indices of the rays that had intersections.
  • triangle indices (Int32[torch.Tensor, "h"]): The indices of the triangles that were intersected by the rays.

Definition at line 157 of file ray_optix.py.

◆ update_raw()

triro.ray.ray_optix.RayMeshIntersector.update_raw (   self,
Float32[torch.Tensor, "n 3"]  vertices,
Int32[torch.Tensor, "f 3"]  faces 
)

Update the raw mesh data.

Parameters
vertices(Float32[torch.Tensor, "n 3"]): The vertices of the mesh.
faces(Int32[torch.Tensor, "f 3"]): The faces of the mesh.

Definition at line 55 of file ray_optix.py.

Member Data Documentation

◆ as_wrapper

triro.ray.ray_optix.RayMeshIntersector.as_wrapper

Definition at line 48 of file ray_optix.py.

◆ intersects_closest

( Tuple triro.ray.ray_optix.RayMeshIntersector.intersects_closest[ Bool[torch.Tensor, "*b"], # hit Bool[torch.Tensor, "*b"], # front Int32[torch.Tensor, "*b"], # triangle index Float32[torch.Tensor, "*b 3"], # intersect location Float32[torch.Tensor, "*b 2"], # uv ] | Tuple[ Bool[torch.Tensor, "*b"], # hit Bool[torch.Tensor, "h"], # front Int32[torch.Tensor, "h"], # ray index Int32[torch.Tensor, "h"], # triangle index Float32[torch.Tensor, "h 3"], # intersect location Float32[torch.Tensor, "h 2"], # uv: ] )(self, Float32[torch.Tensor, "*b 3"] origins, Float32[torch.Tensor, "*b 3"] directions, bool stream_compaction=False)

Find the closest intersection for each ray.

Parameters
origins(Float32[torch.Tensor, "*b 3"]): The origins of the rays.
directions(Float32[torch.Tensor, "*b 3"]): The directions of the rays.
stream_compaction(bool, optional): Whether to perform stream compaction. Defaults to False.
Returns
Tuple: A tuple containing the following elements:
  • If stream_compaction is False:
    • hit (Bool[torch.Tensor, "*b"]): A boolean tensor indicating if each ray intersects with the mesh.
    • front (Bool[torch.Tensor, "*b"]): A boolean tensor indicating if the intersection is from the front face of the mesh.
    • triangle index (Int32[torch.Tensor, "*b"]): The index of the triangle that was intersected by each ray.
    • intersect location (Float32[torch.Tensor, "*b 3"]): The 3D coordinates of the closest intersection point.
    • uv (Float32[torch.Tensor, "*b 2"]): The UV coordinates of the closest intersection point.
  • If stream_compaction is True:
    • hit (Bool[torch.Tensor, "*b"]): A boolean tensor indicating if each ray intersects with the mesh.
    • front (Bool[torch.Tensor, "h"]): A boolean tensor indicating if the intersection is from the front face of the mesh.
    • ray index (Int32[torch.Tensor, "h"]): The index of the ray that had the closest intersection.
    • triangle index (Int32[torch.Tensor, "h"]): The index of the triangle that was intersected by the closest ray.
    • intersect location (Float32[torch.Tensor, "h 3"]): The 3D coordinates of the closest intersection point.
    • uv (Float32[torch.Tensor, "h 2"]): The UV coordinates of the closest intersection point.

Definition at line 117 of file ray_optix.py.

◆ mesh_aabb

triro.ray.ray_optix.RayMeshIntersector.mesh_aabb

Definition at line 43 of file ray_optix.py.

◆ mesh_faces

triro.ray.ray_optix.RayMeshIntersector.mesh_faces

Definition at line 31 of file ray_optix.py.

◆ mesh_vertices

triro.ray.ray_optix.RayMeshIntersector.mesh_vertices

Definition at line 29 of file ray_optix.py.


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