From fe2bdbd5c92fd9f66b6560781d37b2a6f91413df Mon Sep 17 00:00:00 2001 From: Lingjie Zhu Date: Thu, 19 Apr 2018 15:41:25 +0800 Subject: [PATCH] fix clashed names with PMP named parameters move named parameters from CGAL::internal_np to CGAL::Surface_mesh_approximation::internal_np --- .../include/CGAL/VSA_approximation.h | 11 +-- .../named_function_params.h | 65 +++++++++-------- .../named_params_helper.h | 22 +++--- .../include/CGAL/mesh_approximation.h | 73 ++++++++++--------- 4 files changed, 89 insertions(+), 82 deletions(-) diff --git a/Surface_mesh_approximation/include/CGAL/VSA_approximation.h b/Surface_mesh_approximation/include/CGAL/VSA_approximation.h index 056f4f9d6ca..05ccc9254ff 100644 --- a/Surface_mesh_approximation/include/CGAL/VSA_approximation.h +++ b/Surface_mesh_approximation/include/CGAL/VSA_approximation.h @@ -890,12 +890,13 @@ public: bool extract_mesh(const NamedParameters &np) { using boost::get_param; using boost::choose_param; + namespace sma_np = CGAL::Surface_mesh_approximation::internal_np; - const FT subdivision_ratio = choose_param(get_param(np, internal_np::subdivision_ratio), FT(5.0)); - const bool relative_to_chord = choose_param(get_param(np, internal_np::relative_to_chord), false); - const bool with_dihedral_angle = choose_param(get_param(np, internal_np::with_dihedral_angle), false); - const bool optimize_anchor_location = choose_param(get_param(np, internal_np::optimize_anchor_location), true); - const bool pca_plane = choose_param(get_param(np, internal_np::pca_plane), false); + const FT subdivision_ratio = choose_param(get_param(np, sma_np::subdivision_ratio), FT(5.0)); + const bool relative_to_chord = choose_param(get_param(np, sma_np::relative_to_chord), false); + const bool with_dihedral_angle = choose_param(get_param(np, sma_np::with_dihedral_angle), false); + const bool optimize_anchor_location = choose_param(get_param(np, sma_np::optimize_anchor_location), true); + const bool pca_plane = choose_param(get_param(np, sma_np::pca_plane), false); // compute averaged edge length, used in chord subdivision m_average_edge_length = compute_averaged_edge_length(*m_ptm, m_vpoint_map); 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 f65348800f7..8fd159c21a2 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 @@ -5,36 +5,39 @@ #include -namespace CGAL{ -namespace internal_np{ +namespace CGAL { +namespace Surface_mesh_approximation { +namespace internal_np { -enum sma_dummy_output_t { sma_dummy_output }; enum all_default_t { all_default }; //cannot use macro because it takes no argument +enum dummy_output_t { dummy_output }; // define enum types and values for new named parameters #define CGAL_add_named_parameter(X, Y, Z) \ enum X { Y }; #include +#include +#include #undef CGAL_add_named_parameter -}//internal_np +} // namespace internal_np - template - struct sma_bgl_named_params - : CGAL::cgal_bgl_named_params +template +struct sma_bgl_named_params + : CGAL::cgal_bgl_named_params +{ + typedef CGAL::cgal_bgl_named_params base; + typedef sma_bgl_named_params self; + + sma_bgl_named_params(T v = T()) : base(v) {} + sma_bgl_named_params(T v, const Base& b) : base(v, b) {} + + sma_bgl_named_params + all_default() const { - typedef CGAL::cgal_bgl_named_params base; - typedef sma_bgl_named_params self; - - sma_bgl_named_params(T v = T()) : base(v) {} - sma_bgl_named_params(T v, const Base& b) : base(v, b) {} - - sma_bgl_named_params - all_default() const - { - typedef sma_bgl_named_params Params; - return Params(*this); - } + typedef sma_bgl_named_params Params; + return Params(*this); + } // define the functions for new named parameters and the one imported from BGL and boost // used to concatenate several parameters @@ -50,11 +53,9 @@ enum all_default_t { all_default }; //cannot use macro because it takes no argum #include #include #undef CGAL_add_named_parameter - }; +}; -namespace Surface_mesh_approximation{ - -namespace parameters{ +namespace parameters { sma_bgl_named_params inline all_default() @@ -76,10 +77,10 @@ inline all_default() #include #include #undef CGAL_add_named_parameter -} //namespace parameters -} //namespace Surface_mesh_approximation -} //namespace CGAL +} // namespace parameters +} // namespace Surface_mesh_approximation +} // namespace CGAL // partial specializations hate inheritance and we need to repeat // those here. this is rather fragile. @@ -87,12 +88,12 @@ namespace boost { #if BOOST_VERSION < 105100 template inline - typename property_value< CGAL::sma_bgl_named_params, Tag2>::type - get_param(const CGAL::sma_bgl_named_params& p, Tag2 tag2) + typename property_value, Tag2>::type + get_param(const CGAL::Surface_mesh_approximation::sma_bgl_named_params& p, Tag2 tag2) { enum { match = detail::same_property::value }; typedef typename - boost::property_value< CGAL::sma_bgl_named_params, Tag2>::type T2; + boost::property_value, Tag2>::type T2; T2* t2 = 0; typedef detail::property_value_dispatch Dispatcher; return Dispatcher::const_get_value(p, t2, tag2); @@ -100,7 +101,7 @@ namespace boost { #endif template - struct lookup_named_param_def, Def> { + struct lookup_named_param_def, Def> { typedef T type; static const type& get(const bgl_named_params& p, const Def&) { return p.m_value; @@ -108,13 +109,13 @@ namespace boost { }; template - struct lookup_named_param_def, Def> { + struct lookup_named_param_def, Def> { typedef typename lookup_named_param_def::type type; static const type& get(const bgl_named_params& p, const Def& def) { return lookup_named_param_def::get(p.m_base, def); } }; -} // boost +} // namespace boost #endif //CGAL_SMA_BGL_NAMED_FUNCTION_PARAMS_H 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 daf19e7ea07..92fb163720d 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 @@ -13,6 +13,8 @@ #include namespace CGAL { +namespace Surface_mesh_approximation { +namespace internal_np { // shortcut for accessing the value type of the property map template @@ -74,49 +76,51 @@ public: // output helper functions template -void facet_proxy_map(const Approximation &approx, FacetProxyMap fproxymap) { +void facet_proxy_map_helper(const Approximation &approx, FacetProxyMap fproxymap) { approx.proxy_map(fproxymap); } template -void facet_proxy_map(const Approximation &, internal_np::sma_dummy_output_t) {} +void facet_proxy_map_helper(const Approximation &, internal_np::dummy_output_t) {} // proxies template -void proxies(const Approximation &approx, OutputIterator out) +void proxies_helper(const Approximation &approx, OutputIterator out) { approx.proxies(out); } template -void proxies(const Approximation &, internal_np::sma_dummy_output_t) +void proxies_helper(const Approximation &, internal_np::dummy_output_t) {} // anchors template -void anchors(const Approximation &approx, OutputIterator out) +void anchors_helper(const Approximation &approx, OutputIterator out) { approx.anchor_points(out); } template -void anchors(const Approximation &, internal_np::sma_dummy_output_t) +void anchors_helper(const Approximation &, internal_np::dummy_output_t) {} // indexed triangles template -void triangles(const Approximation &approx, OutputIterator out) +void triangles_helper(const Approximation &approx, OutputIterator out) { approx.indexed_triangles(out); } template -void triangles(const Approximation &, internal_np::sma_dummy_output_t) +void triangles_helper(const Approximation &, internal_np::dummy_output_t) {} -} //end of namespace CGAL +} // namespace internal_np +} // namespace Surface_mesh_approximation +} // namespace CGAL #endif //CGAL_SMA_NAMED_PARAMETERS_HELPERS_H diff --git a/Surface_mesh_approximation/include/CGAL/mesh_approximation.h b/Surface_mesh_approximation/include/CGAL/mesh_approximation.h index 8411c398bf3..3e59beaf9ed 100644 --- a/Surface_mesh_approximation/include/CGAL/mesh_approximation.h +++ b/Surface_mesh_approximation/include/CGAL/mesh_approximation.h @@ -104,19 +104,20 @@ bool mesh_approximation(const TriangleMesh &tm, const NamedParameters &np) { using boost::get_param; using boost::choose_param; + namespace sma_np = CGAL::Surface_mesh_approximation::internal_np; - typedef typename GetGeomTraits::type Geom_traits; + typedef typename sma_np::GetGeomTraits::type Geom_traits; typedef typename Geom_traits::FT FT; - typedef typename GetVertexPointMap::type Vertex_point_map; - Vertex_point_map point_pmap = choose_param(get_param(np, internal_np::vertex_point), + typedef typename sma_np::GetVertexPointMap::type Vertex_point_map; + Vertex_point_map point_pmap = choose_param(get_param(np, sma_np::vertex_point), get_property_map(vertex_point, const_cast(tm))); typedef CGAL::VSA_approximation L21_approx; typedef typename L21_approx::Error_metric L21_metric; const Approximation_verbose_level vl = choose_param( - get_param(np, internal_np::verbose_level), CGAL::Main_steps); + get_param(np, sma_np::verbose_level), CGAL::Main_steps); if (vl == CGAL::Main_steps || vl == CGAL::Verbose) { std::cout << "Variational shape approximation:" @@ -130,12 +131,12 @@ bool mesh_approximation(const TriangleMesh &tm, const NamedParameters &np) // hierarchical seeding by default CGAL::Approximation_seeding_tag method = choose_param( - get_param(np, internal_np::seeding_method), CGAL::Hierarchical); + get_param(np, sma_np::seeding_method), CGAL::Hierarchical); boost::optional max_nb_proxies = choose_param( - get_param(np, internal_np::max_nb_proxies), boost::optional()); + get_param(np, sma_np::max_nb_proxies), boost::optional()); boost::optional min_error_drop = choose_param( - get_param(np, internal_np::min_error_drop), boost::optional()); - std::size_t nb_of_relaxations = choose_param(get_param(np, internal_np::nb_of_relaxations), 5); + get_param(np, sma_np::min_error_drop), boost::optional()); + std::size_t nb_of_relaxations = choose_param(get_param(np, sma_np::nb_of_relaxations), 5); if (vl == CGAL::Verbose) { std::cout << (method == CGAL::Random ? "Random" : @@ -155,7 +156,7 @@ bool mesh_approximation(const TriangleMesh &tm, const NamedParameters &np) nb_of_iterations_default = (std::min)((std::max)( nb_of_iterations_default, static_cast(20)), static_cast(60)); const std::size_t nb_of_iterations = choose_param( - get_param(np, internal_np::nb_of_iterations), nb_of_iterations_default); + get_param(np, sma_np::nb_of_iterations), nb_of_iterations_default); if (vl == CGAL::Verbose) std::cout << "\n#nb_of_iterations = " << nb_of_iterations << std::endl; @@ -169,49 +170,49 @@ bool mesh_approximation(const TriangleMesh &tm, const NamedParameters &np) // get proxy map typedef typename boost::lookup_named_param_def< - internal_np::facet_proxy_map_t, + sma_np::facet_proxy_map_t, NamedParameters, - internal_np::sma_dummy_output_t>::type Face_proxy_map; + sma_np::dummy_output_t>::type Face_proxy_map; Face_proxy_map fproxymap = choose_param( - get_param(np, internal_np::facet_proxy_map), internal_np::sma_dummy_output); - facet_proxy_map(approx, fproxymap); + get_param(np, sma_np::facet_proxy_map), sma_np::dummy_output); + sma_np::facet_proxy_map_helper(approx, fproxymap); - if (!boost::is_same::value + if (!boost::is_same::value && (vl == CGAL::Main_steps || vl == CGAL::Verbose)) std::cout << "Filling facet proxy map done." << std::endl; // get proxies typedef typename boost::lookup_named_param_def< - internal_np::proxies_t, + sma_np::proxies_t, NamedParameters, - internal_np::sma_dummy_output_t>::type Proxies_output_iterator; + sma_np::dummy_output_t>::type Proxies_output_iterator; Proxies_output_iterator pxies_out_itr = choose_param( - get_param(np, internal_np::proxies), internal_np::sma_dummy_output); - proxies(approx, pxies_out_itr); + get_param(np, sma_np::proxies), sma_np::dummy_output); + sma_np::proxies_helper(approx, pxies_out_itr); - if (!boost::is_same::value + if (!boost::is_same::value && (vl == CGAL::Main_steps || vl == CGAL::Verbose)) std::cout << "Get proxies done." << std::endl; // meshing typedef typename boost::lookup_named_param_def< - internal_np::anchors_t, + sma_np::anchors_t, NamedParameters, - internal_np::sma_dummy_output_t>::type Anchors_output_iterator; + sma_np::dummy_output_t>::type Anchors_output_iterator; typedef typename boost::lookup_named_param_def< - internal_np::triangles_t, + sma_np::triangles_t, NamedParameters, - internal_np::sma_dummy_output_t>::type Triangles_output_iterator; + sma_np::dummy_output_t>::type Triangles_output_iterator; bool is_manifold = false; - if (!boost::is_same::value - || !boost::is_same::value) { + if (!boost::is_same::value + || !boost::is_same::value) { if (vl == CGAL::Verbose) { - const FT subdivision_ratio = choose_param(get_param(np, internal_np::subdivision_ratio), FT(5.0)); - const bool relative_to_chord = choose_param(get_param(np, internal_np::relative_to_chord), false); - const bool with_dihedral_angle = choose_param(get_param(np, internal_np::with_dihedral_angle), false); - const bool optimize_anchor_location = choose_param(get_param(np, internal_np::optimize_anchor_location), true); - const bool pca_plane = choose_param(get_param(np, internal_np::pca_plane), false); + const FT subdivision_ratio = choose_param(get_param(np, sma_np::subdivision_ratio), FT(5.0)); + const bool relative_to_chord = choose_param(get_param(np, sma_np::relative_to_chord), false); + const bool with_dihedral_angle = choose_param(get_param(np, sma_np::with_dihedral_angle), false); + const bool optimize_anchor_location = choose_param(get_param(np, sma_np::optimize_anchor_location), true); + const bool pca_plane = choose_param(get_param(np, sma_np::pca_plane), false); std::cout << "Meshing: " << "\nchord_error = " << subdivision_ratio << "\nrelative_to_chord = " << relative_to_chord @@ -229,19 +230,19 @@ bool mesh_approximation(const TriangleMesh &tm, const NamedParameters &np) // get anchor points Anchors_output_iterator apts_out_itr = choose_param( - get_param(np, internal_np::anchors) , internal_np::sma_dummy_output); - anchors(approx, apts_out_itr); + get_param(np, sma_np::anchors) , sma_np::dummy_output); + sma_np::anchors_helper(approx, apts_out_itr); - if (!boost::is_same::value + if (!boost::is_same::value && (vl == CGAL::Main_steps || vl == CGAL::Verbose)) std::cout << "Get anchors done." << std::endl; // get indexed triangles Triangles_output_iterator tris_out_itr = choose_param( - get_param(np, internal_np::triangles) , internal_np::sma_dummy_output); - triangles(approx, tris_out_itr); + get_param(np, sma_np::triangles) , sma_np::dummy_output); + sma_np::triangles_helper(approx, tris_out_itr); - if (!boost::is_same::value + if (!boost::is_same::value && (vl == CGAL::Main_steps || vl == CGAL::Verbose)) std::cout << "Get indexed triangles done." << std::endl;