add unittest for writing and reading double positions and normals
This commit is contained in:
@@ -1472,4 +1472,32 @@ TEST_F(OpenMeshReadWriteOM, LoadTriMeshVersion_7_5) {
|
||||
EXPECT_FALSE(ok) << file_name;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Try to write and load positions and normals that can only be represented by doubles
|
||||
*/
|
||||
TEST_F(OpenMeshReadWriteOM, WriteAndLoadDoubles) {
|
||||
|
||||
typedef OpenMesh::PolyMesh_ArrayKernelT<OpenMesh::DefaultTraitsDouble> DoublePolyMesh;
|
||||
|
||||
DoublePolyMesh mesh;
|
||||
mesh.request_vertex_normals();
|
||||
|
||||
mesh.add_vertex(DoublePolyMesh::Point(1.0/3.0, std::numeric_limits<double>::min(), std::numeric_limits<double>::max()));
|
||||
mesh.set_normal(OpenMesh::VertexHandle(0), DoublePolyMesh::Normal(1.0/3.0, std::numeric_limits<double>::min(), std::numeric_limits<double>::max()));
|
||||
|
||||
std::string file_name = "doubles.om";
|
||||
|
||||
OpenMesh::IO::Options opt = OpenMesh::IO::Options::VertexNormal;
|
||||
ASSERT_TRUE(OpenMesh::IO::write_mesh(mesh, file_name, opt)) << "Could not write file " << file_name;
|
||||
|
||||
DoublePolyMesh mesh2;
|
||||
mesh2.request_vertex_normals();
|
||||
|
||||
ASSERT_TRUE(OpenMesh::IO::read_mesh(mesh2, file_name, opt)) << "Could not read file " << file_name;
|
||||
|
||||
EXPECT_EQ(mesh.point(OpenMesh::VertexHandle(0)), mesh2.point(OpenMesh::VertexHandle(0)));
|
||||
EXPECT_EQ(mesh.normal(OpenMesh::VertexHandle(0)), mesh2.normal(OpenMesh::VertexHandle(0)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user