diff --git a/Convex_hull_3/examples/Convex_hull_3/quickhull_3.cpp b/Convex_hull_3/examples/Convex_hull_3/quickhull_3.cpp index 2bb1dc02cb9..25766a83f5f 100644 --- a/Convex_hull_3/examples/Convex_hull_3/quickhull_3.cpp +++ b/Convex_hull_3/examples/Convex_hull_3/quickhull_3.cpp @@ -4,12 +4,13 @@ #include #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Polyhedron_3 Polyhedron_3; typedef K::Point_3 Point_3; typedef CGAL::Surface_mesh Surface_mesh; - +typedef CGAL::HalfedgeDS_default HDS; int main(int argc, char* argv[]) { @@ -27,14 +28,15 @@ int main(int argc, char* argv[]) CGAL::convex_hull_3(points.begin(), points.end(), poly); std::cout << "The convex hull contains " << poly.size_of_vertices() << " vertices" << std::endl; - - Surface_mesh sm; + Surface_mesh sm; CGAL::convex_hull_3(points.begin(), points.end(), sm); std::cout << "The convex hull contains " << num_vertices(sm) << " vertices" << std::endl; - + HDS hds; + CGAL::convex_hull_3(points.begin(), points.end(), hds); + return 0; } diff --git a/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h b/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h index c8b105080ea..cadb269b08c 100644 --- a/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h +++ b/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h @@ -27,7 +27,7 @@ #include -#include +#include #include #include #include @@ -41,6 +41,7 @@ #include #include #include +#include namespace CGAL { @@ -60,13 +61,15 @@ namespace CGAL typedef typename Kernel::RT RT; // Typedefs for dual - typedef typename Polyhedron_dual::Facet Facet; - typedef typename Polyhedron_dual::Facet_const_handle + + typedef typename boost::graph_traits::face_descriptor Facet_const_handle; - typedef typename Polyhedron_dual::Facet_const_iterator + typedef typename boost::graph_traits::face_iterator Facet_const_iterator; - typedef typename Polyhedron_dual::Vertex_const_iterator - Vertex_const_iterator; + typedef typename boost::graph_traits::vertex_descriptor + Vertex_const_descriptor; + typedef typename boost::graph_traits::halfedge_descriptor + Halfedge_const_descriptor; // typedef and type for primal typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; @@ -85,9 +88,8 @@ namespace CGAL size_t n = 0; // First, computing the primal vertices - for (Facet_const_iterator it = _dual.facets_begin(); - it != _dual.facets_end(); ++it, ++n) { - typename Facet::Halfedge_const_handle h = it->halfedge(); + BOOST_FOREACH (Facet_const_handle fd, faces(_dual)){ + Halfedge_const_descriptor h = fd->halfedge(); // Build the dual plane corresponding to the current facet Plane_3 p1 = h->vertex()->point(); Plane_3 p2 = h->next()->vertex()->point(); @@ -119,23 +121,21 @@ namespace CGAL origin.z() + pp->z()); vertex_descriptor vd = add_vertex(primal); - primal_vertices[it] = vd; + primal_vertices[fd] = vd; put(vpm, vd, ppp); + ++n; } // Then, add facets to the primal polyhedron // To do this, for each dual vertex, we circulate around this vertex // and we add an edge between each facet we encounter - for (Vertex_const_iterator it = _dual.vertices_begin(); - it != _dual.vertices_end(); ++it) { - std::vector vertices; - typename Polyhedron_dual::Halfedge_around_vertex_const_circulator - h0 = it->vertex_begin(), hf = h0; - do { - vertices.push_back(primal_vertices[hf->facet()]); - } while (--hf != h0); - Euler::add_face(vertices,primal); + BOOST_FOREACH (Vertex_const_descriptor vd, vertices( _dual)) { + std::deque vertices; + BOOST_FOREACH(Halfedge_const_descriptor hd, halfedges_around_target(vd, _dual)){ + vertices.push_front(primal_vertices[face(hd, _dual)]); + } + Euler::add_face(vertices,primal); } } @@ -249,7 +249,7 @@ namespace CGAL // Types typedef typename Kernel_traits::value_type>::Kernel K; typedef Convex_hull_3::Convex_hull_traits_dual_3 Hull_traits_dual_3; - typedef Polyhedron_3 Polyhedron_dual_3; + typedef HalfedgeDS_default Polyhedron_dual_3; // if a point inside is not provided find one using linear programming if (!origin) { diff --git a/Convex_hull_3/include/CGAL/Convex_hull_traits_3.h b/Convex_hull_3/include/CGAL/Convex_hull_traits_3.h index c4b622c2d4a..caa065b2b58 100644 --- a/Convex_hull_3/include/CGAL/Convex_hull_traits_3.h +++ b/Convex_hull_3/include/CGAL/Convex_hull_traits_3.h @@ -25,7 +25,7 @@ #include -#include +#include #include #include #include diff --git a/Convex_hull_3/include/CGAL/convex_hull_3.h b/Convex_hull_3/include/CGAL/convex_hull_3.h index ec2dfdf4e0e..732893b58bb 100644 --- a/Convex_hull_3/include/CGAL/convex_hull_3.h +++ b/Convex_hull_3/include/CGAL/convex_hull_3.h @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include #include @@ -65,6 +65,7 @@ namespace CGAL { + namespace internal{ namespace Convex_hull_3{ //struct to select the default traits class for computing convex hull diff --git a/Convex_hull_3/include/CGAL/convex_hull_3_to_polyhedron_3.h b/Convex_hull_3/include/CGAL/convex_hull_3_to_polyhedron_3.h index 9c8d292603e..42aa532f67b 100644 --- a/Convex_hull_3/include/CGAL/convex_hull_3_to_polyhedron_3.h +++ b/Convex_hull_3/include/CGAL/convex_hull_3_to_polyhedron_3.h @@ -30,11 +30,14 @@ #define CGAL_REPLACEMENT_HEADER "" #include -#include -#include +//#include +//#include + +#include namespace CGAL { +#if 0 template class Convex_hull_modifier_from_triangulation_3 : public CGAL::Modifier_base { typedef std::map Vertex_map; @@ -88,12 +91,12 @@ public: B.end_surface(); } }; - +#endif + template CGAL_DEPRECATED void convex_hull_3_to_polyhedron_3(const Triangulation_3& T,Polyhedron_3& P){ - P.clear(); - Convex_hull_modifier_from_triangulation_3 modifier(T); - P.delegate(modifier); + clear(P); + link_to_face_graph(T,T.infinite_vertex(), P); } } //namespace CGAL diff --git a/Convex_hull_3/test/Convex_hull_3/convex_hull_traits_3_fp_bug.cpp b/Convex_hull_3/test/Convex_hull_3/convex_hull_traits_3_fp_bug.cpp index d34067e5098..7eb9d41e1bd 100644 --- a/Convex_hull_3/test/Convex_hull_3/convex_hull_traits_3_fp_bug.cpp +++ b/Convex_hull_3/test/Convex_hull_3/convex_hull_traits_3_fp_bug.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include diff --git a/Convex_hull_3/test/Convex_hull_3/quickhull_degenerate_test_3.cpp b/Convex_hull_3/test/Convex_hull_3/quickhull_degenerate_test_3.cpp index 792ec440761..aa9042ff279 100644 --- a/Convex_hull_3/test/Convex_hull_3/quickhull_degenerate_test_3.cpp +++ b/Convex_hull_3/test/Convex_hull_3/quickhull_degenerate_test_3.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include diff --git a/Convex_hull_3/test/Convex_hull_3/quickhull_test_3.cpp b/Convex_hull_3/test/Convex_hull_3/quickhull_test_3.cpp index 61756f28d79..5911cc5c837 100644 --- a/Convex_hull_3/test/Convex_hull_3/quickhull_test_3.cpp +++ b/Convex_hull_3/test/Convex_hull_3/quickhull_test_3.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include diff --git a/HalfedgeDS/include/CGAL/HalfedgeDS_default.h b/HalfedgeDS/include/CGAL/HalfedgeDS_default.h index 8a3ba544426..a3cc7b8db16 100644 --- a/HalfedgeDS/include/CGAL/HalfedgeDS_default.h +++ b/HalfedgeDS/include/CGAL/HalfedgeDS_default.h @@ -29,6 +29,8 @@ #include #include #include +#include + namespace CGAL { diff --git a/HalfedgeDS/include/CGAL/HalfedgeDS_items_2.h b/HalfedgeDS/include/CGAL/HalfedgeDS_items_2.h index ae328e76cc2..63eef24b0a0 100644 --- a/HalfedgeDS/include/CGAL/HalfedgeDS_items_2.h +++ b/HalfedgeDS/include/CGAL/HalfedgeDS_items_2.h @@ -47,7 +47,24 @@ public: typedef HalfedgeDS_face_base< Refs> Face; }; }; + +class HalfedgeDS_items_3 { +public: + template < class Refs, class Traits> + struct Vertex_wrapper { + typedef typename Traits::Point_3 Point; + typedef HalfedgeDS_vertex_base< Refs, Tag_true, Point> Vertex; + }; + template < class Refs, class Traits> + struct Halfedge_wrapper { + typedef HalfedgeDS_halfedge_base< Refs> Halfedge; + }; + template < class Refs, class Traits> + struct Face_wrapper { + typedef HalfedgeDS_face_base< Refs> Face; + }; +}; } //namespace CGAL #endif // CGAL_HALFEDGEDS_ITEMS_2_H // // EOF // diff --git a/HalfedgeDS/include/CGAL/HalfedgeDS_list.h b/HalfedgeDS/include/CGAL/HalfedgeDS_list.h index 354f14bb035..c316a89f3ab 100644 --- a/HalfedgeDS/include/CGAL/HalfedgeDS_list.h +++ b/HalfedgeDS/include/CGAL/HalfedgeDS_list.h @@ -30,6 +30,7 @@ #include #include #include +#include #include namespace CGAL { @@ -135,6 +136,11 @@ public: typedef typename Halfedge_list::iterator Halfedge_iterator; typedef typename Halfedge_list::const_iterator Halfedge_const_iterator; + typedef N_step_adaptor_derived + Edge_iterator; + typedef N_step_adaptor_derived + Edge_const_iterator; + typedef In_place_list Face_list; typedef typename Face_list::iterator Face_handle; typedef typename Face_list::const_iterator Face_const_handle; diff --git a/HalfedgeDS/include/CGAL/boost/graph/graph_traits_HalfedgeDS.h b/HalfedgeDS/include/CGAL/boost/graph/graph_traits_HalfedgeDS.h index 53304971c7b..b0915a0bc7f 100644 --- a/HalfedgeDS/include/CGAL/boost/graph/graph_traits_HalfedgeDS.h +++ b/HalfedgeDS/include/CGAL/boost/graph/graph_traits_HalfedgeDS.h @@ -179,7 +179,6 @@ public: typedef CGAL::Prevent_deref halfedge_iterator; - typedef boost::transform_iterator< internal::Construct_edge, edge_iterator_i, diff --git a/HalfedgeDS/include/CGAL/boost/graph/graph_traits_HalfedgeDS_default.h b/HalfedgeDS/include/CGAL/boost/graph/graph_traits_HalfedgeDS_default.h new file mode 100644 index 00000000000..f9dcd730e23 --- /dev/null +++ b/HalfedgeDS/include/CGAL/boost/graph/graph_traits_HalfedgeDS_default.h @@ -0,0 +1,507 @@ +#ifndef CGAL_GRAPH_TRAITS_HALFEDGEDS_DEFAULT_H +#define CGAL_GRAPH_TRAITS_HALFEDGEDS_DEFAULT_H + +#include +#include +#include + +namespace CGAL { + +template +class HalfedgeDS_default; +}; // namespace CGAL + +namespace boost { + + + +template +struct graph_traits< CGAL::HalfedgeDS_default > + : CGAL::HDS_graph_traits< CGAL::HalfedgeDS_default > +{ + typedef typename T::Point_3 vertex_property_type; +}; + +template +struct graph_traits< CGAL::HalfedgeDS_default const > + : CGAL::HDS_graph_traits< CGAL::HalfedgeDS_default > // See NOTE above! +{}; + +} // namespace boost + +namespace CGAL { + +template +typename boost::graph_traits< HalfedgeDS_default const>::vertices_size_type +num_vertices(const HalfedgeDS_default& p) +{ + return p.size_of_vertices(); +} + +template +typename boost::graph_traits< HalfedgeDS_default const>::edges_size_type +num_edges(const HalfedgeDS_default& p) +{ + return p.size_of_halfedges() / 2; +} + +template +typename boost::graph_traits< HalfedgeDS_default const>::degree_size_type +degree(typename boost::graph_traits< HalfedgeDS_default const>::vertex_descriptor v + , const HalfedgeDS_default&) +{ + return v->vertex_degree(); +} + +template +typename boost::graph_traits< HalfedgeDS_default const>::degree_size_type +out_degree(typename boost::graph_traits< HalfedgeDS_default const>::vertex_descriptor v + , const HalfedgeDS_default&) +{ + return v->vertex_degree(); +} + +template +typename boost::graph_traits< HalfedgeDS_default const>::degree_size_type +in_degree(typename boost::graph_traits< HalfedgeDS_default const>::vertex_descriptor v + , const HalfedgeDS_default&) +{ + return v->vertex_degree(); +} + +template +typename boost::graph_traits< HalfedgeDS_default const>::degree_size_type +degree(typename boost::graph_traits< HalfedgeDS_default const>::face_descriptor f + , const HalfedgeDS_default&) +{ + return f->facet_degree(); +} + +template +typename boost::graph_traits< HalfedgeDS_default const>::vertex_descriptor +source(typename boost::graph_traits< HalfedgeDS_default const>::edge_descriptor e + , const HalfedgeDS_default & ) +{ + return e.halfedge()->opposite()->vertex(); +} + +template +typename boost::graph_traits< HalfedgeDS_default const>::vertex_descriptor +target(typename boost::graph_traits< HalfedgeDS_default const>::edge_descriptor e + , const HalfedgeDS_default & ) +{ + return e.halfedge()->vertex(); +} + +template +std::pair< + typename boost::graph_traits< HalfedgeDS_default const>::edge_descriptor + , bool> +edge(typename boost::graph_traits< HalfedgeDS_default const>::vertex_descriptor u + , typename boost::graph_traits< HalfedgeDS_default const>::vertex_descriptor v + , const HalfedgeDS_default &) +{ + typedef HalfedgeDS_default P; + typedef boost::graph_traits< P > Traits; + typedef typename Traits::halfedge_descriptor halfedge_descriptor; + typedef typename Traits::edge_descriptor edge; + + // circulate around the inedges of u + halfedge_descriptor c(u->halfedge()), d(u->halfedge()); + if(c != halfedge_descriptor()) { + do { + if(c->opposite()->vertex() == v) { + return std::make_pair(edge(c->opposite()), true); + } + c = c->next()->opposite(); + } while (c != d); + } + + return std::make_pair(edge(), false); +} + +template +inline Iterator_range const>::vertex_iterator> +vertices( const HalfedgeDS_default& p) +{ + typedef typename boost::graph_traits< HalfedgeDS_default const>::vertex_iterator Iter; + HalfedgeDS_default& ncp = const_cast&>(p); + return make_range( Iter(ncp.vertices_begin()), Iter(ncp.vertices_end()) ); +} + +template +inline Iterator_range const>::edge_iterator> +edges( const HalfedgeDS_default& p) +{ + typedef typename boost::graph_traits< HalfedgeDS_default const>::edge_iterator_i Iter_i; + typedef typename boost::graph_traits< HalfedgeDS_default const>::edge_iterator Iter; + HalfedgeDS_default& ncp = const_cast&>(p); + return make_range( Iter(Iter_i(ncp.halfedges_begin())), Iter(Iter_i(ncp.halfedges_end()) )); +} + +template +inline Iterator_range const>::in_edge_iterator> +in_edges( typename boost::graph_traits< HalfedgeDS_default const>::vertex_descriptor u + , const HalfedgeDS_default& p) +{ + typedef typename boost::graph_traits< HalfedgeDS_default const>::in_edge_iterator Iter; + return make_range(Iter(halfedge(u,p),p), Iter(halfedge(u,p),p,1)); +} + +template +inline Iterator_range const>::out_edge_iterator> +out_edges( typename boost::graph_traits< HalfedgeDS_default const>::vertex_descriptor u + , const HalfedgeDS_default& p) +{ + typedef typename boost::graph_traits< HalfedgeDS_default const>::out_edge_iterator Iter; + return make_range(Iter(halfedge(u,p),p), Iter(halfedge(u,p),p,1)); +} + +// +// MutableHalfedgeGraph +// + +template +typename boost::graph_traits< HalfedgeDS_default >::vertex_descriptor +add_vertex(HalfedgeDS_default& g) +{ + return g.vertices_push_back(typename HalfedgeDS_default::Vertex()); +} + + +template +typename boost::graph_traits< HalfedgeDS_default >::vertex_descriptor +add_vertex(const typename boost::graph_traits >::vertex_property_type& p + , HalfedgeDS_default& g) +{ + return g.vertices_push_back(typename HalfedgeDS_default::Vertex(p)); +} + +template +void +remove_vertex(typename boost::graph_traits< HalfedgeDS_default >::vertex_descriptor v + , HalfedgeDS_default& g) +{ + g.vertices_erase(v); +} + +template +typename boost::graph_traits< HalfedgeDS_default >::edge_descriptor +add_edge(HalfedgeDS_default& g) +{ + return typename boost::graph_traits< HalfedgeDS_default >::edge_descriptor( + g.edges_push_back(typename HalfedgeDS_default::Halfedge(), + typename HalfedgeDS_default::Halfedge())); +} + +template +void +remove_edge(typename boost::graph_traits< HalfedgeDS_default >::edge_descriptor e + , HalfedgeDS_default& g) +{ + g.edges_erase(e.halfedge()); +} + + +template +void +set_target(typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor h1 + , typename boost::graph_traits< HalfedgeDS_default >::vertex_descriptor v + , HalfedgeDS_default&) +{ + // set_face has become private in the halfedge provided by + // polyhedron for unknown reasons, although it used to be public + // once. + + // We sneak in anyway. Inheritance can't keep us out. + typedef typename HalfedgeDS_default::Halfedge::Base Sneak; + static_cast(*h1).set_vertex(v); +} + +template +void +set_next(typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor h1 + , typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor h2 + , HalfedgeDS_default&) +{ + typedef typename HalfedgeDS_default::Halfedge::Base Sneak; + static_cast(*h1).set_next(h2); + static_cast(*h2).set_prev(h1); +} + +// +// MutableFaceGraph +// + +template +typename boost::graph_traits< HalfedgeDS_default >::face_descriptor +add_face(HalfedgeDS_default& g) +{ + return g.faces_push_back(typename HalfedgeDS_default::Face()); +} + +template +typename boost::graph_traits< HalfedgeDS_default >::face_descriptor +add_face(InputIterator begin, InputIterator end, HalfedgeDS_default& g) +{ + return g.add_facet(begin, end); +} + +template +void +remove_face(typename boost::graph_traits< HalfedgeDS_default >::face_descriptor f + , HalfedgeDS_default& g) +{ + g.faces_erase(f); +} + +template +void +set_face(typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor h + , typename boost::graph_traits< HalfedgeDS_default >::face_descriptor f + , const HalfedgeDS_default&) +{ + // set_face has become private in the halfedge provided by + // polyhedron for unknown reasons, although it used to be public + // once. + + // We sneak in anyway. Inheritance can't keep us out. + typedef typename HalfedgeDS_default::Halfedge::Base Sneak; + static_cast(*h).set_face(f); +} + +template +void +set_halfedge(typename boost::graph_traits< HalfedgeDS_default >::face_descriptor f + , typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor h + , HalfedgeDS_default& g) +{ + typedef typename HalfedgeDS_default Hds; + CGAL::HalfedgeDS_decorator D(g); + D.set_face_halfedge(f, h); +} + +template +void +set_halfedge(typename boost::graph_traits< HalfedgeDS_default >::vertex_descriptor v + , typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor h + , const HalfedgeDS_default&) +{ + typedef typename HalfedgeDS_default::Vertex::Base Sneak; + static_cast(*v).set_halfedge(h); +} + + +// +// HalfedgeGraph +// +template +typename boost::graph_traits< HalfedgeDS_default >::edge_descriptor +edge(typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor h + , const HalfedgeDS_default&) +{ + return typename boost::graph_traits< HalfedgeDS_default >::edge_descriptor(h); +} + +template +typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor +halfedge(typename boost::graph_traits< HalfedgeDS_default >::edge_descriptor e + , const HalfedgeDS_default&) +{ + return e.halfedge(); +} + +template +typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor +halfedge(typename boost::graph_traits< HalfedgeDS_default >::vertex_descriptor v + , const HalfedgeDS_default&) +{ + return v->halfedge(); +} + +template +std::pair< typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor + , bool> +halfedge(typename boost::graph_traits< HalfedgeDS_default >::vertex_descriptor u + , typename boost::graph_traits< HalfedgeDS_default >::vertex_descriptor v + , const HalfedgeDS_default& g) +{ + std::pair< typename boost::graph_traits< HalfedgeDS_default >::edge_descriptor + , bool> e = edge(u, v, g); + return std::make_pair(e.first.halfedge(), e.second); +} + +template +typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor +opposite(typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor h + , const HalfedgeDS_default&) +{ + return h->opposite(); +} + +template +typename boost::graph_traits< HalfedgeDS_default >::vertex_descriptor +source(typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor h + , const HalfedgeDS_default& g) +{ + return target(opposite(h, g), g); +} + +template +typename boost::graph_traits< HalfedgeDS_default >::vertex_descriptor +target(typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor h + , const HalfedgeDS_default&) +{ + return h->vertex(); +} + +template +typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor +next(typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor outedge + , const HalfedgeDS_default&) +{ + return outedge->next(); +} + +template +typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor +prev(typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor outedge + , const HalfedgeDS_default&) +{ + return outedge->prev(); +} + + +// +// HalfedgeListGraph +// + +template +Iterator_range >::halfedge_iterator> +halfedges(const HalfedgeDS_default& p) +{ + typedef typename boost::graph_traits< HalfedgeDS_default >::halfedge_iterator Iter; + HalfedgeDS_default& ncp = const_cast&>(p); + return make_range(Iter(ncp.halfedges_begin()), Iter(ncp.halfedges_end())); +} + +template +typename boost::graph_traits< HalfedgeDS_default >::halfedges_size_type +num_halfedges(const HalfedgeDS_default& p) +{ + return p.size_of_halfedges(); +} + +// FaceGraph +template +typename boost::graph_traits< HalfedgeDS_default >::face_descriptor +face(typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor h + , const HalfedgeDS_default&) +{ + return h->face(); +} + +template +typename boost::graph_traits< HalfedgeDS_default >::halfedge_descriptor +halfedge(typename boost::graph_traits< HalfedgeDS_default >::face_descriptor f + , const HalfedgeDS_default&) +{ + return f->halfedge(); +} + +template +inline Iterator_range const>::face_iterator > +faces(const HalfedgeDS_default& p) +{ + typedef typename boost::graph_traits< HalfedgeDS_default const>::face_iterator face_iterator; + HalfedgeDS_default& ncp = const_cast&>(p); + return make_range( face_iterator(ncp.faces_begin()), face_iterator(ncp.faces_end())); +} + +template +typename boost::graph_traits< HalfedgeDS_default const>::faces_size_type +num_faces(const HalfedgeDS_default& p) +{ + return p.size_of_faces(); +} +namespace internal { + +template +struct HDS_Point_accessor + : boost::put_get_helper< Reference, HDS_Point_accessor > +{ + typedef boost::lvalue_property_map_tag category; + typedef Reference reference; + typedef ValueType value_type; + typedef Handle key_type; + + reference operator[](Handle h) const { return h->point(); } +}; + +} // namespace internal + +template +struct HDS_property_map; + +template <> +struct HDS_property_map +{ + template + struct bind_ + { + typedef internal::HDS_Point_accessor< + typename boost::graph_traits< + HalfedgeDS_default + >::vertex_descriptor, + typename T::Point_3, typename T::Point_3&> type; + + typedef internal::HDS_Point_accessor< + typename boost::graph_traits< + HalfedgeDS_default + >::vertex_descriptor, + typename T::Point_3, const typename T::Point_3&> const_type; + }; +}; + +}// 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; +}; + +} // namespace boost + +namespace CGAL { + +// generalized 2-ary get functions +template +typename boost::property_map< CGAL::HalfedgeDS_default, PropertyTag >::const_type +get(PropertyTag, CGAL::HalfedgeDS_default const&) +{ return typename boost::property_map< CGAL::HalfedgeDS_default, PropertyTag >::const_type(); } + +template +typename boost::property_map< CGAL::HalfedgeDS_default, PropertyTag >::type +get(PropertyTag, CGAL::HalfedgeDS_default&) +{ return typename boost::property_map< CGAL::HalfedgeDS_default, PropertyTag >::type(); } + + +} // namespace CGAL +#endif diff --git a/Polyhedron/include/CGAL/Polyhedron_3.h b/Polyhedron/include/CGAL/Polyhedron_3.h index cbc16b5ce8a..3e4cd452af4 100644 --- a/Polyhedron/include/CGAL/Polyhedron_3.h +++ b/Polyhedron/include/CGAL/Polyhedron_3.h @@ -24,7 +24,7 @@ #include - +#include #include #include #include @@ -465,10 +465,10 @@ public: template < class PolyhedronTraits_3, - class PolyhedronItems_3 = Polyhedron_items_3, + class PolyhedronItems_3, template < class T, class I, class A> - class T_HDS = HalfedgeDS_default, - class Alloc = CGAL_ALLOCATOR(int)> + class T_HDS, + class Alloc> class Polyhedron_3 { // // DEFINITION @@ -553,11 +553,15 @@ public: typedef Iterator_project Plane_const_iterator; + typedef typename HDS::Edge_iterator Edge_iterator; + typedef typename HDS::Edge_const_iterator Edge_const_iterator; + /* typedef N_step_adaptor_derived Edge_iterator; typedef N_step_adaptor_derived Edge_const_iterator; - + */ + // All face related types get a related facet type name. typedef Face Facet; typedef Face_handle Facet_handle;