1#include <gtest/gtest.h>
2#include <Unittests/unittests_common.hh>
12 virtual void SetUp() {
18 virtual void TearDown() {
33class OpenMeshReadWritePLYColorVec3f :
public testing::Test {
38 virtual void SetUp() {
44 virtual void TearDown() {
63TEST_F(OpenMeshReadWritePLY, LoadSimplePointPLYFileWithBadEncoding) {
69 EXPECT_TRUE(ok) <<
"Unable to load pointCloudBadEncoding.ply";
71 EXPECT_EQ(10u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
72 EXPECT_EQ(0u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
73 EXPECT_EQ(0u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
80TEST_F(OpenMeshReadWritePLY, LoadSimplePointPLYFileWithGoodEncoding) {
86 EXPECT_TRUE(ok) <<
"Unable to load pointCloudGoodEncoding.ply";
88 EXPECT_EQ(10u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
89 EXPECT_EQ(0u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
90 EXPECT_EQ(0u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
96TEST_F(OpenMeshReadWritePLY, LoadSimplePLY) {
102 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal.ply";
104 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
105 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
106 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
114TEST_F(OpenMeshReadWritePLY, LoadSimplePLYNoEndl) {
120 EXPECT_TRUE(ok) <<
"Unable to load sphere840.ply";
122 EXPECT_EQ(422u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
123 EXPECT_EQ(1260u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
124 EXPECT_EQ(840u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
131TEST_F(OpenMeshReadWritePLY, LoadSimplePLYForceVertexColorsAlthoughNotAvailable) {
135 mesh_.request_vertex_colors();
137 std::string file_name =
"cube-minimal.ply";
144 EXPECT_TRUE(ok) << file_name;
146 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
147 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
148 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
149 EXPECT_EQ(36u , mesh_.n_halfedges()) <<
"The number of loaded halfedges is not correct!";
151 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
152 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
153 EXPECT_FALSE(options.vertex_has_color()) <<
"Wrong user options are returned!";
159TEST_F(OpenMeshReadWritePLY, LoadSimplePLYWithVertexColors) {
163 mesh_.request_vertex_colors();
170 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-vertexColors.ply";
172 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
173 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
174 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
176#ifdef TEST_DOUBLE_TRAITS
177 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
178 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
179 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
181 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
182 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
183 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
185 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
186 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
187 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
189 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
190 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
191 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
193 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
194 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
195 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
197 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
198 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
199 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
201 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
202 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
203 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
205 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
206 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
207 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
210 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
211 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
212 EXPECT_TRUE(options.vertex_has_color()) <<
"Wrong user options are returned!";
214 mesh_.release_vertex_colors();
220TEST_F(OpenMeshReadWritePLY, LoadPLYFromMeshLabWithVertexColors) {
224 mesh_.request_vertex_colors();
231 EXPECT_TRUE(ok) <<
"Unable to load meshlab.ply";
233 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
234 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
235 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
237#ifdef TEST_DOUBLE_TRAITS
238 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
239 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
240 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
242 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
243 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
244 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
246 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
247 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
248 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
250 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
251 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
252 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
254 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
255 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
256 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
258 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
259 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
260 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
262 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
263 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
264 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
266 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
267 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
268 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
271 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
272 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
273 EXPECT_TRUE(options.vertex_has_color()) <<
"Wrong user options are returned!";
275 mesh_.release_vertex_colors();
281TEST_F(OpenMeshReadWritePLY, WriteAndReadBinaryPLYWithVertexColors) {
285 mesh_.request_vertex_colors();
292 EXPECT_TRUE(ok) <<
"Unable to load meshlab.ply";
297 EXPECT_TRUE(ok) <<
"Unable to write meshlab_binary.ply";
301 EXPECT_TRUE(ok) <<
"Unable to load meshlab_binary.ply";
303 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
304 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
305 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
307#ifdef TEST_DOUBLE_TRAITS
308 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
309 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
310 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
312 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
313 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
314 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
316 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
317 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
318 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
320 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
321 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
322 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
324 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
325 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
326 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
328 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
329 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
330 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
332 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
333 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
334 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
336 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
337 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
338 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
341 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
342 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
343 EXPECT_TRUE(options.vertex_has_color()) <<
"Wrong user options are returned!";
345 mesh_.release_vertex_colors();
351TEST_F(OpenMeshReadWritePLY, WriteAndReadPLYWithFloatVertexColors) {
355 mesh_.request_vertex_colors();
362 EXPECT_TRUE(ok) <<
"Unable to load meshlab.ply";
367 EXPECT_TRUE(ok) <<
"Unable to write meshlab_float.ply";
371 EXPECT_TRUE(ok) <<
"Unable to load meshlab_float.ply";
373 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
374 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
375 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
377#ifdef TEST_DOUBLE_TRAITS
378 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
379 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
380 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
382 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
383 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
384 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
386 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
387 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
388 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
390 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
391 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
392 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
394 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
395 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
396 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
398 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
399 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
400 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
402 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
403 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
404 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
406 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
407 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
408 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
411 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
412 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
413 EXPECT_TRUE(options.vertex_has_color()) <<
"Wrong user options are returned!";
414 EXPECT_TRUE(options.color_is_float()) <<
"Wrong user options are returned!";
416 mesh_.release_vertex_colors();
422TEST_F(OpenMeshReadWritePLY, WriteAndReadBinaryPLYWithFloatVertexColors) {
426 mesh_.request_vertex_colors();
433 EXPECT_TRUE(ok) <<
"Unable to load meshlab.ply";
439 EXPECT_TRUE(ok) <<
"Unable to write meshlab_binary_float.ply";
443 EXPECT_TRUE(ok) <<
"Unable to load meshlab_binary_float.ply";
445 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
446 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
447 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
449#ifdef TEST_DOUBLE_TRAITS
450 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
451 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
452 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
454 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
455 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
456 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
458 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
459 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
460 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
462 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
463 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
464 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
466 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
467 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
468 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
470 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
471 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
472 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
474 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
475 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
476 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
478 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
479 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
480 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
483 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
484 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
485 EXPECT_TRUE(options.vertex_has_color()) <<
"Wrong user options are returned!";
486 EXPECT_TRUE(options.color_is_float()) <<
"Wrong user options are returned!";
487 EXPECT_TRUE(options.is_binary()) <<
"Wrong user options are returned!";
489 mesh_.release_vertex_colors();
495TEST_F(OpenMeshReadWritePLY, LoadPLYFromMeshLabWithFaceTexCoord) {
499 mesh_.request_halfedge_texcoords2D();
500 mesh_.request_face_texture_index();
505 std::string file_name =
"meshlab-faceTexCoords.ply";
509 EXPECT_TRUE(ok) <<
"Unable to load meshlab-faceTexCoords.ply";
511 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
512 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
513 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
515 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
516 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
517 EXPECT_TRUE(options.face_has_texcoord()) <<
"Wrong user options are returned!";
519 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(0))[0] ) <<
"Wrong texCoord at halfedge 0 component 0";
520 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(0))[1] ) <<
"Wrong texCoord at halfedge 0 component 1";
521 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(1))[0] ) <<
"Wrong texCoord at halfedge 1 component 0";
522 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(1))[1] ) <<
"Wrong texCoord at halfedge 1 component 1";
523 EXPECT_FLOAT_EQ(0.2, mesh_.texcoord2D(mesh_.halfedge_handle(2))[0] ) <<
"Wrong texCoord at halfedge 2 component 0";
524 EXPECT_FLOAT_EQ(0.2, mesh_.texcoord2D(mesh_.halfedge_handle(2))[1] ) <<
"Wrong texCoord at halfedge 2 component 1";
525 EXPECT_FLOAT_EQ(-0.2, mesh_.texcoord2D(mesh_.halfedge_handle(3))[0] ) <<
"Wrong texCoord at halfedge 3 component 0";
526 EXPECT_FLOAT_EQ(-0.2, mesh_.texcoord2D(mesh_.halfedge_handle(3))[1] ) <<
"Wrong texCoord at halfedge 3 component 1";
527 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(4))[0] ) <<
"Wrong texCoord at halfedge 4 component 0";
528 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(4))[1] ) <<
"Wrong texCoord at halfedge 4 component 1";
529 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(5))[0] ) <<
"Wrong texCoord at halfedge 5 component 0";
530 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(5))[1] ) <<
"Wrong texCoord at halfedge 5 component 1";
531 EXPECT_FLOAT_EQ(-0.1, mesh_.texcoord2D(mesh_.halfedge_handle(6))[0] ) <<
"Wrong texCoord at halfedge 6 component 0";
532 EXPECT_FLOAT_EQ(-0.1, mesh_.texcoord2D(mesh_.halfedge_handle(6))[1] ) <<
"Wrong texCoord at halfedge 6 component 1";
533 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(7))[0] ) <<
"Wrong texCoord at halfedge 7 component 0";
534 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(7))[1] ) <<
"Wrong texCoord at halfedge 7 component 1";
535 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(8))[0] ) <<
"Wrong texCoord at halfedge 8 component 0";
536 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(8))[1] ) <<
"Wrong texCoord at halfedge 8 component 1";
537 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(9))[0] ) <<
"Wrong texCoord at halfedge 9 component 0";
538 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(9))[1] ) <<
"Wrong texCoord at halfedge 9 component 1";
539 EXPECT_FLOAT_EQ(0.2, mesh_.texcoord2D(mesh_.halfedge_handle(10))[0] ) <<
"Wrong texCoord at halfedge 10 component 0";
540 EXPECT_FLOAT_EQ(0.3, mesh_.texcoord2D(mesh_.halfedge_handle(10))[1] ) <<
"Wrong texCoord at halfedge 10 component 1";
541 EXPECT_FLOAT_EQ(0.2, mesh_.texcoord2D(mesh_.halfedge_handle(11))[0] ) <<
"Wrong texCoord at halfedge 11 component 0";
542 EXPECT_FLOAT_EQ(0.2, mesh_.texcoord2D(mesh_.halfedge_handle(11))[1] ) <<
"Wrong texCoord at halfedge 11 component 1";
543 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(12))[0] ) <<
"Wrong texCoord at halfedge 12 component 0";
544 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(12))[1] ) <<
"Wrong texCoord at halfedge 12 component 1";
545 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(13))[0] ) <<
"Wrong texCoord at halfedge 13 component 0";
546 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(13))[1] ) <<
"Wrong texCoord at halfedge 13 component 1";
547 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(14))[0] ) <<
"Wrong texCoord at halfedge 14 component 0";
548 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(14))[1] ) <<
"Wrong texCoord at halfedge 14 component 1";
549 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(15))[0] ) <<
"Wrong texCoord at halfedge 15 component 0";
550 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(15))[1] ) <<
"Wrong texCoord at halfedge 15 component 1";
551 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(16))[0] ) <<
"Wrong texCoord at halfedge 16 component 0";
552 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(16))[1] ) <<
"Wrong texCoord at halfedge 16 component 1";
553 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(17))[0] ) <<
"Wrong texCoord at halfedge 17 component 0";
554 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(17))[1] ) <<
"Wrong texCoord at halfedge 17 component 1";
558 mesh_.get_property_handle(property,
"TextureMapping");
559 EXPECT_EQ(mesh_.property(property).size(), 2u) <<
"Wrong texture number";
560 EXPECT_EQ(mesh_.property(property).count(0), 1u) <<
"Could not find texture with id 0";
561 EXPECT_TRUE((mesh_.property(property)[0] == std::string(
"tex_0.jpg"))) <<
"Wrong texture name";
562 EXPECT_EQ(mesh_.property(property).count(1), 1u) <<
"Could not find texture with id 1";
563 EXPECT_TRUE((mesh_.property(property)[1] == std::string(
"tex_1.jpg"))) <<
"Wrong texture name";
566 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(0)), 0) <<
"Face 0 texture index is not set correctly";
567 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(1)), 0) <<
"Face 1 texture index is not set correctly";
568 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(2)), 1) <<
"Face 2 texture index is not set correctly";
569 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(3)), 1) <<
"Face 3 texture index is not set correctly";
570 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(4)), 1) <<
"Face 4 texture index is not set correctly";
571 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(5)), 1) <<
"Face 5 texture index is not set correctly";
572 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(6)), 0) <<
"Face 6 texture index is not set correctly";
573 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(7)), 0) <<
"Face 7 texture index is not set correctly";
574 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(8)), 0) <<
"Face 8 texture index is not set correctly";
575 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(9)), 0) <<
"Face 9 texture index is not set correctly";
576 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(10)), 0) <<
"Face 10 texture index is not set correctly";
577 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(11)), 0) <<
"Face 11 texture index is not set correctly";
579 mesh_.release_halfedge_texcoords2D();
580 mesh_.release_face_texture_index();
587TEST_F(OpenMeshReadWritePLY, LoadBinaryPLYFromMeshLabWithFaceTexCoord) {
591 mesh_.request_halfedge_texcoords2D();
592 mesh_.request_face_texture_index();
598 std::string file_name =
"meshlab-faceTexCoords-binary.ply";
602 EXPECT_TRUE(ok) <<
"Unable to load meshlab-faceTexCoords-binary.ply";
604 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
605 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
606 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
608 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
609 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
610 EXPECT_TRUE(options.face_has_texcoord()) <<
"Wrong user options are returned!";
612 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(0))[0] ) <<
"Wrong texCoord at halfedge 0 component 0";
613 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(0))[1] ) <<
"Wrong texCoord at halfedge 0 component 1";
614 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(1))[0] ) <<
"Wrong texCoord at halfedge 1 component 0";
615 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(1))[1] ) <<
"Wrong texCoord at halfedge 1 component 1";
616 EXPECT_FLOAT_EQ(0.2, mesh_.texcoord2D(mesh_.halfedge_handle(2))[0] ) <<
"Wrong texCoord at halfedge 2 component 0";
617 EXPECT_FLOAT_EQ(0.2, mesh_.texcoord2D(mesh_.halfedge_handle(2))[1] ) <<
"Wrong texCoord at halfedge 2 component 1";
618 EXPECT_FLOAT_EQ(-0.2, mesh_.texcoord2D(mesh_.halfedge_handle(3))[0] ) <<
"Wrong texCoord at halfedge 3 component 0";
619 EXPECT_FLOAT_EQ(-0.2, mesh_.texcoord2D(mesh_.halfedge_handle(3))[1] ) <<
"Wrong texCoord at halfedge 3 component 1";
620 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(4))[0] ) <<
"Wrong texCoord at halfedge 4 component 0";
621 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(4))[1] ) <<
"Wrong texCoord at halfedge 4 component 1";
622 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(5))[0] ) <<
"Wrong texCoord at halfedge 5 component 0";
623 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(5))[1] ) <<
"Wrong texCoord at halfedge 5 component 1";
624 EXPECT_FLOAT_EQ(-0.1, mesh_.texcoord2D(mesh_.halfedge_handle(6))[0] ) <<
"Wrong texCoord at halfedge 6 component 0";
625 EXPECT_FLOAT_EQ(-0.1, mesh_.texcoord2D(mesh_.halfedge_handle(6))[1] ) <<
"Wrong texCoord at halfedge 6 component 1";
626 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(7))[0] ) <<
"Wrong texCoord at halfedge 7 component 0";
627 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(7))[1] ) <<
"Wrong texCoord at halfedge 7 component 1";
628 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(8))[0] ) <<
"Wrong texCoord at halfedge 8 component 0";
629 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(8))[1] ) <<
"Wrong texCoord at halfedge 8 component 1";
630 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(9))[0] ) <<
"Wrong texCoord at halfedge 9 component 0";
631 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(9))[1] ) <<
"Wrong texCoord at halfedge 9 component 1";
632 EXPECT_FLOAT_EQ(0.2, mesh_.texcoord2D(mesh_.halfedge_handle(10))[0] ) <<
"Wrong texCoord at halfedge 10 component 0";
633 EXPECT_FLOAT_EQ(0.3, mesh_.texcoord2D(mesh_.halfedge_handle(10))[1] ) <<
"Wrong texCoord at halfedge 10 component 1";
634 EXPECT_FLOAT_EQ(0.2, mesh_.texcoord2D(mesh_.halfedge_handle(11))[0] ) <<
"Wrong texCoord at halfedge 11 component 0";
635 EXPECT_FLOAT_EQ(0.2, mesh_.texcoord2D(mesh_.halfedge_handle(11))[1] ) <<
"Wrong texCoord at halfedge 11 component 1";
636 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(12))[0] ) <<
"Wrong texCoord at halfedge 12 component 0";
637 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(12))[1] ) <<
"Wrong texCoord at halfedge 12 component 1";
638 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(13))[0] ) <<
"Wrong texCoord at halfedge 13 component 0";
639 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(13))[1] ) <<
"Wrong texCoord at halfedge 13 component 1";
640 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(14))[0] ) <<
"Wrong texCoord at halfedge 14 component 0";
641 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(14))[1] ) <<
"Wrong texCoord at halfedge 14 component 1";
642 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(15))[0] ) <<
"Wrong texCoord at halfedge 15 component 0";
643 EXPECT_FLOAT_EQ(0.1, mesh_.texcoord2D(mesh_.halfedge_handle(15))[1] ) <<
"Wrong texCoord at halfedge 15 component 1";
644 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(16))[0] ) <<
"Wrong texCoord at halfedge 16 component 0";
645 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(16))[1] ) <<
"Wrong texCoord at halfedge 16 component 1";
646 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(17))[0] ) <<
"Wrong texCoord at halfedge 17 component 0";
647 EXPECT_FLOAT_EQ(0, mesh_.texcoord2D(mesh_.halfedge_handle(17))[1] ) <<
"Wrong texCoord at halfedge 17 component 1";
651 mesh_.get_property_handle(property,
"TextureMapping");
652 EXPECT_EQ(mesh_.property(property).size(), 2u) <<
"Wrong texture number";
653 EXPECT_EQ(mesh_.property(property).count(0), 1u) <<
"Could not find texture with id 0";
654 EXPECT_TRUE((mesh_.property(property)[0] == std::string(
"tex_0.jpg"))) <<
"Wrong texture name";
655 EXPECT_EQ(mesh_.property(property).count(1), 1u) <<
"Could not find texture with id 1";
656 EXPECT_TRUE((mesh_.property(property)[1] == std::string(
"tex_1.jpg"))) <<
"Wrong texture name";
659 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(0)), 0) <<
"Face 0 texture index is not set correctly";
660 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(1)), 0) <<
"Face 1 texture index is not set correctly";
661 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(2)), 1) <<
"Face 2 texture index is not set correctly";
662 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(3)), 1) <<
"Face 3 texture index is not set correctly";
663 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(4)), 1) <<
"Face 4 texture index is not set correctly";
664 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(5)), 1) <<
"Face 5 texture index is not set correctly";
665 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(6)), 0) <<
"Face 6 texture index is not set correctly";
666 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(7)), 0) <<
"Face 7 texture index is not set correctly";
667 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(8)), 0) <<
"Face 8 texture index is not set correctly";
668 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(9)), 0) <<
"Face 9 texture index is not set correctly";
669 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(10)), 0) <<
"Face 10 texture index is not set correctly";
670 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(), mesh_.face_handle(11)), 0) <<
"Face 11 texture index is not set correctly";
672 mesh_.release_halfedge_texcoords2D();
673 mesh_.release_face_texture_index();
680TEST_F(OpenMeshReadWritePLY, LoadSimplePLYWithTexCoords) {
684 mesh_.request_vertex_texcoords2D();
691 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-texCoords.ply";
693 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
694 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
695 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
697 EXPECT_EQ(10, mesh_.texcoord2D(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
698 EXPECT_EQ(10, mesh_.texcoord2D(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
700 EXPECT_EQ(6, mesh_.texcoord2D(mesh_.vertex_handle(2))[0] ) <<
"Wrong vertex color at vertex 2 component 0";
701 EXPECT_EQ(6, mesh_.texcoord2D(mesh_.vertex_handle(2))[1] ) <<
"Wrong vertex color at vertex 2 component 1";
703 EXPECT_EQ(9, mesh_.texcoord2D(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
704 EXPECT_EQ(9, mesh_.texcoord2D(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
706 EXPECT_EQ(12, mesh_.texcoord2D(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
707 EXPECT_EQ(12, mesh_.texcoord2D(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
710 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
711 EXPECT_TRUE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
712 EXPECT_FALSE(options.vertex_has_color()) <<
"Wrong user options are returned!";
714 mesh_.release_vertex_texcoords2D();
720TEST_F(OpenMeshReadWritePLY, LoadSimplePLYWithNormals) {
724 mesh_.request_vertex_normals();
731 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-normals.ply";
733 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
734 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
735 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
737 EXPECT_TRUE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
738 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
739 EXPECT_FALSE(options.vertex_has_color()) <<
"Wrong user options are returned!";
742 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(0))[0] ) <<
"Wrong normal at vertex 0 component 0";
743 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(0))[1] ) <<
"Wrong normal at vertex 0 component 1";
744 EXPECT_EQ(1, mesh_.normal(mesh_.vertex_handle(0))[2] ) <<
"Wrong normal at vertex 0 component 2";
746 EXPECT_EQ(1, mesh_.normal(mesh_.vertex_handle(3))[0] ) <<
"Wrong normal at vertex 3 component 0";
747 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(3))[1] ) <<
"Wrong normal at vertex 3 component 1";
748 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(3))[2] ) <<
"Wrong normal at vertex 3 component 2";
750 EXPECT_EQ(1, mesh_.normal(mesh_.vertex_handle(4))[0] ) <<
"Wrong normal at vertex 4 component 0";
751 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(4))[1] ) <<
"Wrong normal at vertex 4 component 1";
752 EXPECT_EQ(1, mesh_.normal(mesh_.vertex_handle(4))[2] ) <<
"Wrong normal at vertex 4 component 2";
754 EXPECT_EQ(1, mesh_.normal(mesh_.vertex_handle(7))[0] ) <<
"Wrong normal at vertex 7 component 0";
755 EXPECT_EQ(1, mesh_.normal(mesh_.vertex_handle(7))[1] ) <<
"Wrong normal at vertex 7 component 1";
756 EXPECT_EQ(2, mesh_.normal(mesh_.vertex_handle(7))[2] ) <<
"Wrong normal at vertex 7 component 2";
758 mesh_.release_vertex_normals();
765TEST_F(OpenMeshReadWritePLY, LoadSimplePLYWithCustomProps) {
774 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-custom_props.ply";
776 EXPECT_EQ(8u , mesh.n_vertices()) <<
"The number of loaded vertices is not correct!";
777 EXPECT_EQ(12u , mesh.n_edges()) <<
"The number of loaded edges is not correct!";
778 EXPECT_EQ(6u , mesh.n_faces()) <<
"The number of loaded faces is not correct!";
782 ASSERT_TRUE(mesh.get_property_handle(qualityProp,
"quality")) <<
"Could not access quality property";
783 ASSERT_TRUE(mesh.get_property_handle(indexProp,
"index")) <<
"Could not access index property";
786 for (
unsigned i = 0; i < mesh.n_vertices(); ++i)
787 EXPECT_EQ(i ,mesh.property(indexProp,
OpenMesh::VertexHandle(i))) <<
"Vertex index at vertex " << i <<
" is wrong";
791 EXPECT_EQ(0.5f,mesh.property(qualityProp,
OpenMesh::VertexHandle(1))) <<
"Wrong quality value at Vertex 1";
792 EXPECT_EQ(0.7f,mesh.property(qualityProp,
OpenMesh::VertexHandle(2))) <<
"Wrong quality value at Vertex 2";
794 EXPECT_EQ(0.1f,mesh.property(qualityProp,
OpenMesh::VertexHandle(4))) <<
"Wrong quality value at Vertex 4";
802 ASSERT_TRUE(mesh.get_property_handle(testValues,
"test_values")) <<
"Could not access texcoords per face";
816 ASSERT_TRUE(mesh.get_property_handle(texCoordsPerFace,
"texcoords")) <<
"Could not access texcoords per face";
818 for (
Mesh::FaceIter f_iter = mesh.faces_begin(); f_iter != mesh.faces_end(); ++f_iter)
820 EXPECT_EQ(8u, mesh.property(texCoordsPerFace, *f_iter).size()) <<
"Texcoords per face container has wrong size on face: " << f_iter->
idx();
821 if (!mesh.property(texCoordsPerFace, *f_iter).empty())
823 EXPECT_EQ(1.0, mesh.property(texCoordsPerFace, *f_iter)[0]) <<
"Texcoords wrong on index 0 with face: " << f_iter->idx();
824 EXPECT_EQ(1.0, mesh.property(texCoordsPerFace, *f_iter)[1]) <<
"Texcoords wrong on index 1 with face: " << f_iter->idx();
825 EXPECT_EQ(-1.0f, mesh.property(texCoordsPerFace, *f_iter)[2]) <<
"Texcoords wrong on index 2 with face: " << f_iter->idx();
826 EXPECT_EQ(-1.0f, mesh.property(texCoordsPerFace, *f_iter)[3]) <<
"Texcoords wrong on index 3 with face: " << f_iter->idx();
827 EXPECT_EQ(0.0f, mesh.property(texCoordsPerFace, *f_iter)[4]) <<
"Texcoords wrong on index 4 with face: " << f_iter->idx();
828 EXPECT_EQ(0.0f, mesh.property(texCoordsPerFace, *f_iter)[5]) <<
"Texcoords wrong on index 5 with face: " << f_iter->idx();
829 EXPECT_EQ(-0.5f, mesh.property(texCoordsPerFace, *f_iter)[6]) <<
"Texcoords wrong on index 6 with face: " << f_iter->idx();
830 EXPECT_EQ(-0.5f, mesh.property(texCoordsPerFace, *f_iter)[7]) <<
"Texcoords wrong on index 7 with face: " << f_iter->idx();
836 ASSERT_TRUE(mesh.get_property_handle(faceIndex,
"faceIndex")) <<
"Could not access faceIndex per face";
838 EXPECT_EQ(0u,mesh.property(faceIndex,
OpenMesh::FaceHandle(0))) <<
"Wrong index value at FaceHandle 0";
839 EXPECT_EQ(1u,mesh.property(faceIndex,
OpenMesh::FaceHandle(1))) <<
"Wrong index value at FaceHandle 1";
840 EXPECT_EQ(2u,mesh.property(faceIndex,
OpenMesh::FaceHandle(2))) <<
"Wrong index value at FaceHandle 2";
841 EXPECT_EQ(3u,mesh.property(faceIndex,
OpenMesh::FaceHandle(3))) <<
"Wrong index value at FaceHandle 3";
842 EXPECT_EQ(4u,mesh.property(faceIndex,
OpenMesh::FaceHandle(4))) <<
"Wrong index value at FaceHandle 4";
843 EXPECT_EQ(5u,mesh.property(faceIndex,
OpenMesh::FaceHandle(5))) <<
"Wrong index value at FaceHandle 5";
850TEST_F(OpenMeshReadWritePLY, LoadSimplePLYWithCustomPropsBinary) {
860 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-custom_props.ply";
862 EXPECT_EQ(8u , mesh.n_vertices()) <<
"The number of loaded vertices is not correct!";
863 EXPECT_EQ(12u , mesh.n_edges()) <<
"The number of loaded edges is not correct!";
864 EXPECT_EQ(6u , mesh.n_faces()) <<
"The number of loaded faces is not correct!";
868 ASSERT_TRUE(mesh.get_property_handle(qualityProp,
"quality")) <<
"Could not access quality property";
869 ASSERT_TRUE(mesh.get_property_handle(indexProp,
"index")) <<
"Could not access index property";
872 for (
unsigned i = 0; i < mesh.n_vertices(); ++i)
873 EXPECT_EQ(i ,mesh.property(indexProp,
OpenMesh::VertexHandle(i))) <<
"Vertex index at vertex " << i <<
" is wrong";
877 EXPECT_EQ(0.5f,mesh.property(qualityProp,
OpenMesh::VertexHandle(1))) <<
"Wrong quality value at Vertex 1";
878 EXPECT_EQ(0.7f,mesh.property(qualityProp,
OpenMesh::VertexHandle(2))) <<
"Wrong quality value at Vertex 2";
880 EXPECT_EQ(0.1f,mesh.property(qualityProp,
OpenMesh::VertexHandle(4))) <<
"Wrong quality value at Vertex 4";
888 ASSERT_TRUE(mesh.get_property_handle(testValues,
"test_values")) <<
"Could not access texcoords per face";
902 ASSERT_TRUE(mesh.get_property_handle(texCoordsPerFace,
"texcoords")) <<
"Could not access texcoords per face";
904 for (
Mesh::FaceIter f_iter = mesh.faces_begin(); f_iter != mesh.faces_end(); ++f_iter)
906 EXPECT_EQ(8u, mesh.property(texCoordsPerFace, *f_iter).size()) <<
"Texcoords per face container has wrong size on face: " << f_iter->
idx();
907 if (!mesh.property(texCoordsPerFace, *f_iter).empty())
909 EXPECT_EQ(1.0, mesh.property(texCoordsPerFace, *f_iter)[0]) <<
"Texcoords wrong on index 0 with face: " << f_iter->idx();
910 EXPECT_EQ(1.0, mesh.property(texCoordsPerFace, *f_iter)[1]) <<
"Texcoords wrong on index 1 with face: " << f_iter->idx();
911 EXPECT_EQ(-1.0f, mesh.property(texCoordsPerFace, *f_iter)[2]) <<
"Texcoords wrong on index 2 with face: " << f_iter->idx();
912 EXPECT_EQ(-1.0f, mesh.property(texCoordsPerFace, *f_iter)[3]) <<
"Texcoords wrong on index 3 with face: " << f_iter->idx();
913 EXPECT_EQ(0.0f, mesh.property(texCoordsPerFace, *f_iter)[4]) <<
"Texcoords wrong on index 4 with face: " << f_iter->idx();
914 EXPECT_EQ(0.0f, mesh.property(texCoordsPerFace, *f_iter)[5]) <<
"Texcoords wrong on index 5 with face: " << f_iter->idx();
915 EXPECT_EQ(-0.5f, mesh.property(texCoordsPerFace, *f_iter)[6]) <<
"Texcoords wrong on index 6 with face: " << f_iter->idx();
916 EXPECT_EQ(-0.5f, mesh.property(texCoordsPerFace, *f_iter)[7]) <<
"Texcoords wrong on index 7 with face: " << f_iter->idx();
922 ASSERT_TRUE(mesh.get_property_handle(faceIndex,
"faceIndex")) <<
"Could not access faceIndex per face";
924 EXPECT_EQ(0u,mesh.property(faceIndex,
OpenMesh::FaceHandle(0))) <<
"Wrong index value at FaceHandle 0";
925 EXPECT_EQ(1u,mesh.property(faceIndex,
OpenMesh::FaceHandle(1))) <<
"Wrong index value at FaceHandle 1";
926 EXPECT_EQ(2u,mesh.property(faceIndex,
OpenMesh::FaceHandle(2))) <<
"Wrong index value at FaceHandle 2";
927 EXPECT_EQ(3u,mesh.property(faceIndex,
OpenMesh::FaceHandle(3))) <<
"Wrong index value at FaceHandle 3";
928 EXPECT_EQ(4u,mesh.property(faceIndex,
OpenMesh::FaceHandle(4))) <<
"Wrong index value at FaceHandle 4";
929 EXPECT_EQ(5u,mesh.property(faceIndex,
OpenMesh::FaceHandle(5))) <<
"Wrong index value at FaceHandle 5";
933TEST_F(OpenMeshReadWritePLY, WriteReadSimplePLYWithCustomProps) {
947 const std::string indexPropName =
"mySuperIndexProperty";
948 const std::string qualityPropName =
"quality";
949 const std::string facePropName =
"anotherPropForFaces";
950 const std::string nonPersistantName =
"nonPersistant";
951 const std::string removedPropName =
"willBeRemoved";
953 mesh.add_property(indexProp,indexPropName);
954 mesh.add_property(qualityProp,qualityPropName);
955 mesh.add_property(removedProp, removedPropName);
956 mesh.add_property(faceProp,facePropName);
957 mesh.add_property(nonPersistant,nonPersistantName);
959 mesh.property(indexProp).set_persistent(
true);
960 mesh.property(qualityProp).set_persistent(
true);
961 mesh.property(faceProp).set_persistent(
true);
962 mesh.remove_property(removedProp);
965 for (
Mesh::VertexIter v_iter = mesh.vertices_begin(); v_iter != mesh.vertices_end(); ++v_iter, ++i)
967 mesh.property(indexProp, *v_iter) = i;
968 mesh.property(qualityProp, *v_iter) = 3.5*i;
972 for (
Mesh::FaceIter f_iter = mesh.faces_begin(); f_iter != mesh.faces_end(); ++f_iter, ++i)
974 mesh.property(faceProp, *f_iter) = -i;
977 const char* outFilename =
"cube-minimal-customprops_openmeshOutputTestfile.ply";
984 EXPECT_FALSE(loadedMesh.get_property_handle(indexProp,indexPropName)) <<
"Could access to property which was deleted";
992 ASSERT_TRUE(loadedMesh.get_property_handle(indexProp,indexPropName)) <<
"Could not access index property";
993 ASSERT_TRUE(loadedMesh.get_property_handle(qualityProp,qualityPropName)) <<
"Could not access quality property";
994 ASSERT_TRUE(loadedMesh.get_property_handle(faceProp,facePropName)) <<
"Could not access face property";
995 EXPECT_FALSE(loadedMesh.get_property_handle(nonPersistant,nonPersistantName)) <<
"Could access non persistant property";
998 for (
Mesh::VertexIter v_iter = loadedMesh.vertices_begin(); v_iter != loadedMesh.vertices_end(); ++v_iter, ++i)
1000 EXPECT_EQ(loadedMesh.property(indexProp, *v_iter),
static_cast<unsigned>(i));
1001 EXPECT_EQ(loadedMesh.property(qualityProp, *v_iter),3.5*i);
1005 for (
Mesh::FaceIter f_iter = loadedMesh.faces_begin(); f_iter != loadedMesh.faces_end(); ++f_iter, ++i)
1007 EXPECT_EQ(loadedMesh.property(faceProp, *f_iter),-i);
1011 remove(outFilename);
1015TEST_F(OpenMeshReadWritePLY, WriteReadBinaryPLYWithCustomProps) {
1029 const std::string indexPropName =
"mySuperIndexProperty";
1030 const std::string qualityPropName =
"quality";
1031 const std::string facePropName =
"anotherPropForFaces";
1032 const std::string nonPersistantName =
"nonPersistant";
1033 const std::string removedPropName =
"willBeRemoved";
1035 mesh.add_property(indexProp,indexPropName);
1036 mesh.add_property(qualityProp,qualityPropName);
1037 mesh.add_property(removedProp, removedPropName);
1038 mesh.add_property(faceProp,facePropName);
1039 mesh.add_property(nonPersistant,nonPersistantName);
1041 mesh.property(indexProp).set_persistent(
true);
1042 mesh.property(qualityProp).set_persistent(
true);
1043 mesh.property(faceProp).set_persistent(
true);
1044 mesh.remove_property(removedProp);
1047 for (
Mesh::VertexIter v_iter = mesh.vertices_begin(); v_iter != mesh.vertices_end(); ++v_iter, ++i)
1049 mesh.property(indexProp, *v_iter) = i;
1050 mesh.property(qualityProp, *v_iter) = 3.5*i;
1054 for (
Mesh::FaceIter f_iter = mesh.faces_begin(); f_iter != mesh.faces_end(); ++f_iter, ++i)
1056 mesh.property(faceProp, *f_iter) = -i;
1059 const char* outFilename =
"cube-minimal-customprops_openmeshOutputTestfileBinary.ply";
1067 EXPECT_FALSE(loadedMesh.get_property_handle(indexProp,indexPropName)) <<
"Could access to property which was deleted";
1077 ASSERT_TRUE(loadedMesh.get_property_handle(indexProp,indexPropName)) <<
"Could not access index property";
1078 ASSERT_TRUE(loadedMesh.get_property_handle(qualityProp,qualityPropName)) <<
"Could not access quality property";
1079 ASSERT_TRUE(loadedMesh.get_property_handle(faceProp,facePropName)) <<
"Could not access face property";
1080 EXPECT_FALSE(loadedMesh.get_property_handle(nonPersistant,nonPersistantName)) <<
"Could access non persistant property";
1083 for (
Mesh::VertexIter v_iter = loadedMesh.vertices_begin(); v_iter != loadedMesh.vertices_end(); ++v_iter, ++i)
1085 EXPECT_EQ(loadedMesh.property(indexProp, *v_iter),
static_cast<unsigned>(i));
1086 EXPECT_EQ(loadedMesh.property(qualityProp, *v_iter),3.5*i);
1090 for (
Mesh::FaceIter f_iter = loadedMesh.faces_begin(); f_iter != loadedMesh.faces_end(); ++f_iter, ++i)
1092 EXPECT_EQ(loadedMesh.property(faceProp, *f_iter),-i);
1103TEST_F(OpenMeshReadWritePLY, LoadSimplePLYWithExtraElements) {
1109 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-extra-elements.ply";
1111 EXPECT_EQ(8u, mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
1112 EXPECT_EQ(18u, mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
1113 EXPECT_EQ(12u, mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
1120TEST_F(OpenMeshReadWritePLY, LoadSimpleBinaryPLYWithExtraElements) {
1128 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-extra-elements-binary.ply";
1130 EXPECT_EQ(8u, mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
1131 EXPECT_EQ(18u, mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
1132 EXPECT_EQ(12u, mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
1139TEST_F(OpenMeshReadWritePLY, IgnoreNonMeshPlyFile) {
1143 std::stringstream data;
1144 data <<
"ply" <<
"\n";
1145 data <<
"format binary_little_endian 1.0" <<
"\n";
1146 data <<
"comment Image data" <<
"\n";
1147 data <<
"element image 0" <<
"\n";
1148 data <<
"property list uint16 uint16 row" <<
"\n";
1149 data <<
"end_header" <<
"\n";
1155 EXPECT_TRUE(ok) <<
"This empty file should be readable without an error!";
1157 EXPECT_EQ(0u, mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
1158 EXPECT_EQ(0u, mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
1159 EXPECT_EQ(0u, mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
1166TEST_F(OpenMeshReadWritePLY, FailOnUnknownPropertyTypeForLists) {
1170 std::stringstream data;
1171 data <<
"ply" <<
"\n";
1172 data <<
"format binary_little_endian 1.0" <<
"\n";
1173 data <<
"comment Image data" <<
"\n";
1174 data <<
"element image 0" <<
"\n";
1175 data <<
"property list blibb blubb row" <<
"\n";
1176 data <<
"end_header" <<
"\n";
1182 EXPECT_FALSE(ok) <<
"This file should fail to read!";
1184 EXPECT_EQ(0u, mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
1185 EXPECT_EQ(0u, mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
1186 EXPECT_EQ(0u, mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
1192TEST_F(OpenMeshReadWritePLY, LoadSimplePLYWithFaceColors) {
1196 mesh_.request_face_colors();
1203 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-faceColors.ply";
1205 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
1206 EXPECT_EQ(18u, mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
1207 EXPECT_EQ(12u, mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
1209#ifdef TEST_DOUBLE_TRAITS
1210 EXPECT_FLOAT_EQ(107/255.0, mesh_.color(mesh_.face_handle(0))[0] ) <<
"Wrong face color at face 0";
1211 EXPECT_FLOAT_EQ(117/255.0, mesh_.color(mesh_.face_handle(0))[1] ) <<
"Wrong face color at face 0";
1212 EXPECT_FLOAT_EQ(177/255.0, mesh_.color(mesh_.face_handle(0))[2] ) <<
"Wrong face color at face 0";
1214 EXPECT_FLOAT_EQ(107/255.0, mesh_.color(mesh_.face_handle(3))[0] ) <<
"Wrong face color at face 3";
1215 EXPECT_FLOAT_EQ(255/255.0, mesh_.color(mesh_.face_handle(3))[1] ) <<
"Wrong face color at face 3";
1216 EXPECT_FLOAT_EQ(135/255.0, mesh_.color(mesh_.face_handle(3))[2] ) <<
"Wrong face color at face 3";
1218 EXPECT_FLOAT_EQ(163/255.0, mesh_.color(mesh_.face_handle(4))[0] ) <<
"Wrong face color at face 4";
1219 EXPECT_FLOAT_EQ(107/255.0, mesh_.color(mesh_.face_handle(4))[1] ) <<
"Wrong face color at face 4";
1220 EXPECT_FLOAT_EQ(177/255.0, mesh_.color(mesh_.face_handle(4))[2] ) <<
"Wrong face color at face 4";
1222 EXPECT_FLOAT_EQ(255/255.0, mesh_.color(mesh_.face_handle(7))[0] ) <<
"Wrong face color at face 7";
1223 EXPECT_FLOAT_EQ(140/255.0, mesh_.color(mesh_.face_handle(7))[1] ) <<
"Wrong face color at face 7";
1224 EXPECT_FLOAT_EQ(107/255.0, mesh_.color(mesh_.face_handle(7))[2] ) <<
"Wrong face color at face 7";
1226 EXPECT_EQ(107, mesh_.color(mesh_.face_handle(0))[0] ) <<
"Wrong face color at face 0";
1227 EXPECT_EQ(117, mesh_.color(mesh_.face_handle(0))[1] ) <<
"Wrong face color at face 0";
1228 EXPECT_EQ(177, mesh_.color(mesh_.face_handle(0))[2] ) <<
"Wrong face color at face 0";
1230 EXPECT_EQ(107, mesh_.color(mesh_.face_handle(3))[0] ) <<
"Wrong face color at face 3";
1231 EXPECT_EQ(255, mesh_.color(mesh_.face_handle(3))[1] ) <<
"Wrong face color at face 3";
1232 EXPECT_EQ(135, mesh_.color(mesh_.face_handle(3))[2] ) <<
"Wrong face color at face 3";
1234 EXPECT_EQ(163, mesh_.color(mesh_.face_handle(4))[0] ) <<
"Wrong face color at face 4";
1235 EXPECT_EQ(107, mesh_.color(mesh_.face_handle(4))[1] ) <<
"Wrong face color at face 4";
1236 EXPECT_EQ(177, mesh_.color(mesh_.face_handle(4))[2] ) <<
"Wrong face color at face 4";
1238 EXPECT_EQ(255, mesh_.color(mesh_.face_handle(7))[0] ) <<
"Wrong face color at face 7";
1239 EXPECT_EQ(140, mesh_.color(mesh_.face_handle(7))[1] ) <<
"Wrong face color at face 7";
1240 EXPECT_EQ(107, mesh_.color(mesh_.face_handle(7))[2] ) <<
"Wrong face color at face 7";
1243 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
1244 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
1245 EXPECT_FALSE(options.vertex_has_color()) <<
"Wrong user options are returned!";
1246 EXPECT_TRUE(options.face_has_color()) <<
"Wrong user options are returned!";
1247 EXPECT_FALSE(options.color_has_alpha()) <<
"Wrong user options are returned!";
1248 EXPECT_FALSE(options.is_binary()) <<
"Wrong user options are returned!";
1250 mesh_.release_face_colors();
1256TEST_F(OpenMeshReadWritePLY, WriteAndReadPLYWithFaceColors) {
1259 _outFileName(outFileName),
1262 const char* _outFileName;
1267 Format(
"cube-minimal-faceColors_ascii_uchar.ply",
1269 Format(
"cube-minimal-faceColors_ascii_float.ply",
1271 Format(
"cube-minimal-faceColors_binary_uchar.ply",
1273 Format(
"cube-minimal-faceColors_binary_float.ply",
1277 Format(
"cube-minimal-faceColors_alpha_ascii_uchar.ply",
1279 Format(
"cube-minimal-faceColors_alpha_ascii_float.ply",
1281 Format(
"cube-minimal-faceColors_alpha_binary_uchar.ply",
1283 Format(
"cube-minimal-faceColors_alpha_binary_float.ply",
1287 for (
size_t i = 0; i <
sizeof(formats) /
sizeof(Format); ++i)
1289 const char* outFileName = formats[i]._outFileName;
1293 mesh_.request_face_colors();
1300 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-faceColors.ply";
1302 options = formats[i]._options;
1305 EXPECT_TRUE(ok) <<
"Unable to write " << outFileName;
1311 EXPECT_TRUE(ok) <<
"Unable to load " << outFileName;
1313 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct: " << outFileName;
1314 EXPECT_EQ(18u, mesh_.n_edges()) <<
"The number of loaded edges is not correct: " << outFileName;
1315 EXPECT_EQ(12u, mesh_.n_faces()) <<
"The number of loaded faces is not correct: " << outFileName;
1317#ifdef TEST_DOUBLE_TRAITS
1318 EXPECT_FLOAT_EQ(107/255.0, mesh_.color(mesh_.face_handle(0))[0] ) <<
"Wrong face color at face 0";
1319 EXPECT_FLOAT_EQ(117/255.0, mesh_.color(mesh_.face_handle(0))[1] ) <<
"Wrong face color at face 0";
1320 EXPECT_FLOAT_EQ(177/255.0, mesh_.color(mesh_.face_handle(0))[2] ) <<
"Wrong face color at face 0";
1322 EXPECT_FLOAT_EQ(107/255.0, mesh_.color(mesh_.face_handle(3))[0] ) <<
"Wrong face color at face 3";
1323 EXPECT_FLOAT_EQ(255/255.0, mesh_.color(mesh_.face_handle(3))[1] ) <<
"Wrong face color at face 3";
1324 EXPECT_FLOAT_EQ(135/255.0, mesh_.color(mesh_.face_handle(3))[2] ) <<
"Wrong face color at face 3";
1326 EXPECT_FLOAT_EQ(163/255.0, mesh_.color(mesh_.face_handle(4))[0] ) <<
"Wrong face color at face 4";
1327 EXPECT_FLOAT_EQ(107/255.0, mesh_.color(mesh_.face_handle(4))[1] ) <<
"Wrong face color at face 4";
1328 EXPECT_FLOAT_EQ(177/255.0, mesh_.color(mesh_.face_handle(4))[2] ) <<
"Wrong face color at face 4";
1330 EXPECT_FLOAT_EQ(255/255.0, mesh_.color(mesh_.face_handle(7))[0] ) <<
"Wrong face color at face 7";
1331 EXPECT_FLOAT_EQ(140/255.0, mesh_.color(mesh_.face_handle(7))[1] ) <<
"Wrong face color at face 7";
1332 EXPECT_FLOAT_EQ(107/255.0, mesh_.color(mesh_.face_handle(7))[2] ) <<
"Wrong face color at face 7";
1334 EXPECT_EQ(107, mesh_.color(mesh_.face_handle(0))[0] ) <<
"Wrong face color at face 0";
1335 EXPECT_EQ(117, mesh_.color(mesh_.face_handle(0))[1] ) <<
"Wrong face color at face 0";
1336 EXPECT_EQ(177, mesh_.color(mesh_.face_handle(0))[2] ) <<
"Wrong face color at face 0";
1338 EXPECT_EQ(107, mesh_.color(mesh_.face_handle(3))[0] ) <<
"Wrong face color at face 3";
1339 EXPECT_EQ(255, mesh_.color(mesh_.face_handle(3))[1] ) <<
"Wrong face color at face 3";
1340 EXPECT_EQ(135, mesh_.color(mesh_.face_handle(3))[2] ) <<
"Wrong face color at face 3";
1342 EXPECT_EQ(163, mesh_.color(mesh_.face_handle(4))[0] ) <<
"Wrong face color at face 4";
1343 EXPECT_EQ(107, mesh_.color(mesh_.face_handle(4))[1] ) <<
"Wrong face color at face 4";
1344 EXPECT_EQ(177, mesh_.color(mesh_.face_handle(4))[2] ) <<
"Wrong face color at face 4";
1346 EXPECT_EQ(255, mesh_.color(mesh_.face_handle(7))[0] ) <<
"Wrong face color at face 7";
1347 EXPECT_EQ(140, mesh_.color(mesh_.face_handle(7))[1] ) <<
"Wrong face color at face 7";
1348 EXPECT_EQ(107, mesh_.color(mesh_.face_handle(7))[2] ) <<
"Wrong face color at face 7";
1351 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned: " << outFileName;
1352 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned: " << outFileName;
1353 EXPECT_FALSE(options.vertex_has_color()) <<
"Wrong user options are returned: " << outFileName;
1354 EXPECT_TRUE(options.face_has_color()) <<
"Wrong user options are returned: " << outFileName;
1355 EXPECT_EQ(formats[i]._options.color_is_float(), options.color_is_float()) <<
1356 "Wrong user options are returned: " << outFileName;
1357 EXPECT_EQ(formats[i]._options.is_binary(), options.is_binary()) <<
1358 "Wrong user options are returned: " << outFileName;
1360 mesh_.release_face_colors();
1367TEST_F(OpenMeshReadWritePLYColorVec3f , LoadSimplePLYWithVertexColorsVec3f) {
1371 mesh_.request_vertex_colors();
1378 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-vertexColors.ply";
1380 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
1381 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
1382 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
1384#ifdef TEST_DOUBLE_TRAITS
1385 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
1386 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
1387 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
1389 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
1390 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
1391 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
1393 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
1394 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
1395 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
1397 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
1398 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
1399 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
1401 EXPECT_EQ(1.0f, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
1402 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
1403 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
1405 EXPECT_EQ(1.0f, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
1406 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
1407 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
1409 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
1410 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
1411 EXPECT_EQ(1.0f, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
1413 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
1414 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
1415 EXPECT_EQ(1.0f, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
1418 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
1419 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
1420 EXPECT_TRUE(options.vertex_has_color()) <<
"Wrong user options are returned!";
1422 mesh_.release_vertex_colors();
1428TEST_F(OpenMeshReadWritePLYColorVec3f , WriteAndReadPLYWithFaceColorsVec3f) {
1431 _outFileName(outFileName),
1434 const char* _outFileName;
1439 Format(
"cube-minimal-faceColors_ascii_uchar.ply",
1441 Format(
"cube-minimal-faceColors_ascii_float.ply",
1443 Format(
"cube-minimal-faceColors_binary_uchar.ply",
1445 Format(
"cube-minimal-faceColors_binary_float.ply",
1449 Format(
"cube-minimal-faceColors_alpha_ascii_uchar.ply",
1451 Format(
"cube-minimal-faceColors_alpha_ascii_float.ply",
1453 Format(
"cube-minimal-faceColors_alpha_binary_uchar.ply",
1455 Format(
"cube-minimal-faceColors_alpha_binary_float.ply",
1459 for (
size_t i = 0; i <
sizeof(formats) /
sizeof(Format); ++i)
1461 const char* outFileName = formats[i]._outFileName;
1465 mesh_.request_face_colors();
1472 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-faceColors.ply";
1474 options = formats[i]._options;
1477 EXPECT_TRUE(ok) <<
"Unable to write " << outFileName;
1483 EXPECT_TRUE(ok) <<
"Unable to load " << outFileName;
1485 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct: " << outFileName;
1486 EXPECT_EQ(18u, mesh_.n_edges()) <<
"The number of loaded edges is not correct: " << outFileName;
1487 EXPECT_EQ(12u, mesh_.n_faces()) <<
"The number of loaded faces is not correct: " << outFileName;
1492 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned: " << outFileName;
1493 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned: " << outFileName;
1494 EXPECT_FALSE(options.vertex_has_color()) <<
"Wrong user options are returned: " << outFileName;
1495 EXPECT_TRUE(options.face_has_color()) <<
"Wrong user options are returned: " << outFileName;
1496 EXPECT_EQ(formats[i]._options.color_is_float(), options.color_is_float()) <<
1497 "Wrong user options are returned: " << outFileName;
1498 EXPECT_EQ(formats[i]._options.is_binary(), options.is_binary()) <<
1499 "Wrong user options are returned: " << outFileName;
1501 mesh_.release_face_colors();
int idx() const
Get the underlying index of this handle.
Set options for reader/writer modules.
void clear(void)
Clear all bits.
@ ColorFloat
Has (r) / store (w) float values for colors (currently only implemented for PLY and OFF files)
@ FaceColor
Has (r) / store (w) face colors.
@ FaceTexCoord
Has (r) / store (w) face texture coordinates.
@ Binary
Set binary mode for r/w.
@ Default
By default write persistent custom properties.
@ ColorAlpha
Has (r) / store (w) alpha values for colors.
@ VertexNormal
Has (r) / store (w) vertex normals.
@ VertexTexCoord
Has (r) / store (w) texture coordinates.
@ VertexColor
Has (r) / store (w) vertex colors.
@ Custom
Has (r) / store (w) custom properties marked persistent (currently PLY only supports reading and only...
Kernel::FaceIter FaceIter
Scalar type.
Kernel::VertexIter VertexIter
Scalar type.
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.
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.
Vec3uc Color
The default color type is OpenMesh::Vec3uc.
Handle for a face entity.
Handle for a vertex entity.