mirror of https://github.com/CGAL/cgal
Convex_hull_3: Remove dependency on package Polyhedron
This commit is contained in:
parent
578e2fb606
commit
76ccc9ab6f
|
|
@ -4,12 +4,13 @@
|
|||
#include <CGAL/convex_hull_3.h>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <CGAL/HalfedgeDS_default.h>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
typedef CGAL::Polyhedron_3<K> Polyhedron_3;
|
||||
typedef K::Point_3 Point_3;
|
||||
typedef CGAL::Surface_mesh<Point_3> Surface_mesh;
|
||||
|
||||
typedef CGAL::HalfedgeDS_default<K, CGAL::HalfedgeDS_items_3> 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include <CGAL/disable_warnings.h>
|
||||
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/HalfedgeDS_default.h>
|
||||
#include <CGAL/Convex_hull_3/dual/Convex_hull_traits_dual_3.h>
|
||||
#include <CGAL/Origin.h>
|
||||
#include <CGAL/convex_hull_3.h>
|
||||
|
|
@ -41,6 +41,7 @@
|
|||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/type_traits/is_floating_point.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <deque>
|
||||
|
||||
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<Polyhedron_dual>::face_descriptor
|
||||
Facet_const_handle;
|
||||
typedef typename Polyhedron_dual::Facet_const_iterator
|
||||
typedef typename boost::graph_traits<Polyhedron_dual>::face_iterator
|
||||
Facet_const_iterator;
|
||||
typedef typename Polyhedron_dual::Vertex_const_iterator
|
||||
Vertex_const_iterator;
|
||||
typedef typename boost::graph_traits<Polyhedron_dual>::vertex_descriptor
|
||||
Vertex_const_descriptor;
|
||||
typedef typename boost::graph_traits<Polyhedron_dual>::halfedge_descriptor
|
||||
Halfedge_const_descriptor;
|
||||
|
||||
// typedef and type for primal
|
||||
typedef typename boost::graph_traits<Polyhedron>::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<vertex_descriptor> 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<vertex_descriptor> 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<typename std::iterator_traits<PlaneIterator>::value_type>::Kernel K;
|
||||
typedef Convex_hull_3::Convex_hull_traits_dual_3<K> Hull_traits_dual_3;
|
||||
typedef Polyhedron_3<Hull_traits_dual_3> Polyhedron_dual_3;
|
||||
typedef HalfedgeDS_default<Hull_traits_dual_3, HalfedgeDS_items_3 > Polyhedron_dual_3;
|
||||
|
||||
// if a point inside is not provided find one using linear programming
|
||||
if (!origin) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
#include <CGAL/license/Convex_hull_3.h>
|
||||
|
||||
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/Polyhedron_3_fwd.h>
|
||||
#include <CGAL/Convex_hull_face_base_2.h>
|
||||
#include <CGAL/Projection_traits_xy_3.h>
|
||||
#include <CGAL/Projection_traits_xz_3.h>
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
#include <CGAL/internal/Exact_type_selector.h>
|
||||
#include <CGAL/boost/graph/copy_face_graph.h>
|
||||
#include <CGAL/boost/graph/graph_traits_Triangulation_data_structure_2.h>
|
||||
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
|
||||
#include <CGAL/Polyhedron_3_fwd.h>
|
||||
#include <CGAL/boost/graph/Euler_operations.h>
|
||||
|
||||
#include <boost/unordered_map.hpp>
|
||||
|
|
@ -65,6 +65,7 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
|
||||
namespace internal{ namespace Convex_hull_3{
|
||||
|
||||
//struct to select the default traits class for computing convex hull
|
||||
|
|
|
|||
|
|
@ -30,11 +30,14 @@
|
|||
#define CGAL_REPLACEMENT_HEADER "<CGAL/convex_hull_3_to_face_graph.h>"
|
||||
#include <CGAL/internal/deprecation_warning.h>
|
||||
|
||||
#include <CGAL/Polyhedron_incremental_builder_3.h>
|
||||
#include <CGAL/Modifier_base.h>
|
||||
//#include <CGAL/Polyhedron_incremental_builder_3.h>
|
||||
//#include <CGAL/Modifier_base.h>
|
||||
|
||||
#include <CGAL/Polyhedron_3_fwd.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
#if 0
|
||||
template <class HDS,class Triangulation>
|
||||
class Convex_hull_modifier_from_triangulation_3 : public CGAL::Modifier_base<HDS> {
|
||||
typedef std::map<typename Triangulation::Vertex_handle,unsigned> Vertex_map;
|
||||
|
|
@ -88,12 +91,12 @@ public:
|
|||
B.end_surface();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
template<class Triangulation_3,class Polyhedron_3>
|
||||
CGAL_DEPRECATED void convex_hull_3_to_polyhedron_3(const Triangulation_3& T,Polyhedron_3& P){
|
||||
P.clear();
|
||||
Convex_hull_modifier_from_triangulation_3<typename Polyhedron_3::HalfedgeDS,Triangulation_3> modifier(T);
|
||||
P.delegate(modifier);
|
||||
clear(P);
|
||||
link_to_face_graph(T,T.infinite_vertex(), P);
|
||||
}
|
||||
|
||||
} //namespace CGAL
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/convex_hull_3.h>
|
||||
#include <fstream>
|
||||
#include <cassert>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
|
||||
#include <CGAL/Convex_hull_traits_3.h>
|
||||
#include <CGAL/convex_hull_3.h>
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
#include <CGAL/HalfedgeDS_items_2.h>
|
||||
#include <CGAL/HalfedgeDS_list.h>
|
||||
#include <CGAL/memory.h>
|
||||
#include <CGAL/boost/graph/graph_traits_HalfedgeDS_default.h>
|
||||
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
|
|
|
|||
|
|
@ -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 //
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include <CGAL/HalfedgeDS_items_decorator.h>
|
||||
#include <CGAL/memory.h>
|
||||
#include <CGAL/Unique_hash_map.h>
|
||||
#include <CGAL/N_step_adaptor_derived.h>
|
||||
#include <cstddef>
|
||||
|
||||
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<Halfedge_iterator, 2>
|
||||
Edge_iterator;
|
||||
typedef N_step_adaptor_derived<Halfedge_const_iterator, 2>
|
||||
Edge_const_iterator;
|
||||
|
||||
typedef In_place_list<Face,false,Face_allocator> Face_list;
|
||||
typedef typename Face_list::iterator Face_handle;
|
||||
typedef typename Face_list::const_iterator Face_const_handle;
|
||||
|
|
|
|||
|
|
@ -179,7 +179,6 @@ public:
|
|||
typedef CGAL::Prevent_deref<typename HDS::Halfedge_iterator> halfedge_iterator;
|
||||
|
||||
|
||||
|
||||
typedef boost::transform_iterator<
|
||||
internal::Construct_edge<typename HDS::Halfedge_handle>,
|
||||
edge_iterator_i,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,507 @@
|
|||
#ifndef CGAL_GRAPH_TRAITS_HALFEDGEDS_DEFAULT_H
|
||||
#define CGAL_GRAPH_TRAITS_HALFEDGEDS_DEFAULT_H
|
||||
|
||||
#include <CGAL/boost/graph/graph_traits_HalfedgeDS.h>
|
||||
#include <CGAL/Iterator_range.h>
|
||||
#include <CGAL/HalfedgeDS_decorator.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template <class Traits_, class HalfedgeDSItems,
|
||||
class Alloc>
|
||||
class HalfedgeDS_default;
|
||||
}; // namespace CGAL
|
||||
|
||||
namespace boost {
|
||||
|
||||
|
||||
|
||||
template<class T, class I, class A>
|
||||
struct graph_traits< CGAL::HalfedgeDS_default<T,I,A> >
|
||||
: CGAL::HDS_graph_traits< CGAL::HalfedgeDS_default<T,I,A> >
|
||||
{
|
||||
typedef typename T::Point_3 vertex_property_type;
|
||||
};
|
||||
|
||||
template<class T, class I, class A>
|
||||
struct graph_traits< CGAL::HalfedgeDS_default<T,I,A> const >
|
||||
: CGAL::HDS_graph_traits< CGAL::HalfedgeDS_default<T,I,A> > // See NOTE above!
|
||||
{};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::vertices_size_type
|
||||
num_vertices(const HalfedgeDS_default<T,I,A>& p)
|
||||
{
|
||||
return p.size_of_vertices();
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::edges_size_type
|
||||
num_edges(const HalfedgeDS_default<T,I,A>& p)
|
||||
{
|
||||
return p.size_of_halfedges() / 2;
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::degree_size_type
|
||||
degree(typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::vertex_descriptor v
|
||||
, const HalfedgeDS_default<T,I,A>&)
|
||||
{
|
||||
return v->vertex_degree();
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::degree_size_type
|
||||
out_degree(typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::vertex_descriptor v
|
||||
, const HalfedgeDS_default<T,I,A>&)
|
||||
{
|
||||
return v->vertex_degree();
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::degree_size_type
|
||||
in_degree(typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::vertex_descriptor v
|
||||
, const HalfedgeDS_default<T,I,A>&)
|
||||
{
|
||||
return v->vertex_degree();
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::degree_size_type
|
||||
degree(typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::face_descriptor f
|
||||
, const HalfedgeDS_default<T,I,A>&)
|
||||
{
|
||||
return f->facet_degree();
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::vertex_descriptor
|
||||
source(typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::edge_descriptor e
|
||||
, const HalfedgeDS_default<T,I,A> & )
|
||||
{
|
||||
return e.halfedge()->opposite()->vertex();
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::vertex_descriptor
|
||||
target(typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::edge_descriptor e
|
||||
, const HalfedgeDS_default<T,I,A> & )
|
||||
{
|
||||
return e.halfedge()->vertex();
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
std::pair<
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::edge_descriptor
|
||||
, bool>
|
||||
edge(typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::vertex_descriptor u
|
||||
, typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::vertex_descriptor v
|
||||
, const HalfedgeDS_default<T,I,A> &)
|
||||
{
|
||||
typedef HalfedgeDS_default<T,I,A> 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<class T, class I, class A>
|
||||
inline Iterator_range<typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::vertex_iterator>
|
||||
vertices( const HalfedgeDS_default<T,I,A>& p)
|
||||
{
|
||||
typedef typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::vertex_iterator Iter;
|
||||
HalfedgeDS_default<T,I,A>& ncp = const_cast<HalfedgeDS_default<T,I,A>&>(p);
|
||||
return make_range( Iter(ncp.vertices_begin()), Iter(ncp.vertices_end()) );
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
inline Iterator_range<typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::edge_iterator>
|
||||
edges( const HalfedgeDS_default<T,I,A>& p)
|
||||
{
|
||||
typedef typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::edge_iterator_i Iter_i;
|
||||
typedef typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::edge_iterator Iter;
|
||||
HalfedgeDS_default<T,I,A>& ncp = const_cast<HalfedgeDS_default<T,I,A>&>(p);
|
||||
return make_range( Iter(Iter_i(ncp.halfedges_begin())), Iter(Iter_i(ncp.halfedges_end()) ));
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
inline Iterator_range<typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::in_edge_iterator>
|
||||
in_edges( typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::vertex_descriptor u
|
||||
, const HalfedgeDS_default<T,I,A>& p)
|
||||
{
|
||||
typedef typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::in_edge_iterator Iter;
|
||||
return make_range(Iter(halfedge(u,p),p), Iter(halfedge(u,p),p,1));
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
inline Iterator_range<typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::out_edge_iterator>
|
||||
out_edges( typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::vertex_descriptor u
|
||||
, const HalfedgeDS_default<T,I,A>& p)
|
||||
{
|
||||
typedef typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::out_edge_iterator Iter;
|
||||
return make_range(Iter(halfedge(u,p),p), Iter(halfedge(u,p),p,1));
|
||||
}
|
||||
|
||||
//
|
||||
// MutableHalfedgeGraph
|
||||
//
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::vertex_descriptor
|
||||
add_vertex(HalfedgeDS_default<T,I,A>& g)
|
||||
{
|
||||
return g.vertices_push_back(typename HalfedgeDS_default<T,I,A>::Vertex());
|
||||
}
|
||||
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::vertex_descriptor
|
||||
add_vertex(const typename boost::graph_traits<HalfedgeDS_default<T,I,A> >::vertex_property_type& p
|
||||
, HalfedgeDS_default<T,I,A>& g)
|
||||
{
|
||||
return g.vertices_push_back(typename HalfedgeDS_default<T,I,A>::Vertex(p));
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
void
|
||||
remove_vertex(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::vertex_descriptor v
|
||||
, HalfedgeDS_default<T,I,A>& g)
|
||||
{
|
||||
g.vertices_erase(v);
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::edge_descriptor
|
||||
add_edge(HalfedgeDS_default<T,I,A>& g)
|
||||
{
|
||||
return typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::edge_descriptor(
|
||||
g.edges_push_back(typename HalfedgeDS_default<T,I,A>::Halfedge(),
|
||||
typename HalfedgeDS_default<T,I,A>::Halfedge()));
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
void
|
||||
remove_edge(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::edge_descriptor e
|
||||
, HalfedgeDS_default<T,I,A>& g)
|
||||
{
|
||||
g.edges_erase(e.halfedge());
|
||||
}
|
||||
|
||||
|
||||
template<class T, class I, class A>
|
||||
void
|
||||
set_target(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor h1
|
||||
, typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::vertex_descriptor v
|
||||
, HalfedgeDS_default<T,I,A>&)
|
||||
{
|
||||
// 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<T,I,A>::Halfedge::Base Sneak;
|
||||
static_cast<Sneak&>(*h1).set_vertex(v);
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
void
|
||||
set_next(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor h1
|
||||
, typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor h2
|
||||
, HalfedgeDS_default<T,I,A>&)
|
||||
{
|
||||
typedef typename HalfedgeDS_default<T,I,A>::Halfedge::Base Sneak;
|
||||
static_cast<Sneak&>(*h1).set_next(h2);
|
||||
static_cast<Sneak&>(*h2).set_prev(h1);
|
||||
}
|
||||
|
||||
//
|
||||
// MutableFaceGraph
|
||||
//
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::face_descriptor
|
||||
add_face(HalfedgeDS_default<T,I,A>& g)
|
||||
{
|
||||
return g.faces_push_back(typename HalfedgeDS_default<T,I,A>::Face());
|
||||
}
|
||||
|
||||
template<class T, class I, class A, class InputIterator>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::face_descriptor
|
||||
add_face(InputIterator begin, InputIterator end, HalfedgeDS_default<T,I,A>& g)
|
||||
{
|
||||
return g.add_facet(begin, end);
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
void
|
||||
remove_face(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::face_descriptor f
|
||||
, HalfedgeDS_default<T,I,A>& g)
|
||||
{
|
||||
g.faces_erase(f);
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
void
|
||||
set_face(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor h
|
||||
, typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::face_descriptor f
|
||||
, const HalfedgeDS_default<T,I,A>&)
|
||||
{
|
||||
// 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<T,I,A>::Halfedge::Base Sneak;
|
||||
static_cast<Sneak&>(*h).set_face(f);
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
void
|
||||
set_halfedge(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::face_descriptor f
|
||||
, typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor h
|
||||
, HalfedgeDS_default<T,I,A>& g)
|
||||
{
|
||||
typedef typename HalfedgeDS_default<T,I,A> Hds;
|
||||
CGAL::HalfedgeDS_decorator<Hds> D(g);
|
||||
D.set_face_halfedge(f, h);
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
void
|
||||
set_halfedge(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::vertex_descriptor v
|
||||
, typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor h
|
||||
, const HalfedgeDS_default<T,I,A>&)
|
||||
{
|
||||
typedef typename HalfedgeDS_default<T,I,A>::Vertex::Base Sneak;
|
||||
static_cast<Sneak&>(*v).set_halfedge(h);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// HalfedgeGraph
|
||||
//
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::edge_descriptor
|
||||
edge(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor h
|
||||
, const HalfedgeDS_default<T,I,A>&)
|
||||
{
|
||||
return typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::edge_descriptor(h);
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor
|
||||
halfedge(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::edge_descriptor e
|
||||
, const HalfedgeDS_default<T,I,A>&)
|
||||
{
|
||||
return e.halfedge();
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor
|
||||
halfedge(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::vertex_descriptor v
|
||||
, const HalfedgeDS_default<T,I,A>&)
|
||||
{
|
||||
return v->halfedge();
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
std::pair< typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor
|
||||
, bool>
|
||||
halfedge(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::vertex_descriptor u
|
||||
, typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::vertex_descriptor v
|
||||
, const HalfedgeDS_default<T,I,A>& g)
|
||||
{
|
||||
std::pair< typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::edge_descriptor
|
||||
, bool> e = edge(u, v, g);
|
||||
return std::make_pair(e.first.halfedge(), e.second);
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor
|
||||
opposite(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor h
|
||||
, const HalfedgeDS_default<T,I,A>&)
|
||||
{
|
||||
return h->opposite();
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::vertex_descriptor
|
||||
source(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor h
|
||||
, const HalfedgeDS_default<T,I,A>& g)
|
||||
{
|
||||
return target(opposite(h, g), g);
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::vertex_descriptor
|
||||
target(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor h
|
||||
, const HalfedgeDS_default<T,I,A>&)
|
||||
{
|
||||
return h->vertex();
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor
|
||||
next(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor outedge
|
||||
, const HalfedgeDS_default<T,I,A>&)
|
||||
{
|
||||
return outedge->next();
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor
|
||||
prev(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor outedge
|
||||
, const HalfedgeDS_default<T,I,A>&)
|
||||
{
|
||||
return outedge->prev();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// HalfedgeListGraph
|
||||
//
|
||||
|
||||
template<class T, class I, class A>
|
||||
Iterator_range<typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_iterator>
|
||||
halfedges(const HalfedgeDS_default<T,I,A>& p)
|
||||
{
|
||||
typedef typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_iterator Iter;
|
||||
HalfedgeDS_default<T,I,A>& ncp = const_cast<HalfedgeDS_default<T,I,A>&>(p);
|
||||
return make_range(Iter(ncp.halfedges_begin()), Iter(ncp.halfedges_end()));
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedges_size_type
|
||||
num_halfedges(const HalfedgeDS_default<T,I,A>& p)
|
||||
{
|
||||
return p.size_of_halfedges();
|
||||
}
|
||||
|
||||
// FaceGraph
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::face_descriptor
|
||||
face(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor h
|
||||
, const HalfedgeDS_default<T,I,A>&)
|
||||
{
|
||||
return h->face();
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::halfedge_descriptor
|
||||
halfedge(typename boost::graph_traits< HalfedgeDS_default<T,I,A> >::face_descriptor f
|
||||
, const HalfedgeDS_default<T,I,A>&)
|
||||
{
|
||||
return f->halfedge();
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
inline Iterator_range<typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::face_iterator >
|
||||
faces(const HalfedgeDS_default<T,I,A>& p)
|
||||
{
|
||||
typedef typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::face_iterator face_iterator;
|
||||
HalfedgeDS_default<T,I,A>& ncp = const_cast<HalfedgeDS_default<T,I,A>&>(p);
|
||||
return make_range( face_iterator(ncp.faces_begin()), face_iterator(ncp.faces_end()));
|
||||
}
|
||||
|
||||
template<class T, class I, class A>
|
||||
typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::faces_size_type
|
||||
num_faces(const HalfedgeDS_default<T,I,A>& p)
|
||||
{
|
||||
return p.size_of_faces();
|
||||
}
|
||||
namespace internal {
|
||||
|
||||
template<typename Handle, typename ValueType, typename Reference>
|
||||
struct HDS_Point_accessor
|
||||
: boost::put_get_helper< Reference, HDS_Point_accessor<Handle, ValueType, Reference> >
|
||||
{
|
||||
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 <class T>
|
||||
struct HDS_property_map;
|
||||
|
||||
template <>
|
||||
struct HDS_property_map<vertex_point_t>
|
||||
{
|
||||
template<class T, class I, class A>
|
||||
struct bind_
|
||||
{
|
||||
typedef internal::HDS_Point_accessor<
|
||||
typename boost::graph_traits<
|
||||
HalfedgeDS_default<T, I, A>
|
||||
>::vertex_descriptor,
|
||||
typename T::Point_3, typename T::Point_3&> type;
|
||||
|
||||
typedef internal::HDS_Point_accessor<
|
||||
typename boost::graph_traits<
|
||||
HalfedgeDS_default<T, I, A>
|
||||
>::vertex_descriptor,
|
||||
typename T::Point_3, const typename T::Point_3&> const_type;
|
||||
};
|
||||
};
|
||||
|
||||
}// namespace CGAL
|
||||
namespace boost {
|
||||
|
||||
// property_map dispatcher into Polyhedron
|
||||
template<class T, class I, class A, class Tag>
|
||||
struct property_map<CGAL::HalfedgeDS_default<T,I,A>, Tag>
|
||||
{
|
||||
typedef typename CGAL::HDS_property_map<Tag>::
|
||||
template bind_<T,I,A> map_gen;
|
||||
typedef typename map_gen::type type;
|
||||
typedef typename map_gen::const_type const_type;
|
||||
};
|
||||
|
||||
// property_map dispatcher into const Polyhedron
|
||||
template<class T, class I, class A, class Tag>
|
||||
struct property_map<const CGAL::HalfedgeDS_default<T,I,A>, Tag>
|
||||
{
|
||||
typedef typename CGAL::HDS_property_map<Tag>::
|
||||
template bind_<T,I,A> 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<class Gt, class I, class A, class PropertyTag>
|
||||
typename boost::property_map< CGAL::HalfedgeDS_default<Gt,I,A>, PropertyTag >::const_type
|
||||
get(PropertyTag, CGAL::HalfedgeDS_default<Gt,I,A> const&)
|
||||
{ return typename boost::property_map< CGAL::HalfedgeDS_default<Gt,I,A>, PropertyTag >::const_type(); }
|
||||
|
||||
template<class Gt, class I, class A, class PropertyTag>
|
||||
typename boost::property_map< CGAL::HalfedgeDS_default<Gt,I,A>, PropertyTag >::type
|
||||
get(PropertyTag, CGAL::HalfedgeDS_default<Gt,I,A>&)
|
||||
{ return typename boost::property_map< CGAL::HalfedgeDS_default<Gt,I,A>, PropertyTag >::type(); }
|
||||
|
||||
|
||||
} // namespace CGAL
|
||||
#endif
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include <CGAL/license/Polyhedron.h>
|
||||
|
||||
|
||||
#include <CGAL/Polyhedron_3_fwd.h>
|
||||
#include <CGAL/basic.h>
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
|
|
@ -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<Face_const_iterator, Proj_plane,
|
||||
const Plane_3&, const Plane_3*> Plane_const_iterator;
|
||||
|
||||
typedef typename HDS::Edge_iterator Edge_iterator;
|
||||
typedef typename HDS::Edge_const_iterator Edge_const_iterator;
|
||||
/*
|
||||
typedef N_step_adaptor_derived<Halfedge_iterator, 2>
|
||||
Edge_iterator;
|
||||
typedef N_step_adaptor_derived<Halfedge_const_iterator, 2>
|
||||
Edge_const_iterator;
|
||||
|
||||
*/
|
||||
|
||||
// All face related types get a related facet type name.
|
||||
typedef Face Facet;
|
||||
typedef Face_handle Facet_handle;
|
||||
|
|
|
|||
Loading…
Reference in New Issue