diff --git a/BGL/doc/BGL/dependencies b/BGL/doc/BGL/dependencies index 5dfaea90a13..84e3fe85bb4 100644 --- a/BGL/doc/BGL/dependencies +++ b/BGL/doc/BGL/dependencies @@ -10,3 +10,4 @@ Polyhedron Triangulation_2 Surface_mesh_simplification Property_map +Miscellany diff --git a/BGL/doc/BGL/graph_traits.txt b/BGL/doc/BGL/graph_traits.txt index 62be2100a81..5e9f896139f 100644 --- a/BGL/doc/BGL/graph_traits.txt +++ b/BGL/doc/BGL/graph_traits.txt @@ -27,14 +27,14 @@ The traits class `boost::graph_traits< CGAL::Polyhedron_3 >` provides the fol | Member | Value | Description | | :----------------------- | :----: | :---------- | | `vertex_descriptor` | `Polyhedron_3::Vertex_handle` | The vertex descriptor | -| `edge_descriptor` | `Polyhedron_3::Halfedge_handle` | The edge descriptor | +| `edge_descriptor` | `unspecified_type` | The edge descriptor | | `halfedge_descriptor` | `Polyhedron_3::Halfedge_handle` | The halfedge descriptor | | `face_descriptor` | `Polyhedron_3::Face_handle` | The face descriptor | | `adjacency_iterator` | `CGAL::Vertex_around_target_iterator >` | Iterates through adjacent vertices| | `out_edge_iterator` | `CGAL::Out_edge_iterator >` | Iterate through the out-edges of a vertex. | | `in_edge_iterator` | `CGAL::Out_edge_iterator >` | Iterate through the in-edges of a vertex. | | `vertex_iterator` | `unspecified_type` | Iterate through the vertices of a polyhedron.| -| `edge_iterator` | `Polyhedron_3::Halfedge_iterator` | Iterate through the edges of a polyhedron.| +| `edge_iterator` | `unspecified_type` | Iterate through the edges of a polyhedron.| | `halfedge_iterator` | `Polyhedron_3::Halfedge_iterator` | Iterate through the halfedges of a polyhedron.| | `face_iterator` | `Polyhedron_3::Face_iterator` | Iterate through the faces of a polyhedron.| | `directed_category` | Inherits from `boost::bidirectional_graph_tag`, `boost::vertex_list_graph_tag` and `boost::edge_list_graph_tag` | | @@ -44,6 +44,8 @@ The traits class `boost::graph_traits< CGAL::Polyhedron_3 >` provides the fol | `edges_size_type` | `Polyhedron_3::size_type` | The size type of the edge list | | `degree_size_type` | `Polyhedron_3::size_type` | The size type of the adjacency list | +For convenience, the type `edge_descriptor` is hashable using the functor `CGAL::Handle_hash_function` +that is the default hash functor of `CGAL::Unique_hash_map`. \section BGLT2GT Specializations for the 2D Triangulation Classes diff --git a/BGL/include/CGAL/boost/graph/graph_traits_HalfedgeDS.h b/BGL/include/CGAL/boost/graph/graph_traits_HalfedgeDS.h index 3ecbe845d25..03565011b18 100644 --- a/BGL/include/CGAL/boost/graph/graph_traits_HalfedgeDS.h +++ b/BGL/include/CGAL/boost/graph/graph_traits_HalfedgeDS.h @@ -31,6 +31,8 @@ #include #include +#include + #ifndef CGAL_NO_DEPRECATED_CODE #include #endif @@ -134,6 +136,22 @@ private: Halfedge_handle halfedge_; }; +// make edge_descriptor hashable by default in Unique_hash_map +namespace handle{ + template + struct Hash_functor< HDS_edge > + { + std::size_t + operator()(const HDS_edge& edge) + { + Halfedge_handle he = edge.halfedge(); + if ( he < he->opposite() ) + return Hash_functor()(he); + return Hash_functor()(he->opposite()); + } + }; +} //end of namespace handle + template struct Construct_edge { typedef HDS_edge result_type; diff --git a/BGL/include/CGAL/boost/graph/properties_Polyhedron_3.h b/BGL/include/CGAL/boost/graph/properties_Polyhedron_3.h index 44c2d9407a4..350a479bfd2 100644 --- a/BGL/include/CGAL/boost/graph/properties_Polyhedron_3.h +++ b/BGL/include/CGAL/boost/graph/properties_Polyhedron_3.h @@ -50,7 +50,7 @@ private: CGAL::Unique_hash_map map_; }; -// Special case for edges. Hashes each half_edge. +// Special case for edges. template class Polyhedron_edge_index_map_external : public boost::put_get_helper > @@ -62,21 +62,17 @@ public: typedef typename boost::graph_traits::edge_descriptor key_type; Polyhedron_edge_index_map_external(Polyhedron& p) - : map_(std::size_t(-1), num_halfedges(p)), p(p) + : 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_[halfedge(*it, p)] = data; - map_[opposite(halfedge(*it, p), p)] = data; - } + for(boost::tie(it, end) = edges(p); it != end; ++it, ++data) + map_[*it] = data; } - reference operator[](const key_type& k) const { return map_[halfedge(k,p)]; } + reference operator[](const key_type& k) const { return map_[k]; } private: - CGAL::Unique_hash_map::halfedge_descriptor, - std::size_t> map_; - Polyhedron& p; + CGAL::Unique_hash_map map_; }; template diff --git a/Hash_map/include/CGAL/Handle_hash_function.h b/Hash_map/include/CGAL/Handle_hash_function.h index f7a87fdaf69..675341fa592 100644 --- a/Hash_map/include/CGAL/Handle_hash_function.h +++ b/Hash_map/include/CGAL/Handle_hash_function.h @@ -31,13 +31,28 @@ namespace CGAL { +//mechanism to abuse Handle_hash_function which is the default +//template parameter of Unique_hash_map +namespace internal{ + namespace handle { + template + struct Hash_functor{ + std::size_t + operator()(const H& h) + { + return std::size_t(&*h) / + sizeof( typename std::iterator_traits::value_type); + } + }; + } +} + struct Handle_hash_function { typedef std::size_t result_type; template - std::size_t operator() (const H& h) const { - return std::size_t(&*h) / - sizeof( typename std::iterator_traits::value_type); - } + std::size_t operator() (const H& h) const { + return ::CGAL::internal::handle::Hash_functor()(h); + } }; } //namespace CGAL diff --git a/Installation/changes.html b/Installation/changes.html index 823fd8949ee..25cf5dbe12f 100644 --- a/Installation/changes.html +++ b/Installation/changes.html @@ -204,6 +204,12 @@ and src/ directories).

Triangulated Surface Mesh Simplification

    +
  • + Breaking change: Due to the cleanup of the concepts of the package CGAL and the Boost Graph Library, + the named parameter edge_is_border_map has been removed, and the named parameter + edge_is_constrained_map now expects a property map with an edge descriptor as key type + (vs. halfedge descriptor before). +
  • Add some optimization in the code making the implementation faster (depending on the cost and the placement chosen). However, for an edge which collapse is not topologically valid, the vector of vertices of the link provided @@ -213,7 +219,7 @@ and src/ directories). but if it is a absolute requirement for user defined cost/placement, defining the macro CGAL_SMS_EDGE_PROFILE_ALWAYS_NEED_UNIQUE_VERTEX_IN_LINK will restore the former behavior. -
  • +

Triangulated Surface Mesh Deformation (new package)

diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrain_sharp_edges.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrain_sharp_edges.cpp index d60957975aa..e3f858934ad 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrain_sharp_edges.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrain_sharp_edges.cpp @@ -1,6 +1,8 @@ #include #include + + #include #include #include @@ -25,24 +27,8 @@ typedef boost::graph_traits::edge_iterator edge_iterator; namespace SMS = CGAL::Surface_mesh_simplification ; - // // BGL property map which indicates whether an edge is marked as non-removable - -struct Hash -{ - typedef std::size_t result_type; - - result_type operator()(const edge_descriptor& ed) const - { - // although two edge_descriptors may be equal, they may store any of its two halfedges - CGAL::Handle_hash_function hhf; - std::size_t st1 = hhf(halfedge(ed,Surface_mesh())); - std::size_t st2 = hhf(opposite(halfedge(ed,Surface_mesh()),Surface_mesh())); - return (std::min)(st1,st2); - } -}; - struct Constrained_edge_map : public boost::put_get_helper { typedef boost::readable_property_map_tag category; @@ -50,7 +36,7 @@ struct Constrained_edge_map : public boost::put_get_helper& aConstraints) + Constrained_edge_map(const CGAL::Unique_hash_map& aConstraints) : mConstraints(aConstraints) {} @@ -61,7 +47,7 @@ struct Constrained_edge_map : public boost::put_get_helper& mConstraints; + const CGAL::Unique_hash_map& mConstraints; }; bool is_border (edge_descriptor e, const Surface_mesh& sm) @@ -77,7 +63,7 @@ Point_3 point(vertex_descriptor vd, const Surface_mesh& sm) int main( int argc, char** argv ) { - CGAL::Unique_hash_map constraint_hmap(false); + CGAL::Unique_hash_map constraint_hmap(false); Surface_mesh surface_mesh; diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrained_border_polyhedron.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrained_border_polyhedron.cpp index 71342351e84..f2f75d7c0b9 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrained_border_polyhedron.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_constrained_border_polyhedron.cpp @@ -29,7 +29,7 @@ namespace SMS = CGAL::Surface_mesh_simplification ; // BGL property map which indicates whether an edge is marked as non-removable // struct Border_is_constrained_edge_map{ - const Surface_mesh* sm; + const Surface_mesh* sm_ptr; typedef boost::graph_traits::edge_descriptor key_type; typedef bool value_type; typedef value_type reference; @@ -39,12 +39,11 @@ struct Border_is_constrained_edge_map{ {} Border_is_constrained_edge_map(const Surface_mesh& sm) - : sm(&sm) + : sm_ptr(&sm) {} - friend bool get(Border_is_constrained_edge_map m, key_type edge) { - return (face(halfedge(edge,*m.sm),*m.sm) == boost::graph_traits::null_face()) - || (face(opposite(halfedge(edge,*m.sm),*m.sm),*m.sm) == boost::graph_traits::null_face()); + friend bool get(Border_is_constrained_edge_map m, const key_type& edge) { + return CGAL::is_border(edge, *m.sm_ptr); } };