diff --git a/AABB_tree/include/CGAL/AABB_triangle_primitive_2.h b/AABB_tree/include/CGAL/AABB_triangle_primitive_2.h new file mode 100644 index 00000000000..393d8517cff --- /dev/null +++ b/AABB_tree/include/CGAL/AABB_triangle_primitive_2.h @@ -0,0 +1,101 @@ +// Copyright (c) 2012 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Sebastien Loriot +// + + +#ifndef CGAL_AABB_TRIANGLE_PRIMITIVE_2_H_ +#define CGAL_AABB_TRIANGLE_PRIMITIVE_2_H_ + +#include + +#include + +#include +#include + +namespace CGAL { + +namespace internal { + template + struct Point_from_triangle_2_iterator_property_map{ + //classical typedefs + typedef Iterator key_type; + typedef typename GeomTraits::Point_2 value_type; + // typedef decltype( + // std::declval()( + // std::declval(), + // std::declval())) reference; + typedef decltype( + typename GeomTraits::Construct_vertex_2()( + *std::declval(), 0)) reference; + typedef boost::readable_property_map_tag category; + typedef Point_from_triangle_2_iterator_property_map Self; + + inline friend reference + get(Self, key_type it) + { + return typename GeomTraits::Construct_vertex_2()( *it, 0 ); + } + }; +}//namespace internal + + +/*! + * \ingroup PkgAABBTreeRef + * 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 + * while the AABB tree holding the primitive is in use. + * + * \cgalModels{AABBPrimitive} + * + * \tparam GeomTraits is a traits class providing the nested type `Point_2` and `Triangle_2`. + * It also provides the functor `Construct_vertex_2` that has an operator taking a `Triangle_2` + * and an integer as parameters and returning a triangle point as a type convertible to `Point_2`. + * \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Triangle_2` + * \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). + * + * \sa `AABBPrimitive` + * \sa `AABB_primitive` + * \sa `AABB_segment_primitive_2` + * \sa `AABB_halfedge_graph_segment_primitive` + * \sa `AABB_face_graph_triangle_primitive` + */ +template < class GeomTraits, + class Iterator, + class CacheDatum=Tag_false> +class AABB_triangle_primitive_2 +#ifndef DOXYGEN_RUNNING + : public AABB_primitive< Iterator, + Input_iterator_property_map, + internal::Point_from_triangle_2_iterator_property_map, + Tag_false, + CacheDatum > +#endif +{ + typedef AABB_primitive< Iterator, + Input_iterator_property_map, + internal::Point_from_triangle_2_iterator_property_map, + Tag_false, + CacheDatum > Base; +public: + ///constructor from an iterator + AABB_triangle_primitive_2(Iterator it) : Base(it){} +}; + +} // end namespace CGAL + +#include + +#endif // CGAL_AABB_TRIANGLE_PRIMITIVE_2_H_ diff --git a/AABB_tree/include/CGAL/AABB_triangle_primitive_3.h b/AABB_tree/include/CGAL/AABB_triangle_primitive_3.h index 569e579f12b..8c1116f4510 100644 --- a/AABB_tree/include/CGAL/AABB_triangle_primitive_3.h +++ b/AABB_tree/include/CGAL/AABB_triangle_primitive_3.h @@ -68,7 +68,7 @@ namespace internal { * * \sa `AABBPrimitive` * \sa `AABB_primitive` - * \sa `AABB_segment_primitive` + * \sa `AABB_segment_primitive_3` * \sa `AABB_halfedge_graph_segment_primitive` * \sa `AABB_face_graph_triangle_primitive` */ @@ -99,4 +99,3 @@ public: #include #endif // CGAL_AABB_TRIANGLE_PRIMITIVE_3_H_ - diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index 6da8fab4046..f0b5b7fa5ff 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3279,6 +3279,7 @@ namespace CartesianKernelFunctors { typedef typename K::Point_2 Point_2; typedef typename K::Line_2 Line_2; typedef typename K::Segment_2 Segment_2; + typedef typename K::Triangle_2 Triangle_2; public: typedef Point_2 result_type; @@ -3299,6 +3300,12 @@ namespace CartesianKernelFunctors { // CommonKernelFunctors::Construct_projected_point_3()(s,p,K()); } + Point_2 + operator()( const Triangle_2& t, const Point_2& p ) const + { + assert(false); + return p; + } };