2 #include <gtest/gtest.h> 3 #include <Unittests/unittests_common.hh> 14 virtual void SetUp() {
20 virtual void TearDown() {
38 TEST_F(OpenMeshReadWriteOBJ, LoadSimpleOBJ) {
44 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal.obj";
46 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
47 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
48 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
54 TEST_F(OpenMeshReadWriteOBJ, LoadDegeneratedOBJ) {
60 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-degenerated.obj";
62 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
63 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
64 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
70 TEST_F(OpenMeshReadWriteOBJ, LoadSimpleOBJCheckHalfEdgeAndVertexNormals) {
74 mesh_.request_halfedge_normals();
75 mesh_.request_vertex_normals();
80 std::string file_name =
"cube-minimal.obj";
84 EXPECT_TRUE(ok) << file_name;
86 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
87 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
88 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
89 EXPECT_EQ(36u , mesh_.n_halfedges()) <<
"The number of loaded halfedges is not correct!";
93 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex normal at vertex 0 component 0";
94 EXPECT_EQ(-1, mesh_.normal(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex normal at vertex 0 component 1";
95 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex normal at vertex 0 component 2";
97 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex normal at vertex 3 component 0";
98 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex normal at vertex 3 component 1";
99 EXPECT_EQ(1, mesh_.normal(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex normal at vertex 3 component 2";
101 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex normal at vertex 4 component 0";
102 EXPECT_EQ(-1, mesh_.normal(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex normal at vertex 4 component 1";
103 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex normal at vertex 4 component 2";
105 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex normal at vertex 7 component 0";
106 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex normal at vertex 7 component 1";
107 EXPECT_EQ(1, mesh_.normal(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex normal at vertex 7 component 2";
111 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(0))[0] ) <<
"Wrong halfedge normal at halfedge 0 component 0";
112 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(0))[1] ) <<
"Wrong halfedge normal at halfedge 0 component 1";
113 EXPECT_EQ(-1, mesh_.normal(mesh_.halfedge_handle(0))[2] ) <<
"Wrong halfedge normal at halfedge 0 component 2";
115 EXPECT_EQ(-1, mesh_.normal(mesh_.halfedge_handle(10))[0] ) <<
"Wrong halfedge normal at halfedge 10 component 0";
116 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(10))[1] ) <<
"Wrong halfedge normal at halfedge 10 component 1";
117 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(10))[2] ) <<
"Wrong halfedge normal at halfedge 10 component 2";
119 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(19))[0] ) <<
"Wrong halfedge normal at halfedge 19 component 0";
120 EXPECT_EQ(1, mesh_.normal(mesh_.halfedge_handle(19))[1] ) <<
"Wrong halfedge normal at halfedge 19 component 1";
121 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(19))[2] ) <<
"Wrong halfedge normal at halfedge 19 component 2";
123 EXPECT_EQ(1, mesh_.normal(mesh_.halfedge_handle(24))[0] ) <<
"Wrong halfedge normal at halfedge 24 component 0";
124 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(24))[1] ) <<
"Wrong halfedge normal at halfedge 24 component 1";
125 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(24))[2] ) <<
"Wrong halfedge normal at halfedge 24 component 2";
127 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(30))[0] ) <<
"Wrong halfedge normal at halfedge 30 component 0";
128 EXPECT_EQ(-1, mesh_.normal(mesh_.halfedge_handle(30))[1] ) <<
"Wrong halfedge normal at halfedge 30 component 1";
129 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(30))[2] ) <<
"Wrong halfedge normal at halfedge 30 component 2";
131 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(35))[0] ) <<
"Wrong halfedge normal at halfedge 35 component 0";
132 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(35))[1] ) <<
"Wrong halfedge normal at halfedge 35 component 1";
133 EXPECT_EQ(1, mesh_.normal(mesh_.halfedge_handle(35))[2] ) <<
"Wrong halfedge normal at halfedge 35 component 2";
135 mesh_.release_vertex_normals();
136 mesh_.release_halfedge_normals();
143 TEST_F(OpenMeshReadWriteOBJ, LoadSimpleOBJForceVertexColorsAlthoughNotAvailable) {
147 mesh_.request_vertex_colors();
149 std::string file_name =
"cube-minimal.obj";
156 EXPECT_TRUE(ok) << file_name;
158 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
159 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
160 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
161 EXPECT_EQ(36u , mesh_.n_halfedges()) <<
"The number of loaded halfedges is not correct!";
169 TEST_F(OpenMeshReadWriteOBJ, LoadSimpleOBJCheckTexCoords) {
173 mesh_.request_halfedge_texcoords2D();
178 std::string file_name =
"cube-minimal-texCoords.obj";
182 EXPECT_TRUE(ok) << file_name;
184 EXPECT_EQ(1, mesh_.texcoord2D(mesh_.halfedge_handle(0))[0] ) <<
"Wrong texCoord at halfedge 0 component 0";
185 EXPECT_EQ(1, mesh_.texcoord2D(mesh_.halfedge_handle(0))[1] ) <<
"Wrong texCoord at halfedge 0 component 1";
187 EXPECT_EQ(3, mesh_.texcoord2D(mesh_.halfedge_handle(10))[0] ) <<
"Wrong texCoord at halfedge 1 component 0";
188 EXPECT_EQ(3, mesh_.texcoord2D(mesh_.halfedge_handle(10))[1] ) <<
"Wrong texCoord at halfedge 1 component 1";
190 EXPECT_EQ(6, mesh_.texcoord2D(mesh_.halfedge_handle(19))[0] ) <<
"Wrong texCoord at halfedge 4 component 0";
191 EXPECT_EQ(6, mesh_.texcoord2D(mesh_.halfedge_handle(19))[1] ) <<
"Wrong texCoord at halfedge 4 component 1";
193 EXPECT_EQ(7, mesh_.texcoord2D(mesh_.halfedge_handle(24))[0] ) <<
"Wrong texCoord at halfedge 7 component 0";
194 EXPECT_EQ(7, mesh_.texcoord2D(mesh_.halfedge_handle(24))[1] ) <<
"Wrong texCoord at halfedge 7 component 1";
196 EXPECT_EQ(9, mesh_.texcoord2D(mesh_.halfedge_handle(30))[0] ) <<
"Wrong texCoord at halfedge 9 component 0";
197 EXPECT_EQ(9, mesh_.texcoord2D(mesh_.halfedge_handle(30))[1] ) <<
"Wrong texCoord at halfedge 9 component 1";
199 EXPECT_EQ(12, mesh_.texcoord2D(mesh_.halfedge_handle(35))[0] ) <<
"Wrong texCoord at halfedge 11 component 0";
200 EXPECT_EQ(12, mesh_.texcoord2D(mesh_.halfedge_handle(35))[1] ) <<
"Wrong texCoord at halfedge 11 component 1";
202 mesh_.release_halfedge_texcoords2D();
208 TEST_F(OpenMeshReadWriteOBJ, LoadStoreSimpleOBJCheckTexCoords) {
212 mesh_.request_halfedge_texcoords2D();
217 std::string file_name =
"cube-minimal-texCoords.obj";
221 EXPECT_TRUE(ok) << file_name;
228 EXPECT_TRUE(writeOk) <<
"writeTest.obj";
229 mesh_.release_halfedge_texcoords2D();
234 loadedMesh_.request_halfedge_texcoords2D();
239 EXPECT_TRUE(readOk) << file_name;
240 EXPECT_EQ(1, loadedMesh_.texcoord2D(mesh_.halfedge_handle(0))[0] ) <<
"Wrong texCoord at halfedge 0 component 0";
241 EXPECT_EQ(1, loadedMesh_.texcoord2D(mesh_.halfedge_handle(0))[1] ) <<
"Wrong texCoord at halfedge 0 component 1";
243 EXPECT_EQ(3, loadedMesh_.texcoord2D(mesh_.halfedge_handle(10))[0] ) <<
"Wrong texCoord at halfedge 1 component 0";
244 EXPECT_EQ(3, loadedMesh_.texcoord2D(mesh_.halfedge_handle(10))[1] ) <<
"Wrong texCoord at halfedge 1 component 1";
246 EXPECT_EQ(6, loadedMesh_.texcoord2D(mesh_.halfedge_handle(19))[0] ) <<
"Wrong texCoord at halfedge 4 component 0";
247 EXPECT_EQ(6, loadedMesh_.texcoord2D(mesh_.halfedge_handle(19))[1] ) <<
"Wrong texCoord at halfedge 4 component 1";
249 EXPECT_EQ(7, loadedMesh_.texcoord2D(mesh_.halfedge_handle(24))[0] ) <<
"Wrong texCoord at halfedge 7 component 0";
250 EXPECT_EQ(7, loadedMesh_.texcoord2D(mesh_.halfedge_handle(24))[1] ) <<
"Wrong texCoord at halfedge 7 component 1";
252 EXPECT_EQ(9, loadedMesh_.texcoord2D(mesh_.halfedge_handle(30))[0] ) <<
"Wrong texCoord at halfedge 9 component 0";
253 EXPECT_EQ(9, loadedMesh_.texcoord2D(mesh_.halfedge_handle(30))[1] ) <<
"Wrong texCoord at halfedge 9 component 1";
255 EXPECT_EQ(12, loadedMesh_.texcoord2D(mesh_.halfedge_handle(35))[0] ) <<
"Wrong texCoord at halfedge 11 component 0";
256 EXPECT_EQ(12, loadedMesh_.texcoord2D(mesh_.halfedge_handle(35))[1] ) <<
"Wrong texCoord at halfedge 11 component 1";
258 loadedMesh_.release_halfedge_texcoords2D();
264 TEST_F(OpenMeshReadWriteOBJ, LoadSimpleOBJCheckTexCoords3d) {
268 mesh_.request_halfedge_texcoords3D();
273 std::string file_name =
"cube-minimal-texCoords3d.obj";
277 EXPECT_TRUE(ok) << file_name;
279 EXPECT_EQ(1, mesh_.texcoord3D(mesh_.halfedge_handle(0))[0] ) <<
"Wrong texCoord at halfedge 0 component 0";
280 EXPECT_EQ(1, mesh_.texcoord3D(mesh_.halfedge_handle(0))[1] ) <<
"Wrong texCoord at halfedge 0 component 1";
281 EXPECT_EQ(1, mesh_.texcoord3D(mesh_.halfedge_handle(0))[2] ) <<
"Wrong texCoord at halfedge 0 component 2";
283 EXPECT_EQ(3, mesh_.texcoord3D(mesh_.halfedge_handle(10))[0] ) <<
"Wrong texCoord at halfedge 1 component 0";
284 EXPECT_EQ(3, mesh_.texcoord3D(mesh_.halfedge_handle(10))[1] ) <<
"Wrong texCoord at halfedge 1 component 1";
285 EXPECT_EQ(3, mesh_.texcoord3D(mesh_.halfedge_handle(10))[2] ) <<
"Wrong texCoord at halfedge 1 component 2";
287 EXPECT_EQ(6, mesh_.texcoord3D(mesh_.halfedge_handle(19))[0] ) <<
"Wrong texCoord at halfedge 4 component 0";
288 EXPECT_EQ(6, mesh_.texcoord3D(mesh_.halfedge_handle(19))[1] ) <<
"Wrong texCoord at halfedge 4 component 1";
289 EXPECT_EQ(6, mesh_.texcoord3D(mesh_.halfedge_handle(19))[2] ) <<
"Wrong texCoord at halfedge 4 component 2";
291 EXPECT_EQ(7, mesh_.texcoord3D(mesh_.halfedge_handle(24))[0] ) <<
"Wrong texCoord at halfedge 7 component 0";
292 EXPECT_EQ(7, mesh_.texcoord3D(mesh_.halfedge_handle(24))[1] ) <<
"Wrong texCoord at halfedge 7 component 1";
293 EXPECT_EQ(7, mesh_.texcoord3D(mesh_.halfedge_handle(24))[2] ) <<
"Wrong texCoord at halfedge 7 component 2";
295 EXPECT_EQ(9, mesh_.texcoord3D(mesh_.halfedge_handle(30))[0] ) <<
"Wrong texCoord at halfedge 9 component 0";
296 EXPECT_EQ(9, mesh_.texcoord3D(mesh_.halfedge_handle(30))[1] ) <<
"Wrong texCoord at halfedge 9 component 1";
297 EXPECT_EQ(9, mesh_.texcoord3D(mesh_.halfedge_handle(30))[2] ) <<
"Wrong texCoord at halfedge 9 component 2";
299 EXPECT_EQ(12, mesh_.texcoord3D(mesh_.halfedge_handle(35))[0] ) <<
"Wrong texCoord at halfedge 11 component 0";
300 EXPECT_EQ(12, mesh_.texcoord3D(mesh_.halfedge_handle(35))[1] ) <<
"Wrong texCoord at halfedge 11 component 1";
301 EXPECT_EQ(12, mesh_.texcoord3D(mesh_.halfedge_handle(35))[2] ) <<
"Wrong texCoord at halfedge 11 component 2";
303 mesh_.request_halfedge_texcoords3D();
309 TEST_F(OpenMeshReadWriteOBJ, LoadObjWithMaterial) {
313 mesh_.request_face_colors();
318 std::string file_name =
"square_material.obj";
322 EXPECT_TRUE(ok) << file_name;
326 EXPECT_TRUE(fh.
is_valid()) <<
"fh should be valid";
328 EXPECT_EQ(128, mesh_.color(fh)[0] ) <<
"Wrong vertex color at vertex 0 component 0";
329 EXPECT_EQ(128, mesh_.color(fh)[1] ) <<
"Wrong vertex color at vertex 0 component 1";
330 EXPECT_EQ(128, mesh_.color(fh)[2] ) <<
"Wrong vertex color at vertex 0 component 2";
332 mesh_.release_face_colors();
335 TEST_F(OpenMeshReadWriteOBJ, LoadObjWithTexture) {
339 mesh_.request_face_colors();
340 mesh_.request_face_texture_index();
345 std::string file_name =
"square_material_texture.obj";
349 EXPECT_TRUE(ok) << file_name;
353 mesh_.get_property_handle(property,
"TextureMapping");
354 EXPECT_EQ(mesh_.property(property).size(), 1u) <<
"More than one texture defined";
355 std::map< int, std::string >::iterator tex = mesh_.property(property).find(1);
356 EXPECT_TRUE(tex != mesh_.property(property).end()) <<
"Could not find texture with id 1";
357 EXPECT_TRUE((mesh_.property(property)[1] == std::string(
"square_material_texture.jpg"))) <<
"Wrong texture name";
361 EXPECT_TRUE(fh.
is_valid()) <<
"fh should be valid";
362 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(),fh),1) <<
"Face texture index is not set correctly";
364 mesh_.release_face_colors();
365 mesh_.release_face_texture_index();
371 TEST_F(OpenMeshReadWriteOBJ, LoadSimpleOBJWithVertexColorsAfterVertices) {
375 mesh_.request_vertex_colors();
382 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-vertex-colors-after-vertex-definition.obj";
384 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
385 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
386 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
388 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
389 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
390 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
392 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
393 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
394 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
396 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
397 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
398 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
400 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
401 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
402 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
404 mesh_.release_vertex_colors();
410 TEST_F(OpenMeshReadWriteOBJ, LoadSimpleOBJWithVertexColorsAsVCLines) {
414 mesh_.request_vertex_colors();
421 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-vertex-colors-as-vc-lines.obj";
423 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
424 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
425 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
427 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
428 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
429 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
431 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
432 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
433 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
435 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
436 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
437 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
439 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
440 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
441 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
443 mesh_.release_vertex_colors();
450 TEST_F(OpenMeshReadWriteOBJ, ReadWriteReadSimpleOBJ) {
453 mesh_.request_vertex_normals();
459 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal.obj";
463 const char* filename =
"cube-minimal_openmeshOutputTestfile.obj";
466 mesh_.release_vertex_normals();
467 ASSERT_TRUE(ok) <<
"Unable to write obj mesh";
470 mesh2.request_vertex_normals();
477 ASSERT_TRUE(ok) <<
"Unable to read written mesh";
479 EXPECT_EQ(8u , mesh2.n_vertices()) <<
"The number of loaded vertices is not correct!";
480 EXPECT_EQ(18u , mesh2.n_edges()) <<
"The number of loaded edges is not correct!";
481 EXPECT_EQ(12u , mesh2.n_faces()) <<
"The number of loaded faces is not correct!";
485 EXPECT_EQ(0, mesh2.normal(mesh2.vertex_handle(0))[0] ) <<
"Wrong vertex normal at vertex 0 component 0";
486 EXPECT_EQ(-1, mesh2.normal(mesh2.vertex_handle(0))[1] ) <<
"Wrong vertex normal at vertex 0 component 1";
487 EXPECT_EQ(0, mesh2.normal(mesh2.vertex_handle(0))[2] ) <<
"Wrong vertex normal at vertex 0 component 2";
489 EXPECT_EQ(0, mesh2.normal(mesh2.vertex_handle(3))[0] ) <<
"Wrong vertex normal at vertex 3 component 0";
490 EXPECT_EQ(0, mesh2.normal(mesh2.vertex_handle(3))[1] ) <<
"Wrong vertex normal at vertex 3 component 1";
491 EXPECT_EQ(1, mesh2.normal(mesh2.vertex_handle(3))[2] ) <<
"Wrong vertex normal at vertex 3 component 2";
493 EXPECT_EQ(0, mesh2.normal(mesh2.vertex_handle(4))[0] ) <<
"Wrong vertex normal at vertex 4 component 0";
494 EXPECT_EQ(-1, mesh2.normal(mesh2.vertex_handle(4))[1] ) <<
"Wrong vertex normal at vertex 4 component 1";
495 EXPECT_EQ(0, mesh2.normal(mesh2.vertex_handle(4))[2] ) <<
"Wrong vertex normal at vertex 4 component 2";
497 EXPECT_EQ(0, mesh2.normal(mesh2.vertex_handle(7))[0] ) <<
"Wrong vertex normal at vertex 7 component 0";
498 EXPECT_EQ(0, mesh2.normal(mesh2.vertex_handle(7))[1] ) <<
"Wrong vertex normal at vertex 7 component 1";
499 EXPECT_EQ(1, mesh2.normal(mesh2.vertex_handle(7))[2] ) <<
"Wrong vertex normal at vertex 7 component 2";
504 TEST_F(OpenMeshReadWriteOBJ, FaceTexCoordTest) {
507 mesh_.request_vertex_normals();
508 mesh_.request_halfedge_texcoords2D();
518 std::vector<Mesh::VertexHandle> face_vhandles;
520 face_vhandles.push_back(vhandle[2]);
521 face_vhandles.push_back(vhandle[1]);
522 face_vhandles.push_back(vhandle[0]);
524 Mesh::FaceHandle fh = mesh_.add_face(face_vhandles);
538 for (
auto he : mesh_.halfedges() ) {
547 for (
auto he : mesh_.fh_range(fh) )
562 EXPECT_TRUE(ok) <<
"Unable to write OpenMeshReadWriteOBJ_FaceTexCoordTest.obj";
571 mesh_.request_vertex_normals();
572 mesh_.request_face_normals();
573 mesh_.request_halfedge_texcoords2D();
577 EXPECT_TRUE(ok) <<
"Unable to read back OpenMeshReadWriteOBJ_FaceTexCoordTest.obj";
Has (r) / store (w) vertex colors.
Kernel::Point Point
Coordinate type.
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Has (r) / store (w) face colors.
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.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Has (r) / store (w) face texture coordinates.
Kernel::TexCoord2D TexCoord2D
TexCoord2D type.
Kernel::Normal Normal
Normal type.
Handle for a face entity.
void clear(void)
Clear all bits.
Set options for reader/writer modules.
Has (r) / store (w) vertex normals.
bool is_valid() const
The handle is valid iff the index is not negative.
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.