MCPcopy Create free account
hub / github.com/Geode-solutions/OpenGeode / test_io

Function test_io

tests/mesh/test-polygonal-surface.cpp:463–509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461}
462
463void 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
511void test_backward_io( const std::string& filename )
512{

Callers 1

testFunction · 0.70

Calls 14

save_polygonal_surfaceFunction · 0.85
geode_unusedFunction · 0.85
nb_polygonsMethod · 0.80
testFunction · 0.70
impl_name_staticFunction · 0.50
nb_verticesMethod · 0.45
inexact_equalMethod · 0.45
pointMethod · 0.45
nb_edgesMethod · 0.45
edge_from_verticesMethod · 0.45
valueMethod · 0.45
texture_managerMethod · 0.45

Tested by

no test coverage detected