Merge branch 'PLY_istream_fix' into 'master'
Ply istream fix Closes #46 See merge request OpenMesh/OpenMesh!192
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li>PLY Reader: Allowing the PLY reader to read custom face ( Thanks to morgan Leborgne for the patch)</li>
|
<li>PLY Reader: Allowing the PLY reader to read custom face ( Thanks to morgan Leborgne for the patch)</li>
|
||||||
<li>PLY Reader: Fixed endless loop on unknown property list type</li>
|
<li>PLY Reader: Fixed endless loop on unknown property list type</li>
|
||||||
|
<li>PLY Reader: Fix hang when reading directly from istream (Thanks to Paul Loré for the patch)</li>
|
||||||
<li>OM Writer/Reader: Update file format version to 2.0. Older files can still be read, but older OpenMesh versions cannot read new format.</li>
|
<li>OM Writer/Reader: Update file format version to 2.0. Older files can still be read, but older OpenMesh versions cannot read new format.</li>
|
||||||
<li>OM Writer/Reader: Fixed inconsistent writing/reading of edge properties</li>
|
<li>OM Writer/Reader: Fixed inconsistent writing/reading of edge properties</li>
|
||||||
<li>OM Writer/Reader: Add option to store status</li>
|
<li>OM Writer/Reader: Add option to store status</li>
|
||||||
|
|||||||
@@ -135,6 +135,14 @@ bool _PLYReader_::read(std::istream& _in, BaseImporter& _bi, Options& _opt) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reparse the header
|
||||||
|
if (!can_u_read(_in)) {
|
||||||
|
omerr() << "[PLYReader] : Unable to parse header\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// filter relevant options for reading
|
// filter relevant options for reading
|
||||||
bool swap = _opt.check(Options::Swap);
|
bool swap = _opt.check(Options::Swap);
|
||||||
|
|
||||||
@@ -281,12 +289,6 @@ void _PLYReader_::readCustomProperty(std::istream& _in, BaseImporter& _bi, Handl
|
|||||||
|
|
||||||
bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options& _opt) const {
|
bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options& _opt) const {
|
||||||
|
|
||||||
// Reparse the header
|
|
||||||
if (!can_u_read(_in)) {
|
|
||||||
omerr() << "[PLYReader] : Unable to parse header\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int i, j, k, l, idx;
|
unsigned int i, j, k, l, idx;
|
||||||
unsigned int nV;
|
unsigned int nV;
|
||||||
OpenMesh::Vec3f v, n;
|
OpenMesh::Vec3f v, n;
|
||||||
@@ -507,12 +509,6 @@ bool _PLYReader_::read_ascii(std::istream& _in, BaseImporter& _bi, const Options
|
|||||||
|
|
||||||
bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap*/, const Options& _opt) const {
|
bool _PLYReader_::read_binary(std::istream& _in, BaseImporter& _bi, bool /*_swap*/, const Options& _opt) const {
|
||||||
|
|
||||||
// Reparse the header
|
|
||||||
if (!can_u_read(_in)) {
|
|
||||||
omerr() << "[PLYReader] : Unable to parse header\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
OpenMesh::Vec3f v, n; // Vertex
|
OpenMesh::Vec3f v, n; // Vertex
|
||||||
OpenMesh::Vec2f t; // TexCoords
|
OpenMesh::Vec2f t; // TexCoords
|
||||||
BaseImporter::VHandles vhandles;
|
BaseImporter::VHandles vhandles;
|
||||||
|
|||||||
@@ -499,4 +499,88 @@ TEST_F(OpenMeshReadWriteOBJ, ReadWriteReadSimpleOBJ) {
|
|||||||
EXPECT_EQ(1, mesh2.normal(mesh2.vertex_handle(7))[2] ) << "Wrong vertex normal at vertex 7 component 2";
|
EXPECT_EQ(1, mesh2.normal(mesh2.vertex_handle(7))[2] ) << "Wrong vertex normal at vertex 7 component 2";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST_F(OpenMeshReadWriteOBJ, FaceTexCoordTest) {
|
||||||
|
|
||||||
|
mesh_.clear();
|
||||||
|
mesh_.request_vertex_normals();
|
||||||
|
mesh_.request_halfedge_texcoords2D();
|
||||||
|
|
||||||
|
// Add some vertices
|
||||||
|
Mesh::VertexHandle vhandle[5];
|
||||||
|
|
||||||
|
vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 0, 0));
|
||||||
|
vhandle[1] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
|
||||||
|
vhandle[2] = mesh_.add_vertex(Mesh::Point(1, 1, 0));
|
||||||
|
|
||||||
|
// Add one face
|
||||||
|
std::vector<Mesh::VertexHandle> face_vhandles;
|
||||||
|
|
||||||
|
face_vhandles.push_back(vhandle[2]);
|
||||||
|
face_vhandles.push_back(vhandle[1]);
|
||||||
|
face_vhandles.push_back(vhandle[0]);
|
||||||
|
|
||||||
|
Mesh::FaceHandle fh = mesh_.add_face(face_vhandles);
|
||||||
|
|
||||||
|
// 1 --- 2
|
||||||
|
// | /
|
||||||
|
// | /
|
||||||
|
// | /
|
||||||
|
// 0
|
||||||
|
|
||||||
|
mesh_.set_normal(vhandle[0] , Mesh::Normal(1,0,0));
|
||||||
|
mesh_.set_normal(vhandle[1] , Mesh::Normal(0,1,0));
|
||||||
|
mesh_.set_normal(vhandle[2] , Mesh::Normal(0,0,1));
|
||||||
|
|
||||||
|
|
||||||
|
float u = 8.0f;
|
||||||
|
for ( auto he : mesh_.halfedges() ) {
|
||||||
|
|
||||||
|
mesh_.set_texcoord2D(he,Mesh::TexCoord2D(u,u));
|
||||||
|
u += 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
u = 0.0f;
|
||||||
|
|
||||||
|
for ( auto fh : mesh_.fh_range(fh) )
|
||||||
|
{
|
||||||
|
|
||||||
|
mesh_.set_texcoord2D(fh,Mesh::TexCoord2D(u,u));
|
||||||
|
u += 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
OpenMesh::IO::Options wopt;
|
||||||
|
wopt += OpenMesh::IO::Options::VertexNormal;
|
||||||
|
wopt += OpenMesh::IO::Options::FaceTexCoord;
|
||||||
|
|
||||||
|
bool ok = OpenMesh::IO::write_mesh(mesh_, "OpenMeshReadWriteOBJ_FaceTexCoordTest.obj", wopt);
|
||||||
|
|
||||||
|
EXPECT_TRUE(ok) << "Unable to write OpenMeshReadWriteOBJ_FaceTexCoordTest.obj";
|
||||||
|
|
||||||
|
mesh_.clear();
|
||||||
|
|
||||||
|
|
||||||
|
OpenMesh::IO::Options ropt;
|
||||||
|
|
||||||
|
ropt += OpenMesh::IO::Options::FaceTexCoord;
|
||||||
|
|
||||||
|
mesh_.request_vertex_normals();
|
||||||
|
mesh_.request_face_normals();
|
||||||
|
mesh_.request_halfedge_texcoords2D();
|
||||||
|
|
||||||
|
ok = OpenMesh::IO::read_mesh(mesh_, "OpenMeshReadWriteOBJ_FaceTexCoordTest.obj", ropt);
|
||||||
|
|
||||||
|
EXPECT_TRUE(ok) << "Unable to read back OpenMeshReadWriteOBJ_FaceTexCoordTest.obj";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user