diff --git a/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h b/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h index 61ad6ae95eb..d5e0359fdc8 100644 --- a/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h @@ -85,11 +85,11 @@ namespace internal { * \tparam IndexIterator is a model of `ForwardIterator` with its value type being a `RandomAccessRange` of size 3 with an index type as `value_type`, e.g., `uint8_t`, `uint16_t` or int. * \tparam PointRange is a model of `RandomAccessRange`. Its value type needs to be compatible to PointMap or `Point_2` in the default case. * \tparam CacheDatum 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. - * The default is `CGAL::Tag_false` (datum is not stored). + * the datum is stored in the primitive, while in the latter it is + * constructed on the fly to reduce the memory footprint. + * The default is `CGAL::Tag_false` (datum is not stored). * \tparam PointMap is a model of `ReadablePropertyMap` with its key type being the value type of `PointRange` and the value type being a `Point_2`. - The default is `Identity_property_map`. + * The default is `Identity_property_map`. * * \sa `AABBPrimitive` * \sa `AABB_primitive` diff --git a/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h b/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h index 660da7d5533..7022478a1ff 100644 --- a/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h @@ -24,16 +24,16 @@ namespace CGAL { namespace internal { - template + template struct Segment_2_from_point_iterator_property_map { //classical typedefs typedef Iterator key_type; typedef typename GeomTraits::Segment_2 value_type; typedef typename GeomTraits::Segment_2 reference; // The segments are created on the fly, so working with references is not possible. typedef boost::readable_property_map_tag category; - typedef Segment_2_from_point_iterator_property_map Self; + typedef Segment_2_from_point_iterator_property_map Self; - Segment_2_from_point_iterator_property_map(Iterator b, Iterator e) : begin(b), end(e) {} + Segment_2_from_point_iterator_property_map(Iterator b, Iterator e, PointMap& pmap) : begin(b), end(e), pmap(pmap) {} Segment_2_from_point_iterator_property_map() {} inline friend reference // Cannot return reference as the Segment does not exist, only the points exist. @@ -41,12 +41,35 @@ namespace internal { { Iterator it2 = std::next(it); if (it2 == s.end) - return typename GeomTraits::Construct_segment_2()(*it, *s.begin); + return typename GeomTraits::Construct_segment_2()(get(s.pmap, *it), get(s.pmap, *s.begin)); else - return typename GeomTraits::Construct_segment_2()(*it, *it2 ); + return typename GeomTraits::Construct_segment_2()(get(s.pmap, *it), get(s.pmap, *it2)); } Iterator begin, end; + PointMap pmap; + }; + + template + struct Point_from_iterator_property_map { + //classical typedefs + typedef Iterator key_type; + typedef typename PointMap::value_type value_type; + typedef const value_type reference; + + typedef boost::readable_property_map_tag category; + typedef Point_from_iterator_property_map Self; + + Point_from_iterator_property_map() {} + Point_from_iterator_property_map(PointMap& pmap) : pmap(pmap) {} + + inline friend reference + get(Self s, key_type it) + { + return get(s.pmap, *it); + } + + PointMap pmap; }; }//namespace internal @@ -64,11 +87,13 @@ namespace internal { * It also provides the functor `Construct_segment_2` that has an operator taking two `Point_2` * and returning a `Segment_2`. * \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Point_2` - * \tparam PointRange is a model of `ForwardRange` with its value type convertible to `GeomTraits::Point_2` + * \tparam PointRange is a model of `ConstRange`. Its value type needs to be compatible to PointMap or `Point_2` in the default case. * \tparam CacheDatum 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. - * The default is `CGAL::Tag_false` (datum is not stored). + * the datum is stored in the primitive, while in the latter it is + * constructed on the fly to reduce the memory footprint. + * The default is `CGAL::Tag_false` (datum is not stored). + * \tparam PointMap is a model of `ReadablePropertyMap` with its key type being the value type of `PointRange` and the value type being a `Point_2`. + * The default is `Identity_property_map`. * * \sa `AABBPrimitive` * \sa `AABB_primitive` @@ -82,27 +107,28 @@ namespace internal { template < class GeomTraits, class Iterator, class PointRange, - class CacheDatum=Tag_false> + class CacheDatum = Tag_false, + class PointMap = Identity_property_map> class AABB_polyline_segment_primitive_2 #ifndef DOXYGEN_RUNNING : public AABB_primitive< Iterator, - internal::Segment_2_from_point_iterator_property_map, - Input_iterator_property_map, + internal::Segment_2_from_point_iterator_property_map, + internal::Point_from_iterator_property_map, Tag_true, CacheDatum > #endif { typedef AABB_primitive< Iterator, - internal::Segment_2_from_point_iterator_property_map, - Input_iterator_property_map, + internal::Segment_2_from_point_iterator_property_map, + internal::Point_from_iterator_property_map, Tag_true, CacheDatum > Base; public: AABB_polyline_segment_primitive_2(Iterator it, PointRange& poly) : Base(it) {} /// \internal - static typename Base::Shared_data construct_shared_data(PointRange& range) { - return std::make_pair(internal::Segment_2_from_point_iterator_property_map(range.begin(), range.end()), Input_iterator_property_map()); + static typename Base::Shared_data construct_shared_data(PointRange& range, PointMap pmap = PointMap()) { + return std::make_pair(internal::Segment_2_from_point_iterator_property_map(range.begin(), range.end(), pmap), internal::Point_from_iterator_property_map(pmap)); } };