Skip to content

Commit 4eef4b3

Browse files
authored
make PaintUniformColor return by reference (#5566)
1 parent ea1a263 commit 4eef4b3

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

cpp/open3d/t/geometry/PointCloud.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ std::tuple<PointCloud, core::Tensor> PointCloud::RemoveDuplicatedPoints()
447447
return std::make_tuple(SelectByMask(masks), masks);
448448
}
449449

450-
PointCloud PointCloud::PaintUniformColor(const core::Tensor &color) const {
450+
PointCloud &PointCloud::PaintUniformColor(const core::Tensor &color) {
451451
core::AssertTensorShape(color, {3});
452452
core::Tensor clipped_color = color.To(GetDevice());
453453
if (color.GetDtype() == core::Float32 ||
@@ -458,10 +458,9 @@ PointCloud PointCloud::PaintUniformColor(const core::Tensor &color) const {
458458
core::Tensor::Empty({GetPointPositions().GetLength(), 3},
459459
clipped_color.GetDtype(), GetDevice());
460460
pcd_colors.AsRvalue() = clipped_color;
461-
PointCloud pcd(this->Clone());
462-
pcd.SetPointColors(pcd_colors);
461+
SetPointColors(pcd_colors);
463462

464-
return pcd;
463+
return *this;
465464
}
466465

467466
std::tuple<PointCloud, core::Tensor> PointCloud::ComputeBoundaryPoints(

cpp/open3d/t/geometry/PointCloud.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,12 @@ class PointCloud : public Geometry, public DrawableGeometry {
318318
/// \return Rotated point cloud
319319
PointCloud &Rotate(const core::Tensor &R, const core::Tensor &center);
320320

321+
/// \brief Assigns uniform color to the point cloud.
322+
///
323+
/// \param color RGB color for the point cloud. {3,} shaped Tensor.
324+
/// Floating color values are clipped between 0.0 and 1.0.
325+
PointCloud &PaintUniformColor(const core::Tensor &color);
326+
321327
/// \brief Select points from input pointcloud, based on boolean mask
322328
/// indices into output point cloud.
323329
///
@@ -395,12 +401,6 @@ class PointCloud : public Geometry, public DrawableGeometry {
395401
std::tuple<PointCloud, core::Tensor> RemoveNonFinitePoints(
396402
bool remove_nan = true, bool remove_infinite = true) const;
397403

398-
/// \brief Assigns uniform color to the point cloud.
399-
///
400-
/// \param color RGB color for the point cloud. {3,} shaped Tensor.
401-
/// Floating color values are clipped between 0.0 and 1.0.
402-
PointCloud PaintUniformColor(const core::Tensor &color) const;
403-
404404
/// \brief Returns the device attribute of this PointCloud.
405405
core::Device GetDevice() const override { return device_; }
406406

cpp/tests/t/geometry/PointCloud.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ TEST_P(PointCloudPermuteDevices, HiddenPointRemoval) {
944944
TEST_P(PointCloudPermuteDevices, PaintUniformColor) {
945945
core::Device device = GetParam();
946946

947-
const t::geometry::PointCloud pcd_small(
947+
t::geometry::PointCloud pcd_small(
948948
core::Tensor::Init<double>({{1.0, 1.0, 1.0},
949949
{1.1, 1.1, 1.1},
950950
{1.2, 1.2, 1.2},

0 commit comments

Comments
 (0)