Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <cstdio>
00042 #include <fstream>
00043 #include <string>
00044
00045 #include <gtest/gtest.h>
00046
00047 #include <pcl/geometry/triangle_mesh.h>
00048 #include <pcl/geometry/mesh_io.h>
00049
00051
00052 typedef pcl::geometry::DefaultMeshTraits <> MeshTraits;
00053 typedef pcl::geometry::TriangleMesh <MeshTraits> Mesh;
00054 typedef pcl::geometry::MeshIO <Mesh> MeshIO;
00055
00056 typedef Mesh::VertexIndex VertexIndex;
00057 typedef Mesh::HalfEdgeIndex HalfEdgeIndex;
00058 typedef Mesh::FaceIndex FaceIndex;
00059
00061
00062 TEST (TestMeshIO, WriteAndRead)
00063 {
00064 Mesh expected_mesh, loaded_mesh;
00065
00066 Mesh::VertexIndices vi;
00067 for (unsigned int i=0; i<11; ++i)
00068 {
00069 vi.push_back (expected_mesh.addVertex ());
00070 }
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 ASSERT_TRUE (expected_mesh.addFace (vi [0], vi [3], vi [ 1]).isValid ());
00083 ASSERT_TRUE (expected_mesh.addFace (vi [1], vi [4], vi [ 2]).isValid ());
00084 ASSERT_TRUE (expected_mesh.addFace (vi [3], vi [5], vi [ 4]).isValid ());
00085 ASSERT_TRUE (expected_mesh.addFace (vi [6], vi [8], vi [ 0]).isValid ());
00086 ASSERT_TRUE (expected_mesh.addFace (vi [7], vi [9], vi [10]).isValid ());
00087 ASSERT_TRUE (expected_mesh.addFace (vi [5], vi [6], vi [ 7]).isValid ());
00088
00089
00090 std::string filename = std::string (PCL_TEST_GEOMETRY_BINARY_DIR).append ("/test_mesh_io_mesh_tmp.txt");
00091 MeshIO io;
00092
00093 ASSERT_TRUE (io.write (filename, expected_mesh));
00094 ASSERT_TRUE (io.read (filename, loaded_mesh));
00095
00096 ASSERT_TRUE (expected_mesh.isEqualTopology (loaded_mesh));
00097
00098
00099
00100 std::remove (filename.c_str ());
00101 }
00102
00104
00105 int
00106 main (int argc, char** argv)
00107 {
00108 testing::InitGoogleTest (&argc, argv);
00109 return (RUN_ALL_TESTS ());
00110 }