fix clashed names with PMP named parameters

move named parameters from CGAL::internal_np to CGAL::Surface_mesh_approximation::internal_np
This commit is contained in:
Lingjie Zhu 2018-04-19 15:41:25 +08:00
parent 350c15a18a
commit fe2bdbd5c9
4 changed files with 89 additions and 82 deletions

View File

@ -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);

View File

@ -5,36 +5,39 @@
#include <CGAL/boost/graph/named_function_params.h>
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 <CGAL/internal/Surface_mesh_approximation/parameters_interface.h>
#include <CGAL/boost/graph/parameters_interface.h>
#include <CGAL/boost/graph/boost_parameters_interface.h>
#undef CGAL_add_named_parameter
}//internal_np
} // namespace internal_np
template <typename T, typename Tag, typename Base = boost::no_property>
struct sma_bgl_named_params
: CGAL::cgal_bgl_named_params<T, Tag, Base>
template <typename T, typename Tag, typename Base = boost::no_property>
struct sma_bgl_named_params
: CGAL::cgal_bgl_named_params<T, Tag, Base>
{
typedef CGAL::cgal_bgl_named_params<T, Tag, Base> 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<bool, internal_np::all_default_t, self>
all_default() const
{
typedef CGAL::cgal_bgl_named_params<T, Tag, Base> 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<bool, internal_np::all_default_t, self>
all_default() const
{
typedef sma_bgl_named_params<bool, internal_np::all_default_t, self> Params;
return Params(*this);
}
typedef sma_bgl_named_params<bool, internal_np::all_default_t, self> 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 <CGAL/boost/graph/parameters_interface.h>
#include <CGAL/boost/graph/boost_parameters_interface.h>
#undef CGAL_add_named_parameter
};
};
namespace Surface_mesh_approximation{
namespace parameters{
namespace parameters {
sma_bgl_named_params<bool, internal_np::all_default_t>
inline all_default()
@ -76,10 +77,10 @@ inline all_default()
#include <CGAL/boost/graph/parameters_interface.h>
#include <CGAL/internal/Surface_mesh_approximation/parameters_interface.h>
#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 <class Tag1, class Tag2, class T1, class Base>
inline
typename property_value< CGAL::sma_bgl_named_params<T1,Tag1,Base>, Tag2>::type
get_param(const CGAL::sma_bgl_named_params<T1,Tag1,Base>& p, Tag2 tag2)
typename property_value<CGAL::Surface_mesh_approximation::sma_bgl_named_params<T1,Tag1,Base>, Tag2>::type
get_param(const CGAL::Surface_mesh_approximation::sma_bgl_named_params<T1,Tag1,Base>& p, Tag2 tag2)
{
enum { match = detail::same_property<Tag1,Tag2>::value };
typedef typename
boost::property_value< CGAL::sma_bgl_named_params<T1,Tag1,Base>, Tag2>::type T2;
boost::property_value<CGAL::Surface_mesh_approximation::sma_bgl_named_params<T1,Tag1,Base>, Tag2>::type T2;
T2* t2 = 0;
typedef detail::property_value_dispatch<match> Dispatcher;
return Dispatcher::const_get_value(p, t2, tag2);
@ -100,7 +101,7 @@ namespace boost {
#endif
template <typename T, typename Tag, typename Base, typename Def>
struct lookup_named_param_def<Tag, CGAL::sma_bgl_named_params<T, Tag, Base>, Def> {
struct lookup_named_param_def<Tag, CGAL::Surface_mesh_approximation::sma_bgl_named_params<T, Tag, Base>, Def> {
typedef T type;
static const type& get(const bgl_named_params<T, Tag, Base>& p, const Def&) {
return p.m_value;
@ -108,13 +109,13 @@ namespace boost {
};
template <typename Tag1, typename T, typename Tag, typename Base, typename Def>
struct lookup_named_param_def<Tag1, CGAL::sma_bgl_named_params<T, Tag, Base>, Def> {
struct lookup_named_param_def<Tag1, CGAL::Surface_mesh_approximation::sma_bgl_named_params<T, Tag, Base>, Def> {
typedef typename lookup_named_param_def<Tag1, Base, Def>::type type;
static const type& get(const bgl_named_params<T, Tag, Base>& p, const Def& def) {
return lookup_named_param_def<Tag1, Base, Def>::get(p.m_base, def);
}
};
} // boost
} // namespace boost
#endif //CGAL_SMA_BGL_NAMED_FUNCTION_PARAMS_H

View File

@ -13,6 +13,8 @@
#include <boost/mpl/if.hpp>
namespace CGAL {
namespace Surface_mesh_approximation {
namespace internal_np {
// shortcut for accessing the value type of the property map
template <class Graph, class Property>
@ -74,49 +76,51 @@ public:
// output helper functions
template <typename Approximation, typename FacetProxyMap>
void facet_proxy_map(const Approximation &approx, FacetProxyMap fproxymap) {
void facet_proxy_map_helper(const Approximation &approx, FacetProxyMap fproxymap) {
approx.proxy_map(fproxymap);
}
template <typename Approximation>
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 <typename Approximation, typename OutputIterator>
void proxies(const Approximation &approx, OutputIterator out)
void proxies_helper(const Approximation &approx, OutputIterator out)
{
approx.proxies(out);
}
template <typename Approximation>
void proxies(const Approximation &, internal_np::sma_dummy_output_t)
void proxies_helper(const Approximation &, internal_np::dummy_output_t)
{}
// anchors
template <typename Approximation, typename OutputIterator>
void anchors(const Approximation &approx, OutputIterator out)
void anchors_helper(const Approximation &approx, OutputIterator out)
{
approx.anchor_points(out);
}
template <typename Approximation>
void anchors(const Approximation &, internal_np::sma_dummy_output_t)
void anchors_helper(const Approximation &, internal_np::dummy_output_t)
{}
// indexed triangles
template <typename Approximation, typename OutputIterator>
void triangles(const Approximation &approx, OutputIterator out)
void triangles_helper(const Approximation &approx, OutputIterator out)
{
approx.indexed_triangles(out);
}
template <typename Approximation>
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

View File

@ -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<TriangleMesh, NamedParameters>::type Geom_traits;
typedef typename sma_np::GetGeomTraits<TriangleMesh, NamedParameters>::type Geom_traits;
typedef typename Geom_traits::FT FT;
typedef typename GetVertexPointMap<TriangleMesh, NamedParameters>::type Vertex_point_map;
Vertex_point_map point_pmap = choose_param(get_param(np, internal_np::vertex_point),
typedef typename sma_np::GetVertexPointMap<TriangleMesh, NamedParameters>::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<TriangleMesh &>(tm)));
typedef CGAL::VSA_approximation<TriangleMesh, Vertex_point_map> 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<std::size_t> max_nb_proxies = choose_param(
get_param(np, internal_np::max_nb_proxies), boost::optional<std::size_t>());
get_param(np, sma_np::max_nb_proxies), boost::optional<std::size_t>());
boost::optional<FT> min_error_drop = choose_param(
get_param(np, internal_np::min_error_drop), boost::optional<FT>());
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<FT>());
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<std::size_t>(20)), static_cast<std::size_t>(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<Face_proxy_map, internal_np::sma_dummy_output_t>::value
if (!boost::is_same<Face_proxy_map, sma_np::dummy_output_t>::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<Proxies_output_iterator, internal_np::sma_dummy_output_t>::value
if (!boost::is_same<Proxies_output_iterator, sma_np::dummy_output_t>::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<Anchors_output_iterator, internal_np::sma_dummy_output_t>::value
|| !boost::is_same<Triangles_output_iterator, internal_np::sma_dummy_output_t>::value) {
if (!boost::is_same<Anchors_output_iterator, sma_np::dummy_output_t>::value
|| !boost::is_same<Triangles_output_iterator, sma_np::dummy_output_t>::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<Anchors_output_iterator, internal_np::sma_dummy_output_t>::value
if (!boost::is_same<Anchors_output_iterator, sma_np::dummy_output_t>::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<Triangles_output_iterator, internal_np::sma_dummy_output_t>::value
if (!boost::is_same<Triangles_output_iterator, sma_np::dummy_output_t>::value
&& (vl == CGAL::Main_steps || vl == CGAL::Verbose))
std::cout << "Get indexed triangles done." << std::endl;