Commit 0ba70e94 authored by Jan Möbius's avatar Jan Möbius

Added Unittest to check OBJ Reader Writer Issue refs

parent 2daa0b4e
......@@ -499,4 +499,87 @@ TEST_F(OpenMeshReadWriteOBJ, ReadWriteReadSimpleOBJ) {
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";
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment