From 1e4e6329ba1047daa689d0f1ff78ca16e788ba18 Mon Sep 17 00:00:00 2001 From: Pierre Alliez Date: Tue, 14 Nov 2017 18:31:52 +0100 Subject: [PATCH] simplest example --- .../vsa_approximation_example.cpp | 12 +++--- .../vsa_simple_approximation_example.cpp | 41 ++++++++++--------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_example.cpp index 578f9b78a69..0356fca9741 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_example.cpp @@ -22,20 +22,20 @@ int main() // output polyhedral surface and indexed triangle mesh Polyhedron output; - std::vector triangles; - std::vector points; + std::vector > triangles; // contains triplets of indices + std::vector< Kernel::Point_3 > points; // free function interface with named parameters bool valid_polyhedron = CGAL::VSA::mesh_approximation(input, + std::back_inserter(points), + std::back_inserter(triangles), CGAL::VSA::parameters::init_method(CGAL::VSA::Hierarchical). // hierarchical init refine_until_proxies(200). // refine until target number of proxies iterations(30). // number of relaxation iterations after seeding - anchor_points(std::back_inserter(points)). // get anchor points - indexed_triangles(std::back_inserter(triangles)). // get indexed triangles - output); // output to polyhedron, if 2-manifold and oriented + output_mesh(output)); // output to polyhedron, if 2-manifold and oriented std::cout << "#anchor points: " << points.size() << std::endl; - std::cout << "#triangles: " << triangles.size() / 3 << std::endl; + std::cout << "#triangles: " << triangles.size() << std::endl; if (valid_polyhedron) std::cout << "oriented 2-manifold output." << std::endl; diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_simple_approximation_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_simple_approximation_example.cpp index b714a7d0d57..cc3a89da853 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_simple_approximation_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_simple_approximation_example.cpp @@ -12,28 +12,29 @@ typedef CGAL::Polyhedron_3 Polyhedron; int main() { - // create polyhedral surface and read input surface triangle mesh - Polyhedron input; - std::ifstream file("data/mask.off"); - if (!file || !(file >> input) || input.empty()) { - std::cerr << "Invalid off file." << std::endl; - return EXIT_FAILURE; - } + // create polyhedral surface and read input surface triangle mesh + Polyhedron input; + std::ifstream file("data/mask.off"); + if (!file || !(file >> input) || input.empty()) { + std::cerr << "Invalid off file." << std::endl; + return EXIT_FAILURE; + } - // output polyhedral surface and indexed triangle mesh - std::vector triangles; - std::vector points; + // output polyhedral surface and indexed triangle mesh + Polyhedron output; + std::vector > triangles; // contains triplets of indices + std::vector< Kernel::Point_3 > points; - // free function interface with named parameters - bool valid_polyhedron = CGAL::VSA::mesh_approximation(input, - CGAL::VSA::parameters::init_method(CGAL::VSA::Hierarchical). // hierarchical init - refine_until_proxies(200). // refine until target number of proxies - iterations(30). // number of relaxation iterations after seeding - anchor_points(std::back_inserter(points)). // get anchor points - indexed_triangles(std::back_inserter(triangles))); // get indexed triangles + // free function interface with named parameters + bool valid_polyhedron = CGAL::VSA::mesh_approximation(input, + std::back_inserter(points), + std::back_inserter(triangles), + CGAL::VSA::parameters::init_method(CGAL::VSA::Hierarchical). // hierarchical init + refine_until_proxies(200). // refine until target number of proxies + iterations(30)); - std::cout << "#anchor points: " << points.size() << std::endl; - std::cout << "#triangles: " << triangles.size() / 3 << std::endl; + std::cout << "#anchor points: " << points.size() << std::endl; + std::cout << "#triangles: " << triangles.size() << std::endl; - return EXIT_SUCCESS; + return EXIT_SUCCESS; }