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

Fixed corrupted default values in documentation #7148

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions cpp/open3d/core/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ static Device::DeviceType StringToDeviceType(const std::string& type_colon_id) {
} else {
utility::LogError(
"Invalid device string {}. Valid device strings are like "
"\"CPU:0\" or \"CUDA:1\"",
"\"CPU:0\", \"CUDA:1\" or \"SYCL:0\"",
type_colon_id);
}
} else {
utility::LogError(
"Invalid device string {}. Valid device strings are like "
"\"CPU:0\" or \"CUDA:1\"",
"\"CPU:0\", \"CUDA:1\" or \"SYCL:0\"",
type_colon_id);
}
}
Expand All @@ -51,7 +51,7 @@ static int StringToDeviceId(const std::string& type_colon_id) {
} else {
utility::LogError(
"Invalid device string {}. Valid device strings are like "
"\"CPU:0\" or \"CUDA:1\"",
"\"CPU:0\", \"CUDA:1\" or \"SYCL:0\"",
type_colon_id);
}
}
Expand Down
20 changes: 19 additions & 1 deletion cpp/pybind/core/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ void pybind_core_device_declarations(py::module &m) {
py::enum_<Device::DeviceType>(device, "DeviceType")
.value("CPU", Device::DeviceType::CPU)
.value("CUDA", Device::DeviceType::CUDA)
.value("SYCL", Device::DeviceType::SYCL)
.export_values();
}
void pybind_core_device_definitions(py::module &m) {
Expand All @@ -31,7 +32,24 @@ void pybind_core_device_definitions(py::module &m) {
device.def(py::init<const std::string &>());
device.def("__eq__", &Device::operator==);
device.def("__ene__", &Device::operator!=);
device.def("__repr__", &Device::ToString);
device.def("__repr__", [](const Device &d) {
std::string device_type;
switch (d.GetType()) {
case Device::DeviceType::CPU:
device_type = "CPU";
break;
case Device::DeviceType::CUDA:
device_type = "CUDA";
break;
case Device::DeviceType::SYCL:
device_type = "SYCL";
break;
default:
utility::LogError("Unknown device type");
return d.ToString();
}
return fmt::format("Device(\"{}\", {})", device_type, d.GetID());
});
device.def("__str__", &Device::ToString);
device.def("get_type", &Device::GetType);
device.def("get_id", &Device::GetID);
Expand Down
68 changes: 35 additions & 33 deletions cpp/pybind/geometry/voxelgrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ void pybind_voxelgrid_declarations(py::module &m) {
voxelgrid(m, "VoxelGrid",
"VoxelGrid is a collection of voxels which are aligned "
"in grid.");
py::enum_<VoxelGrid::VoxelPoolingMode>(
voxelgrid, "VoxelPoolingMode",
"Mode of determining color for each voxel.")
.value("AVG", VoxelGrid::VoxelPoolingMode::AVG)
.value("MIN", VoxelGrid::VoxelPoolingMode::MIN)
.value("MAX", VoxelGrid::VoxelPoolingMode::MAX)
.value("SUM", VoxelGrid::VoxelPoolingMode::SUM);
}
void pybind_voxelgrid_definitions(py::module &m) {
auto voxel = static_cast<py::class_<Voxel, std::shared_ptr<Voxel>>>(
Expand Down Expand Up @@ -64,14 +71,6 @@ void pybind_voxelgrid_definitions(py::module &m) {
std::shared_ptr<VoxelGrid>, Geometry3D>>(
m.attr("VoxelGrid"));

py::enum_<VoxelGrid::VoxelPoolingMode> pooling_mode(
voxelgrid, "VoxelPoolingMode",
"Mode of determining color for each voxel.");
pooling_mode.value("AVG", VoxelGrid::VoxelPoolingMode::AVG)
.value("MIN", VoxelGrid::VoxelPoolingMode::MIN)
.value("MAX", VoxelGrid::VoxelPoolingMode::MAX)
.value("SUM", VoxelGrid::VoxelPoolingMode::SUM);

py::detail::bind_default_constructor<VoxelGrid>(voxelgrid);
py::detail::bind_copy_functions<VoxelGrid>(voxelgrid);
voxelgrid
Expand Down Expand Up @@ -135,26 +134,29 @@ void pybind_voxelgrid_definitions(py::module &m) {
"carving",
"origin"_a, "color"_a, "voxel_size"_a, "width"_a,
"height"_a, "depth"_a)
.def_static("create_from_point_cloud",
&VoxelGrid::CreateFromPointCloud,
"Creates a VoxelGrid from a given PointCloud. The "
"color value of a given voxel is determined by the "
"VoxelPoolingMode, e.g. by default the average color "
"value of the points that fall into it (if the "
"PointCloud has colors). The bounds of the created "
"VoxelGrid are computed from the PointCloud.",
"input"_a, "voxel_size"_a,
"pooling_mode"_a = VoxelGrid::VoxelPoolingMode::AVG)
.def_static("create_from_point_cloud_within_bounds",
&VoxelGrid::CreateFromPointCloudWithinBounds,
"Creates a VoxelGrid from a given PointCloud. The "
"color value of a given voxel is determined by the "
"VoxelPoolingMode, e.g. by default the average color "
"value of the points that fall into it (if the "
"PointCloud has colors). The bounds of the created "
"VoxelGrid are defined by the given parameters.",
"input"_a, "voxel_size"_a, "min_bound"_a, "max_bound"_a,
"pooling_mode"_a = VoxelGrid::VoxelPoolingMode::AVG)
.def_static(
"create_from_point_cloud", &VoxelGrid::CreateFromPointCloud,
"Creates a VoxelGrid from a given PointCloud. The "
"color value of a given voxel is determined by the "
"VoxelPoolingMode, e.g. by default the average color "
"value of the points that fall into it (if the "
"PointCloud has colors). The bounds of the created "
"VoxelGrid are computed from the PointCloud.",
"input"_a, "voxel_size"_a,
py::arg_v("pooling_mode", VoxelGrid::VoxelPoolingMode::AVG,
"VoxelPoolingMode.AVG"))
.def_static(
"create_from_point_cloud_within_bounds",
&VoxelGrid::CreateFromPointCloudWithinBounds,
"Creates a VoxelGrid from a given PointCloud. The "
"color value of a given voxel is determined by the "
"VoxelPoolingMode, e.g. by default the average color "
"value of the points that fall into it (if the "
"PointCloud has colors). The bounds of the created "
"VoxelGrid are defined by the given parameters.",
"input"_a, "voxel_size"_a, "min_bound"_a, "max_bound"_a,
py::arg_v("pooling_mode", VoxelGrid::VoxelPoolingMode::AVG,
"VoxelPoolingMode.AVG"))
.def_static("create_from_triangle_mesh",
&VoxelGrid::CreateFromTriangleMesh,
"Creates a VoxelGrid from a given TriangleMesh. No "
Expand Down Expand Up @@ -221,20 +223,20 @@ void pybind_voxelgrid_definitions(py::module &m) {
m, "VoxelGrid", "create_dense",
{{"origin", "Coordinate center of the VoxelGrid"},
{"color", "Voxel color for all voxels if the VoxelGrid."},
{"voxel_size", "Voxel size of of the VoxelGrid construction."},
{"voxel_size", "Voxel size of the VoxelGrid construction."},
{"width", "Spatial width extend of the VoxelGrid."},
{"height", "Spatial height extend of the VoxelGrid."},
{"depth", "Spatial depth extend of the VoxelGrid."}});
docstring::ClassMethodDocInject(
m, "VoxelGrid", "create_from_point_cloud",
{{"input", "The input PointCloud"},
{"voxel_size", "Voxel size of of the VoxelGrid construction."},
{"voxel_size", "Voxel size of the VoxelGrid construction."},
{"pooling_mode",
"VoxelPoolingMode for determining voxel color."}});
docstring::ClassMethodDocInject(
m, "VoxelGrid", "create_from_point_cloud_within_bounds",
{{"input", "The input PointCloud"},
{"voxel_size", "Voxel size of of the VoxelGrid construction."},
{"voxel_size", "Voxel size of the VoxelGrid construction."},
{"min_bound",
"Minimum boundary point for the VoxelGrid to create."},
{"max_bound",
Expand All @@ -245,11 +247,11 @@ void pybind_voxelgrid_definitions(py::module &m) {
docstring::ClassMethodDocInject(
m, "VoxelGrid", "create_from_triangle_mesh",
{{"input", "The input TriangleMesh"},
{"voxel_size", "Voxel size of of the VoxelGrid construction."}});
{"voxel_size", "Voxel size of the VoxelGrid construction."}});
docstring::ClassMethodDocInject(
m, "VoxelGrid", "create_from_triangle_mesh_within_bounds",
{{"input", "The input TriangleMesh"},
{"voxel_size", "Voxel size of of the VoxelGrid construction."},
{"voxel_size", "Voxel size of the VoxelGrid construction."},
{"min_bound",
"Minimum boundary point for the VoxelGrid to create."},
{"max_bound",
Expand Down
22 changes: 11 additions & 11 deletions cpp/pybind/t/geometry/trianglemesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void pybind_trianglemesh_definitions(py::module& m) {
R"(Compute the convex hull of a point cloud using qhull. This runs on the CPU.

Args:
joggle_inputs (bool with default False): Handle precision problems by
joggle_inputs (bool, default=False): Handle precision problems by
randomly perturbing the input data. Set to True if perturbing the input
iis acceptable but you need convex simplicial output. If False,
neighboring facets may be merged in case of precision problems. See
Expand Down Expand Up @@ -1147,17 +1147,17 @@ Example::

triangle_mesh.def("compute_metrics", &TriangleMesh::ComputeMetrics,
"mesh2"_a, "metrics"_a, "params"_a,
R"(Compute various metrics between two triangle meshes.
This uses ray casting for distance computations between a sampled point cloud
and a triangle mesh. Currently, Chamfer distance, Hausdorff distance and
F-Score `[Knapitsch2017] <../tutorial/reference.html#Knapitsch2017>`_ are supported.
R"(Compute various metrics between two triangle meshes.

This uses ray casting for distance computations between a sampled point cloud
and a triangle mesh. Currently, Chamfer distance, Hausdorff distance and
F-Score `[Knapitsch2017] <../tutorial/reference.html#Knapitsch2017>`_ are supported.
The Chamfer distance is the sum of the mean distance to the nearest neighbor from
the sampled surface points of the first mesh to the second mesh and vice versa.
The F-Score at the fixed threshold radius is the harmonic mean of the Precision
and Recall. Recall is the percentage of surface points from the first mesh that
have the second mesh within the threshold radius, while Precision is the
percentage of sampled points from the second mesh that have the first mesh
the sampled surface points of the first mesh to the second mesh and vice versa.
The F-Score at the fixed threshold radius is the harmonic mean of the Precision
and Recall. Recall is the percentage of surface points from the first mesh that
have the second mesh within the threshold radius, while Precision is the
percentage of sampled points from the second mesh that have the first mesh
surface within the threhold radius.

.. math::
Expand Down
Loading