#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/property_map.h>
#include <CGAL/Variational_shape_approximation.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <iostream>
#include <fstream>
typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
typedef boost::property_map<Mesh, boost::vertex_point_t>::type Vertex_point_map;
typedef Mesh::Property_map<face_descriptor, FT> Face_area_map;
typedef Mesh::Property_map<face_descriptor, Point_3> Face_center_map;
struct Compact_metric_point_proxy
{
typedef Point_3 Proxy;
Compact_metric_point_proxy(const Face_center_map ¢er_pmap_, const Face_area_map &area_pmap_)
: center_pmap(center_pmap_), area_pmap(area_pmap_)
{ }
FT compute_error(const face_descriptor &f, const Mesh &, const Proxy &px) const
{
}
template <typename FaceRange>
Proxy fit_proxy(const FaceRange &faces, const Mesh &) const
{
FT sum_areas = FT(0.0);
for(const face_descriptor& f : faces) {
center = center + (center_pmap[f] -
CGAL::ORIGIN) * area_pmap[f];
sum_areas += area_pmap[f];
}
{
std::cerr << "Error: degenerate geometry." << std::endl;
std::exit(EXIT_FAILURE);
}
center = center / sum_areas;
}
const Face_center_map center_pmap;
const Face_area_map area_pmap;
};
Mesh, Vertex_point_map, Compact_metric_point_proxy> Approximation;
int main(int argc, char** argv)
{
Mesh mesh;
{
std::cerr << "Invalid input file." << std::endl;
return EXIT_FAILURE;
}
Vertex_point_map vpmap = get(boost::vertex_point, const_cast<Mesh &>(mesh));
Face_area_map area_pmap = mesh.add_property_map<face_descriptor, FT>("f:area", FT(0.0)).first;
Face_center_map center_pmap = mesh.add_property_map<face_descriptor, Point_3>(
"f:center",
CGAL::ORIGIN).first;
for(face_descriptor f : faces(mesh))
{
const halfedge_descriptor he = halfedge(f, mesh);
const Point_3 &p0 = vpmap[source(he, mesh)];
const Point_3 &p1 = vpmap[target(he, mesh)];
const Point_3 &p2 = vpmap[target(next(he, mesh), mesh)];
}
Compact_metric_point_proxy error_metric(center_pmap, area_pmap);
Approximation approx(mesh, vpmap, error_metric);
.max_number_of_proxies(200));
approx.run(30);
return EXIT_SUCCESS;
}