From 41fe6b206fbfc87e8af534782db972be119902a4 Mon Sep 17 00:00:00 2001 From: Benjamin Ummenhofer Date: Thu, 19 Dec 2024 03:22:53 -0800 Subject: [PATCH] rename VoxelColorMode to VoxelPoolingMode --- cpp/open3d/geometry/VoxelGrid.h | 12 ++++++------ cpp/open3d/geometry/VoxelGridFactory.cpp | 14 +++++++------- cpp/pybind/geometry/voxelgrid.cpp | 24 ++++++++++++------------ docs/jupyter/geometry/voxelization.ipynb | 2 +- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/cpp/open3d/geometry/VoxelGrid.h b/cpp/open3d/geometry/VoxelGrid.h index fe32c20b381..258e975a12d 100644 --- a/cpp/open3d/geometry/VoxelGrid.h +++ b/cpp/open3d/geometry/VoxelGrid.h @@ -189,13 +189,13 @@ class VoxelGrid : public Geometry3D { double height, double depth); - /// \enum VoxelColorMode + /// \enum VoxelPoolingMode /// /// \brief Possible ways of determining voxel color from PointCloud. - enum class VoxelColorMode { AVG, MIN, MAX, SUM }; + enum class VoxelPoolingMode { AVG, MIN, MAX, SUM }; /// Creates a VoxelGrid from a given PointCloud. The color value of a given - /// voxel is determined by the VoxelColorMode, e.g. by default the average + /// 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. @@ -206,10 +206,10 @@ class VoxelGrid : public Geometry3D { static std::shared_ptr CreateFromPointCloud( const PointCloud &input, double voxel_size, - VoxelColorMode color_mode = VoxelColorMode::AVG); + VoxelPoolingMode color_mode = VoxelPoolingMode::AVG); /// Creates a VoxelGrid from a given PointCloud. The color value of a given - /// voxel is determined by the VoxelColorMode, e.g. by default the average + /// 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. @@ -224,7 +224,7 @@ class VoxelGrid : public Geometry3D { double voxel_size, const Eigen::Vector3d &min_bound, const Eigen::Vector3d &max_bound, - VoxelColorMode color_mode = VoxelColorMode::AVG); + VoxelPoolingMode color_mode = VoxelPoolingMode::AVG); /// Creates a VoxelGrid from a given TriangleMesh. No color information is /// converted. The bounds of the created VoxelGrid are computed from the diff --git a/cpp/open3d/geometry/VoxelGridFactory.cpp b/cpp/open3d/geometry/VoxelGridFactory.cpp index 6a3e92eeed9..39fe03668ed 100644 --- a/cpp/open3d/geometry/VoxelGridFactory.cpp +++ b/cpp/open3d/geometry/VoxelGridFactory.cpp @@ -46,7 +46,7 @@ std::shared_ptr VoxelGrid::CreateFromPointCloudWithinBounds( double voxel_size, const Eigen::Vector3d &min_bound, const Eigen::Vector3d &max_bound, - VoxelGrid::VoxelColorMode color_mode) { + VoxelGrid::VoxelPoolingMode pooling_mode) { auto output = std::make_shared(); if (voxel_size <= 0.0) { utility::LogError("voxel_size <= 0."); @@ -79,10 +79,10 @@ std::shared_ptr VoxelGrid::CreateFromPointCloudWithinBounds( const Eigen::Vector3i &grid_index = accpoint.second.GetVoxelIndex(); // clang-format off const Eigen::Vector3d &color = has_colors ? - (color_mode == VoxelColorMode::AVG ? accpoint.second.GetAverageColor() - : color_mode == VoxelColorMode::MIN ? accpoint.second.GetMinColor() - : color_mode == VoxelColorMode::MAX ? accpoint.second.GetMaxColor() - : color_mode == VoxelColorMode::SUM ? accpoint.second.GetSumColor() + (pooling_mode == VoxelPoolingMode::AVG ? accpoint.second.GetAverageColor() + : pooling_mode == VoxelPoolingMode::MIN ? accpoint.second.GetMinColor() + : pooling_mode == VoxelPoolingMode::MAX ? accpoint.second.GetMaxColor() + : pooling_mode == VoxelPoolingMode::SUM ? accpoint.second.GetSumColor() : Eigen::Vector3d::Zero()) : Eigen::Vector3d::Zero(); // clang-format on @@ -97,12 +97,12 @@ std::shared_ptr VoxelGrid::CreateFromPointCloudWithinBounds( std::shared_ptr VoxelGrid::CreateFromPointCloud( const PointCloud &input, double voxel_size, - VoxelGrid::VoxelColorMode color_mode) { + VoxelGrid::VoxelPoolingMode pooling_mode) { Eigen::Vector3d voxel_size3(voxel_size, voxel_size, voxel_size); Eigen::Vector3d min_bound = input.GetMinBound() - voxel_size3 * 0.5; Eigen::Vector3d max_bound = input.GetMaxBound() + voxel_size3 * 0.5; return CreateFromPointCloudWithinBounds(input, voxel_size, min_bound, - max_bound, color_mode); + max_bound, pooling_mode); } std::shared_ptr VoxelGrid::CreateFromTriangleMeshWithinBounds( diff --git a/cpp/pybind/geometry/voxelgrid.cpp b/cpp/pybind/geometry/voxelgrid.cpp index 498210caca2..6bcc6b7264d 100644 --- a/cpp/pybind/geometry/voxelgrid.cpp +++ b/cpp/pybind/geometry/voxelgrid.cpp @@ -64,13 +64,13 @@ void pybind_voxelgrid_definitions(py::module &m) { std::shared_ptr, Geometry3D>>( m.attr("VoxelGrid")); - py::enum_ color_mode( - voxelgrid, "VoxelColorMode", + py::enum_ pooling_mode( + voxelgrid, "VoxelPoolingMode", "Mode of determining color for each voxel."); - color_mode.value("AVG", VoxelGrid::VoxelColorMode::AVG) - .value("MIN", VoxelGrid::VoxelColorMode::MIN) - .value("MAX", VoxelGrid::VoxelColorMode::MAX) - .value("SUM", VoxelGrid::VoxelColorMode::SUM); + 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); py::detail::bind_copy_functions(voxelgrid); @@ -139,22 +139,22 @@ void pybind_voxelgrid_definitions(py::module &m) { &VoxelGrid::CreateFromPointCloud, "Creates a VoxelGrid from a given PointCloud. The " "color value of a given voxel is determined by the " - "VoxelColorMode, e.g. by default the average color " + "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, - "color_mode"_a = VoxelGrid::VoxelColorMode::AVG) + "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 " - "VoxelColorMode, e.g. by default the average color " + "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, - "color_mode"_a = VoxelGrid::VoxelColorMode::AVG) + "pooling_mode"_a = VoxelGrid::VoxelPoolingMode::AVG) .def_static("create_from_triangle_mesh", &VoxelGrid::CreateFromTriangleMesh, "Creates a VoxelGrid from a given TriangleMesh. No " @@ -229,7 +229,7 @@ void pybind_voxelgrid_definitions(py::module &m) { m, "VoxelGrid", "create_from_point_cloud", {{"input", "The input PointCloud"}, {"voxel_size", "Voxel size of of the VoxelGrid construction."}, - {"color_mode", "VoxelColorMode for determining voxel color."}}); + {"pooling_mode", "VoxelPoolingMode for determining voxel color."}}); docstring::ClassMethodDocInject( m, "VoxelGrid", "create_from_point_cloud_within_bounds", {{"input", "The input PointCloud"}, @@ -238,7 +238,7 @@ void pybind_voxelgrid_definitions(py::module &m) { "Minimum boundary point for the VoxelGrid to create."}, {"max_bound", "Maximum boundary point for the VoxelGrid to create."}, - {"color_mode", "VoxelColorMode for determining voxel color."}}); + {"pooling_mode", "VoxelPoolingMode that determines how to compute the voxel color."}}); docstring::ClassMethodDocInject( m, "VoxelGrid", "create_from_triangle_mesh", {{"input", "The input TriangleMesh"}, diff --git a/docs/jupyter/geometry/voxelization.ipynb b/docs/jupyter/geometry/voxelization.ipynb index a724a263e90..e7b98a64f7c 100644 --- a/docs/jupyter/geometry/voxelization.ipynb +++ b/docs/jupyter/geometry/voxelization.ipynb @@ -64,7 +64,7 @@ "metadata": {}, "source": [ "## From point cloud\n", - "The voxel grid can also be created from a point cloud using the method `create_from_point_cloud`. A voxel is occupied if at least one point of the point cloud is within the voxel. The argument `voxel_size` defines the resolution of the voxel grid. By default, the color of the voxel is the average of all the points within the voxel. The argument `color_mode` can be changed to determine the color by average, min, max or sum value of the points, e.g. with `o3d.geometry.VoxelGrid.VoxelColorMode.MIN`." + "The voxel grid can also be created from a point cloud using the method `create_from_point_cloud`. A voxel is occupied if at least one point of the point cloud is within the voxel. The argument `voxel_size` defines the resolution of the voxel grid. By default, the color of the voxel is the average of all the points within the voxel. The argument `pooling_mode` can be changed to determine the color by average, min, max or sum value of the points, e.g. with `o3d.geometry.VoxelGrid.VoxelPoolingMode.MIN`." ] }, {