Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List intersections #6442

Merged
merged 15 commits into from
Nov 3, 2023
Prev Previous commit
Next Next commit
sorting out wrong shapes and unit test error
  • Loading branch information
dmitrishastin committed Oct 29, 2023
commit 9d7dccf6df7b67eaca356528d852373c229a634d
5 changes: 3 additions & 2 deletions cpp/open3d/t/geometry/RaycastingScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,13 +868,14 @@ RaycastingScene::ListIntersections(const core::Tensor& rays,

// generate results structure
std::unordered_map<std::string, core::Tensor> result;
result["ray_splits"] = core::Tensor({cumsum.size() + 1}, core::UInt32);
shape[0] = shape[0] + 1;
result["ray_splits"] = core::Tensor(shape, core::UInt32);
uint32_t* ptr = result["ray_splits"].GetDataPtr<uint32_t>();
ptr[0] = 0;
for (int i = 1; i < cumsum.size() + 1; ++i) {
ptr[i] = cumsum[i - 1];
}
shape = {intersections_vector.sum()};
shape[0] = intersections_vector.sum();
result["ray_ids"] = core::Tensor(shape, core::UInt32);
result["geometry_ids"] = core::Tensor(shape, core::UInt32);
result["primitive_ids"] = core::Tensor(shape, core::UInt32);
Expand Down
2 changes: 1 addition & 1 deletion python/test/t/geometry/test_raycasting_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def test_list_intersections():
ans = scene.list_intersections(rays)

np.testing.assert_allclose(ans['t_hit'].numpy(),
np.array([[1.0], [2.0], [0.5]]),
np.array([1.0, 2.0, 0.5]),
rtol=1e-6,
atol=1e-6)

Expand Down