Skip to content

Commit

Permalink
Merge pull request #4492 from DaniilSNikulin/issue_4491_allow_uint_as…
Browse files Browse the repository at this point in the history
…_index_type

PLY face definition accepts uint fields as well
  • Loading branch information
kunaltyagi authored Nov 14, 2020
2 parents f7ddd84 + 4b1d355 commit 6c2b123
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions io/src/ply_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ pcl::PLYReader::parse (const std::string& istream_filename)

pcl::io::ply::ply_parser::list_property_definition_callbacks_type list_property_definition_callbacks;
pcl::io::ply::ply_parser::at<pcl::io::ply::uint8, pcl::io::ply::int32> (list_property_definition_callbacks) = [this] (const std::string& element_name, const std::string& property_name) { return listPropertyDefinitionCallback<pcl::io::ply::uint8, pcl::io::ply::int32> (element_name, property_name); };
pcl::io::ply::ply_parser::at<pcl::io::ply::uint8, pcl::io::ply::uint32> (list_property_definition_callbacks) = [this] (const std::string& element_name, const std::string& property_name) { return listPropertyDefinitionCallback<pcl::io::ply::uint8, pcl::io::ply::int32> (element_name, property_name); };
pcl::io::ply::ply_parser::at<pcl::io::ply::uint32, pcl::io::ply::float64> (list_property_definition_callbacks) = [this] (const std::string& element_name, const std::string& property_name) { return listPropertyDefinitionCallback<pcl::io::ply::uint32, pcl::io::ply::float64> (element_name, property_name); };
pcl::io::ply::ply_parser::at<pcl::io::ply::uint32, pcl::io::ply::float32> (list_property_definition_callbacks) = [this] (const std::string& element_name, const std::string& property_name) { return listPropertyDefinitionCallback<pcl::io::ply::uint32, pcl::io::ply::float32> (element_name, property_name); };
pcl::io::ply::ply_parser::at<pcl::io::ply::uint32, pcl::io::ply::uint32> (list_property_definition_callbacks) = [this] (const std::string& element_name, const std::string& property_name) { return listPropertyDefinitionCallback<pcl::io::ply::uint32, pcl::io::ply::uint32> (element_name, property_name); };
Expand Down
32 changes: 32 additions & 0 deletions test/io/test_ply_mesh_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,38 @@ TEST (PCL, PLYPolygonMeshColoredIO)
remove ("test_mesh_rgba_binary.ply");
}


TEST (PCL, PLYPolygonMeshUintIndices)
{
std::ofstream fs;
fs.open ("mesh_uint_indices.ply");
fs <<
"ply\n"
"format ascii 1.0\n"
"element vertex 3\n"
"property float x\n"
"property float y\n"
"property float z\n"
"element face 1\n"
"property list uchar uint vertex_indices\n"
"end_header\n"
"0.0 0.0 0.0\n"
"1.0 0.0 0.0\n"
"1.0 1.1 0.0\n"
"3 2 0 1\n";
fs.close();
pcl::PolygonMesh mesh;
int const res = pcl::io::loadPLYFile("mesh_uint_indices.ply", mesh);
EXPECT_NE (res, -1);
EXPECT_EQ (mesh.cloud.width, 3);
EXPECT_EQ (mesh.cloud.height, 1);
EXPECT_EQ (mesh.polygons.size(), 1);
EXPECT_EQ (mesh.polygons.front().vertices.size(), 3);

remove("mesh_uint_indices.ply");
}


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

0 comments on commit 6c2b123

Please sign in to comment.