Test the write output

This commit is contained in:
Mael Rouxel-Labbé 2024-06-10 14:00:28 +02:00
parent 710666a51b
commit c5a688590a
1 changed files with 28 additions and 1 deletions

View File

@ -23,25 +23,52 @@ int main()
CGAL::IO::write_polygon_mesh("write_polygon_mesh_sm.ply", sm,
CGAL::parameters::stream_precision(17).use_binary_mode(true));
Surface_mesh osm;
if(!CGAL::IO::read_polygon_mesh("write_polygon_mesh_sm.ply", osm))
{
std::cerr << "Error: failed to read 'write_polygon_mesh_sm.ply'" << std::endl;
return EXIT_FAILURE;
}
// ERROR this produces an invalid plyfile
CGAL::IO::write_polygon_mesh("write_polygon_mesh_po.ply", po,
CGAL::parameters::stream_precision(17).use_binary_mode(true));
if(!CGAL::IO::read_polygon_mesh("write_polygon_mesh_po.ply", osm))
{
std::cerr << "Error: failed to read 'write_polygon_mesh_po.ply'" << std::endl;
return EXIT_FAILURE;
}
// OK
// from #include <CGAL/boost/graph/IO/PLY.h>
// https://doc.cgal.org/latest/BGL/group__PkgBGLIoFuncsPLY.html#ga959dcd88ca979d3b6b0806d883a0247f
CGAL::IO::write_PLY("generic_write_PLY_sm.ply", sm, "generic write_PLY(Surface_mesh)",
CGAL::parameters::stream_precision(17).use_binary_mode(true));
if(!CGAL::IO::read_polygon_mesh("generic_write_PLY_sm.ply", osm))
{
std::cerr << "Error: failed to read 'generic_write_PLY_sm.ply'" << std::endl;
return EXIT_FAILURE;
}
// ERROR this produces an invalid plyfile
CGAL::IO::write_PLY("generic_write_PLY_po.ply", po, "generic write_PLY(Polyhedron)",
CGAL::parameters::stream_precision(17).use_binary_mode(true));
if(!CGAL::IO::read_polygon_mesh("generic_write_PLY_po.ply", osm))
{
std::cerr << "Error: failed to read 'generic_write_PLY_po.ply'" << std::endl;
return EXIT_FAILURE;
}
// OK
// from #include <CGAL/Surface_mesh/IO/PLY.h>
// https://doc.cgal.org/latest/Surface_mesh/group__PkgSurfaceMeshIOFuncPLY.html#ga50f0e9f2b293855d2c7f1a62939cbe8d
std::ofstream out("overloaded_write_PLY_sm.ply", std::ios::binary);
CGAL::IO::write_PLY(out, sm, "overloaded_write_PLY)Surface_mesh)");
CGAL::IO::write_PLY(out, sm, "overloaded_write_PLY(Surface_mesh)");
if(!CGAL::IO::read_polygon_mesh("overloaded_write_PLY_sm.ply", osm))
{
std::cerr << "Error: failed to read 'overloaded_write_PLY_sm.ply'" << std::endl;
return EXIT_FAILURE;
}
return 0;
}