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

Save normal and curvature in savePLYFile #1057

Merged
merged 1 commit into from
Dec 23, 2014
Merged
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
32 changes: 32 additions & 0 deletions io/src/ply_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,22 @@ pcl::io::savePLYFile (const std::string &file_name, const pcl::PolygonMesh &mesh
"\nproperty uchar green"
"\nproperty uchar blue";
}
// Check if we have normal on vertices
int normal_x_index = getFieldIndex(mesh.cloud, "normal_x");
int normal_y_index = getFieldIndex(mesh.cloud, "normal_y");
int normal_z_index = getFieldIndex(mesh.cloud, "normal_z");
if (normal_x_index != -1 && normal_y_index != -1 && normal_z_index != -1)
{
fs << "\nproperty float nx"
"\nproperty float ny"
"\nproperty float nz";
}
// Check if we have curvature on vertices
int curvature_index = getFieldIndex(mesh.cloud, "curvature");
if ( curvature_index != -1)
{
fs << "\nproperty float curvature";
}
// Faces
fs << "\nelement face "<< nr_faces;
fs << "\nproperty list uchar int vertex_indices";
Expand Down Expand Up @@ -1541,6 +1557,22 @@ pcl::io::savePLYFile (const std::string &file_name, const pcl::PolygonMesh &mesh
memcpy (&color, &mesh.cloud.data[i * point_size + mesh.cloud.fields[rgba_index].offset + c * sizeof (uint32_t)], sizeof (RGB));
fs << int (color.r) << " " << int (color.g) << " " << int (color.b) << " " << int (color.a);
}
else if ((mesh.cloud.fields[d].datatype == pcl::PCLPointField::FLOAT32) && (
mesh.cloud.fields[d].name == "normal_x" ||
mesh.cloud.fields[d].name == "normal_y" ||
mesh.cloud.fields[d].name == "normal_z"))
{
float value;
memcpy (&value, &mesh.cloud.data[i * point_size + mesh.cloud.fields[d].offset + c * sizeof(float)], sizeof(float));
fs << value;
}
else if ((mesh.cloud.fields[d].datatype == pcl::PCLPointField::FLOAT32) && (
mesh.cloud.fields[d].name == "curvature"))
{
float value;
memcpy(&value, &mesh.cloud.data[i * point_size + mesh.cloud.fields[d].offset + c * sizeof(float)], sizeof(float));
fs << value;
}
fs << " ";
}
if (xyz != 3)
Expand Down