the segment and triangle primitive are now compatible with the former classes

even if they were not documented, they were used in examples
This commit is contained in:
Sébastien Loriot 2013-06-19 16:55:29 +02:00
parent caf3bdfac8
commit f395759b35
4 changed files with 53 additions and 46 deletions

View File

@ -17,7 +17,7 @@ typedef K::Segment_3 Segment;
typedef K::Triangle_3 Triangle;
typedef std::list<Segment>::iterator Iterator;
typedef CGAL::AABB_segment_primitive<Iterator> Primitive;
typedef CGAL::AABB_segment_primitive<K, Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;

View File

@ -17,7 +17,7 @@ typedef K::Point_3 Point;
typedef K::Triangle_3 Triangle;
typedef std::list<Triangle>::iterator Iterator;
typedef CGAL::AABB_triangle_primitive<Iterator> Primitive;
typedef CGAL::AABB_triangle_primitive<K, Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> AABB_triangle_traits;
typedef CGAL::AABB_tree<AABB_triangle_traits> Tree;

View File

@ -24,43 +24,45 @@
#define CGAL_AABB_SEGMENT_PRIMITIVE_H_
#include <CGAL/AABB_primitive.h>
#include <CGAL/Kernel_traits.h>
#include <CGAL/result_of.h>
#include <iterator>
namespace CGAL {
namespace internal {
template <class Iterator>
template <class GeomTraits, class Iterator>
struct Source_of_segment_3_iterator_property_map{
//classical typedefs
typedef typename CGAL::Kernel_traits< typename std::iterator_traits<Iterator>::value_type >::Kernel GeomTraits;
typedef Iterator key_type;
typedef typename GeomTraits::Point_3 value_type;
typedef const typename GeomTraits::Point_3& reference;
typedef typename cpp11::result_of<
typename GeomTraits::Construct_source_3(typename GeomTraits::Segment_3)
>::type reference;
typedef boost::readable_property_map_tag category;
};
//get function for property map
template <class Iterator>
inline
typename Source_of_segment_3_iterator_property_map<Iterator>::reference
get(Source_of_segment_3_iterator_property_map<Iterator>, Iterator it)
{
return it->source();
}
inline friend
typename Source_of_segment_3_iterator_property_map<GeomTraits,Iterator>::reference
get(Source_of_segment_3_iterator_property_map<GeomTraits,Iterator>, Iterator it)
{
return typename GeomTraits::Construct_source_3()( *it );
}
};
}//namespace internal
/*!
* \ingroup PkgAABB_tree
* Primitive type that uses as identifier an iterator with a 3D segment as `value_type`.
* The iterator from which the primitive is built should not be invalided
* The iterator from which the primitive is built should not be invalided
* while the AABB tree holding the primitive is in use.
*
* \cgalModels `AABBPrimitive`
*
* \tparam Iterator is a model of `ForwardIterator`, with `Segment_3<Kernel>`
* as value type
* \tparam GeomTraits is a traits class providing the nested type `Point_3` and `Segment_3`.
* It also provides the functor `Construct_source_3` that has an operator taking a `Segment_3`
* and returning its source as a type convertible to `Point_3`.
* In addition `Construct_source_3` must support the result_of protocol.
* \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Segment_3`
* \tparam cache_datum is either `CGAL::Tag_true` or `CGAL::Tag_false`. In the former case,
* the datum is stored in the primitive, while in the latter it is
* constructed on the fly to reduce the memory footprint.
@ -72,20 +74,21 @@ namespace internal {
* \sa `AABB_HalfedgeGraph_segment_primitive<HalfedgeGraph,OneHalfedgeGraphPerTree,cache_datum>`
* \sa `AABB_FaceGraph_triangle_primitive<FaceGraph,OneFaceGraphPerTree,cache_datum>`
*/
template < class Iterator,
template < class GeomTraits,
class Iterator,
class cache_datum=Tag_false>
class AABB_segment_primitive
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Source_of_segment_3_iterator_property_map<Iterator>,
internal::Source_of_segment_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
cache_datum >
#endif
{
typedef AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Source_of_segment_3_iterator_property_map<Iterator>,
internal::Source_of_segment_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
cache_datum > Base;
public:

View File

@ -24,42 +24,45 @@
#define CGAL_AABB_TRIANGLE_PRIMITIVE_H_
#include <CGAL/AABB_primitive.h>
#include <CGAL/property_map.h>
#include <CGAL/result_of.h>
#include <iterator>
namespace CGAL {
namespace internal {
template <class Iterator>
template <class GeomTraits, class Iterator>
struct Point_from_triangle_3_iterator_property_map{
//classical typedefs
typedef typename CGAL::Kernel_traits< typename std::iterator_traits<Iterator>::value_type >::Kernel GeomTraits;
typedef Iterator key_type;
typedef typename GeomTraits::Point_3 value_type;
typedef const typename GeomTraits::Point_3& reference;
typedef typename cpp11::result_of<
typename GeomTraits::Construct_vertex_3(typename GeomTraits::Triangle_3,int)
>::type reference;
typedef boost::readable_property_map_tag category;
};
//get function for property map
template <class Iterator>
inline
typename Point_from_triangle_3_iterator_property_map<Iterator>::reference
get(Point_from_triangle_3_iterator_property_map<Iterator>,Iterator it)
{
return it->vertex(0);
}
inline friend
typename Point_from_triangle_3_iterator_property_map<GeomTraits,Iterator>::reference
get(Point_from_triangle_3_iterator_property_map<GeomTraits,Iterator>, Iterator it)
{
return typename GeomTraits::Construct_vertex_3()( *it, 0 );
}
};
}//namespace internal
/*!
* \ingroup PkgAABB_tree
* Primitive type that uses as identifier an iterator with a 3D triangle as `value_type`.
* The iterator from which the primitive is built should not be invalided
* The iterator from which the primitive is built should not be invalided
* while the AABB tree holding the primitive is in use.
*
* \cgalModels `AABBPrimitive`
*
* \tparam Iterator is a model of `ForwardIterator`, with `Triangle_3<Kernel>`
* as value type
* \tparam GeomTraits is a traits class providing the nested type `Point_3` and `Triangle_3`.
* It also provides the functor `Construct_vertex_3` that has an operator taking a `Triangle_3`
* and an integer as parameters and returning a triangle point as a type convertible to `Point_3`.
* In addition `Construct_vertex_3` must support the result_of protocol.
* \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Triangle_3`
* \tparam cache_datum is either `CGAL::Tag_true` or `CGAL::Tag_false`. In the former case,
* the datum is stored in the primitive, while in the latter it is
* constructed on the fly to reduce the memory footprint.
@ -71,24 +74,25 @@ namespace internal {
* \sa `AABB_HalfedgeGraph_segment_primitive<HalfedgeGraph,OneHalfedgeGraphPerTree,cache_datum>`
* \sa `AABB_FaceGraph_triangle_primitive<FaceGraph,OneFaceGraphPerTree,cache_datum>`
*/
template < class Iterator,
template < class GeomTraits,
class Iterator,
class cache_datum=Tag_false>
class AABB_triangle_primitive
class AABB_triangle_primitive
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Point_from_triangle_3_iterator_property_map<Iterator>,
Tag_false,
cache_datum >
: public AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Point_from_triangle_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
cache_datum >
#endif
{
typedef AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Point_from_triangle_3_iterator_property_map<Iterator>,
internal::Point_from_triangle_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
cache_datum > Base;
public:
// constructors
///Constructor from an iterator
AABB_triangle_primitive(Iterator it) : Base(it){}
};