From 968e9cf5a96017c589da5f24eb0688c6e9de8a90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 16 Jun 2022 13:29:20 +0200 Subject: [PATCH] avoid duplicating properties for Polyhedron --- .../boost/graph/properties_HalfedgeDS_base.h | 494 ++++++++++++++++++ .../graph/properties_HalfedgeDS_default.h | 494 +----------------- .../boost/graph/graph_traits_Polyhedron_3.h | 3 +- .../boost/graph/properties_Polyhedron_3.h | 494 +----------------- .../graph/properties_Polyhedron_3_features.h | 36 +- .../properties_Polyhedron_3_time_stamp.h | 17 +- 6 files changed, 524 insertions(+), 1014 deletions(-) create mode 100644 HalfedgeDS/include/CGAL/boost/graph/properties_HalfedgeDS_base.h diff --git a/HalfedgeDS/include/CGAL/boost/graph/properties_HalfedgeDS_base.h b/HalfedgeDS/include/CGAL/boost/graph/properties_HalfedgeDS_base.h new file mode 100644 index 00000000000..be3d911c0e8 --- /dev/null +++ b/HalfedgeDS/include/CGAL/boost/graph/properties_HalfedgeDS_base.h @@ -0,0 +1,494 @@ +// Copyright (c) 2007 GeometryFactory (France). All rights reserved. +// +// This file is part of CGAL (www.cgal.org) +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Andreas Fabri, Fernando Cacciola + +// note only the properties below are protected by the macro, +// the rest of the file is the shared implementation of properties for +// Polyhedron and HalfedgeDS_default +#ifndef CGAL_BOOST_GRAPH_PROPERTIES_HALFEDGEDS_BASE_H +#define CGAL_BOOST_GRAPH_PROPERTIES_HALFEDGEDS_BASE_H + +#include +#include +#include +#include +#include +#include + +namespace CGAL { + +namespace internal { + +template +class HDS_index_map_external + : public boost::put_get_helper > +{ +public: + typedef boost::lvalue_property_map_tag category; + typedef std::size_t value_type; + typedef std::size_t& reference; + typedef Handle key_type; + +private: + typedef CGAL::Unique_hash_map Map; + +public: + template + HDS_index_map_external(InputIterator begin, InputIterator end, std::size_t max) + : map_(new Map(begin, end, 0, std::size_t(-1), max)) {} + + reference operator[](const key_type& k) const { return (*map_)[k]; } +private: + std::shared_ptr map_; +}; + +// Special case for edges. +template +class HDS_edge_index_map_external + : public boost::put_get_helper > +{ +public: + typedef boost::lvalue_property_map_tag category; + typedef std::size_t value_type; + typedef std::size_t& reference; + typedef typename boost::graph_traits::edge_descriptor key_type; + +private: + typedef CGAL::Unique_hash_map Map; + +public: + HDS_edge_index_map_external(Polyhedron& p) + : map_(new Map(std::size_t(-1), num_halfedges(p))) + { + unsigned int data = 0; + typename boost::graph_traits::edge_iterator it, end; + for(boost::tie(it, end) = edges(p); it != end; ++it, ++data) + (*map_)[*it] = data; + } + + reference operator[](const key_type& k) const { return (*map_)[k]; } +private: + std::shared_ptr map_; +}; + +template +struct HDS_wrap_squared +{ + typedef FT value_type; + typedef FT reference; + typedef Handle key_type; + typedef boost::readable_property_map_tag category; + + template + FT operator[](const E& e) const { + return approximate_sqrt(CGAL::squared_distance(e.halfedge()->vertex()->point(), + e.halfedge()->opposite()->vertex()->point())); + } + + friend inline + value_type get(const HDS_wrap_squared& m, const key_type k) + { + return m[k]; + } +}; + +} + +// the tag we dispatch on from property_map +template +struct HDS_property_map {}; + +} // end of CGAL::internal namespace + +#endif // CGAL_BOOST_GRAPH_PROPERTIES_HALFEDGEDS_BASE_H + +#if !defined(HDS_TMPLT) || ! defined(HDS_CLASS) +#error HDS_TMPLT or HDS_CLASS is not defined +#endif + +namespace CGAL { + +// generalized 2-ary get functions +template +typename boost::property_map::const_type +get(PropertyTag,HDS_CLASS const&) +{ return typename boost::property_map::const_type(); } + +template +typename boost::property_map::type +get(PropertyTag,HDS_CLASS&) +{ return typename boost::property_map::type(); } + +// generalized 3-ary get functions +template +typename boost::property_traits< typename boost::property_map::type >::reference +get(PropertyTag p,HDS_CLASS& g, const Key& key) +{ return get(get(p, g), key); } + +template +typename boost::property_traits< typename boost::property_map::const_type >::reference +get(PropertyTag p,HDS_CLASS const& g, const Key& key) +{ return get(get(p, g), key); } + + + +#define DECLARE_HDS_DYNAMIC_PM(TAG, DESCRIPTOR) \ +template \ +typename boost::property_map::const_type \ +get(const TAG&, const HDS_CLASS&) \ +{ \ + typedef typename boost::graph_traits< HDS_CLASS >::DESCRIPTOR descriptor; \ + return internal::Dynamic_property_map(); \ +} + +DECLARE_HDS_DYNAMIC_PM(dynamic_vertex_property_t, vertex_descriptor) +DECLARE_HDS_DYNAMIC_PM(dynamic_halfedge_property_t, halfedge_descriptor) +DECLARE_HDS_DYNAMIC_PM(dynamic_edge_property_t, edge_descriptor) +DECLARE_HDS_DYNAMIC_PM(dynamic_face_property_t, face_descriptor) + +#undef DECLARE_HDS_DYNAMIC_PM + +// generalized put +template +void put(PropertyTag p,HDS_CLASS& g, const Key& key, const Value& value) +{ + typedef typename boost::property_map::type Map; + Map pmap = get(p, g); + put(pmap, key, value); +} + +// specialization needs to be repeated for halfedge, vertex, face +#define DECLARE_HDS_INDEX_PM(ENTITY, TAG, ACCESSOR) \ + template \ + struct HDS_property_map { \ + struct bind_ { \ + typedef internal::ACCESSOR##_accessor< \ + HDS_CLASS, \ + typename boost::graph_traits< HDS_CLASS \ + >::ENTITY##_descriptor > type;\ + typedef type const_type; \ + }; \ + }; + +DECLARE_HDS_INDEX_PM(halfedge, _index_t, Index) +DECLARE_HDS_INDEX_PM(vertex, _index_t, Index) +DECLARE_HDS_INDEX_PM(face, _index_t, Index) + +} // end of CGAL namespace + +#undef DECLARE_HDS_INDEX_PM + +namespace CGAL { +// not done with macros, because HDS_edge::id does not return a +// reference +template +struct HDS_property_map +{ + struct bind_ + { + typedef internal::Edge_index_accessor< + typename boost::graph_traits< + HDS_CLASS + >::edge_descriptor > type; + typedef type const_type; + }; +}; + +template +struct HDS_property_map +{ + struct bind_ + { + typedef typename HDS_CLASS::Traits::FT FT; + typedef typename boost::graph_traits::edge_descriptor edge_descriptor; + typedef internal::HDS_wrap_squared type; + typedef type const_type; + }; +}; + +template +struct HDS_property_map +{ + struct bind_ + { + typedef internal::Point_accessor< + typename boost::graph_traits< + HDS_CLASS + >::vertex_descriptor, + typename Gt::Point_3, typename Gt::Point_3&> type; + + typedef internal::Point_accessor< + typename boost::graph_traits< + HDS_CLASS + >::vertex_descriptor, + typename Gt::Point_3, const typename Gt::Point_3&> const_type; + }; +}; + +// +// external indices +// + +template +struct HDS_property_map +{ + struct bind_ + { + typedef internal::HDS_edge_index_map_external< + HDS_CLASS + > type; + typedef type const_type; + }; +}; + +template +struct HDS_property_map +{ + struct bind_ + { + typedef internal::HDS_index_map_external< + typename boost::graph_traits< + HDS_CLASS + >::halfedge_descriptor > type; + typedef type const_type; + }; +}; + + +template +struct HDS_property_map +{ + struct bind_ + { + typedef internal::HDS_index_map_external< + typename boost::graph_traits< + HDS_CLASS + >::vertex_descriptor > type; + typedef type const_type; + }; +}; + +template +struct HDS_property_map +{ + struct bind_ + { + typedef internal::HDS_index_map_external< + typename boost::graph_traits< + HDS_CLASS + >::face_descriptor > type; + typedef type const_type; + }; +}; + +template +typename boost::property_map::const_type +get(boost::edge_external_index_t,HDS_CLASS const& p) +{ + return typename boost::property_map::const_type( + const_cast(p)); +} + +template +typename boost::property_map::const_type +get(boost::halfedge_external_index_t,HDS_CLASS const& p) +{ + HDS_CLASS& ncp = const_cast(p); + + return typename boost::property_map::const_type( + ncp.halfedges_begin(), ncp.halfedges_end(), ncp.size_of_halfedges()); +} + +template +typename boost::property_map::const_type +get(boost::vertex_external_index_t,HDS_CLASS const& p) +{ + HDS_CLASS& ncp = const_cast(p); + + return typename boost::property_map::const_type( + ncp.vertices_begin(), ncp.vertices_end(), ncp.size_of_vertices()); +} + +template +typename boost::property_map::const_type +get(boost::face_external_index_t,HDS_CLASS const& p) +{ + HDS_CLASS& ncp = const_cast(p); + + return typename boost::property_map::const_type( + ncp.facets_begin(), ncp.facets_end(), ncp.size_of_facets()); +} + +// the same blurb for non-const + +template +typename boost::property_map::type +get(boost::edge_external_index_t,HDS_CLASS& p) +{ + return typename boost::property_map::type( + p); +} + +template +typename boost::property_map::type +get(boost::halfedge_external_index_t,HDS_CLASS & ncp) +{ + return typename boost::property_map::type( + ncp.halfedges_begin(), ncp.halfedges_end(), ncp.size_of_halfedges()); +} + +template +typename boost::property_map::type +get(boost::vertex_external_index_t,HDS_CLASS & ncp) +{ + return typename boost::property_map::type( + ncp.vertices_begin(), ncp.vertices_end(), ncp.size_of_vertices()); +} + + +template +typename boost::property_map::type +get(boost::face_external_index_t,HDS_CLASS & ncp) +{ + return typename boost::property_map::type( + ncp.facets_begin(), ncp.facets_end(), ncp.size_of_facets()); +} + +} // end of CGAL namespace + + +namespace boost { + +// property_map dispatcher into Polyhedron +template +struct property_map +{ + typedef typename CGAL::HDS_property_map:: + bind_ map_gen; + typedef typename map_gen::type type; + typedef typename map_gen::const_type const_type; +}; + +// property_map dispatcher into const Polyhedron +template +struct property_map +{ + typedef typename CGAL::HDS_property_map:: + bind_ map_gen; + typedef typename map_gen::type type; + typedef typename map_gen::const_type const_type; +}; + +template +struct property_map > +{ + typedef HDS_CLASS G; + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef CGAL::internal::Dynamic_property_map type; + typedef type const_type; +}; + +template +struct property_map > +{ + typedef HDS_CLASS G; + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + typedef CGAL::internal::Dynamic_property_map type; + typedef type const_type; +}; + +template +struct property_map > +{ + typedef HDS_CLASS G; + typedef typename boost::graph_traits::edge_descriptor edge_descriptor; + typedef CGAL::internal::Dynamic_property_map type; + typedef type const_type; +}; + +template +struct property_map > +{ + typedef HDS_CLASS G; + typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef CGAL::internal::Dynamic_property_map type; + typedef type const_type; +}; + +// What are those needed for ??? +template +struct edge_property_type +{ + typedef edge_weight_t type; +}; + +template +struct vertex_property_type +{ + typedef CGAL::vertex_point_t type; +}; + +template +struct vertex_property_type +{ + typedef CGAL::vertex_point_t type; +}; + +} // end of boost namespace + +namespace CGAL{ +template +struct graph_has_property + : CGAL::Tag_true {}; + +template +struct graph_has_property + : CGAL::Tag_true {}; + +template +struct graph_has_property + : CGAL::Boolean_tag< + CGAL::internal::Has_member_id< + typename boost::graph_traits::edge_descriptor + >::value + > +{}; + +template +struct graph_has_property + : CGAL::Boolean_tag< + CGAL::internal::Has_member_id< + typename HDS_CLASS::Facet + >::value + > +{}; + +template +struct graph_has_property + : CGAL::Boolean_tag< + CGAL::internal::Has_member_id< + typename HDS_CLASS::Halfedge + >::value + > +{}; + +template +struct graph_has_property + : CGAL::Boolean_tag< + CGAL::internal::Has_member_id< + typename HDS_CLASS::Vertex + >::value + > +{}; +}// end of CGAL namespace + +#undef HDS_TMPLT +#undef HDS_CLASS diff --git a/HalfedgeDS/include/CGAL/boost/graph/properties_HalfedgeDS_default.h b/HalfedgeDS/include/CGAL/boost/graph/properties_HalfedgeDS_default.h index d0d5a76afb8..39fce7d2b2b 100644 --- a/HalfedgeDS/include/CGAL/boost/graph/properties_HalfedgeDS_default.h +++ b/HalfedgeDS/include/CGAL/boost/graph/properties_HalfedgeDS_default.h @@ -12,497 +12,9 @@ #ifndef CGAL_BOOST_GRAPH_PROPERTIES_HALFEDGEDS_DEFAULT_H #define CGAL_BOOST_GRAPH_PROPERTIES_HALFEDGEDS_DEFAULT_H -#include -#include -#include -#include -#include -#include -#include - - - -namespace CGAL { - -namespace internal { - -template -class HDS_index_map_external - : public boost::put_get_helper > -{ -public: - typedef boost::lvalue_property_map_tag category; - typedef std::size_t value_type; - typedef std::size_t& reference; - typedef Handle key_type; - -private: - typedef CGAL::Unique_hash_map Map; - -public: - template - HDS_index_map_external(InputIterator begin, InputIterator end, std::size_t max) - : map_(new Map(begin, end, 0, std::size_t(-1), max)) {} - - reference operator[](const key_type& k) const { return (*map_)[k]; } -private: - std::shared_ptr map_; -}; - -// Special case for edges. -template -class HDS_edge_index_map_external - : public boost::put_get_helper > -{ -public: - typedef boost::lvalue_property_map_tag category; - typedef std::size_t value_type; - typedef std::size_t& reference; - typedef typename boost::graph_traits::edge_descriptor key_type; - -private: - typedef CGAL::Unique_hash_map Map; - -public: - HDS_edge_index_map_external(Polyhedron& p) - : map_(new Map(std::size_t(-1), num_halfedges(p))) - { - unsigned int data = 0; - typename boost::graph_traits::edge_iterator it, end; - for(boost::tie(it, end) = edges(p); it != end; ++it, ++data) - (*map_)[*it] = data; - } - - reference operator[](const key_type& k) const { return (*map_)[k]; } -private: - std::shared_ptr map_; -}; - - template -struct HDS_wrap_squared -{ - typedef FT value_type; - typedef FT reference; - typedef Handle key_type; - typedef boost::readable_property_map_tag category; - - template - FT operator[](const E& e) const { - return approximate_sqrt(CGAL::squared_distance(e.halfedge()->vertex()->point(), - e.halfedge()->opposite()->vertex()->point())); - } - - friend inline - value_type get(const HDS_wrap_squared& m, const key_type k) - { - return m[k]; - } -}; - -} // internal - -// the tag we dispatch on from property_map -template -struct HDS_property_map {}; - -} // namespace CGAL - -namespace CGAL { - -// generalized 2-ary get functions -template -typename boost::property_map, PropertyTag >::const_type -get(PropertyTag,CGAL::HalfedgeDS_default const&) -{ return typename boost::property_map, PropertyTag >::const_type(); } - -template -typename boost::property_map, PropertyTag >::type -get(PropertyTag,CGAL::HalfedgeDS_default&) -{ return typename boost::property_map, PropertyTag >::type(); } - -// generalized 3-ary get functions -template -typename boost::property_traits< typename boost::property_map, PropertyTag >::type >::reference -get(PropertyTag p,CGAL::HalfedgeDS_default& g, const Key& key) -{ return get(get(p, g), key); } - -template -typename boost::property_traits< typename boost::property_map, PropertyTag >::const_type >::reference -get(PropertyTag p,CGAL::HalfedgeDS_default const& g, const Key& key) -{ return get(get(p, g), key); } - - - -#define CGAL_POLYHEDRON_DYNAMIC_PM(TAG, DESCRIPTOR) \ -template \ -typename boost::property_map, TAG >::const_type \ -get(const TAG&, const HalfedgeDS_default&) \ -{ \ - typedef typename boost::graph_traits< HalfedgeDS_default >::DESCRIPTOR descriptor; \ - return internal::Dynamic_property_map(); \ -} - -CGAL_POLYHEDRON_DYNAMIC_PM(dynamic_vertex_property_t, vertex_descriptor) -CGAL_POLYHEDRON_DYNAMIC_PM(dynamic_halfedge_property_t, halfedge_descriptor) -CGAL_POLYHEDRON_DYNAMIC_PM(dynamic_edge_property_t, edge_descriptor) -CGAL_POLYHEDRON_DYNAMIC_PM(dynamic_face_property_t, face_descriptor) - - -#undef CGAL_POLYHEDRON_DYNAMIC_PM - - -// generalized put -template -void put(PropertyTag p,CGAL::HalfedgeDS_default& g, const Key& key, const Value& value) -{ - typedef typename boost::property_map, PropertyTag>::type Map; - Map pmap = get(p, g); - put(pmap, key, value); -} - -} // CGAL - -// specialization needs to be repeated for halfedge, vertex, face -#define CGAL_POLYHEDRON_INDEX_PM(ENTITY, TAG, ACCESSOR) \ - namespace CGAL { \ - template<> struct HDS_property_map { \ - template \ - struct bind_ { \ - typedef internal::ACCESSOR##_accessor< \ - CGAL::HalfedgeDS_default, \ - typename boost::graph_traits< CGAL::HalfedgeDS_default \ - >::ENTITY##_descriptor > type; \ - typedef type const_type; \ - }; \ - }; \ - } //CGAL - -CGAL_POLYHEDRON_INDEX_PM(halfedge, _index_t, Index) -CGAL_POLYHEDRON_INDEX_PM(vertex, _index_t, Index) -CGAL_POLYHEDRON_INDEX_PM(face, _index_t, Index) - -#undef CGAL_POLYHEDRON_INDEX_PM - -namespace CGAL { -// not done with macros, because HDS_edge::id does not return a -// reference -template <> -struct HDS_property_map -{ - template - struct bind_ - { - typedef internal::Edge_index_accessor< - typename boost::graph_traits< - CGAL::HalfedgeDS_default - >::edge_descriptor > type; - typedef type const_type; - }; -}; - -template <> -struct HDS_property_map -{ - template - struct bind_ - { - typedef typename CGAL::HalfedgeDS_default::Traits::FT FT; - typedef typename boost::graph_traits >::edge_descriptor edge_descriptor; - typedef internal::HDS_wrap_squared type; - typedef type const_type; - }; -}; - -template <> -struct HDS_property_map -{ - template - struct bind_ - { - typedef internal::Point_accessor< - typename boost::graph_traits< - CGAL::HalfedgeDS_default - >::vertex_descriptor, - typename Gt::Point_3, typename Gt::Point_3&> type; - - typedef internal::Point_accessor< - typename boost::graph_traits< - CGAL::HalfedgeDS_default - >::vertex_descriptor, - typename Gt::Point_3, const typename Gt::Point_3&> const_type; - }; -}; - -// -// external indices -// - -template <> -struct HDS_property_map -{ - template - struct bind_ - { - typedef internal::HDS_edge_index_map_external< - CGAL::HalfedgeDS_default - > type; - typedef type const_type; - }; -}; - -template <> -struct HDS_property_map -{ - template - struct bind_ - { - typedef internal::HDS_index_map_external< - typename boost::graph_traits< - CGAL::HalfedgeDS_default - >::halfedge_descriptor > type; - typedef type const_type; - }; -}; - - -template <> -struct HDS_property_map -{ - template - struct bind_ - { - typedef internal::HDS_index_map_external< - typename boost::graph_traits< - CGAL::HalfedgeDS_default - >::vertex_descriptor > type; - typedef type const_type; - }; -}; - -template <> -struct HDS_property_map -{ - template - struct bind_ - { - typedef internal::HDS_index_map_external< - typename boost::graph_traits< - CGAL::HalfedgeDS_default - >::face_descriptor > type; - typedef type const_type; - }; -}; - -} // CGAL - -namespace CGAL { - -template -typename boost::property_map, boost::edge_external_index_t >::const_type -get(boost::edge_external_index_t,CGAL::HalfedgeDS_default const& p) -{ - return typename boost::property_map, boost::edge_external_index_t >::const_type( - const_cast& >(p)); -} - -template -typename boost::property_map, boost::halfedge_external_index_t >::const_type -get(boost::halfedge_external_index_t,CGAL::HalfedgeDS_default const& p) -{ - CGAL::HalfedgeDS_default& ncp = const_cast&>(p); - - return typename boost::property_map, boost::halfedge_external_index_t >::const_type( - ncp.halfedges_begin(), ncp.halfedges_end(), ncp.size_of_halfedges()); -} - -template -typename boost::property_map, boost::vertex_external_index_t >::const_type -get(boost::vertex_external_index_t,CGAL::HalfedgeDS_default const& p) -{ - CGAL::HalfedgeDS_default& ncp = const_cast&>(p); - - return typename boost::property_map, boost::vertex_external_index_t >::const_type( - ncp.vertices_begin(), ncp.vertices_end(), ncp.size_of_vertices()); -} - -template -typename boost::property_map, boost::face_external_index_t >::const_type -get(boost::face_external_index_t,CGAL::HalfedgeDS_default const& p) -{ - CGAL::HalfedgeDS_default& ncp = const_cast&>(p); - - return typename boost::property_map, boost::face_external_index_t >::const_type( - ncp.facets_begin(), ncp.facets_end(), ncp.size_of_facets()); -} - -// the same blurb for non-const - -template -typename boost::property_map, boost::edge_external_index_t >::type -get(boost::edge_external_index_t,CGAL::HalfedgeDS_default& p) -{ - return typename boost::property_map, boost::edge_external_index_t >::type( - p); -} - -template -typename boost::property_map, boost::halfedge_external_index_t >::type -get(boost::halfedge_external_index_t,CGAL::HalfedgeDS_default & ncp) -{ - return typename boost::property_map, boost::halfedge_external_index_t >::type( - ncp.halfedges_begin(), ncp.halfedges_end(), ncp.size_of_halfedges()); -} - -template -typename boost::property_map, boost::vertex_external_index_t >::type -get(boost::vertex_external_index_t,CGAL::HalfedgeDS_default & ncp) -{ - return typename boost::property_map, boost::vertex_external_index_t >::type( - ncp.vertices_begin(), ncp.vertices_end(), ncp.size_of_vertices()); -} - - -template -typename boost::property_map, boost::face_external_index_t >::type -get(boost::face_external_index_t,CGAL::HalfedgeDS_default & ncp) -{ - return typename boost::property_map, boost::face_external_index_t >::type( - ncp.facets_begin(), ncp.facets_end(), ncp.size_of_facets()); -} - - - -} // namespace CGAL - - -namespace boost { - -// property_map dispatcher into Polyhedron -template -struct property_map, Tag> -{ - typedef typename CGAL::HDS_property_map:: - template bind_ map_gen; - typedef typename map_gen::type type; - typedef typename map_gen::const_type const_type; -}; - -// property_map dispatcher into const Polyhedron -template -struct property_map, Tag> -{ - typedef typename CGAL::HDS_property_map:: - template bind_ map_gen; - typedef typename map_gen::type type; - typedef typename map_gen::const_type const_type; -}; - -template -struct property_map, CGAL::dynamic_vertex_property_t > -{ - typedef CGAL::HalfedgeDS_default G; - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef CGAL::internal::Dynamic_property_map type; - typedef type const_type; -}; - -template -struct property_map, CGAL::dynamic_halfedge_property_t > -{ - typedef CGAL::HalfedgeDS_default G; - typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef CGAL::internal::Dynamic_property_map type; - typedef type const_type; -}; - -template -struct property_map, CGAL::dynamic_edge_property_t > -{ - typedef CGAL::HalfedgeDS_default G; - typedef typename boost::graph_traits::edge_descriptor edge_descriptor; - typedef CGAL::internal::Dynamic_property_map type; - typedef type const_type; -}; - -template -struct property_map, CGAL::dynamic_face_property_t > -{ - typedef CGAL::HalfedgeDS_default G; - typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef CGAL::internal::Dynamic_property_map type; - typedef type const_type; -}; - -// What are those needed for ??? -template -struct edge_property_type > -{ - typedef edge_weight_t type; -}; - -template -struct vertex_property_type > -{ - typedef CGAL::vertex_point_t type; -}; - -template -struct vertex_property_type > -{ - typedef CGAL::vertex_point_t type; -}; - - -} // namespace boost - -namespace CGAL{ -template -struct graph_has_property, boost::vertex_point_t> - : CGAL::Tag_true {}; - -template -struct graph_has_property, boost::edge_weight_t> - : CGAL::Tag_true {}; - -template -struct graph_has_property, boost::edge_index_t> - : CGAL::Boolean_tag< - CGAL::internal::Has_member_id< - typename boost::graph_traits >::edge_descriptor - >::value - > -{}; - -template -struct graph_has_property, boost::face_index_t> - : CGAL::Boolean_tag< - CGAL::internal::Has_member_id< - typename CGAL::HalfedgeDS_default::Facet - >::value - > -{}; - -template -struct graph_has_property, boost::halfedge_index_t> - : CGAL::Boolean_tag< - CGAL::internal::Has_member_id< - typename CGAL::HalfedgeDS_default::Halfedge - >::value - > -{}; - -template -struct graph_has_property, boost::vertex_index_t> - : CGAL::Boolean_tag< - CGAL::internal::Has_member_id< - typename CGAL::HalfedgeDS_default::Vertex - >::value - > -{}; -}// end CGAL -#undef CGAL_HDS_PARAM_ - - +#define HDS_TMPLT Gt, class I, class A +#define HDS_CLASS CGAL::HalfedgeDS_default +#include #endif // CGAL_BOOST_GRAPH_PROPERTIES_HALFEDGEDS_DEFAULT_H diff --git a/Polyhedron/include/CGAL/boost/graph/graph_traits_Polyhedron_3.h b/Polyhedron/include/CGAL/boost/graph/graph_traits_Polyhedron_3.h index ca3a39fbe47..8cff560f0a6 100644 --- a/Polyhedron/include/CGAL/boost/graph/graph_traits_Polyhedron_3.h +++ b/Polyhedron/include/CGAL/boost/graph/graph_traits_Polyhedron_3.h @@ -491,10 +491,9 @@ namespace boost { #endif //CGAL_NO_DEPRECATED_CODE -#undef CGAL_HDS_PARAM_ - #include #include #include +#undef CGAL_HDS_PARAM_ #endif // CGAL_BOOST_GRAPH_GRAPH_TRAITS_POLYHEDRON_3_H diff --git a/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3.h b/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3.h index acda7e12558..1f57c28fcef 100644 --- a/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3.h +++ b/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3.h @@ -12,497 +12,9 @@ #ifndef CGAL_BOOST_GRAPH_PROPERTIES_POLYHEDRON_3_H #define CGAL_BOOST_GRAPH_PROPERTIES_POLYHEDRON_3_H -#include -#include -#include -#include -#include -#include -#include - -#define CGAL_HDS_PARAM_ template < class Traits, class Items, class Alloc> class HDS - -namespace CGAL { - -namespace internal { - -template -class Polyhedron_index_map_external - : public boost::put_get_helper > -{ -public: - typedef boost::lvalue_property_map_tag category; - typedef std::size_t value_type; - typedef std::size_t& reference; - typedef Handle key_type; - -private: - typedef CGAL::Unique_hash_map Map; - -public: - template - Polyhedron_index_map_external(InputIterator begin, InputIterator end, std::size_t max) - : map_(new Map(begin, end, 0, std::size_t(-1), max)) {} - - reference operator[](const key_type& k) const { return (*map_)[k]; } -private: - std::shared_ptr map_; -}; - -// Special case for edges. -template -class Polyhedron_edge_index_map_external - : public boost::put_get_helper > -{ -public: - typedef boost::lvalue_property_map_tag category; - typedef std::size_t value_type; - typedef std::size_t& reference; - typedef typename boost::graph_traits::edge_descriptor key_type; - -private: - typedef CGAL::Unique_hash_map Map; - -public: - Polyhedron_edge_index_map_external(Polyhedron& p) - : map_(new Map(std::size_t(-1), num_halfedges(p))) - { - unsigned int data = 0; - typename boost::graph_traits::edge_iterator it, end; - for(boost::tie(it, end) = edges(p); it != end; ++it, ++data) - (*map_)[*it] = data; - } - - reference operator[](const key_type& k) const { return (*map_)[k]; } -private: - std::shared_ptr map_; -}; - - template -struct Wrap_squared -{ - typedef FT value_type; - typedef FT reference; - typedef Handle key_type; - typedef boost::readable_property_map_tag category; - - template - FT operator[](const E& e) const { - return approximate_sqrt(CGAL::squared_distance(e.halfedge()->vertex()->point(), - e.halfedge()->opposite()->vertex()->point())); - } - - friend inline - value_type get(const Wrap_squared& m, const key_type k) - { - return m[k]; - } -}; - -} // internal - -// the tag we dispatch on from property_map -template -struct Polyhedron_property_map {}; - -} // namespace CGAL - -namespace CGAL { - -// generalized 2-ary get functions -template -typename boost::property_map< CGAL::Polyhedron_3, PropertyTag >::const_type -get(PropertyTag, CGAL::Polyhedron_3 const&) -{ return typename boost::property_map< CGAL::Polyhedron_3, PropertyTag >::const_type(); } - -template -typename boost::property_map< CGAL::Polyhedron_3, PropertyTag >::type -get(PropertyTag, CGAL::Polyhedron_3&) -{ return typename boost::property_map< CGAL::Polyhedron_3, PropertyTag >::type(); } - -// generalized 3-ary get functions -template -typename boost::property_traits< typename boost::property_map< CGAL::Polyhedron_3, PropertyTag >::type >::reference -get(PropertyTag p, CGAL::Polyhedron_3& g, const Key& key) -{ return get(get(p, g), key); } - -template -typename boost::property_traits< typename boost::property_map, PropertyTag >::const_type >::reference -get(PropertyTag p, CGAL::Polyhedron_3 const& g, const Key& key) -{ return get(get(p, g), key); } - - - -#define CGAL_POLYHEDRON_DYNAMIC_PM(TAG, DESCRIPTOR) \ -template \ -typename boost::property_map, TAG >::const_type \ -get(const TAG&, const Polyhedron_3&) \ -{ \ - typedef typename boost::graph_traits< Polyhedron_3 >::DESCRIPTOR descriptor; \ - return internal::Dynamic_property_map(); \ -} - -CGAL_POLYHEDRON_DYNAMIC_PM(dynamic_vertex_property_t, vertex_descriptor) -CGAL_POLYHEDRON_DYNAMIC_PM(dynamic_halfedge_property_t, halfedge_descriptor) -CGAL_POLYHEDRON_DYNAMIC_PM(dynamic_edge_property_t, edge_descriptor) -CGAL_POLYHEDRON_DYNAMIC_PM(dynamic_face_property_t, face_descriptor) - - -#undef CGAL_POLYHEDRON_DYNAMIC_PM - - -// generalized put -template -void put(PropertyTag p, CGAL::Polyhedron_3& g, const Key& key, const Value& value) -{ - typedef typename boost::property_map, PropertyTag>::type Map; - Map pmap = get(p, g); - put(pmap, key, value); -} - -} // CGAL - -// specialization needs to be repeated for halfedge, vertex, face -#define CGAL_POLYHEDRON_INDEX_PM(ENTITY, TAG, ACCESSOR) \ - namespace CGAL { \ - template<> struct Polyhedron_property_map { \ - template \ - struct bind_ { \ - typedef internal::ACCESSOR##_accessor< \ - CGAL::Polyhedron_3, \ - typename boost::graph_traits< CGAL::Polyhedron_3 \ - >::ENTITY##_descriptor > type; \ - typedef type const_type; \ - }; \ - }; \ - } //CGAL - -CGAL_POLYHEDRON_INDEX_PM(halfedge, _index_t, Index) -CGAL_POLYHEDRON_INDEX_PM(vertex, _index_t, Index) -CGAL_POLYHEDRON_INDEX_PM(face, _index_t, Index) - -#undef CGAL_POLYHEDRON_INDEX_PM - -namespace CGAL { -// not done with macros, because HDS_edge::id does not return a -// reference -template <> -struct Polyhedron_property_map -{ - template - struct bind_ - { - typedef internal::Edge_index_accessor< - typename boost::graph_traits< - CGAL::Polyhedron_3 - >::edge_descriptor > type; - typedef type const_type; - }; -}; - -template <> -struct Polyhedron_property_map -{ - template - struct bind_ - { - typedef typename CGAL::Polyhedron_3::Traits::FT FT; - typedef typename boost::graph_traits >::edge_descriptor edge_descriptor; - typedef internal::Wrap_squared type; - typedef type const_type; - }; -}; - -template <> -struct Polyhedron_property_map -{ - template - struct bind_ - { - typedef internal::Point_accessor< - typename boost::graph_traits< - CGAL::Polyhedron_3 - >::vertex_descriptor, - typename Gt::Point_3, typename Gt::Point_3&> type; - - typedef internal::Point_accessor< - typename boost::graph_traits< - CGAL::Polyhedron_3 - >::vertex_descriptor, - typename Gt::Point_3, const typename Gt::Point_3&> const_type; - }; -}; - -// -// external indices -// - -template <> -struct Polyhedron_property_map -{ - template - struct bind_ - { - typedef internal::Polyhedron_edge_index_map_external< - CGAL::Polyhedron_3 - > type; - typedef type const_type; - }; -}; - -template <> -struct Polyhedron_property_map -{ - template - struct bind_ - { - typedef internal::Polyhedron_index_map_external< - typename boost::graph_traits< - CGAL::Polyhedron_3 - >::halfedge_descriptor > type; - typedef type const_type; - }; -}; - - -template <> -struct Polyhedron_property_map -{ - template - struct bind_ - { - typedef internal::Polyhedron_index_map_external< - typename boost::graph_traits< - CGAL::Polyhedron_3 - >::vertex_descriptor > type; - typedef type const_type; - }; -}; - -template <> -struct Polyhedron_property_map -{ - template - struct bind_ - { - typedef internal::Polyhedron_index_map_external< - typename boost::graph_traits< - CGAL::Polyhedron_3 - >::face_descriptor > type; - typedef type const_type; - }; -}; - -} // CGAL - -namespace CGAL { - -template -typename boost::property_map< CGAL::Polyhedron_3, boost::edge_external_index_t >::const_type -get(boost::edge_external_index_t, CGAL::Polyhedron_3 const& p) -{ - return typename boost::property_map< CGAL::Polyhedron_3, boost::edge_external_index_t >::const_type( - const_cast& >(p)); -} - -template -typename boost::property_map< CGAL::Polyhedron_3, boost::halfedge_external_index_t >::const_type -get(boost::halfedge_external_index_t, CGAL::Polyhedron_3 const& p) -{ - CGAL::Polyhedron_3& ncp = const_cast&>(p); - - return typename boost::property_map< CGAL::Polyhedron_3, boost::halfedge_external_index_t >::const_type( - ncp.halfedges_begin(), ncp.halfedges_end(), ncp.size_of_halfedges()); -} - -template -typename boost::property_map< CGAL::Polyhedron_3, boost::vertex_external_index_t >::const_type -get(boost::vertex_external_index_t, CGAL::Polyhedron_3 const& p) -{ - CGAL::Polyhedron_3& ncp = const_cast&>(p); - - return typename boost::property_map< CGAL::Polyhedron_3, boost::vertex_external_index_t >::const_type( - ncp.vertices_begin(), ncp.vertices_end(), ncp.size_of_vertices()); -} - -template -typename boost::property_map< CGAL::Polyhedron_3, boost::face_external_index_t >::const_type -get(boost::face_external_index_t, CGAL::Polyhedron_3 const& p) -{ - CGAL::Polyhedron_3& ncp = const_cast&>(p); - - return typename boost::property_map< CGAL::Polyhedron_3, boost::face_external_index_t >::const_type( - ncp.facets_begin(), ncp.facets_end(), ncp.size_of_facets()); -} - -// the same blurb for non-const - -template -typename boost::property_map< CGAL::Polyhedron_3, boost::edge_external_index_t >::type -get(boost::edge_external_index_t, CGAL::Polyhedron_3& p) -{ - return typename boost::property_map< CGAL::Polyhedron_3, boost::edge_external_index_t >::type( - p); -} - -template -typename boost::property_map< CGAL::Polyhedron_3, boost::halfedge_external_index_t >::type -get(boost::halfedge_external_index_t, CGAL::Polyhedron_3 & ncp) -{ - return typename boost::property_map< CGAL::Polyhedron_3, boost::halfedge_external_index_t >::type( - ncp.halfedges_begin(), ncp.halfedges_end(), ncp.size_of_halfedges()); -} - -template -typename boost::property_map< CGAL::Polyhedron_3, boost::vertex_external_index_t >::type -get(boost::vertex_external_index_t, CGAL::Polyhedron_3 & ncp) -{ - return typename boost::property_map< CGAL::Polyhedron_3, boost::vertex_external_index_t >::type( - ncp.vertices_begin(), ncp.vertices_end(), ncp.size_of_vertices()); -} - - -template -typename boost::property_map< CGAL::Polyhedron_3, boost::face_external_index_t >::type -get(boost::face_external_index_t, CGAL::Polyhedron_3 & ncp) -{ - return typename boost::property_map< CGAL::Polyhedron_3, boost::face_external_index_t >::type( - ncp.facets_begin(), ncp.facets_end(), ncp.size_of_facets()); -} - - - -} // namespace CGAL - - -namespace boost { - -// property_map dispatcher into Polyhedron -template -struct property_map, Tag> -{ - typedef typename CGAL::Polyhedron_property_map:: - template bind_ map_gen; - typedef typename map_gen::type type; - typedef typename map_gen::const_type const_type; -}; - -// property_map dispatcher into const Polyhedron -template -struct property_map, Tag> -{ - typedef typename CGAL::Polyhedron_property_map:: - template bind_ map_gen; - typedef typename map_gen::type type; - typedef typename map_gen::const_type const_type; -}; - -template -struct property_map, CGAL::dynamic_vertex_property_t > -{ - typedef CGAL::Polyhedron_3 G; - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef CGAL::internal::Dynamic_property_map type; - typedef type const_type; -}; - -template -struct property_map, CGAL::dynamic_halfedge_property_t > -{ - typedef CGAL::Polyhedron_3 G; - typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef CGAL::internal::Dynamic_property_map type; - typedef type const_type; -}; - -template -struct property_map, CGAL::dynamic_edge_property_t > -{ - typedef CGAL::Polyhedron_3 G; - typedef typename boost::graph_traits::edge_descriptor edge_descriptor; - typedef CGAL::internal::Dynamic_property_map type; - typedef type const_type; -}; - -template -struct property_map, CGAL::dynamic_face_property_t > -{ - typedef CGAL::Polyhedron_3 G; - typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef CGAL::internal::Dynamic_property_map type; - typedef type const_type; -}; - -// What are those needed for ??? -template -struct edge_property_type > -{ - typedef edge_weight_t type; -}; - -template -struct vertex_property_type > -{ - typedef CGAL::vertex_point_t type; -}; - -template -struct vertex_property_type > -{ - typedef CGAL::vertex_point_t type; -}; - - -} // namespace boost - -namespace CGAL{ -template -struct graph_has_property, boost::vertex_point_t> - : CGAL::Tag_true {}; - -template -struct graph_has_property, boost::edge_weight_t> - : CGAL::Tag_true {}; - -template -struct graph_has_property, boost::edge_index_t> - : CGAL::Boolean_tag< - CGAL::internal::Has_member_id< - typename boost::graph_traits >::edge_descriptor - >::value - > -{}; - -template -struct graph_has_property, boost::face_index_t> - : CGAL::Boolean_tag< - CGAL::internal::Has_member_id< - typename CGAL::Polyhedron_3::Facet - >::value - > -{}; - -template -struct graph_has_property, boost::halfedge_index_t> - : CGAL::Boolean_tag< - CGAL::internal::Has_member_id< - typename CGAL::Polyhedron_3::Halfedge - >::value - > -{}; - -template -struct graph_has_property, boost::vertex_index_t> - : CGAL::Boolean_tag< - CGAL::internal::Has_member_id< - typename CGAL::Polyhedron_3::Vertex - >::value - > -{}; -}// end CGAL -#undef CGAL_HDS_PARAM_ - - +#define HDS_TMPLT Gt, class I, CGAL_HDS_PARAM_, class A +#define HDS_CLASS CGAL::Polyhedron_3 +#include #endif // CGAL_BOOST_GRAPH_PROPERTIES_POLYHEDRON_3_H diff --git a/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_features.h b/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_features.h index 1ee30713092..70f89908c7f 100644 --- a/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_features.h +++ b/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_features.h @@ -55,10 +55,9 @@ void put(Polyhedron_face_patch_id_pmap, Handle_type h, Patch_id pid) h->set_patch_id(pid); } -template -struct Polyhedron_property_map > +template +struct HDS_property_map, CGAL::face_patch_id_t > { - template struct bind_ { typedef Polyhedron_face_patch_id_pmap type; @@ -79,10 +78,9 @@ get(CGAL::face_patch_id_t, const Polyhedron_3&) return Pmap( std::pair(0,1) ); } -template <> -struct Polyhedron_property_map > +template +struct HDS_property_map, CGAL::face_patch_id_t > { - template struct bind_ { typedef typename internal::Get_static_property_map::type type; @@ -93,10 +91,9 @@ struct Polyhedron_property_map > // Compatibility: when the `Patch_id` template argument of // `Polyhedron_mesh_domain` is `Tag_true` (because that argument was named // `UsePatchId` in previous versions of CGAL. -template <> -struct Polyhedron_property_map > +template +struct HDS_property_map, CGAL::face_patch_id_t > { - template struct bind_ { typedef Polyhedron_3 Polyhedron; @@ -108,9 +105,9 @@ struct Polyhedron_property_map > // Compatibility: when the `Patch_id` template argument of // `Polyhedron_mesh_domain` is `Tag_false` (because that argument was named // `UsePatchId` in previous versions of CGAL. -template <> -struct Polyhedron_property_map > - : public Polyhedron_property_map > +template +struct HDS_property_map, CGAL::face_patch_id_t > + : public HDS_property_map, CGAL::face_patch_id_t > { }; @@ -144,10 +141,9 @@ void put(Polyhedron_num_feature_edges_pmap, Handle_type h, int n) } -template <> -struct Polyhedron_property_map +template +struct HDS_property_map, CGAL::vertex_feature_degree_t> { - template struct bind_ { typedef Polyhedron_num_feature_edges_pmap type; @@ -177,10 +173,9 @@ void put(Polyhedron_is_feature_edge_pmap, Handle_type e, bool b) e.halfedge()->opposite()->set_feature_edge(b); } -template <> -struct Polyhedron_property_map +template +struct HDS_property_map, CGAL::edge_is_feature_t> { - template struct bind_ { typedef Polyhedron_is_feature_edge_pmap type; @@ -220,10 +215,9 @@ void put(Polyhedron_incident_patches_pmap, h->add_incident_patch(n); } -template -struct Polyhedron_property_map > +template +struct HDS_property_map, CGAL::vertex_incident_patches_t > { - template struct bind_ { typedef Polyhedron_incident_patches_pmap type; diff --git a/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_time_stamp.h b/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_time_stamp.h index cb396919506..bd8ad12bc5f 100644 --- a/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_time_stamp.h +++ b/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_time_stamp.h @@ -38,10 +38,9 @@ void put(Polyhedron_face_time_stamp_pmap, Handle_type h, std::size_t ts) h->set_time_stamp(ts); } -template <> -struct Polyhedron_property_map +template +struct HDS_property_map, CGAL::vertex_time_stamp_t> { - template struct bind_ { typedef Polyhedron_face_time_stamp_pmap type; @@ -49,14 +48,14 @@ struct Polyhedron_property_map }; }; -template <> -struct Polyhedron_property_map - : public Polyhedron_property_map +template +struct HDS_property_map, CGAL::halfedge_time_stamp_t> + : public HDS_property_map, CGAL::vertex_time_stamp_t> {}; -template <> -struct Polyhedron_property_map - : public Polyhedron_property_map +template +struct HDS_property_map, CGAL::face_time_stamp_t> + : public HDS_property_map, CGAL::vertex_time_stamp_t> {};