A scene class with basic ray casting and closest point queries.
More...
#include <RaycastingScene.h>
|
| RaycastingScene (int64_t nthreads=0) |
| Default Constructor. More...
|
|
| ~RaycastingScene () |
|
uint32_t | AddTriangles (const core::Tensor &vertex_positions, const core::Tensor &triangle_indices) |
| Add a triangle mesh to the scene. More...
|
|
uint32_t | AddTriangles (const TriangleMesh &mesh) |
| Add a triangle mesh to the scene. More...
|
|
std::unordered_map< std::string, core::Tensor > | CastRays (const core::Tensor &rays, const int nthreads=0) |
| Computes the first intersection of the rays with the scene. More...
|
|
core::Tensor | TestOcclusions (const core::Tensor &rays, const float tnear=0.f, const float tfar=std::numeric_limits< float >::infinity(), const int nthreads=0) |
| Checks if the rays have any intersection with the scene. More...
|
|
core::Tensor | CountIntersections (const core::Tensor &rays, const int nthreads=0) |
| Computes the number of intersection of the rays with the scene. More...
|
|
std::unordered_map< std::string, core::Tensor > | ComputeClosestPoints (const core::Tensor &query_points, const int nthreads=0) |
| Computes the closest points on the surfaces of the scene. More...
|
|
core::Tensor | ComputeDistance (const core::Tensor &query_points, const int nthreads=0) |
| Computes the distance to the surface of the scene. More...
|
|
core::Tensor | ComputeSignedDistance (const core::Tensor &query_points, const int nthreads=0, const int nsamples=1) |
| Computes the signed distance to the surface of the scene. More...
|
|
core::Tensor | ComputeOccupancy (const core::Tensor &query_points, const int nthreads=0, const int nsamples=1) |
| Computes the occupancy at the query point positions. More...
|
|
A scene class with basic ray casting and closest point queries.
The RaycastingScene allows to compute ray intersections with triangle meshes or compute the closest point on the surface of a mesh with respect to one or more query points. It builds an internal acceleration structure to speed up those queries.
This class supports only the CPU device.
◆ RaycastingScene()
open3d::t::geometry::RaycastingScene::RaycastingScene |
( |
int64_t |
nthreads = 0 | ) |
|
◆ ~RaycastingScene()
open3d::t::geometry::RaycastingScene::~RaycastingScene |
( |
| ) |
|
◆ AddTriangles() [1/2]
uint32_t open3d::t::geometry::RaycastingScene::AddTriangles |
( |
const core::Tensor & |
vertex_positions, |
|
|
const core::Tensor & |
triangle_indices |
|
) |
| |
Add a triangle mesh to the scene.
- Parameters
-
vertex_positions | Vertices as Tensor of dim {N,3} and dtype float. |
triangle_indices | Triangles as Tensor of dim {M,3} and dtype uint32_t. |
- Returns
- The geometry ID of the added mesh.
◆ AddTriangles() [2/2]
uint32_t open3d::t::geometry::RaycastingScene::AddTriangles |
( |
const TriangleMesh & |
mesh | ) |
|
Add a triangle mesh to the scene.
- Parameters
-
- Returns
- The geometry ID of the added mesh.
◆ CastRays()
std::unordered_map< std::string, core::Tensor > open3d::t::geometry::RaycastingScene::CastRays |
( |
const core::Tensor & |
rays, |
|
|
const int |
nthreads = 0 |
|
) |
| |
Computes the first intersection of the rays with the scene.
- Parameters
-
rays | A tensor with >=2 dims, shape {.., 6}, and Dtype Float32 describing the rays. {..} can be any number of dimensions, e.g., to organize rays for creating an image the shape can be {height, width, 6}. The last dimension must be 6 and has the format [ox, oy, oz, dx, dy, dz] with [ox,oy,oz] as the origin and [dx,dy,dz] as the direction. It is not necessary to normalize the direction but the returned hit distance uses the length of the direction vector as unit. |
nthreads | The number of threads to use. Set to 0 for automatic. |
- Returns
- The returned dictionary contains:
- t_hit A tensor with the distance to the first hit. The shape is {..}. If there is no intersection the hit distance is inf .
- geometry_ids A tensor with the geometry IDs. The shape is {..}. If there is no intersection the ID is INVALID_ID .
- primitive_ids A tensor with the primitive IDs, which corresponds to the triangle index. The shape is {..}. If there is no intersection the ID is INVALID_ID .
- primitive_uvs A tensor with the barycentric coordinates of the hit points within the hit triangles. The shape is {.., 2}.
- primitive_normals A tensor with the normals of the hit triangles. The shape is {.., 3}.
◆ ComputeClosestPoints()
std::unordered_map< std::string, core::Tensor > open3d::t::geometry::RaycastingScene::ComputeClosestPoints |
( |
const core::Tensor & |
query_points, |
|
|
const int |
nthreads = 0 |
|
) |
| |
Computes the closest points on the surfaces of the scene.
- Parameters
-
query_points | A tensor with >=2 dims, shape {.., 3} and Dtype Float32 describing the query points. {..} can be any number of dimensions, e.g., to organize the query_point to create a 3D grid the shape can be {depth, height, width, 3}. The last dimension must be 3 and has the format [x, y, z]. |
nthreads | The number of threads to use. Set to 0 for automatic. |
- Returns
- The returned dictionary contains:
- points A tensor with the closest surface points. The shape is {..}.
- geometry_ids A tensor with the geometry IDs. The shape is {..}.
- primitive_ids A tensor with the primitive IDs, which corresponds to the triangle index. The shape is {..}.
- primitive_uvs A tensor with the barycentric coordinates of the closest points within the triangles. The shape is {.., 2}.
- primitive_normals A tensor with the normals of the closest triangle . The shape is {.., 3}.
◆ ComputeDistance()
core::Tensor open3d::t::geometry::RaycastingScene::ComputeDistance |
( |
const core::Tensor & |
query_points, |
|
|
const int |
nthreads = 0 |
|
) |
| |
Computes the distance to the surface of the scene.
- Parameters
-
query_points | A tensor with >=2 dims, shape {.., 3} and Dtype Float32 describing the query points. {..} can be any number of dimensions, e.g., to organize the query_point to create a 3D grid the shape can be {depth, height, width, 3}. The last dimension must be 3 and has the format [x, y, z]. |
nthreads | The number of threads to use. Set to 0 for automatic. |
- Returns
- A tensor with the distances to the surface. The shape is {..}.
◆ ComputeOccupancy()
core::Tensor open3d::t::geometry::RaycastingScene::ComputeOccupancy |
( |
const core::Tensor & |
query_points, |
|
|
const int |
nthreads = 0 , |
|
|
const int |
nsamples = 1 |
|
) |
| |
Computes the occupancy at the query point positions.
This function computes whether the query points are inside or outside. The function assumes that all meshes are watertight and that there are no intersections between meshes, i.e., inside and outside must be well defined. The function determines if a point is inside by counting the intersections of a rays starting at the query points.
- Parameters
-
query_points | A tensor with >=2 dims, shape {.., 3} and Dtype Float32 describing the query_points. {..} can be any number of dimensions, e.g., to organize the query_point to create a 3D grid the shape can be {depth, height, width, 3}. The last dimension must be 3 and has the format [x, y, z]. |
nthreads | The number of threads to use. Set to 0 for automatic. |
nsamples | The number of rays used for determining the inside. This must be an odd number. The default is 1. Use a higher value if you notice errors in the occupancy values. Errors can occur when rays hit exactly an edge or vertex in the scene. |
- Returns
- A tensor with the occupancy values. The shape is {..}. Values are either 0 or 1. A point is occupied or inside if the value is 1.
◆ ComputeSignedDistance()
core::Tensor open3d::t::geometry::RaycastingScene::ComputeSignedDistance |
( |
const core::Tensor & |
query_points, |
|
|
const int |
nthreads = 0 , |
|
|
const int |
nsamples = 1 |
|
) |
| |
Computes the signed distance to the surface of the scene.
This function computes the signed distance to the meshes in the scene. The function assumes that all meshes are watertight and that there are no intersections between meshes, i.e., inside and outside must be well defined. The function determines the sign of the distance by counting the intersections of a rays starting at the query points.
- Parameters
-
query_points | A tensor with >=2 dims, shape {.., 3} and Dtype Float32 describing the query points. {..} can be any number of dimensions, e.g., to organize the query_point to create a 3D grid the shape can be {depth, height, width, 3}. The last dimension must be 3 and has the format [x, y, z]. |
nthreads | The number of threads to use. Set to 0 for automatic. |
nsamples | The number of rays used for determining the inside. This must be an odd number. The default is 1. Use a higher value if you notice sign flipping, which can occur when rays hit exactly an edge or vertex in the scene. |
- Returns
- A tensor with the signed distances to the surface. The shape is {..}. Negative distances mean a point is inside a closed surface.
◆ CountIntersections()
core::Tensor open3d::t::geometry::RaycastingScene::CountIntersections |
( |
const core::Tensor & |
rays, |
|
|
const int |
nthreads = 0 |
|
) |
| |
Computes the number of intersection of the rays with the scene.
- Parameters
-
rays | A tensor with >=2 dims, shape {.., 6}, and Dtype Float32 describing the rays. {..} can be any number of dimensions, e.g., to organize rays for creating an image the shape can be {height, width, 6}. The last dimension must be 6 and has the format [ox, oy, oz, dx, dy, dz] with [ox,oy,oz] as the origin and [dx,dy,dz] as the direction. It is not necessary to normalize the direction. |
nthreads | The number of threads to use. Set to 0 for automatic. |
- Returns
- A tensor with the number of intersections. The shape is {..}.
◆ CreateRaysPinhole() [1/2]
Creates rays for the given camera parameters.
- Parameters
-
intrinsic_matrix | The upper triangular intrinsic matrix with shape {3,3}. |
extrinsic_matrix | The 4x4 world to camera SE(3) transformation matrix. |
width_px | The width of the image in pixels. |
height_px | The height of the image in pixels. |
- Returns
- A tensor of shape {height_px, width_px, 6} with the rays.
◆ CreateRaysPinhole() [2/2]
Creates rays for the given camera parameters.
- Parameters
-
fov_deg | The horizontal field of view in degree. |
center | The point the camera is looking at with shape {3}. |
eye | The position of the camera with shape {3}. |
up | The up-vector with shape {3}. |
width_px | The width of the image in pixels. |
height_px | The height of the image in pixels. |
- Returns
- A tensor of shape {height_px, width_px, 6} with the rays.
◆ INVALID_ID()
uint32_t open3d::t::geometry::RaycastingScene::INVALID_ID |
( |
| ) |
|
|
static |
The value for invalid IDs.
◆ TestOcclusions()
core::Tensor open3d::t::geometry::RaycastingScene::TestOcclusions |
( |
const core::Tensor & |
rays, |
|
|
const float |
tnear = 0.f , |
|
|
const float |
tfar = std::numeric_limits<float>::infinity() , |
|
|
const int |
nthreads = 0 |
|
) |
| |
Checks if the rays have any intersection with the scene.
- Parameters
-
rays | A tensor with >=2 dims, shape {.., 6}, and Dtype Float32 describing the rays. {..} can be any number of dimensions, e.g., to organize rays for creating an image the shape can be {height, width, 6}. The last dimension must be 6 and has the format [ox, oy, oz, dx, dy, dz] with [ox,oy,oz] as the origin and [dx,dy,dz] as the direction. It is not necessary to normalize the direction. |
tnear | The tnear offset for the rays. The default is 0. |
tfar | The tfar value for the ray. The default is infinity. |
nthreads | The number of threads to use. Set to 0 for automatic. |
- Returns
- A boolean tensor which indicates if the ray is occluded by the scene (true) or not (false).
The documentation for this class was generated from the following files: