diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_and_extraction_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_and_extraction_example.cpp index 399c7cf8075..6a3fca361b1 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_and_extraction_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_and_extraction_example.cpp @@ -10,14 +10,14 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Polyhedron_3 Polyhedron; -typedef Polyhedron::Facet_const_handle Facet_const_handle; -typedef Polyhedron::Facet_const_iterator Facet_const_iterator; -typedef std::map Facet_id_map; +typedef Polyhedron::Facet_handle Facet_handle; +typedef Polyhedron::Facet_iterator Facet_iterator; +typedef std::map Facet_id_map; int main(int argc, char *argv[]) { if (argc < 5) - return 0; + return EXIT_FAILURE; // create and read Polyhedron Polyhedron mesh; @@ -29,9 +29,9 @@ int main(int argc, char *argv[]) // create a property-map for facet proxy index map Facet_id_map facet_proxy_map; - for (Facet_const_iterator fitr = mesh.facets_begin(); fitr != mesh.facets_end(); ++fitr) - facet_proxy_map.insert(std::pair(fitr, 0)); - boost::associative_property_map f_proxy_pmap(facet_proxy_map); + for (Facet_iterator fitr = mesh.facets_begin(); fitr != mesh.facets_end(); ++fitr) + facet_proxy_map.insert(std::pair(fitr, 0)); + boost::associative_property_map proxy_pmap(facet_proxy_map); const std::size_t num_proxies = std::atoi(argv[3]); const std::size_t num_iterations = std::atoi(argv[4]); @@ -42,7 +42,7 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; CGAL::vsa_approximate_and_extract(mesh, - f_proxy_pmap, + proxy_pmap, tris, anchor_pos, init, diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_extraction_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_extraction_example.cpp index 76d10e76c33..14878f974cc 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_extraction_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_extraction_example.cpp @@ -13,7 +13,7 @@ typedef CGAL::Polyhedron_3 Polyhedron; int main(int argc, char *argv[]) { if (argc < 5) - return 0; + return EXIT_FAILURE; // create and read Polyhedron Polyhedron mesh; diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_l2_metric_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_l2_metric_example.cpp index ebc5d39838a..b19874938f8 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_l2_metric_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_l2_metric_example.cpp @@ -23,7 +23,7 @@ typedef CGAL::PCAPlaneFitting PCAPlaneFitting; int main(int argc, char *argv[]) { if (argc < 5) - return 0; + return EXIT_FAILURE; // read Polyhedron Polyhedron_3 mesh; 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 8101909ad5f..d03b7f71f07 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 @@ -14,12 +14,12 @@ typedef Kernel::FT FT; typedef Kernel::Vector_3 Vector_3; typedef Kernel::Point_3 Point_3; typedef Polyhedron::Facet_handle Facet_handle; -typedef Polyhedron::Facet_const_handle Facet_const_handle; -typedef Polyhedron::Halfedge_const_handle Halfedge_const_handle; -typedef Polyhedron::Facet_const_iterator Facet_const_iterator; -typedef boost::associative_property_map > FacetNormalMap; -typedef boost::associative_property_map > FacetAreaMap; -typedef boost::associative_property_map > FacetCenterMap; +typedef Polyhedron::Halfedge_handle Halfedge_handle; +typedef Polyhedron::Facet_iterator Facet_iterator; +typedef boost::associative_property_map > FacetNormalMap; +typedef boost::associative_property_map > FacetAreaMap; +typedef boost::associative_property_map > FacetCenterMap; +typedef std::map Facet_id_map; struct PointProxy { Facet_handle seed; @@ -32,7 +32,7 @@ struct CompactMetric { CompactMetric(const FacetCenterMap &_center_pmap) : center_pmap(_center_pmap) {} - FT operator()(const Facet_const_handle &f, const PointProxy &px) const { + FT operator()(const Facet_handle &f, const PointProxy &px) const { return FT(std::sqrt(CGAL::to_double( CGAL::squared_distance(center_pmap[f], px.center)))); } @@ -43,15 +43,11 @@ struct CompactMetric { struct PointProxyFitting { typedef PointProxy Proxy; - PointProxyFitting(const FacetCenterMap &_center_pmap, - const FacetAreaMap &_area_pmap) - : center_pmap(_center_pmap), - area_pmap(_area_pmap) {} + PointProxyFitting(const FacetCenterMap &_center_pmap, const FacetAreaMap &_area_pmap) + : center_pmap(_center_pmap), area_pmap(_area_pmap) {} template PointProxy operator()(const FacetIterator beg, const FacetIterator end) const { - CGAL_assertion(beg != end); - // fitting center Vector_3 center = CGAL::NULL_VECTOR; FT area(0); @@ -75,7 +71,7 @@ struct PointProxyFitting { int main(int argc, char *argv[]) { if (argc < 5) - return 0; + return EXIT_FAILURE; // create and read Polyhedron Polyhedron mesh; @@ -86,26 +82,25 @@ int main(int argc, char *argv[]) } // construct facet normal & area map - std::map facet_areas; - std::map facet_centers; - for(Facet_const_iterator fitr = mesh.facets_begin(); fitr != mesh.facets_end(); ++fitr) { - const Halfedge_const_handle he = fitr->halfedge(); - const Point_3 p1 = he->opposite()->vertex()->point(); - const Point_3 p2 = he->vertex()->point(); - const Point_3 p3 = he->next()->vertex()->point(); - FT area(std::sqrt(CGAL::to_double(CGAL::squared_area(p1, p2, p3)))); - facet_areas.insert(std::pair(fitr, area)); - facet_centers.insert(std::pair(fitr, CGAL::centroid(p1, p2, p3))); + std::map facet_areas; + 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)))); + facet_areas.insert(std::pair(fitr, area)); + facet_centers.insert(std::pair(fitr, CGAL::centroid(p0, p1, p2))); } FacetAreaMap area_pmap(facet_areas); FacetCenterMap center_pmap(facet_centers); // create a property-map for segment-ids - typedef std::map Facet_id_map; - Facet_id_map internal_facet_id_map; - for (Facet_const_iterator fitr = mesh.facets_begin(); fitr != mesh.facets_end(); ++fitr) - internal_facet_id_map.insert(std::pair(fitr, 0)); - boost::associative_property_map proxy_patch_map(internal_facet_id_map); + Facet_id_map facet_proxy_map; + for (Facet_iterator fitr = mesh.facets_begin(); fitr != mesh.facets_end(); ++fitr) + facet_proxy_map.insert(std::pair(fitr, 0)); + boost::associative_property_map proxy_pmap(facet_proxy_map); const std::size_t num_proxies = std::atoi(argv[3]); const std::size_t num_iterations = std::atoi(argv[4]); @@ -114,7 +109,7 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; CGAL::vsa_approximate(mesh, - proxy_patch_map, + proxy_pmap, CompactMetric(center_pmap), PointProxyFitting(center_pmap, area_pmap), init,