From 0549c36aaf58e2dbd7e93865313cda2290339949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 31 Jan 2024 16:37:41 +0100 Subject: [PATCH] Add a helper function to visualize a Cartesian_grid_3 object --- .../CGAL/Isosurfacing_3/Cartesian_grid_3.h | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/Isosurfacing_3/include/CGAL/Isosurfacing_3/Cartesian_grid_3.h b/Isosurfacing_3/include/CGAL/Isosurfacing_3/Cartesian_grid_3.h index af58c8d1dad..b2c01ab2736 100644 --- a/Isosurfacing_3/include/CGAL/Isosurfacing_3/Cartesian_grid_3.h +++ b/Isosurfacing_3/include/CGAL/Isosurfacing_3/Cartesian_grid_3.h @@ -18,9 +18,12 @@ #include #include +#include +#include #include #include +#include #include #include @@ -368,6 +371,62 @@ operator Image_3() const return Image_3{ im, Image_3::OWN_THE_DATA }; } +namespace IO { + +template +bool write_OBJ(const std::string& filename, + const Cartesian_grid_3& grid, + const NamedParameters& np = parameters::default_values()) +{ + using Point_3 = typename GeomTraits::Point_3; + + auto x_coord = grid.geom_traits().compute_x_3_object(); + auto y_coord = grid.geom_traits().compute_y_3_object(); + auto z_coord = grid.geom_traits().compute_z_3_object(); + auto vertex = grid.geom_traits().construct_vertex_3_object(); + + std::ofstream out(filename); + set_ascii_mode(out); // obj is ASCII only + + set_stream_precision_from_NP(out, np); + + if(out.fail()) + return false; + + + // write vertices + for(std::size_t x=0; x