Skip to content

Fix writing pcl::PointCloud to IFS file #6262

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

Merged
merged 1 commit into from
Apr 4, 2025
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: 1 addition & 1 deletion io/include/pcl/io/ifs_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ namespace pcl
const std::string &cloud_name = "cloud")
{
pcl::PCLPointCloud2 blob;
pcl::toPCLPointCloud2<PointT> (cloud, blob);
pcl::toPCLPointCloud2<PointT> (cloud, blob, false); // no padding
return (write (file_name, blob, cloud_name));
}
};
Expand Down
24 changes: 24 additions & 0 deletions test/io/test_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,30 @@ TYPED_TEST (AutoIOTest, AutoLoadCloudFiles)
remove ("test_autoio.ifs");
}

TEST(PCL, IFS)
{
// Write a cloud to an IFS file and check if it is the same after loading
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
cloud->push_back(pcl::PointXYZ(1.0, 2.0, 3.0));
cloud->push_back(pcl::PointXYZ(4.0, 5.0, 6.0));

pcl::io::saveIFSFile("test.ifs", *cloud);

pcl::PointCloud<pcl::PointXYZ>::Ptr loaded(new pcl::PointCloud<pcl::PointXYZ>);
pcl::io::loadIFSFile("test.ifs", *loaded);

EXPECT_EQ(cloud->size(), loaded->size());
for (size_t i = 0; i < cloud->size(); ++i)
{
const auto& src = cloud->points[i];
const auto& dst = loaded->points[i];
EXPECT_EQ(src.x, dst.x);
EXPECT_EQ(src.y, dst.y);
EXPECT_EQ(src.z, dst.z);
}
remove("test.ifs");
}

/* ---[ */
int
main (int argc, char** argv)
Expand Down