diff --git a/io/src/ply_io.cpp b/io/src/ply_io.cpp index 0751b936d92..922702881b8 100644 --- a/io/src/ply_io.cpp +++ b/io/src/ply_io.cpp @@ -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"; @@ -1707,6 +1723,22 @@ pcl::io::savePLYFileBinary (const std::string &file_name, const pcl::PolygonMesh fpout.write (reinterpret_cast (&color.b), sizeof (unsigned char)); fpout.write (reinterpret_cast (&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 (&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 (&value), sizeof (float)); + } } if (xyz != 3) {