Open3D (C++ API)  0.17.0
RaycastingScene.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <memory>
11 
12 #include "open3d/Macro.h"
13 #include "open3d/core/Tensor.h"
16 
17 namespace open3d {
18 namespace t {
19 namespace geometry {
20 
31 public:
33  RaycastingScene(int64_t nthreads = 0);
34 
36 
41  uint32_t AddTriangles(const core::Tensor &vertex_positions,
42  const core::Tensor &triangle_indices);
43 
47  uint32_t AddTriangles(const TriangleMesh &mesh);
48 
72  std::unordered_map<std::string, core::Tensor> CastRays(
73  const core::Tensor &rays, const int nthreads = 0);
74 
89  const core::Tensor &rays,
90  const float tnear = 0.f,
91  const float tfar = std::numeric_limits<float>::infinity(),
92  const int nthreads = 0);
93 
105  const int nthreads = 0);
106 
125  std::unordered_map<std::string, core::Tensor> ComputeClosestPoints(
126  const core::Tensor &query_points, const int nthreads = 0);
127 
137  core::Tensor ComputeDistance(const core::Tensor &query_points,
138  const int nthreads = 0);
139 
162  core::Tensor ComputeSignedDistance(const core::Tensor &query_points,
163  const int nthreads = 0,
164  const int nsamples = 1);
165 
188  core::Tensor ComputeOccupancy(const core::Tensor &query_points,
189  const int nthreads = 0,
190  const int nsamples = 1);
191 
200  static core::Tensor CreateRaysPinhole(const core::Tensor &intrinsic_matrix,
201  const core::Tensor &extrinsic_matrix,
202  int width_px,
203  int height_px);
204 
214  static core::Tensor CreateRaysPinhole(double fov_deg,
215  const core::Tensor &center,
216  const core::Tensor &eye,
217  const core::Tensor &up,
218  int width_px,
219  int height_px);
220 
222  static uint32_t INVALID_ID();
223 
224 private:
225  struct Impl;
226  std::unique_ptr<Impl> impl_;
227 };
228 
229 } // namespace geometry
230 } // namespace t
231 } // namespace open3d
Definition: Tensor.h:32
A scene class with basic ray casting and closest point queries.
Definition: RaycastingScene.h:30
~RaycastingScene()
Definition: RaycastingScene.cpp:558
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.
Definition: RaycastingScene.cpp:621
core::Tensor ComputeDistance(const core::Tensor &query_points, const int nthreads=0)
Computes the distance to the surface of the scene.
Definition: RaycastingScene.cpp:721
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.
Definition: RaycastingScene.cpp:651
static core::Tensor CreateRaysPinhole(const core::Tensor &intrinsic_matrix, const core::Tensor &extrinsic_matrix, int width_px, int height_px)
Creates rays for the given camera parameters.
Definition: RaycastingScene.cpp:858
core::Tensor CountIntersections(const core::Tensor &rays, const int nthreads=0)
Computes the number of intersection of the rays with the scene.
Definition: RaycastingScene.cpp:672
static uint32_t INVALID_ID()
The value for invalid IDs.
Definition: RaycastingScene.cpp:956
RaycastingScene(int64_t nthreads=0)
Default Constructor.
Definition: RaycastingScene.cpp:539
core::Tensor ComputeOccupancy(const core::Tensor &query_points, const int nthreads=0, const int nsamples=1)
Computes the occupancy at the query point positions.
Definition: RaycastingScene.cpp:843
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.
Definition: RaycastingScene.cpp:815
uint32_t AddTriangles(const core::Tensor &vertex_positions, const core::Tensor &triangle_indices)
Add a triangle mesh to the scene.
Definition: RaycastingScene.cpp:563
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.
Definition: RaycastingScene.cpp:691
A triangle mesh contains vertices and triangles.
Definition: TriangleMesh.h:92
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c k4a_image_t image_handle uint8_t image_handle image_handle image_handle image_handle uint32_t
Definition: K4aPlugin.cpp:548
Definition: PinholeCameraIntrinsic.cpp:16
Definition: RaycastingScene.cpp:259