diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_2_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_2_example.cpp index 5db751963a6..c78e2edad26 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_2_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_2_example.cpp @@ -22,7 +22,7 @@ int main() } // output indexed triangle mesh - std::vector points; + std::vector anchors; std::vector > triangles; // triplets of indices // output facet proxy index property map @@ -40,9 +40,9 @@ int main() nb_of_iterations(40). // set number of clustering iterations after seeding mesh_chord_error(0.3). // set chord approximation error threshold when meshing facet_proxy_map(fpxmap). // get facet partition map - proxies(std::back_inserter(proxies)). // get proxies - anchor_points(std::back_inserter(points)). // anchor points - indexed_triangles(std::back_inserter(triangles))); // indexed triangles + proxies(std::back_inserter(proxies)). // output proxies + anchors(std::back_inserter(anchors)). // output anchor points + triangles(std::back_inserter(triangles))); // output indexed triangles return EXIT_SUCCESS; } 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 d15acaa9981..db61e0f8854 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 @@ -24,8 +24,8 @@ int main() CGAL::Surface_mesh_approximation::parameters::seeding_method(CGAL::Hierarchical). // hierarchical seeding max_nb_proxies(200). // seeding with maximum number of proxies nb_of_iterations(30). // number of clustering iterations after seeding - vertex_output_iterator(std::back_inserter(vertices)). // anchor vertices - triangle_output_iterator(std::back_inserter(triangles))); // indexed triangles + anchors(std::back_inserter(vertices)). // anchor vertices + triangles(std::back_inserter(triangles))); // indexed triangles std::cout << "#anchor vertices: " << vertices.size() << std::endl; std::cout << "#triangles: " << triangles.size() << std::endl; diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_isotropic_metric_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_isotropic_metric_example.cpp index cfb6e07323d..376b4923d66 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_isotropic_metric_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_isotropic_metric_example.cpp @@ -22,8 +22,9 @@ typedef boost::associative_property_map > Facet_area_ typedef boost::associative_property_map > Facet_center_map; // user-defined "compact" error metric -struct Compact_metric { -// use point as proxy +struct Compact_metric +{ + // use point as proxy typedef Point Proxy; // we keep a precomputed property map to speed up computations @@ -49,7 +50,7 @@ struct Compact_metric { center = center + (center_pmap[*fitr] - CGAL::ORIGIN) * area_pmap[*fitr]; sum_areas += area_pmap[*fitr]; } - center = center / sum_areas; + center = center / sum_areas; // TODO: deal with case where sum = 0 return CGAL::ORIGIN + center; } @@ -65,10 +66,7 @@ int main() // creates polyhedral surface and reads input mesh Polyhedron input; std::ifstream file("data/bear.off"); - if (!file || !(file >> input) || input.empty()) { - std::cerr << "Invalid off file." << std::endl; - return EXIT_FAILURE; - } + file >> input; // constructs precomputed facet normal and area map std::map facet_areas; diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_segmentation_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_segmentation_example.cpp index 52c71069530..6e658c4c45f 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_segmentation_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_segmentation_example.cpp @@ -8,7 +8,7 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Polyhedron_3 Polyhedron; typedef boost::graph_traits::face_descriptor Face_descriptor; -typedef boost::unordered_map Facet_index_map; +typedef boost::unordered_map Facet_index_map; typedef boost::associative_property_map Facet_proxy_pmap; int main() @@ -27,7 +27,7 @@ int main() // free function interface with named parameters CGAL::mesh_approximation(input, - max_nb_proxies(200). // first stop criterion + CGAL::Surface_mesh_approximation::parameters::max_nb_proxies(200). // first stop criterion min_error_drop(0.05). // second stop criterion nb_of_iterations(30). // number of relaxation iterations after seeding facet_proxy_map(fpxmap)); // output facet-proxy map 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 e12d4139475..59cf9af012d 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 @@ -16,16 +16,16 @@ int main() file >> input; // The output will be an indexed triangle mesh - std::vector points; + std::vector anchors; std::vector > triangles; // free function interface with named parameters CGAL::mesh_approximation(input, CGAL::Surface_mesh_approximation::parameters::max_nb_proxies(200). - anchor_points(std::back_inserter(points)). // anchor points - indexed_triangles(std::back_inserter(triangles))); // indexed triangles + anchors(std::back_inserter(anchors)). // anchor points + triangles(std::back_inserter(triangles))); // indexed triangles - std::cout << "#vertices: " << points.size() << std::endl; + std::cout << "#anchor points: " << anchors.size() << std::endl; std::cout << "#triangles: " << triangles.size() << std::endl; return EXIT_SUCCESS; diff --git a/Surface_mesh_approximation/include/CGAL/VSA_approximation.h b/Surface_mesh_approximation/include/CGAL/VSA_approximation.h index 049d21af834..ce7edcec2de 100644 --- a/Surface_mesh_approximation/include/CGAL/VSA_approximation.h +++ b/Surface_mesh_approximation/include/CGAL/VSA_approximation.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include @@ -85,7 +85,7 @@ public: // ErrorMetric type #ifndef DOXYGEN_RUNNING typedef typename CGAL::Default::Get >::type Error_metric; + CGAL::VSA::L21_metric_plane_proxy >::type Error_metric; #else typedef ErrorMetric Error_metric; #endif @@ -947,9 +947,9 @@ public: * @param out_itr output iterator */ template - void proxies(OutputIterator out_itr) const { + void proxies(OutputIterator out) const { BOOST_FOREACH(const Proxy_wrapper &pxw, m_proxies) - *out_itr++ = pxw.px; + *out++ = pxw.px; } #ifdef CGAL_SURFACE_MESH_APPROXIMATION_DEBUG diff --git a/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/named_function_params.h b/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/named_function_params.h index dc6098466f5..2f0bd0bbb37 100644 --- a/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/named_function_params.h +++ b/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/named_function_params.h @@ -3,7 +3,6 @@ #include - #include namespace CGAL{ diff --git a/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/named_params_helper.h b/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/named_params_helper.h index c346acb9ede..5ab010fe69c 100644 --- a/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/named_params_helper.h +++ b/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/named_params_helper.h @@ -74,36 +74,48 @@ public: // output helper functions template -void get_proxy_map(const Approximation &approx, FacetProxyMap fproxymap) { +void facet_proxy_map(const Approximation &approx, FacetProxyMap fproxymap) { approx.proxy_map(fproxymap); } template -void get_proxy_map(const Approximation &, internal_np::vsa_no_output_t) {} +void facet_proxy_map(const Approximation &, internal_np::vsa_no_output_t) {} + +// proxies template -void get_proxies(const Approximation &approx, OutputIterator out_itr) { - approx.proxies(out_itr); +void proxies(const Approximation &approx, OutputIterator out) +{ + approx.proxies(out); } template -void get_proxies(const Approximation &, internal_np::vsa_no_output_t) {} +void proxies(const Approximation &, internal_np::vsa_no_output_t) +{} + +// anchors template -void get_anchor_points(const Approximation &approx, OutputIterator out_itr) { - approx.anchor_points(out_itr); +void anchors(const Approximation &approx, OutputIterator out) +{ + approx.anchor_points(out); } template -void get_anchor_points(const Approximation &, internal_np::vsa_no_output_t) {} +void anchors(const Approximation &, internal_np::vsa_no_output_t) {} + +// indexed triangles template -void get_indexed_triangles(const Approximation &approx, OutputIterator out_itr) { - approx.indexed_triangles(out_itr); +void triangles(const Approximation &approx, OutputIterator out) +{ + approx.indexed_triangles(out); } template -void get_indexed_triangles(const Approximation &, internal_np::vsa_no_output_t) {} +void triangles(const Approximation &, internal_np::vsa_no_output_t) +{} + } //end of namespace CGAL #endif //CGAL_NAMED_PARAMETERS_HELPERS_H diff --git a/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/parameters_interface.h b/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/parameters_interface.h index 0aae82b4670..1eb7db5917e 100644 --- a/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/parameters_interface.h +++ b/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/parameters_interface.h @@ -12,5 +12,5 @@ CGAL_add_named_parameter(mesh_chord_error_t, mesh_chord_error, mesh_chord_error) // output parameters CGAL_add_named_parameter(facet_proxy_map_t, facet_proxy_map, facet_proxy_map) CGAL_add_named_parameter(proxies_t, proxies, proxies) -CGAL_add_named_parameter(anchor_points_t, anchor_points, anchor_points) -CGAL_add_named_parameter(indexed_triangles_t, indexed_triangles, indexed_triangles) +CGAL_add_named_parameter(anchor_points_t, anchors, anchors) +CGAL_add_named_parameter(indexed_triangles_t, triangles, triangles) diff --git a/Surface_mesh_approximation/include/CGAL/mesh_approximation.h b/Surface_mesh_approximation/include/CGAL/mesh_approximation.h index 2db8ce30826..972acb28f55 100644 --- a/Surface_mesh_approximation/include/CGAL/mesh_approximation.h +++ b/Surface_mesh_approximation/include/CGAL/mesh_approximation.h @@ -75,7 +75,7 @@ bool mesh_approximation(const TriangleMesh &tm, const NamedParameters &np) Vertex_point_map point_pmap = choose_param(get_param(np, internal_np::vertex_point), get_property_map(vertex_point, const_cast(tm))); - typedef CGAL::L21_metric L21_metric; + typedef CGAL::VSA::L21_metric_plane_proxy L21_metric; typedef CGAL::VSA_approximation L21_approx; typedef L21_approx::Error_metric L21_metric; @@ -115,7 +115,7 @@ bool mesh_approximation(const TriangleMesh &tm, const NamedParameters &np) internal_np::vsa_no_output_t>::type FPMap; FPMap fproxymap = choose_param( get_param(np, internal_np::facet_proxy_map), internal_np::vsa_no_output); - get_proxy_map(approx, fproxymap); + proxies(approx, fproxymap); // get proxies typedef typename boost::lookup_named_param_def < @@ -124,7 +124,7 @@ bool mesh_approximation(const TriangleMesh &tm, const NamedParameters &np) internal_np::vsa_no_output_t>::type ProxiesOutItr; ProxiesOutItr pxies_out_itr = choose_param( get_param(np, internal_np::proxies), internal_np::vsa_no_output); - get_proxies(approx, pxies_out_itr); + proxies(approx, pxies_out_itr); // meshing const FT chord_error = choose_param(get_param(np, internal_np::mesh_chord_error), FT(5.0)); @@ -136,8 +136,8 @@ bool mesh_approximation(const TriangleMesh &tm, const NamedParameters &np) NamedParameters, internal_np::vsa_no_output_t>::type Anchor_point_output_iterator; Anchor_point_output_iterator apts_out_itr = choose_param( - get_param(np, internal_np::anchor_points) , internal_np::vsa_no_output); - get_anchor_points(approx, apts_out_itr); + get_param(np, internal_np::anchors) , internal_np::vsa_no_output); + anchors(approx, apts_out_itr); // get indexed triangles typedef typename boost::lookup_named_param_def< @@ -145,8 +145,8 @@ bool mesh_approximation(const TriangleMesh &tm, const NamedParameters &np) NamedParameters, internal_np::vsa_no_output_t>::type Indexed_triangles_output_iterator; Indexed_triangles_output_iterator tris_out_itr = choose_param( - get_param(np, internal_np::indexed_triangles) , internal_np::vsa_no_output); - get_indexed_triangles(approx, tris_out_itr); + get_param(np, internal_np::triangles) , internal_np::vsa_no_output); + triangles(approx, tris_out_itr); return is_manifold; }