From c38fffcee1c86d9def4498071892792e1ca38d16 Mon Sep 17 00:00:00 2001 From: Lingjie Zhu Date: Sun, 7 Oct 2018 20:01:06 +0800 Subject: [PATCH] benchmark use Surface_mesh --- .../vsa_autoinit_timing_benchmark.cpp | 36 +++++++++---------- .../vsa_timing_benchmark.cpp | 32 ++++++++--------- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/vsa_autoinit_timing_benchmark.cpp b/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/vsa_autoinit_timing_benchmark.cpp index 4d58e0c4b24..1411abf6aa7 100644 --- a/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/vsa_autoinit_timing_benchmark.cpp +++ b/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/vsa_autoinit_timing_benchmark.cpp @@ -2,19 +2,17 @@ #include #include -#include -#include +#include -#include #include #include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef Kernel::FT FT; -typedef CGAL::Polyhedron_3 Polyhedron; -typedef boost::property_map::type Vertex_point_map; +typedef CGAL::Surface_mesh Mesh; +typedef boost::property_map::type Vertex_point_map; -typedef CGAL::Variational_shape_approximation L21_approx; +typedef CGAL::Variational_shape_approximation L21_approx; typedef L21_approx::Error_metric L21_metric; typedef CGAL::Timer Timer; @@ -30,22 +28,22 @@ int main(int argc, char *argv[]) if (argc < 5) return EXIT_FAILURE; - Polyhedron mesh; + Mesh mesh; std::ifstream input(argv[1]); - if (!input || !(input >> mesh) || mesh.empty()) { - std::cout << "Invalid off file." << std::endl; + if (!input || !(input >> mesh) || !CGAL::is_triangle_mesh(mesh)) { + std::cout << "Invalid input file." << std::endl; return EXIT_FAILURE; } - std::cout << "#triangles " << mesh.size_of_facets() << std::endl; + std::cout << "#faces " + << std::distance(faces(mesh).first, faces(mesh).second) << std::endl; + + Vertex_point_map vpmap = get(boost::vertex_point, const_cast(mesh)); // error metric and fitting functors - L21_metric error_metric(mesh, - get(boost::vertex_point, const_cast(mesh))); + L21_metric error_metric(mesh, vpmap); // algorithm instance - L21_approx approx(mesh, - get(boost::vertex_point, const_cast(mesh)), - error_metric); + L21_approx approx(mesh, vpmap, error_metric); int method = std::atoi(argv[2]); if (method < 0 || method > 2) @@ -60,12 +58,12 @@ int main(int argc, char *argv[]) std::cout << "start seeding" << std::endl; t.start(); approx.initialize_seeds( - CGAL::parameters::seeding_method(static_cast(method)) - .min_error_drop(error_drop) - .number_of_relaxations(number_of_relaxations)); + CGAL::parameters::seeding_method(static_cast(method)) + .min_error_drop(error_drop) + .number_of_relaxations(number_of_relaxations)); t.stop(); std::cout << "seeding time " << t.time() << " sec." << std::endl; - std::cout << "#proxies " << approx.proxies_size() << std::endl; + std::cout << "#proxies " << approx.number_of_proxies() << std::endl; return EXIT_SUCCESS; } diff --git a/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/vsa_timing_benchmark.cpp b/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/vsa_timing_benchmark.cpp index b12d5ced1c0..d7216de3739 100644 --- a/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/vsa_timing_benchmark.cpp +++ b/Surface_mesh_approximation/benchmark/Surface_mesh_approximation/vsa_timing_benchmark.cpp @@ -2,18 +2,16 @@ #include #include -#include -#include +#include -#include #include #include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef CGAL::Polyhedron_3 Polyhedron; -typedef boost::property_map::type Vertex_point_map; +typedef CGAL::Surface_mesh Mesh; +typedef boost::property_map::type Vertex_point_map; -typedef CGAL::Variational_shape_approximation L21_approx; +typedef CGAL::Variational_shape_approximation L21_approx; typedef L21_approx::Error_metric L21_metric; typedef CGAL::Timer Timer; @@ -31,22 +29,22 @@ int main(int argc, char *argv[]) if (argc < 5) return EXIT_FAILURE; - Polyhedron mesh; + Mesh mesh; std::ifstream input(argv[1]); - if (!input || !(input >> mesh) || mesh.empty()) { - std::cout << "Invalid off file." << std::endl; + if (!input || !(input >> mesh) || !CGAL::is_triangle_mesh(mesh)) { + std::cout << "Invalid input file." << std::endl; return EXIT_FAILURE; } - std::cout << "#triangles " << mesh.size_of_facets() << std::endl; + std::cout << "#faces " + << std::distance(faces(mesh).first, faces(mesh).second) << std::endl; + + Vertex_point_map vpmap = get(boost::vertex_point, const_cast(mesh)); // error metric and fitting functors - L21_metric error_metric(mesh, - get(boost::vertex_point, const_cast(mesh))); + L21_metric error_metric(mesh, vpmap); // algorithm instance - L21_approx approx(mesh, - get(boost::vertex_point, const_cast(mesh)), - error_metric); + L21_approx approx(mesh, vpmap, error_metric); int method = std::atoi(argv[2]); if (method < 0 || method > 2) @@ -64,8 +62,8 @@ int main(int argc, char *argv[]) t0.reset(); t0.start(); approx.initialize_seeds( - CGAL::parameters::seeding_method(static_cast(method)) - .max_number_of_proxies(nb_proxies)); + CGAL::parameters::seeding_method(static_cast(method)) + .max_number_of_proxies(nb_proxies)); t0.stop(); std::cout << "seeding time " << t0.time() << " sec." << std::endl;