\( \newcommand{\E}{\mathrm{E}} \) \( \newcommand{\A}{\mathrm{A}} \) \( \newcommand{\R}{\mathrm{R}} \) \( \newcommand{\N}{\mathrm{N}} \) \( \newcommand{\Q}{\mathrm{Q}} \) \( \newcommand{\Z}{\mathrm{Z}} \) \( \def\ccSum #1#2#3{ \sum_{#1}^{#2}{#3} } \def\ccProd #1#2#3{ \sum_{#1}^{#2}{#3} }\)
CGAL 5.0 - Triangulated Surface Mesh Approximation
Surface_mesh_approximation/vsa_simple_approximation_example.cpp
#include <iostream>
#include <fstream>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Surface_mesh_approximation/approximate_triangle_mesh.h>
int main()
{
// read input surface triangle mesh
Mesh mesh;
std::ifstream file("data/bear.off");
file >> mesh;
// The output will be an indexed triangle mesh
std::vector<Kernel::Point_3> anchors;
std::vector<std::array<std::size_t, 3> > triangles;
// free function interface with named parameters
CGAL::parameters::verbose_level(VSA::MAIN_STEPS).
max_number_of_proxies(200).
anchors(std::back_inserter(anchors)). // anchor points
triangles(std::back_inserter(triangles))); // indexed triangles
std::cout << "#anchor points: " << anchors.size() << std::endl;
std::cout << "#triangles: " << triangles.size() << std::endl;
return EXIT_SUCCESS;
}