| 461 | } |
| 462 | |
| 463 | void test_io( const geode::PolygonalSurface3D& polygonal_surface, |
| 464 | const std::string& filename ) |
| 465 | { |
| 466 | geode::save_polygonal_surface( polygonal_surface, filename ); |
| 467 | const auto reloaded = geode::load_polygonal_surface< 3 >( filename ); |
| 468 | geode_unused( reloaded ); |
| 469 | const auto new_polygonal_surface = geode::load_polygonal_surface< 3 >( |
| 470 | geode::OpenGeodePolygonalSurface3D::impl_name_static(), filename ); |
| 471 | |
| 472 | geode::OpenGeodeMeshException::test( |
| 473 | new_polygonal_surface->nb_vertices() == 7, |
| 474 | "Reloaded PolygonalSurface should have 7 vertices" ); |
| 475 | for( const auto vertex_id : |
| 476 | geode::Range{ polygonal_surface.nb_vertices() } ) |
| 477 | { |
| 478 | geode::OpenGeodeMeshException::test( |
| 479 | polygonal_surface.point( vertex_id ) |
| 480 | .inexact_equal( new_polygonal_surface->point( vertex_id ) ), |
| 481 | "Wrong reloaded mesh point coordinates." ); |
| 482 | } |
| 483 | geode::OpenGeodeMeshException::test( |
| 484 | new_polygonal_surface->edges().nb_edges() == 9, |
| 485 | "Reloaded PolygonalSurface should have 9 edges" ); |
| 486 | geode::OpenGeodeMeshException::test( |
| 487 | new_polygonal_surface->nb_polygons() == 3, |
| 488 | "Reloaded PolygonalSurface should have 3 polygons" ); |
| 489 | geode::OpenGeodeMeshException::test( |
| 490 | new_polygonal_surface->edges().edge_from_vertices( { 1, 0 } ) |
| 491 | == polygonal_surface.edges().edge_from_vertices( { 1, 0 } ), |
| 492 | "Reloaded PolygonalSurface has wrong polygon edge index" ); |
| 493 | const auto attribute = new_polygonal_surface->edges() |
| 494 | .edge_attribute_manager() |
| 495 | .find_attribute< geode::index_t >( "test" ); |
| 496 | for( const auto e : |
| 497 | geode::Range{ new_polygonal_surface->edges().nb_edges() } ) |
| 498 | { |
| 499 | geode::OpenGeodeMeshException::test( attribute->value( e ) == e, |
| 500 | "Reloaded PolygonalSurface has " |
| 501 | "wrong attributes on its edges" ); |
| 502 | } |
| 503 | auto manager = new_polygonal_surface->texture_manager(); |
| 504 | auto texture_names = manager.texture_names(); |
| 505 | geode::OpenGeodeMeshException::test( texture_names.size() == 1, |
| 506 | "Reloaded PolygonalSurface has wrong number of textures" ); |
| 507 | geode::OpenGeodeMeshException::test( texture_names[0] == "texture", |
| 508 | "Reloaded PolygonalSurface has wrong texture name" ); |
| 509 | } |
| 510 | |
| 511 | void test_backward_io( const std::string& filename ) |
| 512 | { |
no test coverage detected