Skip to content

Commit

Permalink
Merge pull request #1057 from Tonsty/master
Browse files Browse the repository at this point in the history
Save normal and curvature in savePLYFile
  • Loading branch information
jspricke committed Dec 23, 2014
2 parents e1bfafc + 3e6747c commit 67f976d
Showing 1 changed file with 32 additions and 0 deletions.
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

0 comments on commit 67f976d

Please sign in to comment.