2 #include <gtest/gtest.h>
3 #include <Unittests/unittests_common.hh>
13 virtual void SetUp() {
19 virtual void TearDown() {
38 TEST_F(OpenMeshReadWriteSTL, LoadSimpleSTLFile) {
46 EXPECT_EQ(7526u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
47 EXPECT_EQ(22572u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
48 EXPECT_EQ(15048u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
56 TEST_F(OpenMeshReadWriteSTL, LoadSimpleSTLFileWithNormals) {
59 mesh_.request_face_normals();
68 EXPECT_TRUE(opt.face_has_normal());
69 EXPECT_FALSE(opt.vertex_has_normal());
71 EXPECT_NEAR(-0.038545f, mesh_.normal(mesh_.face_handle(0))[0], 0.0001 ) <<
"Wrong face normal at face 0 component 0";
72 EXPECT_NEAR(-0.004330f, mesh_.normal(mesh_.face_handle(0))[1], 0.0001 ) <<
"Wrong face normal at face 0 component 1";
73 EXPECT_NEAR(0.999247f, mesh_.normal(mesh_.face_handle(0))[2], 0.0001 ) <<
"Wrong face normal at face 0 component 2";
75 EXPECT_EQ(7526u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
76 EXPECT_EQ(22572u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
77 EXPECT_EQ(15048u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
79 mesh_.release_face_normals();
87 TEST_F(OpenMeshReadWriteSTL, LoadSimpleSTLBinaryFile) {
95 EXPECT_EQ(7526u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
96 EXPECT_EQ(22572u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
97 EXPECT_EQ(15048u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
105 TEST_F(OpenMeshReadWriteSTL, LoadSimpleSTLBinaryFileWithNormals) {
108 mesh_.request_face_normals();
118 EXPECT_TRUE(opt.is_binary());
119 EXPECT_TRUE(opt.face_has_normal());
120 EXPECT_FALSE(opt.vertex_has_normal());
122 EXPECT_NEAR(-0.038545f, mesh_.normal(mesh_.face_handle(0))[0], 0.0001 ) <<
"Wrong face normal at face 0 component 0";
123 EXPECT_NEAR(-0.004330f, mesh_.normal(mesh_.face_handle(0))[1], 0.0001 ) <<
"Wrong face normal at face 0 component 1";
124 EXPECT_NEAR(0.999247f, mesh_.normal(mesh_.face_handle(0))[2], 0.0001 ) <<
"Wrong face normal at face 0 component 2";
126 EXPECT_EQ(7526u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
127 EXPECT_EQ(22572u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
128 EXPECT_EQ(15048u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
130 mesh_.release_face_normals();
136 TEST_F(OpenMeshReadWriteSTL, ReadWriteSimpleSTLBinaryFile) {
147 const char* filename =
"cube1Binary_openmeshWriteTestFile.stl";
157 EXPECT_EQ(7526u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
158 EXPECT_EQ(22572u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
159 EXPECT_EQ(15048u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
168 TEST_F(OpenMeshReadWriteSTL, ReadWriteSimpleSTLBinaryFileWithNormals) {
171 mesh_.request_face_normals();
181 const char* filename =
"cube1BinaryNormal_openmeshWriteTestFile.stl";
191 EXPECT_TRUE(opt.is_binary());
192 EXPECT_TRUE(opt.face_has_normal());
193 EXPECT_FALSE(opt.vertex_has_normal());
195 EXPECT_NEAR(-0.038545f, mesh_.normal(mesh_.face_handle(0))[0], 0.0001 ) <<
"Wrong face normal at face 0 component 0";
196 EXPECT_NEAR(-0.004330f, mesh_.normal(mesh_.face_handle(0))[1], 0.0001 ) <<
"Wrong face normal at face 0 component 1";
197 EXPECT_NEAR(0.999247f, mesh_.normal(mesh_.face_handle(0))[2], 0.0001 ) <<
"Wrong face normal at face 0 component 2";
199 EXPECT_EQ(7526u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
200 EXPECT_EQ(22572u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
201 EXPECT_EQ(15048u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
203 mesh_.release_face_normals();
211 TEST_F(OpenMeshReadWriteSTL, ReadWriteSimpleSTLAsciiFileWithNormals) {
214 mesh_.request_face_normals();
224 const char* filename =
"cube1Normal_openmeshWriteTestFile.stl";
236 EXPECT_FALSE(opt.is_binary());
237 EXPECT_TRUE(opt.face_has_normal());
238 EXPECT_FALSE(opt.vertex_has_normal());
240 EXPECT_NEAR(-0.038545f, mesh_.normal(mesh_.face_handle(0))[0], 0.0001 ) <<
"Wrong face normal at face 0 component 0";
241 EXPECT_NEAR(-0.004330f, mesh_.normal(mesh_.face_handle(0))[1], 0.0001 ) <<
"Wrong face normal at face 0 component 1";
242 EXPECT_NEAR(0.999247f, mesh_.normal(mesh_.face_handle(0))[2], 0.0001 ) <<
"Wrong face normal at face 0 component 2";
244 EXPECT_EQ(7526u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
245 EXPECT_EQ(22572u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
246 EXPECT_EQ(15048u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
248 mesh_.release_face_normals();
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.
Has (r) / store (w) face normals.
Set options for reader/writer modules.
void clear(void)
Clear all bits.
bool write_mesh(const Mesh &_mesh, const std::string &_filename, Options _opt=Options::Default, std::streamsize _precision=6)
Write a mesh to the file _filename.