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

add add_voxel in pybind for VoxelGrid::AddVoxel #6023

Merged
merged 4 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cpp/open3d/geometry/VoxelGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ void VoxelGrid::AddVoxel(const Voxel &voxel) {
voxels_[voxel.grid_index_] = voxel;
}

void VoxelGrid::RemoveVoxel(const Eigen::Vector3i &idx) { voxels_.erase(idx); }

std::vector<bool> VoxelGrid::CheckIfIncluded(
const std::vector<Eigen::Vector3d> &queries) {
std::vector<bool> output;
Expand Down
3 changes: 3 additions & 0 deletions cpp/open3d/geometry/VoxelGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ class VoxelGrid : public Geometry3D {
/// Add a voxel with specified grid index and color.
void AddVoxel(const Voxel &voxel);

/// Remove a voxel with specified grid index.
void RemoveVoxel(const Eigen::Vector3i &idx);

/// Return a vector of 3D coordinates that define the indexed voxel cube.
std::vector<Eigen::Vector3d> GetVoxelBoundingPoints(
const Eigen::Vector3i &index) const;
Expand Down
9 changes: 9 additions & 0 deletions cpp/pybind/geometry/voxelgrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ void pybind_voxelgrid(py::module &m) {
"Returns ``True`` if the voxel grid contains voxels.")
.def("get_voxel", &VoxelGrid::GetVoxel, "point"_a,
"Returns voxel index given query point.")
.def("add_voxel", &VoxelGrid::AddVoxel, "voxel"_a,
"Add a new voxel into the VoxelGrid.")
.def("remove_voxel", &VoxelGrid::RemoveVoxel, "idx"_a,
"Remove a voxel given index.")
.def("check_if_included", &VoxelGrid::CheckIfIncluded, "queries"_a,
"Element-wise check if a query in the list is included in "
"the VoxelGrid. Queries are double precision and "
Expand Down Expand Up @@ -155,6 +159,11 @@ void pybind_voxelgrid(py::module &m) {
docstring::ClassMethodDocInject(m, "VoxelGrid", "has_voxels");
docstring::ClassMethodDocInject(m, "VoxelGrid", "get_voxel",
{{"point", "The query point."}});
docstring::ClassMethodDocInject(m, "VoxelGrid", "add_voxel",
{{"Voxel", "A new voxel."}});
docstring::ClassMethodDocInject(
m, "VoxelGrid", "remove_voxel",
{{"idx", "The grid index of the target voxel."}});
docstring::ClassMethodDocInject(
m, "VoxelGrid", "check_if_included",
{{"query", "a list of voxel indices to check."}});
Expand Down