//======================================================================= // Copyright 1997, 1998, 1999, 2000 University of Notre Dame. // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek // // This file is part of the Boost Graph Library // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) //======================================================================= // Copyright (c) 2007-2015 GeometryFactory (France). All rights reserved. // // $URL$ // $Id$ // SPDX-License-Identifier: BSL-1.0 // // Author(s) : Andreas Fabri, Fernando Cacciola, Jane Tournois #ifndef CGAL_BOOST_GRAPH_NAMED_PARAMETERS_HELPERS_H #define CGAL_BOOST_GRAPH_NAMED_PARAMETERS_HELPERS_H #include #include #include #include #include #include #include #include namespace CGAL { //helper classes 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; typedef typename boost::mpl::if_c< Has_internal_pmap::value , typename boost::property_map::const_type , typename boost::cgal_no_property::const_type >::type const_type; type get_pmap(const PropertyTag& p, PolygonMesh& pmesh) { return get_impl(p, pmesh, Has_internal_pmap()); } const_type get_const_pmap(const PropertyTag& p, const PolygonMesh& pmesh) { return get_const_pmap_impl(p, pmesh, Has_internal_pmap()); } private: type get_impl(const PropertyTag&, PolygonMesh&, CGAL::Tag_false) { return type(); //boost::cgal_no_property::type } type get_impl(const PropertyTag& p, PolygonMesh& pmesh, CGAL::Tag_true) { return get(p, pmesh); } const_type get_const_pmap_impl(const PropertyTag& , const PolygonMesh&, CGAL::Tag_false) { return const_type(); //boost::cgal_no_property::type } const_type get_const_pmap_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, PolygonMesh& pmesh) { property_map_selector pms; return pms.get_pmap(p, pmesh); } template typename property_map_selector::const_type get_const_property_map(const PropertyTag& p, const PolygonMesh& pmesh) { property_map_selector pms; return pms.get_const_pmap(p, pmesh); } // shortcut for accessing the value type of the property map template class property_map_value { typedef typename boost::property_map::const_type PMap; public: typedef typename boost::property_traits::value_type type; }; template class GetVertexPointMap { typedef typename property_map_selector::const_type DefaultVPMap_const; typedef typename property_map_selector::type DefaultVPMap; public: typedef typename boost::lookup_named_param_def< internal_np::vertex_point_t, NamedParameters, DefaultVPMap > ::type type; typedef typename boost::lookup_named_param_def< internal_np::vertex_point_t, NamedParameters, DefaultVPMap_const > ::type const_type; }; template class GetK { typedef typename boost::property_traits< typename GetVertexPointMap::type >::value_type Point; public: typedef typename CGAL::Kernel_traits::Kernel Kernel; }; template > class GetGeomTraits { typedef typename boost::graph_has_property::type Has_internal_pmap; struct Fake_GT {};//to be used if there is no internal vertex_point_map in PolygonMesh typedef typename boost::mpl::if_c< Has_internal_pmap::value , typename GetK::Kernel , Fake_GT >::type DefaultKernel; public: typedef typename boost::lookup_named_param_def < internal_np::geom_traits_t, NamedParameters, DefaultKernel > ::type type; }; template class GetFaceIndexMap { typedef typename property_map_selector::type DefaultMap; typedef typename property_map_selector::const_type DefaultMap_const; public: typedef typename boost::lookup_named_param_def < internal_np::face_index_t, NamedParameters, DefaultMap > ::type type; typedef typename boost::lookup_named_param_def < internal_np::face_index_t, NamedParameters, DefaultMap_const > ::type const_type; typedef typename boost::is_same::type Is_internal_map; typedef typename boost::is_same::type Is_internal_map_const; }; template class GetVertexIndexMap { typedef typename property_map_selector::type DefaultMap; public: typedef typename boost::lookup_named_param_def < internal_np::vertex_index_t, NamedParameters, DefaultMap > ::type type; }; template class GetFaceNormalMap { struct DummyNormalPmap { typedef typename boost::graph_traits::face_descriptor key_type; typedef typename GetGeomTraits::type::Vector_3 value_type; typedef value_type reference; typedef boost::readable_property_map_tag category; typedef DummyNormalPmap Self; friend reference get(const Self&, const key_type&) { return CGAL::NULL_VECTOR; } }; public: typedef DummyNormalPmap NoMap; typedef typename boost::lookup_named_param_def < internal_np::face_normal_t, NamedParameters, DummyNormalPmap//default > ::type type; }; template class GetSolver { public: typedef typename boost::lookup_named_param_def < internal_np::sparse_linear_solver_t, NamedParameters, DefaultSolver > ::type type; }; } //namespace CGAL #endif // CGAL_BOOST_GRAPH_NAMED_PARAMETERS_HELPERS_H