added vertex point map

This commit is contained in:
Sven Oesau 2024-03-27 14:43:39 +01:00
parent f0d32fe869
commit 30d5ca75ee
2 changed files with 46 additions and 20 deletions

View File

@ -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<typename PointRange::value_type>`.
* The default is `Identity_property_map<typename PointRange::value_type>`.
*
* \sa `AABBPrimitive`
* \sa `AABB_primitive<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`

View File

@ -24,16 +24,16 @@
namespace CGAL {
namespace internal {
template <class GeomTraits, class Iterator>
template <class GeomTraits, class Iterator, class PointMap>
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<GeomTraits, Iterator> Self;
typedef Segment_2_from_point_iterator_property_map<GeomTraits, Iterator, PointMap> 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 <class GeomTraits, class Iterator, class PointMap>
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<GeomTraits, Iterator, PointMap> 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<typename PointRange::value_type>`.
*
* \sa `AABBPrimitive`
* \sa `AABB_primitive<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
@ -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<typename PointRange::value_type>>
class AABB_polyline_segment_primitive_2
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< Iterator,
internal::Segment_2_from_point_iterator_property_map<GeomTraits, Iterator>,
Input_iterator_property_map<Iterator>,
internal::Segment_2_from_point_iterator_property_map<GeomTraits, Iterator, PointMap>,
internal::Point_from_iterator_property_map<GeomTraits, Iterator, PointMap>,
Tag_true,
CacheDatum >
#endif
{
typedef AABB_primitive< Iterator,
internal::Segment_2_from_point_iterator_property_map<GeomTraits, Iterator>,
Input_iterator_property_map<Iterator>,
internal::Segment_2_from_point_iterator_property_map<GeomTraits, Iterator, PointMap>,
internal::Point_from_iterator_property_map<GeomTraits, Iterator, PointMap>,
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<GeomTraits, Iterator>(range.begin(), range.end()), Input_iterator_property_map<Iterator>());
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<GeomTraits, Iterator, PointMap>(range.begin(), range.end(), pmap), internal::Point_from_iterator_property_map<GeomTraits, Iterator, PointMap>(pmap));
}
};