diff --git a/src/OpenMesh/Core/IO/reader/PLYReader.cc b/src/OpenMesh/Core/IO/reader/PLYReader.cc index d92c7cde..cd089f53 100644 --- a/src/OpenMesh/Core/IO/reader/PLYReader.cc +++ b/src/OpenMesh/Core/IO/reader/PLYReader.cc @@ -326,12 +326,12 @@ bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap unsigned int i, j, k, l, idx; unsigned int nV; - OpenMesh::Vec3f v, n; // Vertex - OpenMesh::Vec2f t; // TexCoords + OpenMesh::Vec3f v, n; // Vertex + OpenMesh::Vec2f t; // TexCoords BaseImporter::VHandles vhandles; - VertexHandle vh; - OpenMesh::Vec4i c; // Color - float tmp; + VertexHandle vh; + OpenMesh::Vec4i c; // Color + float tmp; _bi.reserve(vertexCount_, 3* vertexCount_ , faceCount_); diff --git a/src/OpenMesh/Core/IO/writer/PLYWriter.cc b/src/OpenMesh/Core/IO/writer/PLYWriter.cc index 8c430cea..4e4563ed 100644 --- a/src/OpenMesh/Core/IO/writer/PLYWriter.cc +++ b/src/OpenMesh/Core/IO/writer/PLYWriter.cc @@ -187,6 +187,12 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const _out << "property float32 y" << std::endl; _out << "property float32 z" << std::endl; + if ( _opt.vertex_has_normal() ){ + _out << "property float32 nx" << std::endl; + _out << "property float32 ny" << std::endl; + _out << "property float32 nz" << std::endl; + } + if ( _opt.vertex_has_texcoord() ){ _out << "property float32 u" << std::endl; _out << "property float32 v" << std::endl; @@ -214,6 +220,12 @@ write_ascii(std::ostream& _out, BaseExporter& _be, Options _opt) const //Vertex _out << v[0] << " " << v[1] << " " << v[2]; + // Vertex Normals + if ( _opt.vertex_has_normal() ){ + n = _be.normal(vh); + _out << " " << n[0] << " " << n[1] << " " << n[2]; + } + // Vertex TexCoords if ( _opt.vertex_has_texcoord() ) { t = _be.texcoord(vh); @@ -384,6 +396,12 @@ write_binary(std::ostream& _out, BaseExporter& _be, Options _opt) const _out << "property float32 x" << std::endl; _out << "property float32 y" << std::endl; _out << "property float32 z" << std::endl; + + if ( _opt.vertex_has_normal() ){ + _out << "property float32 nx" << std::endl; + _out << "property float32 ny" << std::endl; + _out << "property float32 nz" << std::endl; + } if ( _opt.vertex_has_texcoord() ){ _out << "property float32 u" << std::endl; @@ -414,6 +432,14 @@ write_binary(std::ostream& _out, BaseExporter& _be, Options _opt) const writeValue(ValueTypeFLOAT, _out, v[1]); writeValue(ValueTypeFLOAT, _out, v[2]); + // Vertex Normal + if ( _opt.vertex_has_normal() ){ + n = _be.normal(vh); + writeValue(ValueTypeFLOAT, _out, n[0]); + writeValue(ValueTypeFLOAT, _out, n[1]); + writeValue(ValueTypeFLOAT, _out, n[2]); + } + // Vertex TexCoords if ( _opt.vertex_has_texcoord() ) { t = _be.texcoord(vh);