Merge branch 'Surface_mesh-fixes-GF'

Approved by the release manager

Conflicts:
	STL_Extension/include/CGAL/Iterator_range.h
This commit is contained in:
Andreas Fabri 2015-01-26 16:54:03 +01:00
commit cc4192a628
7 changed files with 159 additions and 68 deletions

View File

@ -38,8 +38,9 @@ namespace CGAL {
* \cgalModels `AABBPrimitiveWithSharedData`
*
*\tparam FaceGraph is a model of the face graph concept.
*\tparam VertexPointPMap is a property map with `boost::graph_traits<HalfedgeGraph>::%vertex_descriptor`
*\tparam VertexPointPMap is a property map with `boost::graph_traits<FaceGraph>::%vertex_descriptor`
* as key type and a \cgal Kernel `Point_3` as value type.
* The default is `typename boost::property_map< FaceGraph,vertex_point_t>::%type`.
*\tparam OneFaceGraphPerTree is either `CGAL::Tag_true` or `CGAL::Tag_false`.
* In the former case, we guarantee that all the primitives will be from a
* common polyhedron and some data will be factorized so that the size of
@ -120,7 +121,7 @@ public:
is available with `vppm` set to `boost::get(vertex_point, graph)`.
*/
template <class Iterator>
AABB_face_graph_triangle_primitive(Iterator it, const FaceGraph& graph, VertexPointPMap vppm)
AABB_face_graph_triangle_primitive(Iterator it, const FaceGraph& graph, VertexPointPMap_ vppm)
: Base( Id_(*it),
Triangle_property_map(const_cast<FaceGraph*>(&graph),vppm),
Point_property_map(const_cast<FaceGraph*>(&graph),vppm) )
@ -131,7 +132,7 @@ public:
If `VertexPointPMap` is the default of the class, an additional constructor
is available with `vppm` set to `boost::get(vertex_point, graph)`.
*/
AABB_face_graph_triangle_primitive(Id id, const FaceGraph& graph, VertexPointPMap vppm)
AABB_face_graph_triangle_primitive(Id id, const FaceGraph& graph, VertexPointPMap_ vppm)
: Base( Id_(id),
Triangle_property_map(const_cast<FaceGraph*>(&graph),vppm),
Point_property_map(const_cast<FaceGraph*>(&graph),vppm) )
@ -164,7 +165,7 @@ public:
static
typename Cstr_shared_data::Shared_data
construct_shared_data(const FaceGraph& graph, const VertexPointPMap& vpm)
construct_shared_data(const FaceGraph& graph, const VertexPointPMap_& vpm)
{
return Cstr_shared_data::construct_shared_data(const_cast<FaceGraph&>(graph), vpm);
}

View File

@ -31,6 +31,8 @@
#include <boost/type_traits/is_convertible.hpp>
#include <boost/utility/enable_if.hpp>
#include <CGAL/Default.h>
namespace CGAL {
@ -47,8 +49,9 @@ namespace CGAL {
* and `AABBPrimitiveWithSharedData` if `OneHalfedgeGraphPerTree` is `CGAL::Tag_true`.
*
* \tparam HalfedgeGraph is a model of the halfedge graph concept.
* \tparam VertexPointPMap is a property map with `boost::graph_traits<HalfedgeGraph>::%vertex_descriptor`
* as key type and a \cgal Kernel `Point_3` as value type.
* as key type and a \cgal Kernel `Point_3` as value type.
* \tparam VertexPointPMap is a property map with `boost::graph_traits<HalfedgeGraph>::%vertex_descriptor`.
* The default is `typename boost::property_map< HalfedgeGraph,vertex_point_t>::%type`.
* \tparam OneHalfedgeGraphPerTree is either `CGAL::Tag_true` or `CGAL::Tag_false`.
* In the former case, we guarantee that all the primitives will be from a
* common `HalfedgeGraph` and some data will be factorized so that the size of
@ -64,21 +67,31 @@ namespace CGAL {
* \sa \link BGLPolyGT `boost::graph_traits<Polyhedron>` \endlink
*/
template < class HalfedgeGraph,
class VertexPointPMap = typename boost::property_map< HalfedgeGraph, vertex_point_t>::type,
class VertexPointPMap = Default,
class OneHalfedgeGraphPerTree = Tag_true,
class CacheDatum = Tag_false >
class AABB_halfedge_graph_segment_primitive
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< typename boost::graph_traits<HalfedgeGraph>::edge_descriptor,
Segment_from_edge_descriptor_property_map<HalfedgeGraph,VertexPointPMap>,
Source_point_from_edge_descriptor<HalfedgeGraph,VertexPointPMap>,
Segment_from_edge_descriptor_property_map<
HalfedgeGraph,
typename Default::Get<VertexPointPMap,
typename boost::property_map< HalfedgeGraph,
vertex_point_t>::type >::type >,
Source_point_from_edge_descriptor<
HalfedgeGraph,
typename Default::Get<VertexPointPMap,
typename boost::property_map< HalfedgeGraph,
vertex_point_t>::type >::type >,
OneHalfedgeGraphPerTree,
CacheDatum >
#endif
{
typedef typename Default::Get<VertexPointPMap,typename boost::property_map< HalfedgeGraph,vertex_point_t>::type >::type VertexPointPMap_;
typedef typename boost::graph_traits<HalfedgeGraph>::edge_descriptor Id_;
typedef Segment_from_edge_descriptor_property_map<HalfedgeGraph,VertexPointPMap> Segment_property_map;
typedef Source_point_from_edge_descriptor<HalfedgeGraph,VertexPointPMap> Point_property_map;
typedef Segment_from_edge_descriptor_property_map<HalfedgeGraph,VertexPointPMap_> Segment_property_map;
typedef Source_point_from_edge_descriptor<HalfedgeGraph,VertexPointPMap_> Point_property_map;
typedef AABB_primitive< Id_,
Segment_property_map,
@ -122,7 +135,7 @@ public:
is available with `vppm` set to `boost::get(vertex_point, graph)`.
*/
template <class Iterator>
AABB_halfedge_graph_segment_primitive(Iterator it, const HalfedgeGraph& graph, VertexPointPMap vppm)
AABB_halfedge_graph_segment_primitive(Iterator it, const HalfedgeGraph& graph, VertexPointPMap_ vppm)
: Base( Id_(*it),
Segment_property_map(const_cast<HalfedgeGraph*>(&graph), vppm),
Point_property_map(const_cast<HalfedgeGraph*>(&graph), vppm) )
@ -133,7 +146,7 @@ public:
If `VertexPointPMap` is the default of the class, an additional constructor
is available with `vppm` set to `boost::get(vertex_point, graph)`.
*/
AABB_halfedge_graph_segment_primitive(Id id, const HalfedgeGraph& graph, VertexPointPMap vppm)
AABB_halfedge_graph_segment_primitive(Id id, const HalfedgeGraph& graph, VertexPointPMap_ vppm)
: Base( Id_(id),
Segment_property_map(const_cast<HalfedgeGraph*>(&graph), vppm),
Point_property_map(const_cast<HalfedgeGraph*>(&graph), vppm) )
@ -164,7 +177,7 @@ public:
static
typename Cstr_shared_data::Shared_data
construct_shared_data(const HalfedgeGraph& graph, const VertexPointPMap& vpm)
construct_shared_data(const HalfedgeGraph& graph, const VertexPointPMap_& vpm)
{
return Cstr_shared_data::construct_shared_data(const_cast<HalfedgeGraph&>(graph), vpm);
}

View File

@ -84,7 +84,7 @@ template < class HalfedgeGraph,
class VertexPointPMap >
struct Segment_from_edge_descriptor_property_map{
Segment_from_edge_descriptor_property_map()
Segment_from_edge_descriptor_property_map() : m_graph(NULL)
{}
Segment_from_edge_descriptor_property_map(HalfedgeGraph* g)
@ -126,9 +126,12 @@ Segment_from_edge_descriptor_property_map(HalfedgeGraph* g)
template <class FaceGraph,
class VertexPointPMap>
struct One_point_from_face_descriptor_property_map{
One_point_from_face_descriptor_property_map() : m_graph(NULL)
{}
One_point_from_face_descriptor_property_map(FaceGraph* g = NULL)
One_point_from_face_descriptor_property_map(FaceGraph* g)
: m_graph( const_cast<typename boost::remove_const<FaceGraph>::type*>(g) )
, m_vppm( get(vertex_point, *m_graph) )
{}
One_point_from_face_descriptor_property_map(FaceGraph* g, VertexPointPMap vppm )
@ -159,10 +162,12 @@ struct One_point_from_face_descriptor_property_map{
template < class HalfedgeGraph,
class VertexPointPMap >
struct Source_point_from_edge_descriptor{
Source_point_from_edge_descriptor(
HalfedgeGraph* g = NULL ) :
m_graph( const_cast<typename boost::remove_const<HalfedgeGraph>::type*>(g) ),
m_vppm( get(vertex_point, *m_graph) )
Source_point_from_edge_descriptor() : m_graph(NULL)
{}
Source_point_from_edge_descriptor(HalfedgeGraph* g)
: m_graph( const_cast<typename boost::remove_const<HalfedgeGraph>::type*>(g) )
, m_vppm( get(vertex_point, *m_graph) )
{}
Source_point_from_edge_descriptor(

View File

@ -81,6 +81,93 @@ join_face(typename boost::graph_traits<Graph>::halfedge_descriptor h,
/// \ingroup PkgBGLEulerOperations
/// @{
template<typename Graph, typename P>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_tetrahedron(Graph& g, const P& p0, const P& p1, const P& p2, const P& p3)
{
typedef typename boost::graph_traits<Graph> Traits;
typedef typename Traits::halfedge_descriptor halfedge_descriptor;
typedef typename Traits::vertex_descriptor vertex_descriptor;
typedef typename Traits::face_descriptor face_descriptor;
typedef typename boost::property_map<Graph,vertex_point_t>::type Point_property_map;
Point_property_map ppmap = get(CGAL::vertex_point, g);
vertex_descriptor v0, v1, v2, v3, v4;
v0 = add_vertex(g);
v1 = add_vertex(g);
v2 = add_vertex(g);
v3 = add_vertex(g);
ppmap[v0] = p0;
ppmap[v1] = p1;
ppmap[v2] = p2;
ppmap[v3] = p3;
halfedge_descriptor h0 = halfedge(add_edge(g),g);
halfedge_descriptor h1 = halfedge(add_edge(g),g);
halfedge_descriptor h2 = halfedge(add_edge(g),g);
set_next(h0, h1, g);
set_next(h1, h2, g);
set_next(h2, h0, g);
set_target(h0, v1, g);
set_target(h1, v2, g);
set_target(h2, v0, g);
set_halfedge(v1, h0, g);
set_halfedge(v2, h1, g);
set_halfedge(v0, h2, g);
face_descriptor f = add_face(g);
set_face(h0,f,g);
set_face(h1,f,g);
set_face(h2,f,g);
set_halfedge(f,h0,g);
h0 = opposite(h0,g);
h1 = opposite(h1,g);
h2 = opposite(h2,g);
set_target(h0, v0, g);
set_target(h1, v1, g);
set_target(h2, v2, g);
halfedge_descriptor h3 = halfedge(add_edge(g),g);
halfedge_descriptor h4 = halfedge(add_edge(g),g);
halfedge_descriptor h5 = halfedge(add_edge(g),g);
set_target(h3, v3, g);
set_target(h4, v3, g);
set_target(h5, v3, g);
set_halfedge(v3, h3, g);
set_next(h0, h3, g);
set_next(h1, h4, g);
set_next(h2, h5, g);
set_next(h3, opposite(h4,g), g);
set_next(h4, opposite(h5,g), g);
set_next(h5, opposite(h3,g), g);
set_next(opposite(h4,g), h0, g);
set_next(opposite(h5,g), h1, g);
set_next(opposite(h3,g), h2, g);
set_target(opposite(h3,g), v0, g);
set_target(opposite(h4,g), v1, g);
set_target(opposite(h5,g), v2, g);
f = add_face(g);
set_halfedge(f,h0,g);
set_face(h0, f, g);
set_face(h3, f, g);
set_face(opposite(h4,g), f, g);
f = add_face(g);
set_halfedge(f,h1,g);
set_face(h1, f, g);
set_face(h4, f, g);
set_face(opposite(h5,g), f, g);
f = add_face(g);
set_halfedge(f,h2,g);
set_face(h2, f, g);
set_face(h5, f, g);
set_face(opposite(h3,g), f, g);
return h0;
}
/**
* joins the two vertices incident to `h`, (that is `source(h, g)` and
* `target(h, g)`) and removes `source(h,g)`. Returns the predecessor

View File

@ -28,6 +28,8 @@
#include <CGAL/boost/graph/properties.h>
#include <boost/cstdint.hpp>
namespace CGAL {
template <typename Point>
@ -62,17 +64,17 @@ private:
template <typename K, typename VEF>
class SM_index_pmap : public boost::put_get_helper<int, SM_index_pmap<K,VEF> >
class SM_index_pmap : public boost::put_get_helper<boost::uint32_t, SM_index_pmap<K,VEF> >
{
public:
typedef boost::readable_property_map_tag category;
typedef unsigned int value_type;
typedef unsigned int reference;
typedef boost::uint32_t value_type;
typedef boost::uint32_t reference;
typedef VEF key_type;
value_type operator[](const key_type& vd) const
{
return (size_t)vd;
return vd;
}
};
@ -224,10 +226,10 @@ get(CGAL::vertex_point_t, const CGAL::Surface_mesh<K>& g) {
typename boost::graph_traits< CGAL::Surface_mesh<Point> >::TYPE x) \
{ return get(get(p, sm), x); } \
CGAL_SM_INTRINSIC_PROPERTY(std::size_t, boost::vertex_index_t, vertex_descriptor)
CGAL_SM_INTRINSIC_PROPERTY(std::size_t, boost::edge_index_t, edge_descriptor)
CGAL_SM_INTRINSIC_PROPERTY(std::size_t, boost::halfedge_index_t, halfedge_descriptor)
CGAL_SM_INTRINSIC_PROPERTY(std::size_t, boost::face_index_t, face_descriptor)
CGAL_SM_INTRINSIC_PROPERTY(boost::uint32_t, boost::vertex_index_t, vertex_descriptor)
CGAL_SM_INTRINSIC_PROPERTY(boost::uint32_t, boost::edge_index_t, edge_descriptor)
CGAL_SM_INTRINSIC_PROPERTY(boost::uint32_t, boost::halfedge_index_t, halfedge_descriptor)
CGAL_SM_INTRINSIC_PROPERTY(boost::uint32_t, boost::face_index_t, face_descriptor)
CGAL_SM_INTRINSIC_PROPERTY(Point&, CGAL::vertex_point_t, vertex_descriptor)
#undef CGAL_SM_INTRINSIC_PROPERTY

View File

@ -23,6 +23,7 @@
#include <CGAL/tuple.h>
#include <utility>
namespace CGAL {
/*!
@ -91,27 +92,4 @@ namespace CGAL {
}
} // namespace CGAL
#include <boost/range.hpp>
namespace boost {
template <typename T>
struct range_iterator<CGAL::Iterator_range<T> >
{
typedef T type;
};
template<typename T>
struct range_mutable_iterator< CGAL::Iterator_range<T> >
{
typedef T type;
};
template<typename T>
struct range_const_iterator< CGAL::Iterator_range<T> >
{
typedef T type;
};
}
#endif // CGAL_ITERATOR_RANGE_H

View File

@ -1,5 +1,3 @@
// Author(s) : Camille Wormser, Pierre Alliez
#include <iostream>
#include <CGAL/Simple_cartesian.h>
@ -7,6 +5,9 @@
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/boost/graph/graph_traits_Surface_mesh.h>
#include <CGAL/boost/graph/properties_Surface_mesh.h>
#include <CGAL/boost/graph/Euler_operations.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::Point_3 Point;
@ -28,11 +29,11 @@ int main()
Point r(0.0, 0.0, 1.0);
Point s(0.0, 0.0, 0.0);
Mesh m;
// m.make_tetrahedron(p, q, r, s);
CGAL::Euler::make_tetrahedron(m, p, q, r, s);
// constructs AABB tree
Tree tree(m.faces_begin(),m.faces_end(),m);
#if 0
Tree tree(faces(m).first, faces(m).second, m);
// constructs segment query
Point a(-0.2, 0.2, -0.2);
Point b(1.3, 0.2, 1.3);
@ -52,11 +53,13 @@ int main()
// (generally a point)
Segment_intersection intersection =
tree.any_intersection(segment_query);
if(intersection)
{
// gets intersection object
if(boost::get<Point>(&(intersection->first)))
std::cout << "intersection object is a point" << std::endl;
if(intersection){
// gets intersection object
if(boost::get<Point>(&(intersection->first))){
Point* p = boost::get<Point>(&(intersection->first));
std::cout << "intersection object is a point " << *p << std::endl;
std::cout << "with face "<< intersection->second << std::endl;
}
}
// computes all intersections with segment query (as pairs object - primitive_id)
@ -68,18 +71,20 @@ int main()
tree.all_intersected_primitives(segment_query, std::back_inserter(primitives));
// constructs plane query
Point base(0.0,0.0,0.5);
Vector vec(0.0,0.0,1.0);
Plane plane_query(a,vec);
Plane plane_query(base,vec);
// computes first encountered intersection with plane query
// (generally a segment)
Plane_intersection plane_intersection = tree.any_intersection(plane_query);
if(plane_intersection)
{
if(boost::get<Segment>(&(plane_intersection->first)))
std::cout << "intersection object is a segment" << std::endl;
if(plane_intersection){
if(boost::get<Segment>(&(plane_intersection->first))){
Segment* s = boost::get<Segment>(&(plane_intersection->first));
std::cout << "one intersection object is the segment " << s << std::endl;
std::cout << "with face "<< intersection->second << std::endl;
}
}
#endif
return EXIT_SUCCESS;
}