diff --git a/src/Unittests/unittests_read_write_OM.cc b/src/Unittests/unittests_read_write_OM.cc index 35e4522d..2c437537 100644 --- a/src/Unittests/unittests_read_write_OM.cc +++ b/src/Unittests/unittests_read_write_OM.cc @@ -1509,4 +1509,62 @@ TEST_F(OpenMeshReadWriteOM, WriteAndLoadDoubles) { EXPECT_EQ(mesh.normal(OpenMesh::FaceHandle(0)), mesh2.normal(OpenMesh::FaceHandle(0))); } + + +/* + * Try to write and load bool property + */ +TEST_F(OpenMeshReadWriteOM, WriteAndLoadBoolCheckSpaces) { + + typedef OpenMesh::PolyMesh_ArrayKernelT DoublePolyMesh; + + DoublePolyMesh mesh; + + OpenMesh::VPropHandleT prop; + mesh.add_property(prop,"VBProp"); + mesh.property(prop).set_persistent(true); + + + // Generate a bool property which will be packed into a space character + + std::vector vertices; + for (unsigned int i = 0; i < 8; ++i) + { + vertices.push_back(mesh.add_vertex(DoublePolyMesh::Point(0.0, 0.0, 0.0))); + + if ( i == 5) + mesh.property(prop,vertices[i]) = true; + else + mesh.property(prop,vertices[i]) = false; + } + + std::string file_name = "bool-space-test.om"; + + OpenMesh::IO::Options opt = OpenMesh::IO::Options::Default; + ASSERT_TRUE(OpenMesh::IO::write_mesh(mesh, file_name, opt)) << "Could not write file " << file_name; + + + // ==================================================== + // Now read it back + // ==================================================== + + DoublePolyMesh mesh2; + OpenMesh::VPropHandleT prop2; + mesh2.add_property(prop2,"VBProp"); + mesh2.property(prop2).set_persistent(true); + + ASSERT_TRUE(OpenMesh::IO::read_mesh(mesh2, file_name, opt)) << "Could not read file " << file_name; + + // Check if the property is still ok + for (unsigned int i = 0; i < 8; ++i) + { + if ( i == 5) + EXPECT_TRUE( mesh.property(prop,mesh2.vertex_handle((i)) ) ); + else + EXPECT_FALSE(mesh.property(prop,mesh2.vertex_handle((i)))); + } +} + + + }