From ef9ffb4fd62fbe63e33bd690e7055ae153af44d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 29 May 2020 12:06:31 +0200 Subject: [PATCH] Add data/tests for GOCAD/OFF/OBJ --- .../test/Stream_support/test_GOCAD.cpp | 3 + .../test/Stream_support/test_OBJ.cpp | 68 +++++++++++++++++ .../test/Stream_support/test_OFF.cpp | 73 +++++++++++++++---- 3 files changed, 129 insertions(+), 15 deletions(-) create mode 100644 Stream_support/test/Stream_support/test_OBJ.cpp diff --git a/Stream_support/test/Stream_support/test_GOCAD.cpp b/Stream_support/test/Stream_support/test_GOCAD.cpp index 59d80c20f3a..5d5838651fc 100644 --- a/Stream_support/test/Stream_support/test_GOCAD.cpp +++ b/Stream_support/test/Stream_support/test_GOCAD.cpp @@ -22,6 +22,9 @@ int main(int argc, char** argv) assert(ok); std::cout << points.size() << " points and " << polygons.size() << " polygons" << std::endl; + if(argc == 0) + assert(points.size() == 12491 && polygons.size() == 24191); + points.clear(); polygons.clear(); std::string gocad_string(gocad_file); diff --git a/Stream_support/test/Stream_support/test_OBJ.cpp b/Stream_support/test/Stream_support/test_OBJ.cpp new file mode 100644 index 00000000000..8d84ea557a8 --- /dev/null +++ b/Stream_support/test/Stream_support/test_OBJ.cpp @@ -0,0 +1,68 @@ +#include + +#include +#include + +#include +#include +#include + +typedef CGAL::Simple_cartesian Kernel; +typedef Kernel::Point_3 Point; +typedef std::vector Face; + +int main(int argc, char** argv) +{ + const char* obj_file = (argc > 1) ? argv[1] : "data/90089.obj"; + + std::vector points; + std::vector polygons; + + bool ok = CGAL::read_OBJ(obj_file, points, polygons); + assert(ok); + std::cout << points.size() << " points and " << polygons.size() << " polygons" << std::endl; + + if(argc == 0) + assert(points.size() == 434 && polygons.size() == 864); + + points.clear(); + polygons.clear(); + std::string obj_string(obj_file); + ok = CGAL::read_OBJ(obj_string, points, polygons); + assert(ok); + + points.clear(); + polygons.clear(); + std::ifstream is(obj_file); + ok = CGAL::read_OBJ(is, points, polygons); + assert(ok); + is.close(); + + std::ofstream os("tmp.obj", std::ios::binary); + ok = CGAL::write_OBJ(os, points, polygons); + assert(ok); + os.close(); + + ok = CGAL::write_OBJ("tmp.obj", points, polygons); + assert(ok); + + std::vector pts_backup = points; + std::vector pls_backup = polygons; + + ok = CGAL::write_polygon_soup("tmp.obj", points, polygons); + assert(ok); + + points.clear(); + polygons.clear(); + + ok = CGAL::read_polygon_soup("tmp.obj", points, polygons); + assert(ok); + + assert(points.size() == pts_backup.size()); + for(std::size_t i=0; i -#include +#include #include +#include -#include +#include +#include #include -typedef CGAL::Simple_cartesian Kernel; -typedef Kernel::Point_3 Point; -typedef std::vector Face; -int main() +typedef CGAL::Simple_cartesian Kernel; +typedef Kernel::Point_3 Point; +typedef std::vector Face; + +int main(int argc, char** argv) { - std::ifstream in("data/cube.off"); + const char* off_file = (argc > 1) ? argv[1] : "data/cube.off"; + std::vector points; - std::vector faces; - CGAL::read_OFF(in, points, faces); - in.close(); - assert(points.size() == 8); - assert(faces.size() == 12); + std::vector polygons; - assert(CGAL::write_OFF(std::cout, points, faces)); + bool ok = CGAL::read_OFF(off_file, points, polygons); + assert(ok); + std::cout << points.size() << " points and " << polygons.size() << " polygons" << std::endl; - return 0; + if(argc == 0) + assert(points.size() == 8 && polygons.size() == 12); + + points.clear(); + polygons.clear(); + std::string off_string(off_file); + ok = CGAL::read_OFF(off_string, points, polygons); + assert(ok); + + points.clear(); + polygons.clear(); + std::ifstream is(off_file); + ok = CGAL::read_OFF(is, points, polygons); + assert(ok); + is.close(); + + std::ofstream os("tmp.off", std::ios::binary); + ok = CGAL::write_OFF(os, points, polygons); + assert(ok); + os.close(); + + ok = CGAL::write_OFF("tmp.off", points, polygons); + assert(ok); + + std::vector pts_backup = points; + std::vector pls_backup = polygons; + + ok = CGAL::write_polygon_soup("tmp.off", points, polygons); + assert(ok); + + points.clear(); + polygons.clear(); + + ok = CGAL::read_polygon_soup("tmp.off", points, polygons); + assert(ok); + + assert(points.size() == pts_backup.size()); + for(std::size_t i=0; i