diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/CMakeLists.txt b/Surface_mesh_approximation/examples/Surface_mesh_approximation/CMakeLists.txt index 09316de8319..e7ffca93380 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/CMakeLists.txt +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/CMakeLists.txt @@ -31,6 +31,8 @@ if ( NOT Boost_FOUND ) endif() +add_definitions(-DBOOST_NO_CXX11_TEMPLATE_ALIASES) + # include for local directory # include for local package diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_example.cpp index 34fab8cc103..b229a4b1990 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_example.cpp @@ -13,28 +13,28 @@ typedef CGAL::Polyhedron_3 Polyhedron; int main() { // create and read Polyhedron - Polyhedron mesh; - std::ifstream input("data/bear.off"); - if (!input || !(input >> mesh) || mesh.empty()) { + Polyhedron input; + std::ifstream file("data/bear.off"); + if (!file || !(file >> input) || input.empty()) { std::cerr << "Invalid off file." << std::endl; return EXIT_FAILURE; } // output data - Polyhedron out_mesh; - std::vector tris; - std::vector anchor_pos; + Polyhedron output; + std::vector triangles; + std::vector anchors; // free function interface with named parameters - CGAL::vsa_mesh_approximation(mesh, out_mesh, + CGAL::vsa_mesh_approximation(input, output, CGAL::VSA::parameters::number_of_proxies(200). // number of fitting proxies number_of_iterations(30). // number of iterations init_method(1). // hierarchical init - anchor_point(std::back_inserter(anchor_pos)). // get anchor points - indexed_triangles(std::back_inserter(tris))); // get indexed triangles + anchor_point(std::back_inserter(anchors)). // get anchor points + indexed_triangles(std::back_inserter(triangles))); // get indexed triangles - std::cout << "#anchor_pos " << anchor_pos.size() << std::endl; - std::cout << "#tris " << tris.size() << std::endl; + std::cout << "#anchors: " << anchors.size() << std::endl; + std::cout << "#triangles: " << triangles.size() << std::endl; return EXIT_SUCCESS; } diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_metric_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_metric_example.cpp index 9944c9d538d..4255727be1b 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_metric_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_metric_example.cpp @@ -11,20 +11,20 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef Kernel::FT FT; -typedef Kernel::Vector_3 Vector_3; -typedef Kernel::Point_3 Point_3; +typedef Kernel::Vector_3 Vector; +typedef Kernel::Point_3 Point; -typedef CGAL::Polyhedron_3 Polyhedron_3; -typedef Polyhedron_3::Facet_handle Facet_handle; -typedef Polyhedron_3::Halfedge_handle Halfedge_handle; -typedef Polyhedron_3::Facet_iterator Facet_iterator; +typedef CGAL::Polyhedron_3 Polyhedron; +typedef Polyhedron::Facet_handle Facet_handle; +typedef Polyhedron::Halfedge_handle Halfedge_handle; +typedef Polyhedron::Facet_iterator Facet_iterator; typedef boost::associative_property_map > FacetAreaMap; -typedef boost::associative_property_map > FacetCenterMap; +typedef boost::associative_property_map > FacetCenterMap; // proxy struct PointProxy { Facet_handle seed; - Point_3 center; + Point center; }; // metric functor @@ -57,8 +57,8 @@ struct PointProxyFitting { template PointProxy operator()(const FacetIterator beg, const FacetIterator end) const { // fitting center - Vector_3 center = CGAL::NULL_VECTOR; - FT area(0); + Vector center = CGAL::NULL_VECTOR; + FT area = FT(0.0); for (FacetIterator fitr = beg; fitr != end; ++fitr) { center = center + (center_pmap[*fitr] - CGAL::ORIGIN) * area_pmap[*fitr]; area += area_pmap[*fitr]; @@ -75,12 +75,12 @@ struct PointProxyFitting { const FacetCenterMap center_pmap; const FacetAreaMap area_pmap; }; -typedef CGAL::VSA_approximation CompactVSA; +typedef CGAL::VSA_approximation CompactVSA; int main() { // create and read Polyhedron_3 - Polyhedron_3 mesh; + Polyhedron mesh; std::ifstream input("data/bear.off"); if (!input || !(input >> mesh) || mesh.empty()) { std::cerr << "Invalid off file." << std::endl; @@ -89,15 +89,16 @@ int main() // construct precomputed facet normal and area map std::map facet_areas; - std::map facet_centers; + std::map facet_centers; for(Facet_iterator fitr = mesh.facets_begin(); fitr != mesh.facets_end(); ++fitr) { const Halfedge_handle he = fitr->halfedge(); - const Point_3 &p0 = he->opposite()->vertex()->point(); - const Point_3 &p1 = he->vertex()->point(); - const Point_3 &p2 = he->next()->vertex()->point(); - FT area(std::sqrt(CGAL::to_double(CGAL::squared_area(p0, p1, p2)))); + const Point &p0 = he->opposite()->vertex()->point(); + const Point &p1 = he->vertex()->point(); + const Point &p2 = he->next()->vertex()->point(); + const FT area = std::sqrt(CGAL::to_double(CGAL::squared_area(p0, p1, p2))); + const Point barycenter = CGAL::centroid(p0, p1, p2); facet_areas.insert(std::pair(fitr, area)); - facet_centers.insert(std::pair(fitr, CGAL::centroid(p0, p1, p2))); + facet_centers.insert(std::pair(fitr, barycenter)); } FacetAreaMap area_pmap(facet_areas); FacetCenterMap center_pmap(facet_centers);