Commit 6e92c1dc authored by Mike Kremer's avatar Mike Kremer

Added another unit test on writing files

git-svn-id: http://www.openvolumemesh.org/svnrepo/OpenVolumeMesh/trunk@62 66977474-1d4b-4f09-8fe9-267525286df2
parent ca994b01
......@@ -922,7 +922,10 @@ bool FileManager::writeFile(const std::string& _filename, const MeshT& _mesh) co
return false;
}
int n_vertices(_mesh.n_vertices());
// Write header
off << "OVM ASCII" << std::endl;
unsigned int n_vertices(_mesh.n_vertices());
off << "Vertices" << std::endl;
off << n_vertices << std::endl;
......@@ -933,7 +936,7 @@ bool FileManager::writeFile(const std::string& _filename, const MeshT& _mesh) co
off << v[0] << " " << v[1] << " " << v[2] << std::endl;
}
int n_edges(_mesh.n_edges());
unsigned int n_edges(_mesh.n_edges());
off << "Edges" << std::endl;
off << n_edges << std::endl;
......@@ -945,7 +948,7 @@ bool FileManager::writeFile(const std::string& _filename, const MeshT& _mesh) co
off << from_vertex << " " << to_vertex << std::endl;
}
int n_faces(_mesh.n_faces());
unsigned int n_faces(_mesh.n_faces());
off << "Faces" << std::endl;
off << n_faces << std::endl;
......@@ -959,7 +962,7 @@ bool FileManager::writeFile(const std::string& _filename, const MeshT& _mesh) co
for (typename std::vector<typename MeshT::HalfEdgeHandle>::const_iterator it = halfedges.begin(); it
!= halfedges.end(); ++it) {
off << *it;
off << it->idx();
if ((it + 1) != halfedges.end())
off << " ";
......@@ -968,7 +971,7 @@ bool FileManager::writeFile(const std::string& _filename, const MeshT& _mesh) co
off << std::endl;
}
int n_cells(_mesh.n_cells());
unsigned int n_cells(_mesh.n_cells());
off << "Polyhedra" << std::endl;
off << n_cells << std::endl;
......@@ -981,7 +984,7 @@ bool FileManager::writeFile(const std::string& _filename, const MeshT& _mesh) co
for (typename std::vector<typename MeshT::HalfFaceHandle>::const_iterator it = halffaces.begin(); it
!= halffaces.end(); ++it) {
off << *it;
off << it->idx();
if ((it + 1) != halffaces.end())
off << " ";
......
......@@ -31,6 +31,30 @@ TEST_F(HexahedralMeshBase, LoadFile) {
EXPECT_EQ(288u, mesh_.n_cells());
}
TEST_F(PolyhedralMeshBase, SaveFile) {
OpenVolumeMesh::IO::FileManager fileManager;
ASSERT_TRUE(fileManager.readFile("Cylinder.ovm", mesh_));
EXPECT_EQ(399u, mesh_.n_vertices());
EXPECT_EQ(1070u, mesh_.n_edges());
EXPECT_EQ(960u, mesh_.n_faces());
EXPECT_EQ(288u, mesh_.n_cells());
// Write file
ASSERT_TRUE(fileManager.writeFile("Cylinder.copy.ovm", mesh_));
mesh_.clear();
ASSERT_TRUE(fileManager.readFile("Cylinder.copy.ovm", mesh_));
EXPECT_EQ(399u, mesh_.n_vertices());
EXPECT_EQ(1070u, mesh_.n_edges());
EXPECT_EQ(960u, mesh_.n_faces());
EXPECT_EQ(288u, mesh_.n_cells());
}
TEST_F(PolyhedralMeshBase, LoadFileWithProps) {
OpenVolumeMesh::IO::FileManager fileManager;
......
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