diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/named_params_helper.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/named_params_helper.h index 0abff9fbd45..cd3171b14bd 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/named_params_helper.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/named_params_helper.h @@ -25,6 +25,8 @@ #include #include +#include +#include // shortcut for accessing the value type of the property map template @@ -56,6 +58,40 @@ public: > ::type type; }; +template +class property_map_selector +{ +public: + typedef typename boost::graph_has_property::type Has_internal_pmap; + typedef typename boost::mpl::if_c< Has_internal_pmap::value + , typename boost::property_map::type + , typename boost::cgal_no_property::type + >::type type; + + type get_pmap(const PropertyTag& p, const PolygonMesh& pmesh) + { + return get_impl(p, pmesh, Has_internal_pmap()); + } + +private: + type get_impl(const PropertyTag& p, const PolygonMesh& pmesh, CGAL::Tag_false) + { + return type(); //boost::cgal_no_property::type + } + type get_impl(const PropertyTag& p, const PolygonMesh& pmesh, CGAL::Tag_true) + { + return get(p, pmesh); + } +}; + +template +typename property_map_selector::type +get_property_map(const PropertyTag& p, const PolygonMesh& pmesh) +{ + property_map_selector pms; + return pms.get_pmap(p, pmesh); +} + template class GetVertexPointMap { @@ -79,7 +115,7 @@ public: template class GetFaceIndexMap { - typedef typename boost::property_map < PolygonMesh, boost::face_index_t>::type DefaultMap; + typedef typename property_map_selector::type DefaultMap; public: typedef typename boost::lookup_named_param_def < boost::face_index_t,