Skip to content

Commit

Permalink
Merge pull request #1058 from Tonsty/master
Browse files Browse the repository at this point in the history
save normal and curvature in binay format
  • Loading branch information
jspricke committed Dec 24, 2014
2 parents 67f976d + 55a4e70 commit ac4205a
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 @@ -1648,6 +1648,22 @@ pcl::io::savePLYFileBinary (const std::string &file_name, const pcl::PolygonMesh
"\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 @@ -1707,6 +1723,22 @@ pcl::io::savePLYFileBinary (const std::string &file_name, const pcl::PolygonMesh
fpout.write (reinterpret_cast<const char*> (&color.b), sizeof (unsigned char));
fpout.write (reinterpret_cast<const char*> (&color.a), sizeof (unsigned char));
}
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));
fpout.write (reinterpret_cast<const char*> (&value), sizeof (float));
}
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));
fpout.write (reinterpret_cast<const char*> (&value), sizeof (float));
}
}
if (xyz != 3)
{
Expand Down

0 comments on commit ac4205a

Please sign in to comment.