From 006d46b1d4cc8188992a04d06fb23020cd70d0d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 4 Mar 2024 12:54:59 +0100 Subject: [PATCH 001/100] start updating the AABB-tree to work in both 2D and 3D --- .../{AABBGeomTraits.h => AABBGeomTraits_3.h} | 10 +- .../Concepts/AABBRayIntersectionGeomTraits.h | 28 +- AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h | 25 +- .../doc/AABB_tree/PackageDescription.txt | 19 +- AABB_tree/doc/AABB_tree/aabb_tree.txt | 2 +- ...primitive.h => AABB_segment_primitive_3.h} | 0 AABB_tree/include/CGAL/AABB_traits.h | 524 +---------------- AABB_tree/include/CGAL/AABB_traits_3.h | 539 ++++++++++++++++++ AABB_tree/include/CGAL/AABB_tree.h | 6 +- ...rimitive.h => AABB_triangle_primitive_3.h} | 0 10 files changed, 595 insertions(+), 558 deletions(-) rename AABB_tree/doc/AABB_tree/Concepts/{AABBGeomTraits.h => AABBGeomTraits_3.h} (93%) rename AABB_tree/include/CGAL/{AABB_segment_primitive.h => AABB_segment_primitive_3.h} (100%) create mode 100644 AABB_tree/include/CGAL/AABB_traits_3.h rename AABB_tree/include/CGAL/{AABB_triangle_primitive.h => AABB_triangle_primitive_3.h} (100%) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h similarity index 93% rename from AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits.h rename to AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h index ca49f3ab247b..e235a5e871fb 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h @@ -3,8 +3,8 @@ \ingroup PkgAABBTreeConcepts \cgalConcept -The concept `AABBGeomTraits` defines the requirements for the first template parameter of the class -`CGAL::AABB_traits`. It provides predicates and constructors to detect +The concept `AABBGeomTraits_3` defines the requirements for the first template parameter of the class +`CGAL::AABB_traits`. It provides predicates and constructors to detect and compute intersections between query objects and the primitives stored in the AABB tree. In addition, it contains predicates and constructors to compute distances between a point query and the primitives stored in the AABB tree. @@ -15,13 +15,13 @@ and the primitives stored in the AABB tree. \cgalHasModelsBare{All models of the concept `Kernel`} \cgalHasModelsEnd -\sa `CGAL::AABB_traits` +\sa `CGAL::AABB_traits` \sa `CGAL::AABB_tree` \sa `AABBPrimitive` */ -class AABBGeomTraits { +class AABBGeomTraits_3 { public: /// \name Types @@ -199,5 +199,5 @@ Equal_3 equal_3_object(); /// @} -}; /* end AABBGeomTraits */ +}; /* end AABBGeomTraits_3 */ diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits.h index c34d88be491e..b29abd3b645f 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits.h @@ -21,46 +21,48 @@ define the Intersection_distance functor. class AABBRayIntersectionGeomTraits { public: /*! - Type of a 3D ray. + Type of a ray. */ - typedef unspecified_type Ray_3; + typedef unspecified_type Ray; /*! - Type of a 3D vector. + Type of a vector. */ - typedef unspecified_type Vector_3; + typedef unspecified_type Vector; /*! A functor object to construct the source point of a ray. Provides the operator: - `Point_3 operator()(const Ray_3&);` + `Point operator()(const Ray&);` */ - typedef unspecified_type Construct_source_3; + typedef unspecified_type Construct_source; /*! */ - Construct_source_3 construct_source_3_object(); + Construct_source construct_source_object(); /*! + @todo update me A model of `CartesianConstIterator3`. */ - typedef unspecified_type Cartesian_const_iterator_3; + typedef unspecified_type Cartesian_const_iterator; /*! + @todo update me A model of `ConstructCartesianConstIterator3`. */ - typedef unspecified_type Construct_cartesian_const_iterator_3; + typedef unspecified_type Construct_cartesian_const_iterator; /*! */ - Construct_source_3 construct_cartesian_const_iterator_3_object(); + Construct_source construct_cartesian_const_iterator_object(); /*! A functor object to construct a vector giving the direction of a ray. Provides the operator: - `Vector_3 operator()(const Ray_3&);` + `Vector operator()(const Ray&);` */ - typedef unspecified_type Construct_vector_3; + typedef unspecified_type Construct_vector; /*! */ - Construct_source_3 construct_vector_3_object(); + Construct_source construct_vector_object(); }; diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h index 3c101a2211b7..685ce425d668 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h @@ -9,7 +9,7 @@ The concept `AABBTraits` provides the geometric primitive types and methods for \cgalHasModels{CGAL::AABB_traits} \cgalHasModelsEnd -\cgalRefines{SearchGeomTraits_3} +\cgalRefines{SearchTraits} \sa `CGAL::AABB_traits` \sa `CGAL::AABB_tree` @@ -30,7 +30,7 @@ typedef unspecified_type FT; /*! Type of a 3D point. */ -typedef unspecified_type Point_3; +typedef unspecified_type Point; /*! Type of primitive. @@ -43,19 +43,10 @@ Bounding box type. */ typedef unspecified_type Bounding_box; - /*! - enum required for axis selection - */ - enum Axis { - CGAL_X_AXIS, - CGAL_Y_AXIS, - CGAL_Z_AXIS - }; - /*! 3D Point and Primitive Id type */ -typedef std::pair Point_and_primitive_id; +typedef std::pair Point_and_primitive_id; /*! \deprecated @@ -145,21 +136,21 @@ typedef unspecified_type Compare_distance; /*! A functor object to compute closest point from the query on a primitive. Provides the operator: -`Point_3 operator()(const Query& query, const Primitive& primitive, const Point_3 & closest);` which returns the closest point to `query`, among `closest` and all points of the primitive. +`Point operator()(const Query& query, const Primitive& primitive, const Point & closest);` which returns the closest point to `query`, among `closest` and all points of the primitive. */ typedef unspecified_type Closest_point; /*! A functor object to compute the squared distance between two points. Provides the operator: -`FT operator()(const Point& query, const Point_3 & p);` which returns the squared distance between `p` and `q`. +`FT operator()(const Point& query, const Point & p);` which returns the squared distance between `p` and `q`. */ typedef unspecified_type Squared_distance; /*! A functor object to compare two points. Provides the operator: -`bool operator()(const Point_3& p, const Point_3& q);}` which returns `true` if `p` is equal to `q`. +`bool operator()(const Point& p, const Point& q);}` which returns `true` if `p` is equal to `q`. */ -typedef unspecified_type Equal_3; +typedef unspecified_type Equal; /// @} /// \name Operations @@ -203,7 +194,7 @@ Squared_distance squared_distance_object(); /*! returns the equal functor. */ -Equal_3 equal_3_object(); +Equal equal_object(); /// @} diff --git a/AABB_tree/doc/AABB_tree/PackageDescription.txt b/AABB_tree/doc/AABB_tree/PackageDescription.txt index c032420bb769..c53fc291f7ea 100644 --- a/AABB_tree/doc/AABB_tree/PackageDescription.txt +++ b/AABB_tree/doc/AABB_tree/PackageDescription.txt @@ -5,12 +5,12 @@ /*! \addtogroup PkgAABBTreeRef -\cgalPkgDescriptionBegin{3D Fast Intersection and Distance Computation,PkgAABBTree} +\cgalPkgDescriptionBegin{Fast Intersection and Distance Computation,PkgAABBTree} \cgalPkgPicture{aabb-teaser-thumb.png} \cgalPkgSummaryBegin \cgalPkgAuthors{Pierre Alliez, Stéphane Tayeb, and Camille Wormser} \cgalPkgDesc{The AABB (axis-aligned bounding box) tree component offers a static data structure and algorithms to perform efficient intersection and distance queries on sets of finite 3D geometric objects.} -\cgalPkgManuals{Chapter_3D_Fast_Intersection_and_Distance_Computation,PkgAABBTreeRef} +\cgalPkgManuals{Chapter_Fast_Intersection_and_Distance_Computation,PkgAABBTreeRef} \cgalPkgSummaryEnd \cgalPkgShortInfoBegin \cgalPkgSince{3.5} @@ -25,18 +25,23 @@ \cgalCRPSection{Concepts} - `AABBPrimitive` - `AABBPrimitiveWithSharedData` -- `AABBGeomTraits` +- `AABBGeomTraits_2` +- `AABBGeomTraits_3` - `AABBTraits` -- `AABBRayIntersectionGeomTraits` +- `AABBRayIntersectionGeomTraits_2` +- `AABBRayIntersectionGeomTraits_3` - `AABBRayIntersectionTraits` \cgalCRPSection{Classes} -- `CGAL::AABB_traits` +- `CGAL::AABB_traits_2` +- `CGAL::AABB_traits_3` - `CGAL::AABB_tree` \cgalCRPSection{Primitives} -- `CGAL::AABB_triangle_primitive` -- `CGAL::AABB_segment_primitive` +- `CGAL::AABB_triangle_primitive_2` +- `CGAL::AABB_segment_primitive_2` +- `CGAL::AABB_triangle_primitive_3` +- `CGAL::AABB_segment_primitive_3` - `CGAL::AABB_primitive` - `CGAL::AABB_halfedge_graph_segment_primitive` - `CGAL::AABB_face_graph_triangle_primitive` diff --git a/AABB_tree/doc/AABB_tree/aabb_tree.txt b/AABB_tree/doc/AABB_tree/aabb_tree.txt index bdeefbdd0323..fcba3e318aae 100644 --- a/AABB_tree/doc/AABB_tree/aabb_tree.txt +++ b/AABB_tree/doc/AABB_tree/aabb_tree.txt @@ -3,7 +3,7 @@ namespace CGAL { /*! \mainpage User Manual -\anchor Chapter_3D_Fast_Intersection_and_Distance_Computation +\anchor Chapter_Fast_Intersection_and_Distance_Computation \cgalAutoToc \authors Pierre Alliez, Stephane Tayeb, and Camille Wormser diff --git a/AABB_tree/include/CGAL/AABB_segment_primitive.h b/AABB_tree/include/CGAL/AABB_segment_primitive_3.h similarity index 100% rename from AABB_tree/include/CGAL/AABB_segment_primitive.h rename to AABB_tree/include/CGAL/AABB_segment_primitive_3.h diff --git a/AABB_tree/include/CGAL/AABB_traits.h b/AABB_tree/include/CGAL/AABB_traits.h index f7d52f9968ca..c991aa32c77a 100644 --- a/AABB_tree/include/CGAL/AABB_traits.h +++ b/AABB_tree/include/CGAL/AABB_traits.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 INRIA Sophia-Antipolis (France). +// Copyright (c) 2024 INRIA Sophia-Antipolis (France). // All rights reserved. // // This file is part of CGAL (www.cgal.org). @@ -14,524 +14,24 @@ #ifndef CGAL_AABB_TRAITS_H_ #define CGAL_AABB_TRAITS_H_ -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - - -#include - -/// \file AABB_traits.h - -namespace CGAL { - -namespace internal{ namespace AABB_tree { - -template -struct Remove_optional { typedef T type; }; - -template -struct Remove_optional< ::std::optional > { typedef T type; }; - -//helper controlling whether extra data should be stored in the AABB_tree traits class -template ::value> -struct AABB_traits_base; - -template -struct AABB_traits_base{}; - -template -struct AABB_traits_base{ - typename Primitive::Shared_data m_primitive_data; - - template - void set_shared_data(T&& ... t){ - m_primitive_data=Primitive::construct_shared_data(std::forward(t)...); - } - const typename Primitive::Shared_data& shared_data() const {return m_primitive_data;} -}; - -// AABB_traits_base_2 brings in the Intersection_distance predicate, -// if GeomTraits is a model RayIntersectionGeomTraits. -template ::value> -struct AABB_traits_base_2; - -template -struct AABB_traits_base_2{}; - -template -struct AABB_traits_base_2{ - typedef typename GeomTraits::Ray_3 Ray_3; - typedef typename GeomTraits::Point_3 Point_3; - typedef typename GeomTraits::Vector_3 Vector_3; - typedef typename GeomTraits::FT FT; - typedef typename GeomTraits::Cartesian_const_iterator_3 Cartesian_const_iterator_3; - typedef typename GeomTraits::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator_3; - typedef typename GeomTraits::Construct_source_3 Construct_source_3; - typedef typename GeomTraits::Construct_vector_3 Construct_vector_3; - - // Defining Bounding_box and other types from the full AABB_traits - // here is might seem strange, but otherwise we would need to use - // CRTP to get access to the derived class, which would bloat the - // code more. - typedef typename CGAL::Bbox_3 Bounding_box; - - struct Intersection_distance { - std::optional operator()(const Ray_3& ray, const Bounding_box& bbox) const { - FT t_near = -DBL_MAX; // std::numeric_limits::lowest(); C++1903 - FT t_far = DBL_MAX; - - const Construct_cartesian_const_iterator_3 construct_cartesian_const_iterator_3 - = GeomTraits().construct_cartesian_const_iterator_3_object(); - const Construct_source_3 construct_source_3 = GeomTraits().construct_source_3_object(); - const Construct_vector_3 construct_vector_3 = GeomTraits().construct_vector_3_object(); - const Point_3 source = construct_source_3(ray); - const Vector_3 direction = construct_vector_3(ray); - Cartesian_const_iterator_3 source_iter = construct_cartesian_const_iterator_3(source); - Cartesian_const_iterator_3 direction_iter = construct_cartesian_const_iterator_3(direction); - - for(int i = 0; i < 3; ++i, ++source_iter, ++direction_iter) { - if(*direction_iter == 0) { - if((*source_iter < (bbox.min)(i)) || (*source_iter > (bbox.max)(i))) { - return std::nullopt; - } - } else { - FT t1 = ((bbox.min)(i) - *source_iter) / *direction_iter; - FT t2 = ((bbox.max)(i) - *source_iter) / *direction_iter; - - t_near = (std::max)(t_near, (std::min)(t1, t2)); - t_far = (std::min)(t_far, (std::max)(t1, t2)); - - // if(t1 > t2) - // std::swap(t1, t2); - // if(t1 > t_near) - // t_near = t1; - // if(t2 < t_far) - // t_far = t2; - - if(t_near > t_far || t_far < FT(0.)) - return std::nullopt; - } - } - - if(t_near < FT(0.)) - return FT(0.); - else - return t_near; - } - }; - - Intersection_distance intersection_distance_object() const { return Intersection_distance(); } -}; - -} } //end of namespace internal::AABB_tree - -/// \addtogroup PkgAABBTreeRef -/// @{ - -// forward declaration -template< typename AABBTraits> -class AABB_tree; - - -/// This traits class handles any type of 3D geometric -/// primitives provided that the proper intersection tests and -/// constructions are implemented. It handles points, rays, lines and -/// segments as query types for intersection detection and -/// computations, and it handles points as query type for distance -/// queries. -/// -/// \cgalModels{AABBTraits,AABBRayIntersectionTraits} -/// -/// \tparam GeomTraits must be a model of the concept \ref AABBGeomTraits, -/// and provide the geometric types as well as the intersection tests and computations. -/// \tparam Primitive provide the type of primitives stored in the AABB_tree. -/// It is a model of the concept `AABBPrimitive` or `AABBPrimitiveWithSharedData`. -/// -/// \tparam BboxMap must be a model of `ReadablePropertyMap` that has as key type a primitive id, -/// and as value type a `Bounding_box`. -/// If the type is `Default` the `Datum` must have the -/// member function `bbox()` that returns the bounding box of the primitive. -/// -/// If the argument `GeomTraits` is a model of the concept \ref -/// AABBRayIntersectionGeomTraits, this class is also a model of \ref -/// AABBRayIntersectionTraits. -/// -/// \sa `AABBTraits` -/// \sa `AABB_tree` -/// \sa `AABBPrimitive` -/// \sa `AABBPrimitiveWithSharedData` - - template -class AABB_traits -#ifndef DOXYGEN_RUNNING -: public internal::AABB_tree::AABB_traits_base, - public internal::AABB_tree::AABB_traits_base_2 -#endif -{ - typedef typename CGAL::Object Object; -public: - typedef GeomTraits Geom_traits; - - typedef AABB_traits AT; - // AABBTraits concept types - typedef typename GeomTraits::FT FT; - typedef AABBPrimitive Primitive; - - typedef typename std::pair Object_and_primitive_id; - - typedef typename std::pair Point_and_primitive_id; - - /// `Intersection_and_primitive_id::%Type::first_type` is found according to - /// the result type of `GeomTraits::Intersect_3::operator()`. If it is - /// `std::optional` then it is `T`, and the result type otherwise. - template - struct Intersection_and_primitive_id { - typedef decltype( - std::declval()( - std::declval(), - std::declval())) Intersection_type; - - typedef std::pair< - typename internal::AABB_tree::Remove_optional::type, - typename Primitive::Id > Type; - }; - - // types for search tree - /// \name Types - /// @{ - - /// Point query type. - typedef typename GeomTraits::Point_3 Point_3; - - /// additional types for the search tree, required by the RangeSearchTraits concept - /// \bug This is not documented for now in the AABBTraits concept. - typedef typename GeomTraits::Iso_cuboid_3 Iso_cuboid_3; - - /// Bounding box type. - typedef typename CGAL::Bbox_3 Bounding_box; +#define CGAL_DEPRECATED_HEADER "" +#define CGAL_REPLACEMENT_HEADER "" +#include - /// @} +#ifndef CGAL_NO_DEPRECATED_CODE - typedef typename GeomTraits::Sphere_3 Sphere_3; - typedef typename GeomTraits::Cartesian_const_iterator_3 Cartesian_const_iterator_3; - typedef typename GeomTraits::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator_3; - typedef typename GeomTraits::Construct_center_3 Construct_center_3; - typedef typename GeomTraits::Compute_squared_radius_3 Compute_squared_radius_3; - typedef typename GeomTraits::Construct_min_vertex_3 Construct_min_vertex_3; - typedef typename GeomTraits::Construct_max_vertex_3 Construct_max_vertex_3; - typedef typename GeomTraits::Construct_iso_cuboid_3 Construct_iso_cuboid_3; - - BboxMap bbm; - - /// Default constructor. - AABB_traits() { } - - AABB_traits(BboxMap bbm) - : bbm(bbm) - {} - - - typedef typename GeomTraits::Compute_squared_distance_3 Squared_distance; - Squared_distance squared_distance_object() const { return GeomTraits().compute_squared_distance_3_object(); } - - typedef typename GeomTraits::Equal_3 Equal_3; - Equal_3 equal_3_object() const { return GeomTraits().equal_3_object(); } - - /** - * @internal - * @brief Sorts [first,beyond[ - * @param first iterator on first element - * @param beyond iterator on beyond element - * @param bbox the bounding box of [first,beyond[ - * - * Sorts the range defined by [first,beyond[. Sort is achieved on bbox longest - * axis, using the comparison function `_less_than` (dim in {x,y,z}) - */ - class Split_primitives - { - typedef AABB_traits Traits; - const Traits& m_traits; - public: - Split_primitives(const AABB_traits& traits) - : m_traits(traits) {} - - typedef void result_type; - template - void operator()(PrimitiveIterator first, - PrimitiveIterator beyond, - const typename AT::Bounding_box& bbox) const - { - PrimitiveIterator middle = first + (beyond - first)/2; - switch(Traits::longest_axis(bbox)) - { - case AT::CGAL_AXIS_X: // sort along x - std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_x(p1, p2, this->m_traits); }); - break; - case AT::CGAL_AXIS_Y: // sort along y - std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_y(p1, p2, this->m_traits); }); - break; - case AT::CGAL_AXIS_Z: // sort along z - std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_z(p1, p2, this->m_traits); }); - break; - default: - CGAL_error(); - } - } - }; - - Split_primitives split_primitives_object() const {return Split_primitives(*this);} - - - /* - * Computes the bounding box of a set of primitives - * @param first an iterator on the first primitive - * @param beyond an iterator on the past-the-end primitive - * @return the bounding box of the primitives of the iterator range - */ - class Compute_bbox { - const AABB_traits& m_traits; - public: - Compute_bbox(const AABB_traits& traits) - :m_traits (traits) {} - - template - typename AT::Bounding_box operator()(ConstPrimitiveIterator first, - ConstPrimitiveIterator beyond) const - { - typename AT::Bounding_box bbox = m_traits.compute_bbox(*first,m_traits.bbm); - for(++first; first != beyond; ++first) - { - bbox = bbox + m_traits.compute_bbox(*first,m_traits.bbm); - } - return bbox; - } - - }; - - Compute_bbox compute_bbox_object() const {return Compute_bbox(*this);} - - /// \brief Function object using `GeomTraits::Do_intersect`. - /// In the case the query is a `CGAL::AABB_tree`, the `do_intersect()` - /// function of this tree is used. - class Do_intersect { - const AABB_traits& m_traits; - public: - Do_intersect(const AABB_traits& traits) - :m_traits(traits) {} - - template - bool operator()(const Query& q, const Bounding_box& bbox) const - { - return GeomTraits().do_intersect_3_object()(q, bbox); - } - - template - bool operator()(const Query& q, const Primitive& pr) const - { - return GeomTraits().do_intersect_3_object()(q, internal::Primitive_helper::get_datum(pr,m_traits)); - } - - // intersection with AABB-tree - template - bool operator()(const CGAL::AABB_tree& other_tree, const Primitive& pr) const - { - return other_tree.do_intersect( internal::Primitive_helper::get_datum(pr,m_traits) ); - } - - template - bool operator()(const CGAL::AABB_tree& other_tree, const Bounding_box& bbox) const - { - return other_tree.do_intersect(bbox); - } - }; - - Do_intersect do_intersect_object() const {return Do_intersect(*this);} - - - class Intersection { - const AABB_traits& m_traits; - public: - Intersection(const AABB_traits& traits) - :m_traits(traits) {} - template - std::optional< typename Intersection_and_primitive_id::Type > - operator()(const Query& query, const typename AT::Primitive& primitive) const { - auto inter_res = GeomTraits().intersect_3_object()(query, internal::Primitive_helper::get_datum(primitive,m_traits)); - if (!inter_res) - return std::nullopt; - return std::make_optional( std::make_pair(*inter_res, primitive.id()) ); - } - }; - - Intersection intersection_object() const {return Intersection(*this);} - - - // This should go down to the GeomTraits, i.e. the kernel - class Closest_point { - typedef typename AT::Point_3 Point; - typedef typename AT::Primitive Primitive; - const AABB_traits& m_traits; - public: - Closest_point(const AABB_traits& traits) - : m_traits(traits) {} - - - Point operator()(const Point& p, const Primitive& pr, const Point& bound) const - { - GeomTraits geom_traits; - Point closest_point = geom_traits.construct_projected_point_3_object()( - internal::Primitive_helper::get_datum(pr,m_traits), p); - - return (geom_traits.compare_distance_3_object()(p, closest_point, bound) == LARGER) ? - bound : closest_point; - } - }; - - // This should go down to the GeomTraits, i.e. the kernel - // and the internal implementation should change its name from - // do_intersect to something like does_contain (this is what we compute, - // this is not the same do_intersect as the spherical kernel) - class Compare_distance { - typedef typename AT::Point_3 Point; - typedef typename AT::FT FT; - typedef typename AT::Primitive Primitive; - public: - CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, Tag_true) const - { - return GeomTraits().do_intersect_3_object() - (GeomTraits().construct_sphere_3_object() - (p, GeomTraits().compute_squared_distance_3_object()(p, bound)), bb,true)? - CGAL::SMALLER : CGAL::LARGER; - } - - CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, Tag_false) const - { - return GeomTraits().do_intersect_3_object() - (GeomTraits().construct_sphere_3_object() - (p, GeomTraits().compute_squared_distance_3_object()(p, bound)), bb)? - CGAL::SMALLER : CGAL::LARGER; - } - - CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound) const - { - return (*this)(p, bb, bound, Boolean_tag::value>()); - } - - // The following functions seem unused...? - template - CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const Point& bound) const - { - return GeomTraits().do_intersect_3_object() - (GeomTraits().construct_sphere_3_object() - (p, GeomTraits().compute_squared_distance_3_object()(p, bound)), pr)? - CGAL::SMALLER : CGAL::LARGER; - } - - template - CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const FT& sq_distance) const - { - return GeomTraits().do_intersect_3_object() - (GeomTraits().construct_sphere_3_object()(p, sq_distance), - pr) ? - CGAL::SMALLER : - CGAL::LARGER; - } - }; - - Closest_point closest_point_object() const {return Closest_point(*this);} - Compare_distance compare_distance_object() const {return Compare_distance();} - - typedef enum { CGAL_AXIS_X = 0, - CGAL_AXIS_Y = 1, - CGAL_AXIS_Z = 2} Axis; - - static Axis longest_axis(const Bounding_box& bbox); - -private: - /** - * @brief Computes bounding box of one primitive - * @param pr the primitive - * @return the bounding box of the primitive \c pr - */ - template - Bounding_box compute_bbox(const Primitive& pr, const PM&)const - { - return get(bbm, pr.id()); - } - - Bounding_box compute_bbox(const Primitive& pr, const Default&)const - { - return internal::Primitive_helper::get_datum(pr,*this).bbox(); - } - - /// Comparison functions - static bool less_x(const Primitive& pr1, const Primitive& pr2,const AABB_traits& traits) - { - return GeomTraits().less_x_3_object()( internal::Primitive_helper::get_reference_point(pr1,traits), - internal::Primitive_helper::get_reference_point(pr2,traits) ); - } - static bool less_y(const Primitive& pr1, const Primitive& pr2,const AABB_traits& traits) - { - return GeomTraits().less_y_3_object()( internal::Primitive_helper::get_reference_point(pr1,traits), - internal::Primitive_helper::get_reference_point(pr2,traits) ); - } - static bool less_z(const Primitive& pr1, const Primitive& pr2,const AABB_traits& traits) - { - return GeomTraits().less_z_3_object()( internal::Primitive_helper::get_reference_point(pr1,traits), - internal::Primitive_helper::get_reference_point(pr2,traits) ); - } - -}; // end class AABB_traits +#include +#include -//------------------------------------------------------- -// Private methods -//------------------------------------------------------- - template - typename AABB_traits::Axis - AABB_traits::longest_axis(const Bounding_box& bbox) +namespace CGAL { - const double dx = bbox.xmax() - bbox.xmin(); - const double dy = bbox.ymax() - bbox.ymin(); - const double dz = bbox.zmax() - bbox.zmin(); - - if(dx>=dy) - { - if(dx>=dz) - { - return CGAL_AXIS_X; - } - else // dz>dx and dx>=dy - { - return CGAL_AXIS_Z; - } - } - else // dy>dx - { - if(dy>=dz) - { - return CGAL_AXIS_Y; - } - else // dz>dy and dy>dx - { - return CGAL_AXIS_Z; - } - } -} -/// @} +template +using AABB_traits = AABB_traits_3; -} // end namespace CGAL +} // namespace CGAL -#include +#endif // CGAL_NO_DEPRECATED_CODE #endif // CGAL_AABB_TRAITS_H_ diff --git a/AABB_tree/include/CGAL/AABB_traits_3.h b/AABB_tree/include/CGAL/AABB_traits_3.h new file mode 100644 index 000000000000..1c7ad6829ed0 --- /dev/null +++ b/AABB_tree/include/CGAL/AABB_traits_3.h @@ -0,0 +1,539 @@ +// Copyright (c) 2009 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) : Stéphane Tayeb, Pierre Alliez, Camille Wormser +// + +#ifndef CGAL_AABB_TRAITS_3_H_ +#define CGAL_AABB_TRAITS_3_H_ + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + + +#include + +/// \file AABB_traits_3.h + +namespace CGAL { + +namespace internal{ namespace AABB_tree { + +template +struct Remove_optional { typedef T type; }; + +template +struct Remove_optional< ::std::optional > { typedef T type; }; + +//helper controlling whether extra data should be stored in the AABB_tree traits class +template ::value> +struct AABB_traits_base; + +template +struct AABB_traits_base{}; + +template +struct AABB_traits_base{ + typename Primitive::Shared_data m_primitive_data; + + template + void set_shared_data(T&& ... t){ + m_primitive_data=Primitive::construct_shared_data(std::forward(t)...); + } + const typename Primitive::Shared_data& shared_data() const {return m_primitive_data;} +}; + +// AABB_traits_intersection_base brings in the Intersection_distance predicate, +// if GeomTraits is a model RayIntersectionGeomTraits. +template ::value> +struct AABB_traits_intersection_base; + +template +struct AABB_traits_intersection_base{}; + +template +struct AABB_traits_intersection_base{ + typedef typename GeomTraits::Ray_3 Ray_3; + typedef typename GeomTraits::Point_3 Point_3; + typedef typename GeomTraits::Point_3 Point; + typedef typename GeomTraits::Point_3 Ray; + typedef typename GeomTraits::Vector_3 Vector_3; + typedef typename GeomTraits::FT FT; + typedef typename GeomTraits::Cartesian_const_iterator_3 Cartesian_const_iterator_3; + typedef typename GeomTraits::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator_3; + typedef typename GeomTraits::Construct_source_3 Construct_source_3; + typedef typename GeomTraits::Construct_vector_3 Construct_vector_3; + + // Defining Bounding_box and other types from the full AABB_traits_3 + // here is might seem strange, but otherwise we would need to use + // CRTP to get access to the derived class, which would bloat the + // code more. + typedef typename CGAL::Bbox_3 Bounding_box; + + struct Intersection_distance { + std::optional operator()(const Ray_3& ray, const Bounding_box& bbox) const { + FT t_near = -DBL_MAX; // std::numeric_limits::lowest(); C++1903 + FT t_far = DBL_MAX; + + const Construct_cartesian_const_iterator_3 construct_cartesian_const_iterator_3 + = GeomTraits().construct_cartesian_const_iterator_3_object(); + const Construct_source_3 construct_source_3 = GeomTraits().construct_source_3_object(); + const Construct_vector_3 construct_vector_3 = GeomTraits().construct_vector_3_object(); + const Point_3 source = construct_source_3(ray); + const Vector_3 direction = construct_vector_3(ray); + Cartesian_const_iterator_3 source_iter = construct_cartesian_const_iterator_3(source); + Cartesian_const_iterator_3 direction_iter = construct_cartesian_const_iterator_3(direction); + + for(int i = 0; i < 3; ++i, ++source_iter, ++direction_iter) { + if(*direction_iter == 0) { + if((*source_iter < (bbox.min)(i)) || (*source_iter > (bbox.max)(i))) { + return std::nullopt; + } + } else { + FT t1 = ((bbox.min)(i) - *source_iter) / *direction_iter; + FT t2 = ((bbox.max)(i) - *source_iter) / *direction_iter; + + t_near = (std::max)(t_near, (std::min)(t1, t2)); + t_far = (std::min)(t_far, (std::max)(t1, t2)); + + // if(t1 > t2) + // std::swap(t1, t2); + // if(t1 > t_near) + // t_near = t1; + // if(t2 < t_far) + // t_far = t2; + + if(t_near > t_far || t_far < FT(0.)) + return std::nullopt; + } + } + + if(t_near < FT(0.)) + return FT(0.); + else + return t_near; + } + }; + + Intersection_distance intersection_distance_object() const { return Intersection_distance(); } +}; + +} } //end of namespace internal::AABB_tree + +/// \addtogroup PkgAABBTreeRef +/// @{ + +// forward declaration +template< typename AABBTraits> +class AABB_tree; + + +/// This traits class handles any type of 3D geometric +/// primitives provided that the proper intersection tests and +/// constructions are implemented. It handles points, rays, lines and +/// segments as query types for intersection detection and +/// computations, and it handles points as query type for distance +/// queries. +/// +/// \cgalModels{AABBTraits,AABBRayIntersectionTraits} +/// +/// \tparam GeomTraits must be a model of the concept \ref AABBGeomTraits_3, +/// and provide the geometric types as well as the intersection tests and computations. +/// \tparam Primitive provide the type of primitives stored in the AABB_tree. +/// It is a model of the concept `AABBPrimitive` or `AABBPrimitiveWithSharedData`. +/// +/// \tparam BboxMap must be a model of `ReadablePropertyMap` that has as key type a primitive id, +/// and as value type a `Bounding_box`. +/// If the type is `Default` the `Datum` must have the +/// member function `bbox()` that returns the bounding box of the primitive. +/// +/// If the argument `GeomTraits` is a model of the concept \ref +/// AABBRayIntersectionGeomTraits, this class is also a model of \ref +/// AABBRayIntersectionTraits. +/// +/// \sa `AABBTraits` +/// \sa `AABB_tree` +/// \sa `AABBPrimitive` +/// \sa `AABBPrimitiveWithSharedData` + +template +class AABB_traits_3 +#ifndef DOXYGEN_RUNNING +: public internal::AABB_tree::AABB_traits_base, + public internal::AABB_tree::AABB_traits_intersection_base +#endif +{ + typedef typename CGAL::Object Object; +public: + typedef GeomTraits Geom_traits; + + typedef AABB_traits_3 AT; + // AABBTraits concept types + typedef typename GeomTraits::FT FT; + typedef AABBPrimitive Primitive; + + typedef typename std::pair Object_and_primitive_id; + + typedef typename std::pair Point_and_primitive_id; + + /// `Intersection_and_primitive_id::%Type::first_type` is found according to + /// the result type of `GeomTraits::Intersect_3::operator()`. If it is + /// `std::optional` then it is `T`, and the result type otherwise. + template + struct Intersection_and_primitive_id { + typedef decltype( + std::declval()( + std::declval(), + std::declval())) Intersection_type; + + typedef std::pair< + typename internal::AABB_tree::Remove_optional::type, + typename Primitive::Id > Type; + }; + + // types for search tree + /// \name Types + /// @{ + + /// Point query type. + typedef typename GeomTraits::Point_3 Point_3; + + /// additional types for the search tree, required by the RangeSearchTraits concept + /// \bug This is not documented for now in the AABBTraits concept. + typedef typename GeomTraits::Iso_cuboid_3 Iso_cuboid_3; + + /// Bounding box type. + typedef typename CGAL::Bbox_3 Bounding_box; + + /// @} + + typedef typename GeomTraits::Sphere_3 Sphere_3; + typedef typename GeomTraits::Cartesian_const_iterator_3 Cartesian_const_iterator_3; + typedef typename GeomTraits::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator_3; + typedef typename GeomTraits::Construct_center_3 Construct_center_3; + typedef typename GeomTraits::Compute_squared_radius_3 Compute_squared_radius_3; + typedef typename GeomTraits::Construct_min_vertex_3 Construct_min_vertex_3; + typedef typename GeomTraits::Construct_max_vertex_3 Construct_max_vertex_3; + typedef typename GeomTraits::Construct_iso_cuboid_3 Construct_iso_cuboid_3; + + BboxMap bbm; + + /// Default constructor. + AABB_traits_3() { } + + AABB_traits_3(BboxMap bbm) + : bbm(bbm) + {} + + + typedef typename GeomTraits::Compute_squared_distance_3 Squared_distance; + Squared_distance squared_distance_object() const { return GeomTraits().compute_squared_distance_3_object(); } + + typedef typename GeomTraits::Equal_3 Equal_3; + Equal_3 equal_3_object() const { return GeomTraits().equal_3_object(); } + + /** + * @internal + * @brief Sorts [first,beyond[ + * @param first iterator on first element + * @param beyond iterator on beyond element + * @param bbox the bounding box of [first,beyond[ + * + * Sorts the range defined by [first,beyond[. Sort is achieved on bbox longest + * axis, using the comparison function `_less_than` (dim in {x,y,z}) + */ + class Split_primitives + { + typedef AABB_traits_3 Traits; + const Traits& m_traits; + public: + Split_primitives(const AABB_traits_3& traits) + : m_traits(traits) {} + + typedef void result_type; + template + void operator()(PrimitiveIterator first, + PrimitiveIterator beyond, + const typename AT::Bounding_box& bbox) const + { + PrimitiveIterator middle = first + (beyond - first)/2; + switch(Traits::longest_axis(bbox)) + { + case AT::CGAL_AXIS_X: // sort along x + std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_x(p1, p2, this->m_traits); }); + break; + case AT::CGAL_AXIS_Y: // sort along y + std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_y(p1, p2, this->m_traits); }); + break; + case AT::CGAL_AXIS_Z: // sort along z + std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_z(p1, p2, this->m_traits); }); + break; + default: + CGAL_error(); + } + } + }; + + Split_primitives split_primitives_object() const {return Split_primitives(*this);} + + + /* + * Computes the bounding box of a set of primitives + * @param first an iterator on the first primitive + * @param beyond an iterator on the past-the-end primitive + * @return the bounding box of the primitives of the iterator range + */ + class Compute_bbox { + const AABB_traits_3& m_traits; + public: + Compute_bbox(const AABB_traits_3& traits) + :m_traits (traits) {} + + template + typename AT::Bounding_box operator()(ConstPrimitiveIterator first, + ConstPrimitiveIterator beyond) const + { + typename AT::Bounding_box bbox = m_traits.compute_bbox(*first,m_traits.bbm); + for(++first; first != beyond; ++first) + { + bbox = bbox + m_traits.compute_bbox(*first,m_traits.bbm); + } + return bbox; + } + + }; + + Compute_bbox compute_bbox_object() const {return Compute_bbox(*this);} + + /// \brief Function object using `GeomTraits::Do_intersect`. + /// In the case the query is a `CGAL::AABB_tree`, the `do_intersect()` + /// function of this tree is used. + class Do_intersect { + const AABB_traits_3& m_traits; + public: + Do_intersect(const AABB_traits_3& traits) + :m_traits(traits) {} + + template + bool operator()(const Query& q, const Bounding_box& bbox) const + { + return GeomTraits().do_intersect_3_object()(q, bbox); + } + + template + bool operator()(const Query& q, const Primitive& pr) const + { + return GeomTraits().do_intersect_3_object()(q, internal::Primitive_helper::get_datum(pr,m_traits)); + } + + // intersection with AABB-tree + template + bool operator()(const CGAL::AABB_tree& other_tree, const Primitive& pr) const + { + return other_tree.do_intersect( internal::Primitive_helper::get_datum(pr,m_traits) ); + } + + template + bool operator()(const CGAL::AABB_tree& other_tree, const Bounding_box& bbox) const + { + return other_tree.do_intersect(bbox); + } + }; + + Do_intersect do_intersect_object() const {return Do_intersect(*this);} + + + class Intersection { + const AABB_traits_3& m_traits; + public: + Intersection(const AABB_traits_3& traits) + :m_traits(traits) {} + template + std::optional< typename Intersection_and_primitive_id::Type > + operator()(const Query& query, const typename AT::Primitive& primitive) const { + auto inter_res = GeomTraits().intersect_3_object()(query, internal::Primitive_helper::get_datum(primitive,m_traits)); + if (!inter_res) + return std::nullopt; + return std::make_optional( std::make_pair(*inter_res, primitive.id()) ); + } + }; + + Intersection intersection_object() const {return Intersection(*this);} + + + // This should go down to the GeomTraits, i.e. the kernel + class Closest_point { + typedef typename AT::Point_3 Point; + typedef typename AT::Primitive Primitive; + const AABB_traits_3& m_traits; + public: + Closest_point(const AABB_traits_3& traits) + : m_traits(traits) {} + + + Point operator()(const Point& p, const Primitive& pr, const Point& bound) const + { + GeomTraits geom_traits; + Point closest_point = geom_traits.construct_projected_point_3_object()( + internal::Primitive_helper::get_datum(pr,m_traits), p); + + return (geom_traits.compare_distance_3_object()(p, closest_point, bound) == LARGER) ? + bound : closest_point; + } + }; + + // This should go down to the GeomTraits, i.e. the kernel + // and the internal implementation should change its name from + // do_intersect to something like does_contain (this is what we compute, + // this is not the same do_intersect as the spherical kernel) + class Compare_distance { + typedef typename AT::Point_3 Point; + typedef typename AT::FT FT; + typedef typename AT::Primitive Primitive; + public: + CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, Tag_true) const + { + return GeomTraits().do_intersect_3_object() + (GeomTraits().construct_sphere_3_object() + (p, GeomTraits().compute_squared_distance_3_object()(p, bound)), bb,true)? + CGAL::SMALLER : CGAL::LARGER; + } + + CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, Tag_false) const + { + return GeomTraits().do_intersect_3_object() + (GeomTraits().construct_sphere_3_object() + (p, GeomTraits().compute_squared_distance_3_object()(p, bound)), bb)? + CGAL::SMALLER : CGAL::LARGER; + } + + CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound) const + { + return (*this)(p, bb, bound, Boolean_tag::value>()); + } + + // The following functions seem unused...? + template + CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const Point& bound) const + { + return GeomTraits().do_intersect_3_object() + (GeomTraits().construct_sphere_3_object() + (p, GeomTraits().compute_squared_distance_3_object()(p, bound)), pr)? + CGAL::SMALLER : CGAL::LARGER; + } + + template + CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const FT& sq_distance) const + { + return GeomTraits().do_intersect_3_object() + (GeomTraits().construct_sphere_3_object()(p, sq_distance), + pr) ? + CGAL::SMALLER : + CGAL::LARGER; + } + }; + + Closest_point closest_point_object() const {return Closest_point(*this);} + Compare_distance compare_distance_object() const {return Compare_distance();} + + typedef enum { CGAL_AXIS_X = 0, + CGAL_AXIS_Y = 1, + CGAL_AXIS_Z = 2} Axis; + + static Axis longest_axis(const Bounding_box& bbox); + +private: + /** + * @brief Computes bounding box of one primitive + * @param pr the primitive + * @return the bounding box of the primitive \c pr + */ + template + Bounding_box compute_bbox(const Primitive& pr, const PM&)const + { + return get(bbm, pr.id()); + } + + Bounding_box compute_bbox(const Primitive& pr, const Default&)const + { + return internal::Primitive_helper::get_datum(pr,*this).bbox(); + } + + /// Comparison functions + static bool less_x(const Primitive& pr1, const Primitive& pr2,const AABB_traits_3& traits) + { + return GeomTraits().less_x_3_object()( internal::Primitive_helper::get_reference_point(pr1,traits), + internal::Primitive_helper::get_reference_point(pr2,traits) ); + } + static bool less_y(const Primitive& pr1, const Primitive& pr2,const AABB_traits_3& traits) + { + return GeomTraits().less_y_3_object()( internal::Primitive_helper::get_reference_point(pr1,traits), + internal::Primitive_helper::get_reference_point(pr2,traits) ); + } + static bool less_z(const Primitive& pr1, const Primitive& pr2,const AABB_traits_3& traits) + { + return GeomTraits().less_z_3_object()( internal::Primitive_helper::get_reference_point(pr1,traits), + internal::Primitive_helper::get_reference_point(pr2,traits) ); + } + +}; // end class AABB_traits_3 + + +//------------------------------------------------------- +// Private methods +//------------------------------------------------------- + template + typename AABB_traits_3::Axis + AABB_traits_3::longest_axis(const Bounding_box& bbox) +{ + const double dx = bbox.xmax() - bbox.xmin(); + const double dy = bbox.ymax() - bbox.ymin(); + const double dz = bbox.zmax() - bbox.zmin(); + + if(dx>=dy) + { + if(dx>=dz) + { + return CGAL_AXIS_X; + } + else // dz>dx and dx>=dy + { + return CGAL_AXIS_Z; + } + } + else // dy>dx + { + if(dy>=dz) + { + return CGAL_AXIS_Y; + } + else // dz>dy and dy>dx + { + return CGAL_AXIS_Z; + } + } +} + +/// @} + +} // end namespace CGAL + +#include + +#endif // CGAL_AABB_TRAITS_3_H_ diff --git a/AABB_tree/include/CGAL/AABB_tree.h b/AABB_tree/include/CGAL/AABB_tree.h index 16c39099b383..f8034bc4837e 100644 --- a/AABB_tree/include/CGAL/AABB_tree.h +++ b/AABB_tree/include/CGAL/AABB_tree.h @@ -76,7 +76,7 @@ namespace CGAL { /// Type of 3D point. - typedef typename AABBTraits::Point_3 Point; + typedef typename AABBTraits::Point Point; /// Type of input primitive. typedef typename AABBTraits::Primitive Primitive; @@ -300,7 +300,7 @@ namespace CGAL { /// returns the intersection and primitive id closest to the source point of the ray /// query. - /// \tparam Ray must be the same as `AABBTraits::Ray_3` and + /// \tparam Ray must be the same as `AABBTraits::Ray` and /// `do_intersect` predicates and intersections for it must be /// defined. /// \tparam Skip a functor with an operator @@ -331,7 +331,7 @@ namespace CGAL { /// returns the primitive id closest to the source point of the ray /// query. - /// \tparam Ray must be the same as `AABBTraits::Ray_3` and + /// \tparam Ray must be the same as `AABBTraits::Ray` and /// `do_intersect` predicates and intersections for it must be /// defined. /// \tparam Skip a functor with an operator diff --git a/AABB_tree/include/CGAL/AABB_triangle_primitive.h b/AABB_tree/include/CGAL/AABB_triangle_primitive_3.h similarity index 100% rename from AABB_tree/include/CGAL/AABB_triangle_primitive.h rename to AABB_tree/include/CGAL/AABB_triangle_primitive_3.h From 4a482dd32befe8dcca95f44a16a3560005aa2ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 4 Mar 2024 13:09:08 +0100 Subject: [PATCH 002/100] compatibility headers --- AABB_tree/include/CGAL/AABB_segment_primitive_3.h | 10 +++++----- AABB_tree/include/CGAL/AABB_triangle_primitive_3.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_segment_primitive_3.h b/AABB_tree/include/CGAL/AABB_segment_primitive_3.h index f13523ba40ca..b9459de0208a 100644 --- a/AABB_tree/include/CGAL/AABB_segment_primitive_3.h +++ b/AABB_tree/include/CGAL/AABB_segment_primitive_3.h @@ -12,8 +12,8 @@ // -#ifndef CGAL_AABB_SEGMENT_PRIMITIVE_H_ -#define CGAL_AABB_SEGMENT_PRIMITIVE_H_ +#ifndef CGAL_AABB_SEGMENT_PRIMITIVE_3_H_ +#define CGAL_AABB_SEGMENT_PRIMITIVE_3_H_ #include @@ -74,7 +74,7 @@ namespace internal { template < class GeomTraits, class Iterator, class CacheDatum=Tag_false> -class AABB_segment_primitive +class AABB_segment_primitive_3 #ifndef DOXYGEN_RUNNING : public AABB_primitive< Iterator, Input_iterator_property_map, @@ -90,12 +90,12 @@ class AABB_segment_primitive CacheDatum > Base; public: ///constructor from an iterator - AABB_segment_primitive(Iterator it) : Base(it){} + AABB_segment_primitive_3(Iterator it) : Base(it){} }; } // end namespace CGAL #include -#endif // CGAL_AABB_SEGMENT_PRIMITIVE_H_ +#endif // CGAL_AABB_SEGMENT_PRIMITIVE_3_H_ diff --git a/AABB_tree/include/CGAL/AABB_triangle_primitive_3.h b/AABB_tree/include/CGAL/AABB_triangle_primitive_3.h index 1fc1b140c582..569e579f12b9 100644 --- a/AABB_tree/include/CGAL/AABB_triangle_primitive_3.h +++ b/AABB_tree/include/CGAL/AABB_triangle_primitive_3.h @@ -12,8 +12,8 @@ // -#ifndef CGAL_AABB_TRIANGLE_PRIMITIVE_H_ -#define CGAL_AABB_TRIANGLE_PRIMITIVE_H_ +#ifndef CGAL_AABB_TRIANGLE_PRIMITIVE_3_H_ +#define CGAL_AABB_TRIANGLE_PRIMITIVE_3_H_ #include @@ -75,7 +75,7 @@ namespace internal { template < class GeomTraits, class Iterator, class CacheDatum=Tag_false> -class AABB_triangle_primitive +class AABB_triangle_primitive_3 #ifndef DOXYGEN_RUNNING : public AABB_primitive< Iterator, Input_iterator_property_map, @@ -91,12 +91,12 @@ class AABB_triangle_primitive CacheDatum > Base; public: ///constructor from an iterator - AABB_triangle_primitive(Iterator it) : Base(it){} + AABB_triangle_primitive_3(Iterator it) : Base(it){} }; } // end namespace CGAL #include -#endif // CGAL_AABB_TRIANGLE_PRIMITIVE_H_ +#endif // CGAL_AABB_TRIANGLE_PRIMITIVE_3_H_ From 2eff0eb0e05b8ce4715ce9b17975fe617299ee37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 4 Mar 2024 13:50:51 +0100 Subject: [PATCH 003/100] add missing files --- .../include/CGAL/AABB_segment_primitive.h | 38 +++++++++++++++++++ .../include/CGAL/AABB_triangle_primitive.h | 38 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 AABB_tree/include/CGAL/AABB_segment_primitive.h create mode 100644 AABB_tree/include/CGAL/AABB_triangle_primitive.h diff --git a/AABB_tree/include/CGAL/AABB_segment_primitive.h b/AABB_tree/include/CGAL/AABB_segment_primitive.h new file mode 100644 index 000000000000..b9b0ca3c7fe1 --- /dev/null +++ b/AABB_tree/include/CGAL/AABB_segment_primitive.h @@ -0,0 +1,38 @@ +// Copyright (c) 2024 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_SEGMENT_PRIMITIVE_H_ +#define CGAL_AABB_SEGMENT_PRIMITIVE_H_ + +#include + +#define CGAL_DEPRECATED_HEADER "" +#define CGAL_REPLACEMENT_HEADER "" +#include + +#ifndef CGAL_NO_DEPRECATED_CODE + +#include + +namespace CGAL{ + +template < class GeomTraits, + class Iterator, + class CacheDatum=Tag_false> +using AABB_segment_primitive = AABB_segment_primitive_3; + +} // CGAL namespace + +#endif // CGAL_NO_DEPRECATED_CODE + +#endif //CGAL_AABB_SEGMENT_PRIMITIVE_H_ diff --git a/AABB_tree/include/CGAL/AABB_triangle_primitive.h b/AABB_tree/include/CGAL/AABB_triangle_primitive.h new file mode 100644 index 000000000000..edf1c94299cf --- /dev/null +++ b/AABB_tree/include/CGAL/AABB_triangle_primitive.h @@ -0,0 +1,38 @@ +// Copyright (c) 2024 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_H_ +#define CGAL_AABB_TRIANGLE_PRIMITIVE_H_ + +#include + +#define CGAL_DEPRECATED_HEADER "" +#define CGAL_REPLACEMENT_HEADER "" +#include + +#ifndef CGAL_NO_DEPRECATED_CODE + +#include + +namespace CGAL { + +template < class GeomTraits, + class Iterator, + class CacheDatum=Tag_false> +using AABB_triangle_primitive = AABB_triangle_primitive_3; + +} //CGAL namespace + +#endif // CGAL_NO_DEPRECATED_CODE + +#endif //CGAL_AABB_TRIANGLE_PRIMITIVE_H_ From 26d40e7ca271d607165faf8237586d7dead0c250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 4 Mar 2024 14:00:59 +0100 Subject: [PATCH 004/100] rename concept --- ...rsectionGeomTraits.h => AABBRayIntersectionGeomTraits_3.h} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename AABB_tree/doc/AABB_tree/Concepts/{AABBRayIntersectionGeomTraits.h => AABBRayIntersectionGeomTraits_3.h} (92%) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h similarity index 92% rename from AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits.h rename to AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h index b29abd3b645f..331c76b44958 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h @@ -2,7 +2,7 @@ \ingroup PkgAABBTreeConcepts \cgalConcept -The concept `AABBRayIntersectionGeomTraits` is a refinement of the +The concept `AABBRayIntersectionGeomTraits_3` is a refinement of the concept `AABBGeomTraits`. In addition to the types required by `AABBGeomTraits` it also requires types and functors necessary to define the Intersection_distance functor. @@ -18,7 +18,7 @@ define the Intersection_distance functor. \sa `AABBPrimitive` */ -class AABBRayIntersectionGeomTraits { +class AABBRayIntersectionGeomTraits_3 { public: /*! Type of a ray. From ae0f114238dbfa82c7ccadc3d8e41bcb1050ca12 Mon Sep 17 00:00:00 2001 From: Sebastien Loriot Date: Mon, 4 Mar 2024 15:27:13 +0100 Subject: [PATCH 005/100] Update AABB_tree/include/CGAL/AABB_traits_3.h Co-authored-by: Andreas Fabri --- AABB_tree/include/CGAL/AABB_traits_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AABB_tree/include/CGAL/AABB_traits_3.h b/AABB_tree/include/CGAL/AABB_traits_3.h index 1c7ad6829ed0..198e46abc965 100644 --- a/AABB_tree/include/CGAL/AABB_traits_3.h +++ b/AABB_tree/include/CGAL/AABB_traits_3.h @@ -72,7 +72,7 @@ struct AABB_traits_intersection_base{ typedef typename GeomTraits::Ray_3 Ray_3; typedef typename GeomTraits::Point_3 Point_3; typedef typename GeomTraits::Point_3 Point; - typedef typename GeomTraits::Point_3 Ray; + typedef typename GeomTraits::Ray_3 Ray; typedef typename GeomTraits::Vector_3 Vector_3; typedef typename GeomTraits::FT FT; typedef typename GeomTraits::Cartesian_const_iterator_3 Cartesian_const_iterator_3; From ee187c5008b0c7520cb87a5ce41acc1de036f340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 4 Mar 2024 15:45:19 +0100 Subject: [PATCH 006/100] use Search_traits_adapter instead of Decorated_point --- .../AABB_tree/internal/AABB_search_tree.h | 139 ++++++------------ 1 file changed, 43 insertions(+), 96 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h index 9ba3cf2481b9..2ea2b8efb5b9 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h @@ -15,108 +15,55 @@ #include - #include #include +#include +#include namespace CGAL { - template - class Add_decorated_point: public Underlying - { - class Decorated_point: public Underlying::Point_3 - { - public: - const Id& id() const { return m_id; } - - Decorated_point() - : Underlying::Point_3() - , m_id() - , m_is_id_initialized(false) {} - - // Allows the user not to provide the id - // so that we don't break existing code - Decorated_point(const typename Underlying::Point_3& p) - : Underlying::Point_3(p) - , m_id() - , m_is_id_initialized(false) {} - - Decorated_point(const typename Underlying::Point_3& p, - const Id& id) - : Underlying::Point_3(p) - , m_id(id) - , m_is_id_initialized(true) {} - - Decorated_point(const Decorated_point& rhs) - : Underlying::Point_3(rhs) - , m_id() - , m_is_id_initialized(rhs.m_is_id_initialized) - { - if ( m_is_id_initialized ) - m_id = rhs.m_id; - } - - Decorated_point& operator=(const Decorated_point&)=default; - private: - Id m_id; - // Needed to avoid exception (depending on Id type) - // "error: attempt to copy-construct an iterator from a singular iterator." - // This exception may appear if we copy-construct an Id - // which has Id() as value (It is done when constructing - // Neighbor_search since we pass the Point only as query) - bool m_is_id_initialized; - }; - public: - typedef Decorated_point Point_3; - }; - - template - class AABB_search_tree - { - public: - typedef typename Traits::FT FT; - typedef typename Traits::Point_3 Point; - typedef typename Traits::Primitive Primitive; - typedef typename Traits::Point_and_primitive_id Point_and_primitive_id; - typedef typename CGAL::Search_traits_3 > TreeTraits; - typedef typename CGAL::Orthogonal_k_neighbor_search Neighbor_search; - typedef typename Neighbor_search::Tree Tree; - private: - Tree m_tree; - - - Point_and_primitive_id get_p_and_p(const Point_and_primitive_id& p) - { - return p; - } - Point_and_primitive_id get_p_and_p(const Point& p) - { - return Point_and_primitive_id(p, typename Primitive::Id()); - } - - public: - template - AABB_search_tree(ConstPointIterator begin, ConstPointIterator beyond) - : m_tree{} - { - typedef typename Add_decorated_point::Point_3 Decorated_point; - std::vector points; - while(begin != beyond) { - Point_and_primitive_id pp = get_p_and_p(*begin); - points.emplace_back(pp.first, pp.second); - ++begin; - } - m_tree.insert(points.begin(), points.end()); - m_tree.build(); - } - - Point_and_primitive_id closest_point(const Point& query) const - { - Neighbor_search search(m_tree, query, 1); - return Point_and_primitive_id(static_cast(search.begin()->first), search.begin()->first.id()); - } - }; +template +struct AABB_search_tree +{ + typedef typename Traits::FT FT; + typedef typename Traits::Point_3 Point; + typedef typename Traits::Primitive Primitive; + typedef typename Traits::Point_and_primitive_id Point_and_primitive_id; + typedef First_of_pair_property_map Pmap; + typedef Search_traits_3 Search_traits; + typedef Search_traits_adapter TreeTraits; + typedef typename CGAL::Orthogonal_k_neighbor_search Neighbor_search; + typedef typename Neighbor_search::Tree Tree; +private: + Tree m_tree; + + Point_and_primitive_id get_p_and_p(const Point_and_primitive_id& p) + { + return p; + } + +public: + template + AABB_search_tree(ConstPointIterator begin, ConstPointIterator beyond) + : m_tree{} + { + std::vector points; + while(begin != beyond) { + Point_and_primitive_id pp = get_p_and_p(*begin); + points.emplace_back(pp); + ++begin; + } + m_tree.insert(points.begin(), points.end()); + m_tree.build(); + } + + Point_and_primitive_id closest_point(const Point& query) const + { + Neighbor_search search(m_tree, query, 1); + return search.begin()->first; + } +}; } From c4a11970c4105811d619575442d4f527cf6674cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 4 Mar 2024 16:00:47 +0100 Subject: [PATCH 007/100] AABB_traits_3 is model of Search_traits --- AABB_tree/include/CGAL/AABB_traits_3.h | 5 +++-- AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h | 4 +--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_traits_3.h b/AABB_tree/include/CGAL/AABB_traits_3.h index 198e46abc965..de0a4cefd2f3 100644 --- a/AABB_tree/include/CGAL/AABB_traits_3.h +++ b/AABB_tree/include/CGAL/AABB_traits_3.h @@ -25,7 +25,7 @@ #include #include #include - +#include #include @@ -176,7 +176,8 @@ template, - public internal::AABB_tree::AABB_traits_intersection_base + public internal::AABB_tree::AABB_traits_intersection_base, + public Search_traits_3 #endif { typedef typename CGAL::Object Object; diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h index 2ea2b8efb5b9..b4b15a924998 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h @@ -16,7 +16,6 @@ #include #include -#include #include #include @@ -31,8 +30,7 @@ struct AABB_search_tree typedef typename Traits::Primitive Primitive; typedef typename Traits::Point_and_primitive_id Point_and_primitive_id; typedef First_of_pair_property_map Pmap; - typedef Search_traits_3 Search_traits; - typedef Search_traits_adapter TreeTraits; + typedef Search_traits_adapter TreeTraits; typedef typename CGAL::Orthogonal_k_neighbor_search Neighbor_search; typedef typename Neighbor_search::Tree Tree; private: From 32e68f8c31733a338531cbdbbb49f3756622589f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 4 Mar 2024 16:07:04 +0100 Subject: [PATCH 008/100] fix concept doc --- .../Concepts/AABBRayIntersectionGeomTraits_3.h | 8 ++++---- .../doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h | 10 +++++----- AABB_tree/include/CGAL/AABB_traits_3.h | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h index 331c76b44958..eda2becd19bc 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h @@ -21,14 +21,14 @@ define the Intersection_distance functor. class AABBRayIntersectionGeomTraits_3 { public: /*! - Type of a ray. + Type of a 3D ray. */ - typedef unspecified_type Ray; + typedef unspecified_type Ray_3; /*! - Type of a vector. + Type of a 3D vector. */ - typedef unspecified_type Vector; + typedef unspecified_type Vector_3; /*! A functor object to construct the source point of a ray. Provides the operator: diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h index 7b8b6dd4ec45..e234eba160c2 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h @@ -19,9 +19,9 @@ class AABBRayIntersectionTraits { public: /*! - Type of a 3D ray. + Type of a ray. */ - typedef unspecified_type Ray_3; + typedef unspecified_type Ray; /*! @@ -34,9 +34,9 @@ class AABBRayIntersectionTraits { respectively. Provides the operators: - `std::optional operator()(const Ray_3& r, const Bounding_box& bbox)`. - `std::optional::%Type > > - operator()(const Ray_3& r, const Primitive& primitive)`. + `std::optional operator()(const Ray& r, const Bounding_box& bbox)`. + `std::optional::%Type > > + operator()(const Ray& r, const Primitive& primitive)`. A common algorithm to compute the intersection between a bounding box and a ray is the diff --git a/AABB_tree/include/CGAL/AABB_traits_3.h b/AABB_tree/include/CGAL/AABB_traits_3.h index de0a4cefd2f3..1dc9189516b1 100644 --- a/AABB_tree/include/CGAL/AABB_traits_3.h +++ b/AABB_tree/include/CGAL/AABB_traits_3.h @@ -164,7 +164,7 @@ class AABB_tree; /// member function `bbox()` that returns the bounding box of the primitive. /// /// If the argument `GeomTraits` is a model of the concept \ref -/// AABBRayIntersectionGeomTraits, this class is also a model of \ref +/// AABBRayIntersectionGeomTraits_3, this class is also a model of \ref /// AABBRayIntersectionTraits. /// /// \sa `AABBTraits` From 6453b0858037773700075b6d27f7dfe16c14ed4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 4 Mar 2024 16:10:16 +0100 Subject: [PATCH 009/100] more doc fixes --- .../AABBRayIntersectionGeomTraits_3.h | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h index eda2becd19bc..8e286e9699b6 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h @@ -32,37 +32,35 @@ class AABBRayIntersectionGeomTraits_3 { /*! A functor object to construct the source point of a ray. Provides the operator: - `Point operator()(const Ray&);` + `Point_3 operator()(const Ray_3&);` */ - typedef unspecified_type Construct_source; + typedef unspecified_type Construct_source_3; /*! */ - Construct_source construct_source_object(); + Construct_source_3 construct_source_3_object(); /*! - @todo update me A model of `CartesianConstIterator3`. */ - typedef unspecified_type Cartesian_const_iterator; + typedef unspecified_type Cartesian_const_iterator_3; /*! - @todo update me A model of `ConstructCartesianConstIterator3`. */ - typedef unspecified_type Construct_cartesian_const_iterator; + typedef unspecified_type Construct_cartesian_const_iterator_3; /*! */ - Construct_source construct_cartesian_const_iterator_object(); + Construct_source_3 construct_cartesian_const_iterator_3_object(); /*! A functor object to construct a vector giving the direction of a ray. Provides the operator: - `Vector operator()(const Ray&);` + `Vector_3 operator()(const Ray_3&);` */ - typedef unspecified_type Construct_vector; + typedef unspecified_type Construct_vector_3; /*! */ - Construct_source construct_vector_object(); + Construct_source_3 construct_vector_3_object(); }; From 84362a2b1eb98898b99b56a422467002dd5a07fb Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 4 Mar 2024 15:42:49 +0000 Subject: [PATCH 010/100] Add Construct_projected_point_2::operator()(Segment_2,Point_2) --- .../AABB_tree/AABB_segment_2_example.cpp | 54 ++ .../include/CGAL/AABB_segment_primitive_2.h | 100 ++++ AABB_tree/include/CGAL/AABB_traits_2.h | 493 ++++++++++++++++++ .../include/CGAL/Cartesian/function_objects.h | 10 + 4 files changed, 657 insertions(+) create mode 100644 AABB_tree/examples/AABB_tree/AABB_segment_2_example.cpp create mode 100644 AABB_tree/include/CGAL/AABB_segment_primitive_2.h create mode 100644 AABB_tree/include/CGAL/AABB_traits_2.h diff --git a/AABB_tree/examples/AABB_tree/AABB_segment_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_segment_2_example.cpp new file mode 100644 index 000000000000..62cbadafff8e --- /dev/null +++ b/AABB_tree/examples/AABB_tree/AABB_segment_2_example.cpp @@ -0,0 +1,54 @@ +#include +#include + +#include +#include +#include +#include + + +typedef CGAL::Simple_cartesian K; + +typedef K::FT FT; +typedef K::Segment_2 Segment; +typedef K::Point_2 Point; + +typedef std::list::iterator Iterator; +typedef CGAL::AABB_segment_primitive_2 Primitive; +typedef CGAL::AABB_traits_2 Traits; +typedef CGAL::AABB_tree Tree; + + +int main() +{ + Point a(0.0, 0.0); + Point b(2.0, 1.0); + Point c(3.0, 4.0); + Point d(1.0, 6.0); + Point e(-1.0, 3.0); + + std::list segments; + segments.push_back(Segment(a, b)); + segments.push_back(Segment(b, c)); + segments.push_back(Segment(c, d)); + segments.push_back(Segment(d, e)); + segments.push_back(Segment(e, a)); + + // // constructs the AABB tree and the internal search tree for + // // efficient distance computations. + Tree tree(segments.begin(), segments.end()); + // tree.accelerate_distance_queries(); + + // // counts #intersections with a segment query + Segment segment_query(Point(1.0, 0.0), Point(0.0, 7.0)); + std::cout << tree.number_of_intersected_primitives(segment_query) + << " intersections(s) with segment" << std::endl; + + + // computes the closest point from a point query + Point point_query(1.5, 3.0); + Point closest = tree.closest_point(point_query); + + //std::cerr << "closest point is: " << closest << std::endl; + return EXIT_SUCCESS; +} diff --git a/AABB_tree/include/CGAL/AABB_segment_primitive_2.h b/AABB_tree/include/CGAL/AABB_segment_primitive_2.h new file mode 100644 index 000000000000..3b4fdab16a7f --- /dev/null +++ b/AABB_tree/include/CGAL/AABB_segment_primitive_2.h @@ -0,0 +1,100 @@ +// 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_SEGMENT_PRIMITIVE_2_H_ +#define CGAL_AABB_SEGMENT_PRIMITIVE_2_H_ + +#include + +#include + +#include +#include + +namespace CGAL { + +namespace internal { + template + struct Source_of_segment_2_iterator_property_map{ + //classical typedefs + typedef Iterator key_type; + typedef typename GeomTraits::Point_2 value_type; + // typedef decltype( + // std::declval()( + // std::declval())) reference; + typedef decltype( + typename GeomTraits::Construct_source_2()( + *std::declval())) reference; + typedef boost::readable_property_map_tag category; + typedef Source_of_segment_2_iterator_property_map Self; + + inline friend reference + get(Self, key_type it) + { + return typename GeomTraits::Construct_source_2()( *it ); + } + }; +}//namespace internal + + +/*! + * \ingroup PkgAABBTreeRef + * 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 + * 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 `Segment_2`. + * It also provides the functor `Construct_source_2` that has an operator taking a `Segment_2` + * and returning its source as a type convertible to `Point_2`. + * \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Segment_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_triangle_primitive` + * \sa `AABB_halfedge_graph_segment_primitive` + * \sa `AABB_face_graph_triangle_primitive` + */ +template < class GeomTraits, + class Iterator, + class CacheDatum=Tag_false> +class AABB_segment_primitive_2 +#ifndef DOXYGEN_RUNNING + : public AABB_primitive< Iterator, + Input_iterator_property_map, + internal::Source_of_segment_2_iterator_property_map, + Tag_false, + CacheDatum > +#endif +{ + typedef AABB_primitive< Iterator, + Input_iterator_property_map, + internal::Source_of_segment_2_iterator_property_map, + Tag_false, + CacheDatum > Base; +public: + ///constructor from an iterator + AABB_segment_primitive_2(Iterator it) : Base(it){} +}; + +} // end namespace CGAL + +#include + +#endif // CGAL_AABB_SEGMENT_PRIMITIVE_2_H_ diff --git a/AABB_tree/include/CGAL/AABB_traits_2.h b/AABB_tree/include/CGAL/AABB_traits_2.h new file mode 100644 index 000000000000..f053513dab5d --- /dev/null +++ b/AABB_tree/include/CGAL/AABB_traits_2.h @@ -0,0 +1,493 @@ +// Copyright (c) 2009 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) : Stéphane Tayeb, Pierre Alliez, Camille Wormser +// + +#ifndef CGAL_AABB_TRAITS_2_H_ +#define CGAL_AABB_TRAITS_2_H_ + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include // for Remove_optional +#include +#include + +/// \file AABB_traits_2.h + +namespace CGAL { + +namespace internal{ namespace AABB_tree { + + +// AABB_traits_intersection_base brings in the Intersection_distance predicate, +// if GeomTraits is a model RayIntersectionGeomTraits. +template ::value> +struct AABB_traits_intersection_base_2; + +template +struct AABB_traits_intersection_base_2{}; + +template +struct AABB_traits_intersection_base_2{ + typedef typename GeomTraits::Ray_2 Ray_2; + typedef typename GeomTraits::Point_2 Point_2; + typedef typename GeomTraits::Point_2 Point; + typedef typename GeomTraits::Ray_2 Ray; + typedef typename GeomTraits::Vector_2 Vector_2; + typedef typename GeomTraits::FT FT; + typedef typename GeomTraits::Cartesian_const_iterator_2 Cartesian_const_iterator_2; + typedef typename GeomTraits::Construct_cartesian_const_iterator_2 Construct_cartesian_const_iterator_2; + typedef typename GeomTraits::Construct_source_2 Construct_source_2; + typedef typename GeomTraits::Construct_vector_2 Construct_vector_2; + + // Defining Bounding_box and other types from the full AABB_traits_2 + // here is might seem strange, but otherwise we would need to use + // CRTP to get access to the derived class, which would bloat the + // code more. + typedef typename CGAL::Bbox_2 Bounding_box; + + struct Intersection_distance { + std::optional operator()(const Ray_2& ray, const Bounding_box& bbox) const { + FT t_near = -DBL_MAX; // std::numeric_limits::lowest(); C++1903 + FT t_far = DBL_MAX; + + const Construct_cartesian_const_iterator_2 construct_cartesian_const_iterator_2 + = GeomTraits().construct_cartesian_const_iterator_2_object(); + const Construct_source_2 construct_source_2 = GeomTraits().construct_source_2_object(); + const Construct_vector_2 construct_vector_2 = GeomTraits().construct_vector_2_object(); + const Point_2 source = construct_source_2(ray); + const Vector_2 direction = construct_vector_2(ray); + Cartesian_const_iterator_2 source_iter = construct_cartesian_const_iterator_2(source); + Cartesian_const_iterator_2 direction_iter = construct_cartesian_const_iterator_2(direction); + + for(int i = 0; i < 3; ++i, ++source_iter, ++direction_iter) { + if(*direction_iter == 0) { + if((*source_iter < (bbox.min)(i)) || (*source_iter > (bbox.max)(i))) { + return std::nullopt; + } + } else { + FT t1 = ((bbox.min)(i) - *source_iter) / *direction_iter; + FT t2 = ((bbox.max)(i) - *source_iter) / *direction_iter; + + t_near = (std::max)(t_near, (std::min)(t1, t2)); + t_far = (std::min)(t_far, (std::max)(t1, t2)); + + // if(t1 > t2) + // std::swap(t1, t2); + // if(t1 > t_near) + // t_near = t1; + // if(t2 < t_far) + // t_far = t2; + + if(t_near > t_far || t_far < FT(0.)) + return std::nullopt; + } + } + + if(t_near < FT(0.)) + return FT(0.); + else + return t_near; + } + }; + + Intersection_distance intersection_distance_object() const { return Intersection_distance(); } +}; + +} } //end of namespace internal::AABB_tree + +/// \addtogroup PkgAABBTreeRef +/// @{ + +// forward declaration +template< typename AABBTraits> +class AABB_tree; + + +/// This traits class handles any type of 3D geometric +/// primitives provided that the proper intersection tests and +/// constructions are implemented. It handles points, rays, lines and +/// segments as query types for intersection detection and +/// computations, and it handles points as query type for distance +/// queries. +/// +/// \cgalModels{AABBTraits,AABBRayIntersectionTraits} +/// +/// \tparam GeomTraits must be a model of the concept \ref AABBGeomTraits_2, +/// and provide the geometric types as well as the intersection tests and computations. +/// \tparam Primitive provide the type of primitives stored in the AABB_tree. +/// It is a model of the concept `AABBPrimitive` or `AABBPrimitiveWithSharedData`. +/// +/// \tparam BboxMap must be a model of `ReadablePropertyMap` that has as key type a primitive id, +/// and as value type a `Bounding_box`. +/// If the type is `Default` the `Datum` must have the +/// member function `bbox()` that returns the bounding box of the primitive. +/// +/// If the argument `GeomTraits` is a model of the concept \ref +/// AABBRayIntersectionGeomTraits, this class is also a model of \ref +/// AABBRayIntersectionTraits. +/// +/// \sa `AABBTraits` +/// \sa `AABB_tree` +/// \sa `AABBPrimitive` +/// \sa `AABBPrimitiveWithSharedData` + +template +class AABB_traits_2 +#ifndef DOXYGEN_RUNNING +: public internal::AABB_tree::AABB_traits_base, + public internal::AABB_tree::AABB_traits_intersection_base_2, + public Search_traits_2 +#endif +{ + typedef typename CGAL::Object Object; +public: + typedef GeomTraits Geom_traits; + + typedef AABB_traits_2 AT; + // AABBTraits concept types + typedef typename GeomTraits::FT FT; + typedef AABBPrimitive Primitive; + + typedef typename std::pair Object_and_primitive_id; + + typedef typename std::pair Point_and_primitive_id; + + /// `Intersection_and_primitive_id::%Type::first_type` is found according to + /// the result type of `GeomTraits::Intersect_2::operator()`. If it is + /// `std::optional` then it is `T`, and the result type otherwise. + template + struct Intersection_and_primitive_id { + typedef decltype( + std::declval()( + std::declval(), + std::declval())) Intersection_type; + + typedef std::pair< + typename internal::AABB_tree::Remove_optional::type, + typename Primitive::Id > Type; + }; + + // types for search tree + /// \name Types + /// @{ + + /// Point query type. + typedef typename GeomTraits::Point_2 Point_2; + + /// additional types for the search tree, required by the RangeSearchTraits concept + /// \bug This is not documented for now in the AABBTraits concept. + typedef typename GeomTraits::Iso_rectangle_2 Iso_rectangle_2; + + /// Bounding box type. + typedef typename CGAL::Bbox_2 Bounding_box; + + /// @} + + typedef typename GeomTraits::Circle_2 Circle_2; + typedef typename GeomTraits::Cartesian_const_iterator_2 Cartesian_const_iterator_2; + typedef typename GeomTraits::Construct_cartesian_const_iterator_2 Construct_cartesian_const_iterator_2; + typedef typename GeomTraits::Construct_center_2 Construct_center_2; + typedef typename GeomTraits::Compute_squared_radius_2 Compute_squared_radius_2; + typedef typename GeomTraits::Construct_min_vertex_2 Construct_min_vertex_2; + typedef typename GeomTraits::Construct_max_vertex_2 Construct_max_vertex_2; + typedef typename GeomTraits::Construct_iso_rectangle_2 Construct_iso_rectangle_2; + + BboxMap bbm; + + /// Default constructor. + AABB_traits_2() { } + + AABB_traits_2(BboxMap bbm) + : bbm(bbm) + {} + + + typedef typename GeomTraits::Compute_squared_distance_2 Squared_distance; + Squared_distance squared_distance_object() const { return GeomTraits().compute_squared_distance_2_object(); } + + typedef typename GeomTraits::Equal_2 Equal; + Equal equal_object() const { return GeomTraits().equal_2_object(); } + + /** + * @internal + * @brief Sorts [first,beyond[ + * @param first iterator on first element + * @param beyond iterator on beyond element + * @param bbox the bounding box of [first,beyond[ + * + * Sorts the range defined by [first,beyond[. Sort is achieved on bbox longest + * axis, using the comparison function `_less_than` (dim in {x,y,z}) + */ + class Split_primitives + { + typedef AABB_traits_2 Traits; + const Traits& m_traits; + public: + Split_primitives(const AABB_traits_2& traits) + : m_traits(traits) {} + + typedef void result_type; + template + void operator()(PrimitiveIterator first, + PrimitiveIterator beyond, + const typename AT::Bounding_box& bbox) const + { + PrimitiveIterator middle = first + (beyond - first)/2; + switch(Traits::longest_axis(bbox)) + { + case AT::CGAL_AXIS_X: // sort along x + std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_x(p1, p2, this->m_traits); }); + break; + case AT::CGAL_AXIS_Y: // sort along y + std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_y(p1, p2, this->m_traits); }); + break; + default: + CGAL_error(); + } + } + }; + + Split_primitives split_primitives_object() const {return Split_primitives(*this);} + + + /* + * Computes the bounding box of a set of primitives + * @param first an iterator on the first primitive + * @param beyond an iterator on the past-the-end primitive + * @return the bounding box of the primitives of the iterator range + */ + class Compute_bbox { + const AABB_traits_2& m_traits; + public: + Compute_bbox(const AABB_traits_2& traits) + :m_traits (traits) {} + + template + typename AT::Bounding_box operator()(ConstPrimitiveIterator first, + ConstPrimitiveIterator beyond) const + { + typename AT::Bounding_box bbox = m_traits.compute_bbox(*first,m_traits.bbm); + for(++first; first != beyond; ++first) + { + bbox = bbox + m_traits.compute_bbox(*first,m_traits.bbm); + } + return bbox; + } + + }; + + Compute_bbox compute_bbox_object() const {return Compute_bbox(*this);} + + /// \brief Function object using `GeomTraits::Do_intersect`. + /// In the case the query is a `CGAL::AABB_tree`, the `do_intersect()` + /// function of this tree is used. + class Do_intersect { + const AABB_traits_2& m_traits; + public: + Do_intersect(const AABB_traits_2& traits) + :m_traits(traits) {} + + template + bool operator()(const Query& q, const Bounding_box& bbox) const + { + return GeomTraits().do_intersect_2_object()(q, bbox); + } + + template + bool operator()(const Query& q, const Primitive& pr) const + { + return GeomTraits().do_intersect_2_object()(q, internal::Primitive_helper::get_datum(pr,m_traits)); + } + + // intersection with AABB-tree + template + bool operator()(const CGAL::AABB_tree& other_tree, const Primitive& pr) const + { + return other_tree.do_intersect( internal::Primitive_helper::get_datum(pr,m_traits) ); + } + + template + bool operator()(const CGAL::AABB_tree& other_tree, const Bounding_box& bbox) const + { + return other_tree.do_intersect(bbox); + } + }; + + Do_intersect do_intersect_object() const {return Do_intersect(*this);} + + + class Intersection { + const AABB_traits_2& m_traits; + public: + Intersection(const AABB_traits_2& traits) + :m_traits(traits) {} + template + std::optional< typename Intersection_and_primitive_id::Type > + operator()(const Query& query, const typename AT::Primitive& primitive) const { + auto inter_res = GeomTraits().intersect_2_object()(query, internal::Primitive_helper::get_datum(primitive,m_traits)); + if (!inter_res) + return std::nullopt; + return std::make_optional( std::make_pair(*inter_res, primitive.id()) ); + } + }; + + Intersection intersection_object() const {return Intersection(*this);} + + + // This should go down to the GeomTraits, i.e. the kernel + class Closest_point { + typedef typename AT::Point_2 Point; + typedef typename AT::Primitive Primitive; + const AABB_traits_2& m_traits; + public: + Closest_point(const AABB_traits_2& traits) + : m_traits(traits) {} + + + Point operator()(const Point& p, const Primitive& pr, const Point& bound) const + { + GeomTraits geom_traits; + Point closest_point = geom_traits.construct_projected_point_2_object()( + internal::Primitive_helper::get_datum(pr,m_traits), p); + + return (geom_traits.compare_distance_2_object()(p, closest_point, bound) == LARGER) ? + bound : closest_point; + } + }; + + // This should go down to the GeomTraits, i.e. the kernel + // and the internal implementation should change its name from + // do_intersect to something like does_contain (this is what we compute, + // this is not the same do_intersect as the spherical kernel) + class Compare_distance { + typedef typename AT::Point_2 Point; + typedef typename AT::FT FT; + typedef typename AT::Primitive Primitive; + public: + CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, Tag_true) const + { + return GeomTraits().do_intersect_2_object() + (GeomTraits().construct_circle_2_object() + (p, GeomTraits().compute_squared_distance_2_object()(p, bound)), bb,true)? + CGAL::SMALLER : CGAL::LARGER; + } + + CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound, Tag_false) const + { + return GeomTraits().do_intersect_2_object() + (GeomTraits().construct_circle_2_object() + (p, GeomTraits().compute_squared_distance_2_object()(p, bound)), bb)? + CGAL::SMALLER : CGAL::LARGER; + } + + CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound) const + { + return (*this)(p, bb, bound, Boolean_tag::value>()); + } + + // The following functions seem unused...? + template + CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const Point& bound) const + { + return GeomTraits().do_intersect_2_object() + (GeomTraits().construct_circle_2_object() + (p, GeomTraits().compute_squared_distance_2_object()(p, bound)), pr)? + CGAL::SMALLER : CGAL::LARGER; + } + + template + CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const FT& sq_distance) const + { + return GeomTraits().do_intersect_2_object() + (GeomTraits().construct_circle_2_object()(p, sq_distance), + pr) ? + CGAL::SMALLER : + CGAL::LARGER; + } + }; + + Closest_point closest_point_object() const {return Closest_point(*this);} + Compare_distance compare_distance_object() const {return Compare_distance();} + + typedef enum { CGAL_AXIS_X = 0, + CGAL_AXIS_Y = 1} Axis; + + static Axis longest_axis(const Bounding_box& bbox); + +private: + /** + * @brief Computes bounding box of one primitive + * @param pr the primitive + * @return the bounding box of the primitive \c pr + */ + template + Bounding_box compute_bbox(const Primitive& pr, const PM&)const + { + return get(bbm, pr.id()); + } + + Bounding_box compute_bbox(const Primitive& pr, const Default&)const + { + return internal::Primitive_helper::get_datum(pr,*this).bbox(); + } + + /// Comparison functions + static bool less_x(const Primitive& pr1, const Primitive& pr2,const AABB_traits_2& traits) + { + return GeomTraits().less_x_2_object()( internal::Primitive_helper::get_reference_point(pr1,traits), + internal::Primitive_helper::get_reference_point(pr2,traits) ); + } + static bool less_y(const Primitive& pr1, const Primitive& pr2,const AABB_traits_2& traits) + { + return GeomTraits().less_y_2_object()( internal::Primitive_helper::get_reference_point(pr1,traits), + internal::Primitive_helper::get_reference_point(pr2,traits) ); + } + +}; // end class AABB_traits_2 + + +//------------------------------------------------------- +// Private methods +//------------------------------------------------------- + template + typename AABB_traits_2::Axis + AABB_traits_2::longest_axis(const Bounding_box& bbox) +{ + const double dx = bbox.xmax() - bbox.xmin(); + const double dy = bbox.ymax() - bbox.ymin(); + + if(dx>=dy) + { + return CGAL_AXIS_X; + } + else + { + return CGAL_AXIS_Y; + } +} + +/// @} + +} // end namespace CGAL + +#include + +#endif // CGAL_AABB_TRAITS_2_H_ diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index 737a52dfc143..6da8fab40463 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3278,6 +3278,7 @@ namespace CartesianKernelFunctors { { typedef typename K::Point_2 Point_2; typedef typename K::Line_2 Line_2; + typedef typename K::Segment_2 Segment_2; public: typedef Point_2 result_type; @@ -3289,6 +3290,15 @@ namespace CartesianKernelFunctors { line_project_pointC2(l.a(), l.b(), l.c(), p.x(), p.y(), x, y); return construct_point_2(x, y); } + + Point_2 + operator()( const Segment_2& s, const Point_2& p ) const + { + assert(false); + return p; + // CommonKernelFunctors::Construct_projected_point_3()(s,p,K()); + } + }; From 26d87931d313133a95252982579eb6c3f43b8eae Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 4 Mar 2024 15:43:26 +0000 Subject: [PATCH 011/100] Changes so that the 2D example compiles --- AABB_tree/include/CGAL/AABB_traits_3.h | 4 ++-- .../include/CGAL/AABB_tree/internal/AABB_search_tree.h | 5 ++--- .../include/CGAL/AABB_tree/internal/AABB_traversal_traits.h | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_traits_3.h b/AABB_tree/include/CGAL/AABB_traits_3.h index 1dc9189516b1..dac9422eb7b4 100644 --- a/AABB_tree/include/CGAL/AABB_traits_3.h +++ b/AABB_tree/include/CGAL/AABB_traits_3.h @@ -246,8 +246,8 @@ class AABB_traits_3 typedef typename GeomTraits::Compute_squared_distance_3 Squared_distance; Squared_distance squared_distance_object() const { return GeomTraits().compute_squared_distance_3_object(); } - typedef typename GeomTraits::Equal_3 Equal_3; - Equal_3 equal_3_object() const { return GeomTraits().equal_3_object(); } + typedef typename GeomTraits::Equal_3 Equal; + Equal equal_object() const { return GeomTraits().equal_3_object(); } /** * @internal diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h index b4b15a924998..8ce31d31af42 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h @@ -25,9 +25,7 @@ namespace CGAL template struct AABB_search_tree { - typedef typename Traits::FT FT; - typedef typename Traits::Point_3 Point; - typedef typename Traits::Primitive Primitive; + typedef typename Traits::Point_and_primitive_id Point_and_primitive_id; typedef First_of_pair_property_map Pmap; typedef Search_traits_adapter TreeTraits; @@ -56,6 +54,7 @@ struct AABB_search_tree m_tree.build(); } + template Point_and_primitive_id closest_point(const Point& query) const { Neighbor_search search(m_tree, query, 1); diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traversal_traits.h b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traversal_traits.h index ce9a56e15b9d..cb421f42ba43 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traversal_traits.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traversal_traits.h @@ -151,7 +151,7 @@ template class Listing_primitive_traits { typedef typename AABBTraits::FT FT; - typedef typename AABBTraits::Point_3 Point; + typedef typename AABBTraits::Point Point; typedef typename AABBTraits::Primitive Primitive; typedef typename AABBTraits::Bounding_box Bounding_box; typedef typename AABBTraits::Primitive::Id Primitive_id; @@ -278,7 +278,7 @@ template class Projection_traits { typedef typename AABBTraits::FT FT; - typedef typename AABBTraits::Point_3 Point; + typedef typename AABBTraits::Point Point; typedef typename AABBTraits::Primitive Primitive; typedef typename AABBTraits::Bounding_box Bounding_box; typedef typename AABBTraits::Primitive::Id Primitive_id; @@ -301,7 +301,7 @@ class Projection_traits { Point new_closest_point = m_traits.closest_point_object() (query, primitive, m_closest_point); - if( !m_traits.equal_3_object()(new_closest_point, m_closest_point) ) + if( !m_traits.equal_object()(new_closest_point, m_closest_point) ) { m_closest_primitive = primitive.id(); m_closest_point = new_closest_point; // this effectively shrinks the sphere From a76cc2b3abe056ed2590ea63533969a188526dfc Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 4 Mar 2024 15:46:20 +0000 Subject: [PATCH 012/100] Typo in concept AABBGeomTraits_3 --- AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h index e235a5e871fb..19763cfba82b 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h @@ -4,7 +4,7 @@ \cgalConcept The concept `AABBGeomTraits_3` defines the requirements for the first template parameter of the class -`CGAL::AABB_traits`. It provides predicates and constructors to detect +`CGAL::AABB_traits_3`. It provides predicates and constructors to detect and compute intersections between query objects and the primitives stored in the AABB tree. In addition, it contains predicates and constructors to compute distances between a point query and the primitives stored in the AABB tree. @@ -200,4 +200,3 @@ Equal_3 equal_3_object(); /// @} }; /* end AABBGeomTraits_3 */ - From 14efb2c0d502858caa7489d960b3cf0bfa49cb1a Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 4 Mar 2024 16:03:42 +0000 Subject: [PATCH 013/100] whitespace --- AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h index 8ce31d31af42..2716a99b9050 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h @@ -25,7 +25,7 @@ namespace CGAL template struct AABB_search_tree { - + typedef typename Traits::Point_and_primitive_id Point_and_primitive_id; typedef First_of_pair_property_map Pmap; typedef Search_traits_adapter TreeTraits; @@ -65,4 +65,3 @@ struct AABB_search_tree } #endif // CGAL_AABB_SEARCH_TREE_H - From b34c63c3f93322c46e42ef7174b1f54e4b1bb359 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 4 Mar 2024 16:06:42 +0000 Subject: [PATCH 014/100] Add AABBGeomTraits_2 --- .../doc/AABB_tree/Concepts/AABBGeomTraits_2.h | 202 ++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h new file mode 100644 index 000000000000..17000ef1a6ad --- /dev/null +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h @@ -0,0 +1,202 @@ + +/*! +\ingroup PkgAABBTreeConcepts +\cgalConcept + +The concept `AABBGeomTraits_2` defines the requirements for the first template parameter of the class +`CGAL::AABB_traits_2`. It provides predicates and constructors to detect +and compute intersections between query objects and the primitives stored in the AABB tree. +In addition, it contains predicates and constructors to compute distances between a point query +and the primitives stored in the AABB tree. + +\cgalRefines{SearchGeomTraits_2} + +\cgalHasModelsBegin +\cgalHasModelsBare{All models of the concept `Kernel`} +\cgalHasModelsEnd + +\sa `CGAL::AABB_traits` +\sa `CGAL::AABB_tree` +\sa `AABBPrimitive` + +*/ + +class AABBGeomTraits_2 { +public: + +/// \name Types +/// @{ + +/*! +A functor object to detect intersections between two geometric objects. +Provides the following operators: + +`bool operator()(Query, Bbox_2)`, + +`bool operator()(Query, Primitive::Datum)`, + +`bool operator()(Circle_2, Bbox_2)`. + +The operator returns `true` iff there exists a non-empty intersection. +*/ +typedef unspecified_type Do_intersect_2; + +/*! +A functor object to construct the intersection between two geometric objects. + +Provides the operator: + +`return_type operator()(const Query& q, const Primitive::Datum& d)`, + +which computes the intersection between `q` and `d`. The type of the returned object +must be a `std::optional` of a `std::variant` of the possible intersection types. +*/ +typedef unspecified_type Intersect_2; + +/*! +A functor object to construct the circle centered at one point and passing through another one. +Provides the operator: + +`Circle_2 operator()(const Point_2& p, const FT & sr)`, + +which returns the circle centered at `p` with `sr` as squared radius. +*/ +typedef unspecified_type Construct_circle_2; + +/*! +A functor object to compute the point on a geometric primitive which is closest from a query. +Provides the operator: + +`Point_2 operator()(const Primitive::Datum& d, const Point_2& p)`, + +which returns the point on `d` that is closest to `p`. +*/ +typedef unspecified_type Construct_projected_point_2; + +/*! +A functor object to compare the distance of two points wrt a third one. Provides the operator: + +`CGAL::Comparison_result operator()(const Point_2& p1, const Point_2& p2, const Point_2& p3)`, + +which compares the distance between `p1` and `p2`, and between `p2` and `p3`. +*/ +typedef unspecified_type Compare_distance_2; + +/*! +A functor object to compute the squared radius of a circle. +Provides the operator: + +`FT operator()(const Circle_2& s),` + +which returns the squared radius of `s`. +*/ +typedef unspecified_type Compute_squared_radius_2; + +/*! +A functor object to compute the squared distance between two points. Provides the operator: + +`FT operator()(const Point_2& p, const Point_2& q),` + +which returns the squared distance between `p` and `q`. +*/ +typedef unspecified_type Compute_squared_distance_2; + +/*! +A functor object to compare the x-coordinates of two points. Provides the operator: + +`bool operator()(const Point_2& p, const Point_2& q)`, + + which returns `true` iff the x-coordinate of `p` is smaller than the x-coordinate of `q`. +*/ +typedef unspecified_type Less_x_2; + +/*! +A functor object to compare the y-coordinates of two points. Provides the operator: + +`bool operator()(const Point_2& p, const Point_2& q)`, + +which returns `true` iff the y-coordinate of `p` is smaller than the y-coordinate of `q`. +*/ +typedef unspecified_type Less_y_2; + +/*! +A functor object to compare the z-coordinates of two points. Provides the operator: + +`bool operator()(const Point_2& p, const Point_2& q)`, + +which returns `true` iff the z-coordinate of `p` is smaller than the z-coordinate of `q`. +*/ +typedef unspecified_type Less_z_2; + +/*! +A functor object to compare two points. Provides the operator: + +`bool operator()(const Point_2& p, const Point_2& q)`, + +which returns `true` iff `p` is equal to `q`. +*/ +typedef unspecified_type Equal_2; + +/// @} + +/// \name Operations +/// @{ + +/*! +returns the intersection detection predicate. +*/ +Do_intersect_2 do_intersect_2_object(); + +/*! +returns the intersection constructor. +*/ +Intersect_2 intersect_2_object(); + +/*! +returns the circle constructor. +*/ +Construct_circle_2 construct_circle_2_object(); + +/*! +returns the closest point constructor. +*/ +Construct_projected_point_2 construct_projected_point_2_object(); + +/*! +returns the compare distance predicate. +*/ +Compare_distance_2 compare_distance_2_object(); + +/*! +returns the squared radius functor. +*/ +Compute_squared_radius_2 compute_squared_radius_2_object(); + +/*! +returns the squared distance functor. +*/ +Compute_squared_distance_2 compute_squared_distance_2_object(); + +/*! +returns the `Less_x_2` predicate. +*/ +Less_x_2 less_x_2_object(); + +/*! +returns the `Less_y_2` predicate. +*/ +Less_y_2 less_y_2_object(); + +/*! +returns the `Less_z_2` predicate. +*/ +Less_z_2 less_z_2_object(); + +/*! +returns the equal predicate. +*/ +Equal_2 equal_2_object(); + +/// @} + +}; /* end AABBGeomTraits_2 */ From f0bdc2d867766a02e886f9b7a6232b88375569a9 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 4 Mar 2024 19:31:20 +0000 Subject: [PATCH 015/100] Make Minkowski_sum_2 work --- .../AABB_collision_detector_2.h | 2 +- .../CGAL/Minkowski_sum_2/AABB_traits_2.h | 26 ++++++++++++------- .../AABB_traversal_traits_with_join.h | 2 +- .../Minkowski_sum_2/AABB_tree_with_join.h | 2 +- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_collision_detector_2.h b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_collision_detector_2.h index b926d6808062..4a4d8ab4757e 100644 --- a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_collision_detector_2.h +++ b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_collision_detector_2.h @@ -37,7 +37,7 @@ class AABB_collision_detector_2 typedef typename Polygon_2::Edge_const_iterator Edge_iterator; typedef AABB_segment_2_primitive Tree_segment_2; - typedef AABB_traits_2 Tree_traits; + typedef Minkowski_sum::AABB_traits_2 Tree_traits; typedef AABB_tree_with_join Tree_2; public: diff --git a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_traits_2.h b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_traits_2.h index 601fc8febc74..8317616c9a00 100644 --- a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_traits_2.h +++ b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_traits_2.h @@ -13,12 +13,16 @@ #define CGAL_AABB_TRAITS_2_H #include +#include namespace CGAL { +namespace Minkowski_sum { + template class AABB_traits_2 + :public Search_traits_2 { public: @@ -37,18 +41,18 @@ class AABB_traits_2 // Types for AABB_tree typedef typename GeomTraits::FT FT; - typedef typename GeomTraits::Point_2 Point_3; - typedef typename GeomTraits::Circle_2 Sphere_3; - typedef typename GeomTraits::Iso_rectangle_2 Iso_cuboid_3; - typedef typename GeomTraits::Construct_center_2 Construct_center_3; - typedef typename GeomTraits::Construct_iso_rectangle_2 Construct_iso_cuboid_3; - typedef typename GeomTraits::Construct_min_vertex_2 Construct_min_vertex_3; - typedef typename GeomTraits::Construct_max_vertex_2 Construct_max_vertex_3; - typedef typename GeomTraits::Compute_squared_radius_2 Compute_squared_radius_3; + typedef typename GeomTraits::Point_2 Point_2; + typedef typename GeomTraits::Circle_2 Circle_2; + typedef typename GeomTraits::Iso_rectangle_2 Iso_rectangle_2; + typedef typename GeomTraits::Construct_center_2 Construct_center_2; + typedef typename GeomTraits::Construct_iso_rectangle_2 Construct_iso_cuboid_2; + typedef typename GeomTraits::Construct_min_vertex_2 Construct_min_vertex_2; + typedef typename GeomTraits::Construct_max_vertex_2 Construct_max_vertex_2; + typedef typename GeomTraits::Compute_squared_radius_2 Compute_squared_radius_2; typedef typename GeomTraits::Cartesian_const_iterator_2 - Cartesian_const_iterator_3; + Cartesian_const_iterator_2; typedef typename GeomTraits::Construct_cartesian_const_iterator_2 - Construct_cartesian_const_iterator_3; + Construct_cartesian_const_iterator_2; AABB_traits_2(const Point &translation_point): m_translation_point( translation_point) @@ -214,6 +218,8 @@ class AABB_traits_2 } }; +} // namespace Minkowski_sum + } // namespace CGAL #endif diff --git a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_traversal_traits_with_join.h b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_traversal_traits_with_join.h index b44438f24e8e..50a500300756 100644 --- a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_traversal_traits_with_join.h +++ b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_traversal_traits_with_join.h @@ -277,7 +277,7 @@ class Do_intersect_traits template class Do_intersect_joined_traits { - typedef typename AABBTraits::Point_3 Point; + typedef typename AABBTraits::Point Point; typedef typename AABBTraits::Primitive Primitive; typedef AABB_node_with_join Node; diff --git a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_tree_with_join.h b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_tree_with_join.h index aabc398f7398..9c97212c8c59 100644 --- a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_tree_with_join.h +++ b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_tree_with_join.h @@ -70,7 +70,7 @@ namespace CGAL { /// Type of 3D point. - typedef typename AABBTraits::Point_3 Point; + typedef typename AABBTraits::Point Point; /// Type of input primitive. typedef typename AABBTraits::Primitive Primitive; From eb49100a96f998e5cd69d22b0a92ed480d0db7e5 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 5 Mar 2024 07:08:51 +0000 Subject: [PATCH 016/100] Replace deprecated classes --- AABB_tree/include/CGAL/AABB_primitive.h | 5 ++--- .../include/CGAL/AABB_segment_primitive_2.h | 2 +- .../include/CGAL/AABB_segment_primitive_3.h | 3 +-- .../Alpha_wrap_3/internal/Point_set_oracle.h | 4 ++-- .../internal/Segment_soup_oracle.h | 6 +++--- .../internal/Triangle_soup_oracle.h | 2 +- .../Alpha_wrap_3/internal/splitting_helper.h | 4 ++-- .../Lipschitz_sizing_experimental.h | 8 ++++---- .../Lipschitz_sizing_polyhedron.h | 6 +++--- .../polyhedral_to_labeled_function_wrapper.h | 8 ++++---- .../Mesh_domain_with_polyline_features_3.h | 6 +++--- .../include/CGAL/Polyhedral_mesh_domain_3.h | 2 +- .../angle_and_area_smoothing.h | 4 ++-- .../CGAL/Polygon_mesh_processing/clip.h | 2 +- .../CGAL/Polygon_mesh_processing/distance.h | 18 ++++++++--------- ...traversal_traits_with_Hausdorff_distance.h | 4 ++-- .../internal/Corefinement/face_graph_utils.h | 4 ++-- .../Isotropic_remeshing/remesh_impl.h | 8 ++++---- .../internal/Smoothing/mesh_smoothing_impl.h | 2 +- .../internal/Snapping/snap.h | 4 ++-- .../Polygon_mesh_processing/intersection.h | 6 +++--- .../CGAL/Polygon_mesh_processing/locate.h | 20 +++++++++---------- .../orient_polygon_soup_extension.h | 10 +++++----- .../random_perturbation.h | 4 ++-- .../repair_self_intersections.h | 8 ++++---- .../include/CGAL/Polygon_mesh_slicer.h | 4 ++-- .../include/CGAL/Polyhedral_envelope.h | 4 ++-- .../Rigid_triangle_mesh_collision_detection.h | 4 ++-- .../include/CGAL/Side_of_triangle_mesh.h | 4 ++-- .../Plugins/AABB_tree/Cut_plugin.cpp | 6 +++--- .../Plugins/Mesh_3/Offset_meshing_plugin.cpp | 6 +++--- .../Plugins/PMP/Distance_plugin.cpp | 2 +- .../Plugins/PMP/Engrave_text_plugin.cpp | 4 ++-- .../Point_set_to_mesh_distance_plugin.cpp | 8 ++++---- .../Surface_reconstruction_poisson_impl.cpp | 5 ++--- .../Surface_mesh/Offset_meshing_plugin.cpp | 6 +++--- .../Scene_polyhedron_shortest_path_item.cpp | 2 +- .../Scene_polyhedron_shortest_path_item.h | 4 ++-- .../demo/Polyhedron/Scene_c3t3_item.cpp | 4 ++-- .../Polyhedron/Scene_surface_mesh_item.cpp | 4 ++-- .../Polyhedron/Scene_triangulation_3_item.cpp | 4 ++-- .../internal/AABB_traits.h | 8 ++++---- .../Bounded_distance_placement.h | 8 ++++---- .../include/CGAL/AABB_polyhedral_oracle.h | 4 ++-- 44 files changed, 119 insertions(+), 122 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_primitive.h b/AABB_tree/include/CGAL/AABB_primitive.h index 4c58b83f4dba..31d0d77181b5 100644 --- a/AABB_tree/include/CGAL/AABB_primitive.h +++ b/AABB_tree/include/CGAL/AABB_primitive.h @@ -71,8 +71,8 @@ struct AABB_primitive_base * it is constructed on the fly to reduce the memory footprint. * The default is `CGAL::Tag_false` (datum is not stored). * - * \sa `AABB_segment_primitive` - * \sa `AABB_triangle_primitive` + * \sa `AABB_segment_primitive_3` + * \sa `AABB_triangle_primitive_3` * \sa `AABB_halfedge_graph_segment_primitive` * \sa `AABB_face_graph_triangle_primitive` */ @@ -251,4 +251,3 @@ class AABB_primitive #include #endif // CGAL_AABB_PRIMITIVE_H - diff --git a/AABB_tree/include/CGAL/AABB_segment_primitive_2.h b/AABB_tree/include/CGAL/AABB_segment_primitive_2.h index 3b4fdab16a7f..f0d2ed8e463b 100644 --- a/AABB_tree/include/CGAL/AABB_segment_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_segment_primitive_2.h @@ -67,7 +67,7 @@ namespace internal { * * \sa `AABBPrimitive` * \sa `AABB_primitive` - * \sa `AABB_triangle_primitive` + * \sa `AABB_triangle_primitive_3` * \sa `AABB_halfedge_graph_segment_primitive` * \sa `AABB_face_graph_triangle_primitive` */ diff --git a/AABB_tree/include/CGAL/AABB_segment_primitive_3.h b/AABB_tree/include/CGAL/AABB_segment_primitive_3.h index b9459de0208a..9f76c66844b6 100644 --- a/AABB_tree/include/CGAL/AABB_segment_primitive_3.h +++ b/AABB_tree/include/CGAL/AABB_segment_primitive_3.h @@ -67,7 +67,7 @@ namespace internal { * * \sa `AABBPrimitive` * \sa `AABB_primitive` - * \sa `AABB_triangle_primitive` + * \sa `AABB_triangle_primitive_3` * \sa `AABB_halfedge_graph_segment_primitive` * \sa `AABB_face_graph_triangle_primitive` */ @@ -98,4 +98,3 @@ class AABB_segment_primitive_3 #include #endif // CGAL_AABB_SEGMENT_PRIMITIVE_3_H_ - diff --git a/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Point_set_oracle.h b/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Point_set_oracle.h index 33f8a52b178b..d35a20c93fa4 100644 --- a/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Point_set_oracle.h +++ b/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Point_set_oracle.h @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include @@ -51,7 +51,7 @@ struct PS_oracle_traits CGAL::Tag_false, // not external CGAL::Tag_false>; // no caching - using AABB_traits = CGAL::AABB_traits; + using AABB_traits = CGAL::AABB_traits_3; using AABB_tree = CGAL::AABB_tree; }; diff --git a/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Segment_soup_oracle.h b/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Segment_soup_oracle.h index 349cd012ef7a..88d565c6b664 100644 --- a/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Segment_soup_oracle.h +++ b/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Segment_soup_oracle.h @@ -17,9 +17,9 @@ #include #include -#include +#include #include -#include +#include #include #include #include @@ -52,7 +52,7 @@ struct SS_oracle_traits CGAL::Tag_false, // not external CGAL::Tag_false>; // no caching - using AABB_traits = CGAL::AABB_traits; + using AABB_traits = CGAL::AABB_traits_3; using AABB_tree = CGAL::AABB_tree; }; diff --git a/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Triangle_soup_oracle.h b/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Triangle_soup_oracle.h index dadfb5d8be10..f7e7fe50f3d2 100644 --- a/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Triangle_soup_oracle.h +++ b/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Triangle_soup_oracle.h @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include diff --git a/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/splitting_helper.h b/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/splitting_helper.h index 617c76fd1047..0495bca9fb42 100644 --- a/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/splitting_helper.h +++ b/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/splitting_helper.h @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include @@ -192,7 +192,7 @@ struct AABB_tree_splitter_traits CGAL::Tag_true /*external pmaps*/, CGAL::Tag_false /*no caching*/>; - using AABB_traits = CGAL::AABB_traits; + using AABB_traits = CGAL::AABB_traits_3; using AABB_tree = CGAL::AABB_tree; }; diff --git a/Mesh_3/include/CGAL/Mesh_3/experimental/Lipschitz_sizing_experimental.h b/Mesh_3/include/CGAL/Mesh_3/experimental/Lipschitz_sizing_experimental.h index 0973865378f7..5a4448f90d5d 100644 --- a/Mesh_3/include/CGAL/Mesh_3/experimental/Lipschitz_sizing_experimental.h +++ b/Mesh_3/include/CGAL/Mesh_3/experimental/Lipschitz_sizing_experimental.h @@ -17,8 +17,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -58,8 +58,8 @@ class Lipschitz_sizing typedef typename Kernel::Point_3 Point_3; typedef typename std::list::iterator Tr_iterator; - typedef CGAL::AABB_triangle_primitive Primitive; - typedef CGAL::AABB_traits AABB_tr_traits; + typedef CGAL::AABB_triangle_primitive_3 Primitive; + typedef CGAL::AABB_traits_3 AABB_tr_traits; typedef CGAL::AABB_tree AABB_tree; typedef typename CGAL::Default::Get::type Tree; diff --git a/Mesh_3/include/CGAL/Mesh_3/experimental/Lipschitz_sizing_polyhedron.h b/Mesh_3/include/CGAL/Mesh_3/experimental/Lipschitz_sizing_polyhedron.h index df2c3e0bd46b..d9c4957dfba5 100644 --- a/Mesh_3/include/CGAL/Mesh_3/experimental/Lipschitz_sizing_polyhedron.h +++ b/Mesh_3/include/CGAL/Mesh_3/experimental/Lipschitz_sizing_polyhedron.h @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include @@ -51,8 +51,8 @@ class Lipschitz_sizing typedef typename Kernel::Point_3 Point_3; typedef typename std::list::iterator Tr_iterator; - typedef CGAL::AABB_triangle_primitive Primitive; - typedef CGAL::AABB_traits AABB_tr_traits; + typedef CGAL::AABB_triangle_primitive_3 Primitive; + typedef CGAL::AABB_traits_3 AABB_tr_traits; typedef CGAL::AABB_tree AABB_tree; typedef typename CGAL::Default::Get::type Tree; diff --git a/Mesh_3/include/CGAL/Mesh_3/polyhedral_to_labeled_function_wrapper.h b/Mesh_3/include/CGAL/Mesh_3/polyhedral_to_labeled_function_wrapper.h index 940a08eb03c6..ba1b5285945e 100644 --- a/Mesh_3/include/CGAL/Mesh_3/polyhedral_to_labeled_function_wrapper.h +++ b/Mesh_3/include/CGAL/Mesh_3/polyhedral_to_labeled_function_wrapper.h @@ -23,7 +23,7 @@ #include -#include +#include #include #include @@ -68,7 +68,7 @@ class Polyhedral_to_labeled_function_wrapper // AABB_tree Types typedef class AABB_const_polyhedron_triangle_primitive AABB_primitive; - typedef class AABB_traits AABB_traits; + typedef class AABB_traits_3 AABB_traits; typedef class AABB_tree AABB_tree; typedef typename AABB_traits::Bounding_box Bounding_box; @@ -189,7 +189,7 @@ class Polyhedral_tolerance_to_labeled_function_wrapper // AABB_tree Types typedef class AABB_const_polyhedron_triangle_primitive AABB_primitive; - typedef class AABB_traits AABB_traits; + typedef class AABB_traits_3 AABB_traits; typedef class AABB_tree AABB_tree; typedef typename AABB_traits::Bounding_box Bounding_box; @@ -264,7 +264,7 @@ class Polyhedral_edge_tolerance_to_labeled_function_wrapper // AABB_tree Types typedef class AABB_const_polyhedron_edge_primitive AABB_primitive; - typedef class AABB_traits AABB_traits; + typedef class AABB_traits_3 AABB_traits; typedef class AABB_tree AABB_tree; typedef typename AABB_traits::Bounding_box Bounding_box; diff --git a/Mesh_3/include/CGAL/Mesh_domain_with_polyline_features_3.h b/Mesh_3/include/CGAL/Mesh_domain_with_polyline_features_3.h index 1792177d9d5a..61eb0682d831 100644 --- a/Mesh_3/include/CGAL/Mesh_domain_with_polyline_features_3.h +++ b/Mesh_3/include/CGAL/Mesh_domain_with_polyline_features_3.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -848,8 +848,8 @@ class Mesh_domain_with_polyline_features_3 GT, typename Edges::const_iterator> Curves_primitives; - typedef CGAL::AABB_traits AABB_curves_traits; + typedef CGAL::AABB_traits_3 AABB_curves_traits; Corners corners_; Corners_tmp_incidences corners_tmp_incidences_; diff --git a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h index 60f6d9bc8278..1020e1b38acc 100644 --- a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h +++ b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h @@ -212,7 +212,7 @@ class Polyhedral_mesh_domain_3 public: typedef typename Primitive_type::type Ins_fctor_primitive; - typedef CGAL::AABB_traits Ins_fctor_traits; + typedef CGAL::AABB_traits_3 Ins_fctor_traits; typedef CGAL::AABB_tree Ins_fctor_AABB_tree; typedef Side_of_triangle_mesh Triangle_container; - typedef CGAL::AABB_triangle_primitive AABB_Primitive; - typedef CGAL::AABB_traits AABB_Traits; + typedef CGAL::AABB_traits_3 AABB_Traits; typedef CGAL::AABB_tree Tree; if(std::begin(faces) == std::end(faces)) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h index f37105cd6e60..586139b663f2 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h index a071b3591d07..a3df6d5d9c52 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h @@ -21,8 +21,8 @@ #include #include -#include -#include +#include +#include #include #include #include @@ -1116,7 +1116,7 @@ double max_distance_to_triangle_mesh(const PointRange& points, spatial_sort(points_cpy.begin(), points_cpy.end()); typedef AABB_face_graph_triangle_primitive Primitive; - typedef AABB_traits Tree_traits; + typedef AABB_traits_3 Tree_traits; typedef AABB_tree Tree; Tree_traits tgt/*(gt)*/; @@ -2009,8 +2009,8 @@ bounded_error_squared_one_sided_Hausdorff_distance_impl(const TriangleMesh1& tm1 using TM1_primitive = AABB_face_graph_triangle_primitive; using TM2_primitive = AABB_face_graph_triangle_primitive; - using TM1_traits = AABB_traits; - using TM2_traits = AABB_traits; + using TM1_traits = AABB_traits_3; + using TM2_traits = AABB_traits_3; using TM1_tree = AABB_tree; using TM2_tree = AABB_tree; @@ -2026,7 +2026,7 @@ bounded_error_squared_one_sided_Hausdorff_distance_impl(const TriangleMesh1& tm1 #if defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) && defined(USE_PARALLEL_BEHD) using TMF = CGAL::Face_filtered_graph; using TMF_primitive = AABB_face_graph_triangle_primitive; - using TMF_traits = AABB_traits; + using TMF_traits = AABB_traits_3; using TMF_tree = AABB_tree; using TM1_wrapper = Triangle_mesh_wrapper; using TM2_wrapper = Triangle_mesh_wrapper; @@ -2285,8 +2285,8 @@ bounded_error_squared_symmetric_Hausdorff_distance_impl(const TriangleMesh1& tm1 using TM1_primitive = AABB_face_graph_triangle_primitive; using TM2_primitive = AABB_face_graph_triangle_primitive; - using TM1_traits = AABB_traits; - using TM2_traits = AABB_traits; + using TM1_traits = AABB_traits_3; + using TM2_traits = AABB_traits_3; using TM1_tree = AABB_tree; using TM2_tree = AABB_tree; @@ -2419,7 +2419,7 @@ bounded_error_squared_Hausdorff_distance_naive_impl(const TriangleMesh1& tm1, using Triangle_3 = typename Kernel::Triangle_3; using TM2_primitive = AABB_face_graph_triangle_primitive; - using TM2_traits = AABB_traits; + using TM2_traits = AABB_traits_3; using TM2_tree = AABB_tree; using TM1_face_to_triangle_map = Triangle_from_face_descriptor_map; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/AABB_traversal_traits_with_Hausdorff_distance.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/AABB_traversal_traits_with_Hausdorff_distance.h index ccf77246ee65..e1eb934042a2 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/AABB_traversal_traits_with_Hausdorff_distance.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/AABB_traversal_traits_with_Hausdorff_distance.h @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include @@ -379,7 +379,7 @@ class Hausdorff_primitive_traits_tm1 using Triangle_3 = typename Kernel::Triangle_3; using TM2_primitive = AABB_face_graph_triangle_primitive; - using TM2_traits = AABB_traits; + using TM2_traits = AABB_traits_3; using TM2_tree = AABB_tree; using TM2_hd_traits = Hausdorff_primitive_traits_tm2; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h index 68f0c9e5e6c8..ef7db0585872 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h @@ -255,7 +255,7 @@ struct Side_of_helper typedef Node_vector_exact_vertex_point_map VPM; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree_type; static @@ -331,7 +331,7 @@ struct Side_of_helper Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree_type; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h index 30d201d1ef51..c58717496098 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h @@ -25,8 +25,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -290,9 +290,9 @@ namespace internal { typedef std::vector Patch_id_list; typedef std::map Patch_id_to_index_map; - typedef CGAL::AABB_triangle_primitive AABB_primitive; - typedef CGAL::AABB_traits AABB_traits; + typedef CGAL::AABB_traits_3 AABB_traits; typedef CGAL::AABB_tree AABB_tree; typedef typename boost::property_map< diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/mesh_smoothing_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/mesh_smoothing_impl.h index e15ae718823d..1bf2088e5bac 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/mesh_smoothing_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/mesh_smoothing_impl.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap.h index b7c0d086c5cb..311605545edb 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap.h @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include @@ -875,7 +875,7 @@ std::size_t snap_non_conformal_one_way(const HalfedgeRange& halfedge_range_S, typedef typename boost::property_traits::value_type Point; typedef CGAL::AABB_halfedge_graph_segment_primitive Primitive; - typedef CGAL::AABB_traits AABB_Traits; + typedef CGAL::AABB_traits_3 AABB_Traits; typedef CGAL::AABB_tree AABB_tree; typedef std::pair Vertex_with_new_position; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/intersection.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/intersection.h index a996edae6483..5726723cc3da 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/intersection.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/intersection.h @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include @@ -1109,7 +1109,7 @@ bool is_mesh2_in_mesh1(const TriangleMesh& tm1, const GT& gt) { typedef CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree AABBTree; AABBTree tree1(faces(tm1).begin(), faces(tm1).end(), tm1, vpm1); @@ -1464,7 +1464,7 @@ struct Mesh_callback typedef typename boost::range_value::type NamedParameters; typedef typename GetVertexPointMap::const_type VPM; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree AABBTree; typedef typename boost::graph_traits::face_descriptor face_descriptor; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/locate.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/locate.h index b99ed460a6f6..c8653c0196d4 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/locate.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/locate.h @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include #include @@ -1522,7 +1522,7 @@ template locate_with_AABB_tree(const Point& p, - const AABB_tree > >& tree, #else typename internal::Location_traits::Face_location locate_with_AABB_tree(const typename internal::Location_traits::Point& p, - const AABB_tree::type, CGAL::AABB_face_graph_triangle_primitive > >& tree, #endif @@ -1613,7 +1613,7 @@ locate_with_AABB_tree(const typename internal::Location_traits::type Geom_traits; typedef typename CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef typename CGAL::AABB_traits AABB_traits; + typedef typename CGAL::AABB_traits_3 AABB_traits; typedef typename Primitive::Point Point_3; static_assert(std::is_same::value); @@ -1701,7 +1701,7 @@ locate(const typename internal::Location_traits:: typedef typename GetGeomTraits::type Geom_traits; typedef AABB_face_graph_triangle_primitive AABB_face_graph_primitive; - typedef CGAL::AABB_traits AABB_face_graph_traits; + typedef CGAL::AABB_traits_3 AABB_face_graph_traits; typedef internal::Point_to_Point_3 P_to_P3; typedef typename AABB_face_graph_traits::Point_3 Point_3; @@ -1772,12 +1772,12 @@ template locate_with_AABB_tree(const Ray& ray, - const AABB_tree > >& tree, + const AABB_tree > >& tree, #else typename internal::Location_traits::Face_location locate_with_AABB_tree(const typename internal::Location_traits::Ray& ray, const AABB_tree< - CGAL::AABB_traits< + CGAL::AABB_traits_3< typename GetGeomTraits::type, CGAL::AABB_face_graph_triangle_primitive > >& tree, @@ -1798,7 +1798,7 @@ locate_with_AABB_tree(const typename internal::Location_traits R_to_R3; typedef typename CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef typename CGAL::AABB_traits AABB_traits; + typedef typename CGAL::AABB_traits_3 AABB_traits; typedef AABB_tree AABB_face_graph_tree; typedef typename AABB_face_graph_tree::template Intersection_and_primitive_id::Type Intersection_type; typedef std::optional Ray_intersection; @@ -1919,7 +1919,7 @@ locate(const typename internal::Location_traits:: typedef typename GetGeomTraits::type Geom_traits; typedef AABB_face_graph_triangle_primitive AABB_face_graph_primitive; - typedef CGAL::AABB_traits AABB_face_graph_traits; + typedef CGAL::AABB_traits_3 AABB_face_graph_traits; using parameters::get_parameter; using parameters::choose_parameter; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup_extension.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup_extension.h index c2f323744806..0b1a7ae95881 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup_extension.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup_extension.h @@ -19,8 +19,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -190,8 +190,8 @@ void orient_triangle_soup_with_reference_triangle_soup(const ReferencePointRange } typedef typename std::vector::const_iterator Iterator; - typedef CGAL::AABB_triangle_primitive Primitive; - typedef CGAL::AABB_traits Tree_traits; + typedef CGAL::AABB_triangle_primitive_3 Primitive; + typedef CGAL::AABB_traits_3 Tree_traits; CGAL::AABB_tree tree(ref_triangles.begin(), ref_triangles.end()); @@ -326,7 +326,7 @@ void orient_triangle_soup_with_reference_triangle_mesh(const TriangleMesh& tm_re }; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef CGAL::AABB_traits Tree_traits; + typedef CGAL::AABB_traits_3 Tree_traits; boost::filter_iterator begin(is_not_deg, faces(tm_ref).begin(), faces(tm_ref).end()), diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/random_perturbation.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/random_perturbation.h index 08875a0b9e8d..8afb829b4b2c 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/random_perturbation.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/random_perturbation.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include @@ -67,7 +67,7 @@ namespace internal { typedef typename GT::Point_3 Point_3; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; Tree tree; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_self_intersections.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_self_intersections.h index ed92f836dec4..364a8dc624b1 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_self_intersections.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_self_intersections.h @@ -29,8 +29,8 @@ #endif #include -#include -#include +#include +#include #include #include #include @@ -1070,8 +1070,8 @@ struct Mesh_projection_functor typedef typename GeomTraits::Triangle_3 Triangle_3; typedef std::vector Triangle_container; - typedef CGAL::AABB_triangle_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_triangle_primitive_3 Primitive; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; template diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_slicer.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_slicer.h index a608179f49ae..624c0078c76e 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_slicer.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_slicer.h @@ -17,7 +17,7 @@ #include -#include +#include #include #include @@ -76,7 +76,7 @@ template::type, class AABBTree = AABB_tree< - AABB_traits #include -#include +#include #include #include @@ -283,7 +283,7 @@ struct Polyhedral_envelope { }; typedef AABB_primitive, Point_map, Tag_true /*UseSharedData*/, Tag_false /*CacheDatum*/> Primitive; - typedef AABB_traits Tree_traits; + typedef AABB_traits_3 Tree_traits; typedef AABB_tree Tree; // Data members diff --git a/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h b/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h index bde9c86826e4..36b7e965c88a 100644 --- a/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h +++ b/Polygon_mesh_processing/include/CGAL/Rigid_triangle_mesh_collision_detection.h @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include @@ -76,7 +76,7 @@ class Rigid_triangle_mesh_collision_detection // AABB-tree type typedef AABB_face_graph_triangle_primitive Default_primitive; - typedef AABB_traits Default_tree_traits; + typedef AABB_traits_3 Default_tree_traits; typedef CGAL::AABB_tree Default_tree; typedef typename Default::Get::type Tree; typedef typename Tree::AABB_traits Tree_traits; diff --git a/Polygon_mesh_processing/include/CGAL/Side_of_triangle_mesh.h b/Polygon_mesh_processing/include/CGAL/Side_of_triangle_mesh.h index eff54edea7c2..85f9f4c8f607 100644 --- a/Polygon_mesh_processing/include/CGAL/Side_of_triangle_mesh.h +++ b/Polygon_mesh_processing/include/CGAL/Side_of_triangle_mesh.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include namespace CGAL { @@ -81,7 +81,7 @@ class Side_of_triangle_mesh struct AABB_tree_default { typedef CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree type; }; typedef typename Default::Lazy_get #include -#include +#include #include #include #include @@ -216,11 +216,11 @@ struct PPMAP }; typedef CGAL::AABB_face_graph_triangle_primitive > Facet_sm_primitive; -typedef CGAL::AABB_traits Facet_sm_traits; +typedef CGAL::AABB_traits_3 Facet_sm_traits; typedef CGAL::AABB_tree Facet_sm_tree; typedef CGAL::AABB_halfedge_graph_segment_primitive > Edge_sm_primitive; -typedef CGAL::AABB_traits Edge_sm_traits; +typedef CGAL::AABB_traits_3 Edge_sm_traits; typedef CGAL::AABB_tree Edge_sm_tree; typedef QMap Facet_sm_trees; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Offset_meshing_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Offset_meshing_plugin.cpp index d4a5dc15ffba..8ce2f79c600e 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Offset_meshing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Offset_meshing_plugin.cpp @@ -8,7 +8,7 @@ #include "C3t3_type.h" #include -#include +#include #include #include @@ -53,7 +53,7 @@ template class Offset_function { using Primitive = AABB_face_graph_triangle_primitive; - using Traits = AABB_traits; + using Traits = AABB_traits_3; using Tree = AABB_tree; using Side_of = Side_of_triangle_mesh; @@ -198,7 +198,7 @@ class Polygon_soup_offset_function } }; // struct template Polygon_soup_primitive - using AABB_traits = CGAL::AABB_traits; + using AABB_traits = CGAL::AABB_traits_3; using AABB_tree = CGAL::AABB_tree; std::shared_ptr m_tree_ptr; diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp index 3034e7f58a3e..e0cc78af9d36 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp @@ -130,7 +130,7 @@ class Scene_distance_polyhedron_item: public Scene_item_rendering_helper std::vector& out)const { typedef CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree< Traits > Tree; Tree tree( faces(m).first, faces(m).second, m); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Engrave_text_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Engrave_text_plugin.cpp index 8c3048eaa3ff..7beb6d42dce7 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Engrave_text_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Engrave_text_plugin.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -307,7 +307,7 @@ class Q_DECL_EXPORT Engrave_text_plugin : typedef CGAL::Surface_mesh_shortest_path Surface_mesh_shortest_path; typedef Surface_mesh_shortest_path::Face_location Face_location; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef CGAL::AABB_traits Tree_traits; + typedef CGAL::AABB_traits_3 Tree_traits; typedef CGAL::AABB_tree Tree; typedef EPICK::Point_3 Point_3; Messages_interface* messages; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_plugin.cpp index ca915ab64cb8..de1ec885a6b3 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_plugin.cpp @@ -15,8 +15,8 @@ #include -#include -#include +#include +#include #include #include #ifdef CGAL_LINKED_WITH_TBB @@ -72,8 +72,8 @@ double compute_distances(const Mesh& m, const Point_set & point_set, std::vector& out) { - typedef CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_face_graph_triangle_primitive_3 Primitive; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree< Traits > Tree; Tree tree( faces(m).first, faces(m).second, m); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Surface_reconstruction_poisson_impl.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Surface_reconstruction_poisson_impl.cpp index 56b882dd652f..11a8fe9a7b32 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Surface_reconstruction_poisson_impl.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Surface_reconstruction_poisson_impl.cpp @@ -5,7 +5,7 @@ // CGAL #include // must be included before kernel -#include +#include #include #include #include @@ -186,7 +186,7 @@ SMesh* poisson_reconstruct(Point_set& points, // AABB tree typedef CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef CGAL::AABB_traits AABB_traits; + typedef CGAL::AABB_traits_3 AABB_traits; typedef CGAL::AABB_tree AABB_tree; CGAL::Timer task_timer; task_timer.start(); @@ -393,4 +393,3 @@ SMesh* poisson_reconstruct(Point_set& points, } return mesh; } - diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Offset_meshing_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Offset_meshing_plugin.cpp index eb9be7db96ed..7232068ae0c2 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Offset_meshing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Offset_meshing_plugin.cpp @@ -21,7 +21,7 @@ #include "C3t3_type.h" #include -#include +#include #include #include @@ -45,7 +45,7 @@ template class Offset_function { typedef AABB_face_graph_triangle_primitive Primitive; - typedef AABB_traits Traits; + typedef AABB_traits_3 Traits; typedef AABB_tree Tree; typedef Side_of_triangle_mesh Side_of; @@ -169,7 +169,7 @@ class Polygon_soup_offset_function { }; // end struct template AABB_primitive - typedef CGAL::AABB_traits AABB_traits; + typedef CGAL::AABB_traits_3 AABB_traits; typedef CGAL::AABB_tree AABB_tree; std::shared_ptr m_tree_ptr; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Scene_polyhedron_shortest_path_item.cpp b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Scene_polyhedron_shortest_path_item.cpp index f32bef66a0f8..90477043da7f 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Scene_polyhedron_shortest_path_item.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Scene_polyhedron_shortest_path_item.cpp @@ -37,7 +37,7 @@ struct Scene_polyhedron_shortest_path_item_priv typedef Surface_mesh_shortest_path::Face_location Face_location; typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; - typedef CGAL::AABB_traits AABB_face_graph_traits; + typedef CGAL::AABB_traits_3 AABB_face_graph_traits; typedef CGAL::AABB_tree AABB_face_graph_tree; typedef Surface_mesh_shortest_path_traits::Barycentric_coordinates diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Scene_polyhedron_shortest_path_item.h b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Scene_polyhedron_shortest_path_item.h index f9af8a8cfec4..26ec5055df55 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Scene_polyhedron_shortest_path_item.h +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Scene_polyhedron_shortest_path_item.h @@ -24,7 +24,7 @@ #endif #include -#include +#include #include #include @@ -50,7 +50,7 @@ class SCENE_POLYHEDRON_SHORTEST_PATH_ITEM_EXPORT Scene_polyhedron_shortest_path_ typedef CGAL::Surface_mesh_shortest_path Surface_mesh_shortest_path; typedef Surface_mesh_shortest_path::Face_location Face_location; typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; - typedef CGAL::AABB_traits AABB_face_graph_traits; + typedef CGAL::AABB_traits_3 AABB_face_graph_traits; typedef CGAL::AABB_tree AABB_face_graph_tree; typedef Surface_mesh_shortest_path_traits::Barycentric_coordinates Barycentric_coordinates; diff --git a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp index 47bfe0edbb73..e90c719cec88 100644 --- a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp @@ -33,7 +33,7 @@ #include #include -#include +#include #include #include @@ -42,7 +42,7 @@ typedef CGAL::AABB_triangulation_3_cell_primitive Primitive; -typedef CGAL::AABB_traits Traits; +typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; typedef Tree::Point_and_primitive_id Point_and_primitive_id; using namespace CGAL::Three; diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp index 4bdd7f765818..8457074755a6 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include @@ -91,7 +91,7 @@ class Primitive }; -typedef CGAL::AABB_traits AABB_traits; +typedef CGAL::AABB_traits_3 AABB_traits; typedef CGAL::AABB_tree Input_facets_AABB_tree; diff --git a/Polyhedron/demo/Polyhedron/Scene_triangulation_3_item.cpp b/Polyhedron/demo/Polyhedron/Scene_triangulation_3_item.cpp index 507122e3de6d..8f20e0cf1b47 100644 --- a/Polyhedron/demo/Polyhedron/Scene_triangulation_3_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_triangulation_3_item.cpp @@ -38,7 +38,7 @@ #include #include -#include +#include #include #include #include @@ -48,7 +48,7 @@ typedef CGAL::AABB_triangulation_3_cell_primitive Primitive; -typedef CGAL::AABB_traits Traits; +typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; typedef Tree::Point_and_primitive_id Point_and_primitive_id; using namespace CGAL::Three; diff --git a/Surface_mesh_segmentation/include/CGAL/Surface_mesh_segmentation/internal/AABB_traits.h b/Surface_mesh_segmentation/include/CGAL/Surface_mesh_segmentation/internal/AABB_traits.h index ae2a6de7ae0f..01a1cba7ec6a 100644 --- a/Surface_mesh_segmentation/include/CGAL/Surface_mesh_segmentation/internal/AABB_traits.h +++ b/Surface_mesh_segmentation/include/CGAL/Surface_mesh_segmentation/internal/AABB_traits.h @@ -16,7 +16,7 @@ #include -#include +#include #include #include @@ -27,10 +27,10 @@ namespace CGAL /// @cond CGAL_DOCUMENT_INTERNAL template class AABB_traits_SDF : - public AABB_traits + public AABB_traits_3 { public: - typedef AABB_traits Base_traits; + typedef AABB_traits_3 Base_traits; typedef typename Base_traits::Bounding_box Bounding_box; typedef typename Base_traits::Point_3 Point_3; @@ -38,7 +38,7 @@ class AABB_traits_SDF : : public Base_traits::Do_intersect { public: - Do_intersect(const AABB_traits& traits) + Do_intersect(const AABB_traits_3& traits) :Base_traits::Do_intersect(traits) {} // not sure is it safe on templated funcs ? may be do not inherit and repeat functions... diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Bounded_distance_placement.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Bounded_distance_placement.h index 0e88fec1c8c1..81824c17c9b4 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Bounded_distance_placement.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Bounded_distance_placement.h @@ -15,8 +15,8 @@ #include #include -#include -#include +#include +#include #include #include #include @@ -41,8 +41,8 @@ class Bounded_distance_placement typedef std::vector Triangle_container; typedef typename Triangle_container::iterator TC_iterator; - typedef CGAL::AABB_triangle_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_triangle_primitive_3 Primitive; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree AABB_tree; private: diff --git a/Surface_mesher/include/CGAL/AABB_polyhedral_oracle.h b/Surface_mesher/include/CGAL/AABB_polyhedral_oracle.h index d03fe0b0fe51..0f05ae1f18e8 100644 --- a/Surface_mesher/include/CGAL/AABB_polyhedral_oracle.h +++ b/Surface_mesher/include/CGAL/AABB_polyhedral_oracle.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -46,7 +46,7 @@ namespace CGAL { // AABB tree typedef AABB_face_graph_triangle_primitive AABB_primitive; - typedef class AABB_traits AABB_traits; + typedef class AABB_traits_3 AABB_traits; typedef AABB_tree Tree; typedef typename AABB_traits::Bounding_box Bounding_box; From b70a7360834be6f3164379b2aa7c4b7f8c6e35d3 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 5 Mar 2024 07:20:28 +0000 Subject: [PATCH 017/100] Replace deprecated classes --- .../internal/Smoothing/mesh_smoothing_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/mesh_smoothing_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/mesh_smoothing_impl.h index 1bf2088e5bac..c3f84b683ec8 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/mesh_smoothing_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/mesh_smoothing_impl.h @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include From 6c1185d60b472f5e5fbfa5300fa2f2f782a1cbe6 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 5 Mar 2024 10:03:52 +0000 Subject: [PATCH 018/100] Add AABB_triangle_primitive_2 --- .../include/CGAL/AABB_triangle_primitive_2.h | 101 ++++++++++++++++++ .../include/CGAL/AABB_triangle_primitive_3.h | 3 +- .../include/CGAL/Cartesian/function_objects.h | 7 ++ 3 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 AABB_tree/include/CGAL/AABB_triangle_primitive_2.h 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 000000000000..393d8517cff0 --- /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 569e579f12b9..8c1116f45109 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 @@ class AABB_triangle_primitive_3 #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 6da8fab40463..f0b5b7fa5ff8 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; + } }; From 56ac3a5c31a92244a567dfb6aab7d4b2e4e182a2 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 5 Mar 2024 10:16:53 +0000 Subject: [PATCH 019/100] Replace deprecated classes --- .../include/CGAL/Alpha_wrap_3/internal/Triangle_soup_oracle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Triangle_soup_oracle.h b/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Triangle_soup_oracle.h index f7e7fe50f3d2..d066107f6207 100644 --- a/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Triangle_soup_oracle.h +++ b/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Triangle_soup_oracle.h @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include From 911ac1a34dc32fc910c8035f211eafcde43ee05e Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Tue, 5 Mar 2024 15:54:27 +0100 Subject: [PATCH 020/100] added Construct_projected_point_2(Segment_2, Point_2) --- .../include/CGAL/Cartesian/function_objects.h | 25 ++++++++++++++++--- .../include/CGAL/_test_fct_constructions_2.h | 11 +++++++- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index f0b5b7fa5ff8..759213e26878 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3295,9 +3295,28 @@ namespace CartesianKernelFunctors { Point_2 operator()( const Segment_2& s, const Point_2& p ) const { - assert(false); - return p; - // CommonKernelFunctors::Construct_projected_point_3()(s,p,K()); + const Point_2& a = s.source(); + const Point_2& b = s.target(); + typename K::FT dx = b.x() - a.x(); + typename K::FT dy = b.y() - a.y(); + + // Degenerate segment + if (dx == 0 && dy == 0) + return a; + + typename K::FT px = p.x() - a.x(); + typename K::FT py = p.y() - a.y(); + + typename K::FT proj = (dx * px + dy * py) / (dx * dx + dy * dy); + + if (proj <= 0.0) + return a; + + if (proj >= 1.0) + return b; + + typename K::Construct_point_2 construct_point_2; + return construct_point_2(a.x() + proj * dx, a.y() + proj * dy); } Point_2 diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_2.h index 288d6a55dfd4..c4411533b412 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_2.h @@ -20,7 +20,7 @@ template bool -_test_fct_constructions_2(const R&) +_test_fct_constructions_2(const R& r) { typedef typename R::RT RT; typedef CGAL::Point_2 Point; @@ -89,6 +89,15 @@ _test_fct_constructions_2(const R&) assert( CGAL::weighted_circumcenter( wpnw_b, wpse_b, wpsw_b ) == psw); + Point a(0.0, 1.0); + Point b(3.0, 4.0); + Segment seg(a, b); + + assert(r.construct_projected_point_2_object()(seg, Point(0, 0)) == a); + assert(r.construct_projected_point_2_object()(seg, Point(5.0, 0)) == Point(2.0, 3.0)); + assert(r.construct_projected_point_2_object()(seg, Point(5.0, 4.0)) == b); + assert(r.construct_projected_point_2_object()(seg, Point(2.0, 4.0)) == Point(2.5, 3.5)); + return true; } From 3f9c5222e21fcbcbe50b9c0986bb8163b34987ad Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Wed, 6 Mar 2024 18:23:39 +0100 Subject: [PATCH 021/100] WIP: adding Construct_projected_point_2 for point onto segment and point onto triangle --- .../include/CGAL/Cartesian/function_objects.h | 30 +-- .../CGAL/Homogeneous/function_objects.h | 10 + .../include/CGAL/Kernel/function_objects.h | 200 ++++++++++++++++++ .../include/CGAL/_test_fct_constructions_2.h | 23 +- 4 files changed, 231 insertions(+), 32 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index 759213e26878..e84312b95798 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3294,37 +3294,11 @@ namespace CartesianKernelFunctors { Point_2 operator()( const Segment_2& s, const Point_2& p ) const - { - const Point_2& a = s.source(); - const Point_2& b = s.target(); - typename K::FT dx = b.x() - a.x(); - typename K::FT dy = b.y() - a.y(); - - // Degenerate segment - if (dx == 0 && dy == 0) - return a; - - typename K::FT px = p.x() - a.x(); - typename K::FT py = p.y() - a.y(); - - typename K::FT proj = (dx * px + dy * py) / (dx * dx + dy * dy); - - if (proj <= 0.0) - return a; - - if (proj >= 1.0) - return b; - - typename K::Construct_point_2 construct_point_2; - return construct_point_2(a.x() + proj * dx, a.y() + proj * dy); - } + { return CommonKernelFunctors::Construct_projected_point_2()(s, p, K()); } Point_2 operator()( const Triangle_2& t, const Point_2& p ) const - { - assert(false); - return p; - } + { return CommonKernelFunctors::Construct_projected_point_2()(t, p, K()); } }; diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h index 3028950d7aff..e28450256a07 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h @@ -3373,6 +3373,8 @@ namespace HomogeneousKernelFunctors { typedef typename K::Point_2 Point_2; typedef typename K::Direction_2 Direction_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; @@ -3385,6 +3387,14 @@ namespace HomogeneousKernelFunctors { l2.a()*l.c() - l.a()*l2.c(), l.a()*l2.b() - l2.a()*l.b() ); } + + Point_2 + operator()(const Segment_2& s, const Point_2& p) const + { return CommonKernelFunctors::Construct_projected_point_2()(s, p, K()); } + + Point_2 + operator()(const Triangle_2& t, const Point_2& p) const + { return CommonKernelFunctors::Construct_projected_point_2()(t, p, K()); } }; template diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index 084a6578913c..ba7db14d92be 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -2874,6 +2874,206 @@ namespace CommonKernelFunctors { } }; + template + class Construct_projected_point_2 + { + bool + is_inside_triangle_2_aux( + const typename K::Point_2& p1, + const typename K::Point_2& p2, + const typename K::Point_2& q, + typename K::Point_2& result, + bool& outside, + const K& k) + { + typedef typename K::Vector_2 Vector_2; + typedef typename K::FT FT; + + typename K::Construct_vector_2 vector = + k.construct_vector_2_object(); + typename K::Construct_projected_point_2 projection = + k.construct_projected_point_2_object(); + typename K::Construct_line_2 line = + k.construct_line_2_object(); + typename K::Compute_scalar_product_2 scalar_product = + k.compute_scalar_product_2_object(); + typename K::Construct_direction_2 direction = + k.construct_direction_2_object(); + typename K::Construct_perpendicular_direction_2 perpendicular = + k.construct_perpendicular_direction_2_object(); + + // Check whether the point is cw or ccw with the triangle side (p1,p2) + Vector_2 orth = vector(p1, p2); + + if (scalar_product(vector(p1, q), vector(perpendicular(direction(orth), CGAL::COUNTERCLOCKWISE))) < FT(0)) + { + if (scalar_product(vector(p1, q), vector(p1, p2)) >= FT(0) + && scalar_product(vector(p2, q), vector(p2, p1)) >= FT(0)) + { + result = projection(line(p1, p2), q); + return true; + } + outside = true; + } + + return false; + } + + /** + * Returns the nearest point of p1,p2,p3 from origin + * @param origin the origin point + * @param p1 the first point + * @param p2 the second point + * @param p3 the third point + * @param k the kernel + * @return the nearest point from origin + */ + typename K::Point_2 + nearest_point_2(const typename K::Point_2& origin, + const typename K::Point_2& p1, + const typename K::Point_2& p2, + const typename K::Point_2& p3, + const K& k) + { + typedef typename K::FT FT; + + typename K::Compute_squared_distance_2 sq_distance = + k.compute_squared_distance_2_object(); + + const FT dist_origin_p1 = sq_distance(origin, p1); + const FT dist_origin_p2 = sq_distance(origin, p2); + const FT dist_origin_p3 = sq_distance(origin, p3); + + if (dist_origin_p2 >= dist_origin_p1 + && dist_origin_p3 >= dist_origin_p1) + { + return p1; + } + if (dist_origin_p3 >= dist_origin_p2) + { + return p2; + } + + return p3; + } + + /** + * @brief returns true if p is inside triangle t. If p is not inside t, + * result is the nearest point of t from p. + * @param p the reference point + * @param t the triangle + * @param result if p is not inside t, the nearest point of t from p + * @param k the kernel + * @return true if p is inside t + */ + bool + is_inside_triangle_2(const typename K::Point_2& p, + const typename K::Triangle_2& t, + typename K::Point_2& result, + const K& k) + { + typedef typename K::Point_2 Point_2; + + typename K::Construct_vertex_2 vertex_on = + k.construct_vertex_2_object(); + + const Point_2& t0 = vertex_on(t, 0); + const Point_2& t1 = vertex_on(t, 1); + const Point_2& t2 = vertex_on(t, 2); + + bool outside = false; + if (is_inside_triangle_2_aux(t0, t1, p, result, outside, k) + || is_inside_triangle_2_aux(t1, t2, p, result, outside, k) + || is_inside_triangle_2_aux(t2, t0, p, result, outside, k)) + { + return false; + } + + if (outside) + { + result = nearest_point_2(p, t0, t1, t2, k); + return false; + } + else + { + return true; + } + } + + public: + typename K::Point_2 + operator()(const typename K::Triangle_2& triangle, + const typename K::Point_2& origin, + const K& k) + { + typedef typename K::Point_2 Point_2; + typename K::Construct_vertex_2 vertex_on; + typename K::Construct_segment_2 segment; + + // Check if triangle is degenerated to call segment operator. + const Point_2& t0 = vertex_on(triangle, 0); + const Point_2& t1 = vertex_on(triangle, 1); + const Point_2& t2 = vertex_on(triangle, 2); + + if (t0 == t1) + return (*this)(segment(t1, t2), origin, k); + if (t1 == t2) + return (*this)(segment(t2, t0), origin, k); + if (t2 == t0) + return (*this)(segment(t0, t1), origin, k); + + Point_2 moved_point; + bool inside = is_inside_triangle_2(origin, triangle, moved_point, k); + + // If proj is inside triangle, return it + if (inside) + { + return origin; + } + + // Else return the constructed point + return moved_point; + } + + typename K::Point_2 + operator()(const typename K::Segment_2& s, + const typename K::Point_2& query, + const K& k) { + + typename K::Construct_vector_2 vector = + k.construct_vector_2_object(); + + typename K::Compute_scalar_product_2 scalar_product = + k.compute_scalar_product_2_object(); + + typename K::Construct_scaled_vector_2 scaled_vector = + k.construct_scaled_vector_2_object(); + + const typename K::Point_2& a = s.source(); + const typename K::Point_2& b = s.target(); + const typename K::Vector_2 d = vector(a, b); + + typename K::FT sqlen = scalar_product(d, d); + + // Degenerate segment + if (is_zero(sqlen)) + return a; + + const typename K::Vector_2 p = vector(a, query); + + typename K::FT proj = (scalar_product(p, d)) / sqlen; + + if (!is_positive(proj)) + return a; + + if (proj >= 1.0) + return b; + + typename K::Construct_point_2 construct_point_2; + return construct_point_2(a + scaled_vector(d, proj)); + } + }; + template class Construct_projected_point_3 { diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_2.h index c4411533b412..90e8cbcd2c15 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_2.h @@ -93,10 +93,25 @@ _test_fct_constructions_2(const R& r) Point b(3.0, 4.0); Segment seg(a, b); - assert(r.construct_projected_point_2_object()(seg, Point(0, 0)) == a); - assert(r.construct_projected_point_2_object()(seg, Point(5.0, 0)) == Point(2.0, 3.0)); - assert(r.construct_projected_point_2_object()(seg, Point(5.0, 4.0)) == b); - assert(r.construct_projected_point_2_object()(seg, Point(2.0, 4.0)) == Point(2.5, 3.5)); + assert(CGAL::equal_xy(r.construct_projected_point_2_object()(seg, Point(0, 0)), a)); + assert(CGAL::equal_xy(r.construct_projected_point_2_object()(seg, Point(5.0, 0)), Point(2.0, 3.0))); + assert(CGAL::equal_xy(r.construct_projected_point_2_object()(seg, Point(5.0, 4.0)), b)); + assert(CGAL::equal_xy(r.construct_projected_point_2_object()(seg, Point(2.0, 4.0)), Point(2.5, 3.5))); + + Point c(2.0, 5.0); + Triangle tri(a, b, c); + assert(CGAL::equal_xy(r.construct_projected_point_2_object()(tri, Point(0, 0)), a)); + assert(CGAL::equal_xy(r.construct_projected_point_2_object()(tri, Point(0, 10.0)), c)); + assert(CGAL::equal_xy(r.construct_projected_point_2_object()(tri, Point(3.5, 3.5)), b)); + assert(CGAL::equal_xy(r.construct_projected_point_2_object()(tri, Point(2.0, 1.0)), Point(1.0, 2.0))); + assert(CGAL::equal_xy(r.construct_projected_point_2_object()(tri, Point(2.0, 4.0)), Point(2.0, 4.0))); + + Triangle dtri(a, b, a); + + assert(CGAL::equal_xy(r.construct_projected_point_2_object()(dtri, Point(0, 0)), a)); + assert(CGAL::equal_xy(r.construct_projected_point_2_object()(dtri, Point(5.0, 0)), Point(2.0, 3.0))); + assert(CGAL::equal_xy(r.construct_projected_point_2_object()(dtri, Point(5.0, 4.0)), b)); + assert(CGAL::equal_xy(r.construct_projected_point_2_object()(dtri, Point(2.0, 4.0)), Point(2.5, 3.5))); return true; } From cda5d0ab60e3e7b68244e3bd64f0498509efa927 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Wed, 6 Mar 2024 18:25:07 +0100 Subject: [PATCH 022/100] adding AABB_polyline_segment_primitive_2 for Polygon_2 and PointRange --- .../AABB_tree/AABB_segment_2_example.cpp | 101 ++++++++++------ .../CGAL/AABB_polyline_segment_primitive_2.h | 110 ++++++++++++++++++ 2 files changed, 177 insertions(+), 34 deletions(-) create mode 100644 AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h diff --git a/AABB_tree/examples/AABB_tree/AABB_segment_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_segment_2_example.cpp index 62cbadafff8e..b759aa91a8c1 100644 --- a/AABB_tree/examples/AABB_tree/AABB_segment_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_segment_2_example.cpp @@ -4,7 +4,9 @@ #include #include #include +#include #include +#include typedef CGAL::Simple_cartesian K; @@ -13,42 +15,73 @@ typedef K::FT FT; typedef K::Segment_2 Segment; typedef K::Point_2 Point; -typedef std::list::iterator Iterator; -typedef CGAL::AABB_segment_primitive_2 Primitive; -typedef CGAL::AABB_traits_2 Traits; -typedef CGAL::AABB_tree Tree; +typedef std::list SegmentRange; +typedef SegmentRange::iterator Iterator_seg; +typedef CGAL::AABB_segment_primitive_2 Primitive_seg; +typedef CGAL::AABB_traits_2 Traits_seg; +typedef CGAL::AABB_tree Tree_seg; + +typedef std::vector PointRange; +typedef PointRange::iterator Iterator_pr; +typedef CGAL::AABB_polyline_segment_primitive_2 Primitive_pr; +typedef CGAL::AABB_traits_2 Traits_pr; +typedef CGAL::AABB_tree Tree_pr; + +typedef CGAL::Polygon_2 Polygon; +typedef Polygon::iterator Iterator_poly; +typedef CGAL::AABB_polyline_segment_primitive_2 Primitive_poly; +typedef CGAL::AABB_traits_2 Traits_poly; +typedef CGAL::AABB_tree Tree_poly; int main() { - Point a(0.0, 0.0); - Point b(2.0, 1.0); - Point c(3.0, 4.0); - Point d(1.0, 6.0); - Point e(-1.0, 3.0); - - std::list segments; - segments.push_back(Segment(a, b)); - segments.push_back(Segment(b, c)); - segments.push_back(Segment(c, d)); - segments.push_back(Segment(d, e)); - segments.push_back(Segment(e, a)); - - // // constructs the AABB tree and the internal search tree for - // // efficient distance computations. - Tree tree(segments.begin(), segments.end()); - // tree.accelerate_distance_queries(); - - // // counts #intersections with a segment query - Segment segment_query(Point(1.0, 0.0), Point(0.0, 7.0)); - std::cout << tree.number_of_intersected_primitives(segment_query) - << " intersections(s) with segment" << std::endl; - - - // computes the closest point from a point query - Point point_query(1.5, 3.0); - Point closest = tree.closest_point(point_query); - - //std::cerr << "closest point is: " << closest << std::endl; - return EXIT_SUCCESS; + Point a(0.0, 0.0); + Point b(2.0, 1.0); + Point c(3.0, 4.0); + Point d(1.0, 6.0); + Point e(-1.0, 3.0); + + std::list seg; + seg.push_back(Segment(a, b)); + seg.push_back(Segment(b, c)); + seg.push_back(Segment(c, d)); + seg.push_back(Segment(d, e)); + seg.push_back(Segment(e, a)); + + std::vector polyline = { a, b, c, d, e }; + + Polygon poly(polyline.begin(), polyline.end()); + + // // constructs the AABB tree and the internal search tree for + // // efficient distance computations. + Tree_seg tree_seg(seg.begin(), seg.end()); + Tree_pr tree_pr(polyline.begin(), polyline.end(), polyline); + Tree_poly tree_poly(poly.begin(), poly.end(), poly); + + tree_seg.accelerate_distance_queries(); + tree_pr.accelerate_distance_queries(); + tree_poly.accelerate_distance_queries(); + + // // counts #intersections with a segment query + + Segment segment_query(Point(1.0, 0.0), Point(0.0, 7.0)); + std::cout << tree_seg.number_of_intersected_primitives(segment_query) + << " intersections(s) with segment" << std::endl; + + std::cout << tree_pr.number_of_intersected_primitives(segment_query) + << " intersections(s) with segment" << std::endl; + + std::cout << tree_poly.number_of_intersected_primitives(segment_query) + << " intersections(s) with segment" << std::endl; + + // computes the closest point from a point query + Point point_query(1.5, 3.0); + Point closest = tree_seg.closest_point(point_query); + std::cerr << "closest point is: " << closest << std::endl; + closest = tree_pr.closest_point(point_query); + std::cerr << "closest point is: " << closest << std::endl; + closest = tree_poly.closest_point(point_query); + std::cerr << "closest point is: " << closest << std::endl; + return EXIT_SUCCESS; } diff --git a/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h b/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h new file mode 100644 index 000000000000..c2bbbf6da957 --- /dev/null +++ b/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h @@ -0,0 +1,110 @@ +// Copyright (c) 2024 GeometryFactory. +// 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_POLYLINE_SEGMENT_PRIMITIVE_2_H_ +#define CGAL_AABB_POLYLINE_SEGMENT_PRIMITIVE_2_H_ + +#include + +#include + +#include +#include + +namespace CGAL { + +namespace internal { + 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; + + Segment_2_from_point_iterator_property_map(Iterator b, Iterator e) : begin(b), end(e) {} + Segment_2_from_point_iterator_property_map() {} + + inline friend reference // Cannot return reference as the Segment does not exist, only the points exist. + get(Self s, key_type it) + { + typename Iterator::value_type& p = *it; + it++; + if (it == s.end) + return typename GeomTraits::Construct_segment_2()(p, *s.begin); + else + return typename GeomTraits::Construct_segment_2()( p, *it ); + } + + Iterator begin, end; + }; +}//namespace internal + + +/*! + * \ingroup PkgAABBTreeRef + * 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 + * 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 `Segment_2`. + * It also provides the functor `Construct_source_2` that has an operator taking a `Segment_2` + * and returning its source as a type convertible to `Point_2`. + * \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Segment_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_triangle_primitive_3` + * \sa `AABB_halfedge_graph_segment_primitive` + * \sa `AABB_face_graph_triangle_primitive` + */ +template < class PointRange, + class GeomTraits, + class Iterator, + class CacheDatum=Tag_false> +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, + Tag_true, + CacheDatum > +#endif +{ + typedef AABB_primitive< Iterator, + internal::Segment_2_from_point_iterator_property_map, + Input_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()); + } +}; + +} // end namespace CGAL + +#include + +#endif // CGAL_AABB_POLYLINE_SEGMENT_PRIMITIVE_2_H_ From 1be8f232dce4501e3932d38c1164633cc0217460 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 7 Mar 2024 13:14:34 +0100 Subject: [PATCH 023/100] Apply suggestions from code review Co-authored-by: Sebastien Loriot --- AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 c2bbbf6da957..8b3a4eb5178e 100644 --- a/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h @@ -8,7 +8,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // -// Author(s) : Sebastien Loriot +// Author(s) : Sven Oesau // @@ -17,7 +17,6 @@ #include -#include #include #include @@ -105,6 +104,5 @@ class AABB_polyline_segment_primitive_2 } // end namespace CGAL -#include #endif // CGAL_AABB_POLYLINE_SEGMENT_PRIMITIVE_2_H_ From 6ae5c638bdf3419d2d550603694452e55cdbfc41 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 8 Mar 2024 07:01:03 +0000 Subject: [PATCH 024/100] A _3 too much --- .../Plugins/Point_set/Point_set_to_mesh_distance_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_plugin.cpp index de1ec885a6b3..608a8b5d3a4d 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_plugin.cpp @@ -72,7 +72,7 @@ double compute_distances(const Mesh& m, const Point_set & point_set, std::vector& out) { - typedef CGAL::AABB_face_graph_triangle_primitive_3 Primitive; + typedef CGAL::AABB_face_graph_triangle_primitive Primitive; typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree< Traits > Tree; From 19725c0b0824f63145261d99ac5e2d691cfd9008 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 8 Mar 2024 08:40:02 +0000 Subject: [PATCH 025/100] Fix PMP testsuite --- AABB_tree/include/CGAL/AABB_traits_3.h | 2 ++ .../CGAL/Polygon_mesh_processing/internal/Snapping/snap.h | 2 +- .../point_inside_polyhedron_boundary_test.cpp | 2 +- .../point_inside_surface_mesh_test.cpp | 2 +- .../test/Polygon_mesh_processing/test_pmp_locate.cpp | 6 +++--- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_traits_3.h b/AABB_tree/include/CGAL/AABB_traits_3.h index dac9422eb7b4..2bc1ec3b9454 100644 --- a/AABB_tree/include/CGAL/AABB_traits_3.h +++ b/AABB_tree/include/CGAL/AABB_traits_3.h @@ -215,6 +215,8 @@ class AABB_traits_3 /// Point query type. typedef typename GeomTraits::Point_3 Point_3; + typedef Point_3 Point; // AF: because the AABB_tree dimension agnostic + /// additional types for the search tree, required by the RangeSearchTraits concept /// \bug This is not documented for now in the AABBTraits concept. typedef typename GeomTraits::Iso_cuboid_3 Iso_cuboid_3; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap.h index 311605545edb..7fbf5fd1902a 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap.h @@ -373,7 +373,7 @@ class Projection_traits return; const typename Primitive::Datum& s = primitive.datum(m_traits.shared_data()); - if(m_traits.equal_3_object()(s[0], query) || m_traits.equal_3_object()(s[1], query)) + if(m_traits.equal_object()(s[0], query) || m_traits.equal_object()(s[1], query)) { // If we are NOT using the same mesh and the query is (geometrically) equal to one extremity // of the target edge, we don't want to move the source point away from the target point diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_polyhedron_boundary_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_polyhedron_boundary_test.cpp index 7029c29a2f8e..e7473ce575ff 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_polyhedron_boundary_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_polyhedron_boundary_test.cpp @@ -32,7 +32,7 @@ int main(int argc, char** argv) //test compilation of constructor from AABB_tree typedef CGAL::AABB_face_graph_triangle_primitive FGTP; - typedef CGAL::AABB_traits AABB_traits; + typedef CGAL::AABB_traits_3 AABB_traits; typedef CGAL::AABB_tree AABB_tree; AABB_tree tree(faces(poly).first, faces(poly).second, poly); diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_surface_mesh_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_surface_mesh_test.cpp index ef7bf8f9e992..9338820c0004 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_surface_mesh_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_surface_mesh_test.cpp @@ -39,7 +39,7 @@ int test_surface_mesh(const std::string filename) //test compilation of constructor from AABB_tree typedef CGAL::AABB_face_graph_triangle_primitive FGTP; - typedef CGAL::AABB_traits AABB_traits; + typedef CGAL::AABB_traits_3 AABB_traits; typedef CGAL::AABB_tree AABB_tree; AABB_tree tree(faces(mesh).first, faces(mesh).second, mesh); diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_locate.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_locate.cpp index c0b57f62449f..b2250c03641a 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_locate.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_locate.cpp @@ -519,7 +519,7 @@ struct Locate_with_AABB_tree_Tester // 2D case typedef PMP::internal::Point_to_Point_3 Intrinsic_point_to_Point_3; typedef PMP::internal::Point_to_Point_3_VPM WrappedVPM; typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; - typedef CGAL::AABB_traits AABB_face_graph_traits; + typedef CGAL::AABB_traits_3 AABB_face_graph_traits; static_assert(std::is_same::value); @@ -629,7 +629,7 @@ struct Locate_with_AABB_tree_Tester // 3D // --------------------------------------------------------------------------- typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; - typedef CGAL::AABB_traits AABB_face_graph_traits; + typedef CGAL::AABB_traits_3 AABB_face_graph_traits; typedef typename K::Point_3 Point_3; static_assert(std::is_same::value); @@ -643,7 +643,7 @@ struct Locate_with_AABB_tree_Tester // 3D typedef boost::associative_property_map Custom_VPM; typedef PMP::internal::Point_to_Point_3_VPM WrappedVPM; typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive_with_WVPM; - typedef CGAL::AABB_traits AABB_face_graph_traits_with_WVPM; + typedef CGAL::AABB_traits_3 AABB_face_graph_traits_with_WVPM; CGAL::AABB_tree tree_b; Custom_map custom_map; From 37e36b85327dcacd2c4ff42d6d406a43866bbf25 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 7 Mar 2024 12:51:46 +0100 Subject: [PATCH 026/100] fixed tests for point_2 on segment_2 and on triangle_2 --- .../include/CGAL/_test_fct_constructions_2.h | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_2.h index 90e8cbcd2c15..dcbb3fec1124 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_2.h @@ -89,29 +89,29 @@ _test_fct_constructions_2(const R& r) assert( CGAL::weighted_circumcenter( wpnw_b, wpse_b, wpsw_b ) == psw); - Point a(0.0, 1.0); - Point b(3.0, 4.0); + Point a(0, 1); + Point b(3, 4); Segment seg(a, b); - assert(CGAL::equal_xy(r.construct_projected_point_2_object()(seg, Point(0, 0)), a)); - assert(CGAL::equal_xy(r.construct_projected_point_2_object()(seg, Point(5.0, 0)), Point(2.0, 3.0))); - assert(CGAL::equal_xy(r.construct_projected_point_2_object()(seg, Point(5.0, 4.0)), b)); - assert(CGAL::equal_xy(r.construct_projected_point_2_object()(seg, Point(2.0, 4.0)), Point(2.5, 3.5))); + assert(r.construct_projected_point_2_object()(seg, Point(0, 0)) == a); + assert(r.construct_projected_point_2_object()(seg, Point(5, 0)) == Point(2, 3)); + assert(r.construct_projected_point_2_object()(seg, Point(5, 4)) == b); + assert(r.construct_projected_point_2_object()(seg, Point(2, 4)) == Point(5, 7, 2)); Point c(2.0, 5.0); Triangle tri(a, b, c); - assert(CGAL::equal_xy(r.construct_projected_point_2_object()(tri, Point(0, 0)), a)); - assert(CGAL::equal_xy(r.construct_projected_point_2_object()(tri, Point(0, 10.0)), c)); - assert(CGAL::equal_xy(r.construct_projected_point_2_object()(tri, Point(3.5, 3.5)), b)); - assert(CGAL::equal_xy(r.construct_projected_point_2_object()(tri, Point(2.0, 1.0)), Point(1.0, 2.0))); - assert(CGAL::equal_xy(r.construct_projected_point_2_object()(tri, Point(2.0, 4.0)), Point(2.0, 4.0))); + assert(r.construct_projected_point_2_object()(tri, Point(0, 0)) == a); + assert(r.construct_projected_point_2_object()(tri, Point(0, 10)) == c); + assert(r.construct_projected_point_2_object()(tri, Point(7, 7, 2)) == b); + assert(r.construct_projected_point_2_object()(tri, Point(2, 1)) == Point(1, 2)); + assert(r.construct_projected_point_2_object()(tri, Point(2, 4)) == Point(2, 4)); Triangle dtri(a, b, a); - assert(CGAL::equal_xy(r.construct_projected_point_2_object()(dtri, Point(0, 0)), a)); - assert(CGAL::equal_xy(r.construct_projected_point_2_object()(dtri, Point(5.0, 0)), Point(2.0, 3.0))); - assert(CGAL::equal_xy(r.construct_projected_point_2_object()(dtri, Point(5.0, 4.0)), b)); - assert(CGAL::equal_xy(r.construct_projected_point_2_object()(dtri, Point(2.0, 4.0)), Point(2.5, 3.5))); + assert(r.construct_projected_point_2_object()(dtri, Point(0, 0)) == a); + assert(r.construct_projected_point_2_object()(dtri, Point(5, 0)) == Point(2, 3)); + assert(r.construct_projected_point_2_object()(dtri, Point(5, 4)) == b); + assert(r.construct_projected_point_2_object()(dtri, Point(2, 4)) == Point(5, 7, 2)); return true; } From 30cec7dada3d44979b54be2415198b9eda33281a Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Fri, 8 Mar 2024 16:43:12 +0100 Subject: [PATCH 027/100] updating polyline segment primitive and example --- .../doc/AABB_tree/PackageDescription.txt | 1 + AABB_tree/doc/AABB_tree/examples.txt | 1 + .../AABB_polyline_segment_2_example.cpp | 83 +++++++++++++++++++ .../AABB_tree/AABB_segment_2_example.cpp | 62 ++++---------- .../CGAL/AABB_polyline_segment_primitive_2.h | 26 +++--- .../include/CGAL/AABB_segment_primitive_2.h | 2 +- 6 files changed, 117 insertions(+), 58 deletions(-) create mode 100644 AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp diff --git a/AABB_tree/doc/AABB_tree/PackageDescription.txt b/AABB_tree/doc/AABB_tree/PackageDescription.txt index c53fc291f7ea..628074b747d4 100644 --- a/AABB_tree/doc/AABB_tree/PackageDescription.txt +++ b/AABB_tree/doc/AABB_tree/PackageDescription.txt @@ -40,6 +40,7 @@ \cgalCRPSection{Primitives} - `CGAL::AABB_triangle_primitive_2` - `CGAL::AABB_segment_primitive_2` +- `CGAL::AABB_polyline_segment_primitive_2` - `CGAL::AABB_triangle_primitive_3` - `CGAL::AABB_segment_primitive_3` - `CGAL::AABB_primitive` diff --git a/AABB_tree/doc/AABB_tree/examples.txt b/AABB_tree/doc/AABB_tree/examples.txt index cc274a274697..4e6213186f15 100644 --- a/AABB_tree/doc/AABB_tree/examples.txt +++ b/AABB_tree/doc/AABB_tree/examples.txt @@ -7,6 +7,7 @@ \example AABB_tree/AABB_polyhedron_edge_example.cpp \example AABB_tree/AABB_polyhedron_facet_distance_example.cpp \example AABB_tree/AABB_polyhedron_facet_intersection_example.cpp +\example AABB_tree/AABB_polyline_segment_2_example.cpp \example AABB_tree/AABB_segment_3_example.cpp \example AABB_tree/AABB_ray_shooting_example.cpp \example AABB_tree/AABB_triangle_3_example.cpp diff --git a/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp new file mode 100644 index 000000000000..0dc2be17b8c9 --- /dev/null +++ b/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp @@ -0,0 +1,83 @@ +#include +#include + +#include +#include +#include +#include +#include +#include + + +typedef CGAL::Simple_cartesian K; + +typedef K::FT FT; +typedef K::Segment_2 Segment; +typedef K::Point_2 Point; + +typedef std::vector PointRange; +typedef PointRange::iterator Iterator_pr; +typedef CGAL::AABB_polyline_segment_primitive_2 Primitive_pr; +typedef CGAL::AABB_traits_2 Traits_pr; +typedef CGAL::AABB_tree Tree_pr; +typedef Tree_pr::Point_and_primitive_id Point_and_primitive_id_pr; + +typedef CGAL::Polygon_2 Polygon; +typedef Polygon::iterator Iterator_poly; +typedef CGAL::AABB_polyline_segment_primitive_2 Primitive_poly; +typedef CGAL::AABB_traits_2 Traits_poly; +typedef CGAL::AABB_tree Tree_poly; +typedef Tree_poly::Point_and_primitive_id Point_and_primitive_id_poly; + + +int main() +{ + Point a(0.0, 0.0); + Point b(2.0, 1.0); + Point c(3.0, 4.0); + Point d(1.0, 6.0); + Point e(-1.0, 3.0); + + std::vector polyline = { a, b, c, d, e }; + + Polygon poly(polyline.begin(), polyline.end()); + + // constructs the AABB tree and the internal search tree for + // efficient distance computations. + + // For a point range, the second iterator must be of the second-last point in the range. + // If it points to the end of the range, to polyline is considered to be closed. + Tree_pr tree_pr(polyline.begin(), std::prev(polyline.end()), polyline); + Tree_poly tree_poly(poly.begin(), poly.end(), poly); + + tree_pr.build(); + tree_poly.build(); + + tree_pr.accelerate_distance_queries(); + tree_poly.accelerate_distance_queries(); + + // counts #intersections with a segment query + Segment segment_query(Point(1.0, 0.0), Point(0.0, 7.0)); + + std::cout << tree_pr.number_of_intersected_primitives(segment_query) + << " intersections(s) with segment" << std::endl; + + std::cout << tree_poly.number_of_intersected_primitives(segment_query) + << " intersections(s) with segment" << std::endl; + + // computes the closest point from a point query + Point point_query(1.5, 3.0); + Point closest = tree_pr.closest_point(point_query); + std::cerr << "closest point is: " << closest << std::endl; + + closest = tree_poly.closest_point(point_query); + std::cerr << "closest point is: " << closest << std::endl; + + Point_and_primitive_id_poly id_poly = tree_poly.closest_point_and_primitive(point_query); + // id_poly.second is of type Iterator_poly and points to the first point of the segment in the polygon point range. + + Point_and_primitive_id_pr id_pr = tree_pr.closest_point_and_primitive(point_query); + // id_pr.second is of type Iterator_poly and points to the first point of the segment in the point range. + + return EXIT_SUCCESS; +} diff --git a/AABB_tree/examples/AABB_tree/AABB_segment_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_segment_2_example.cpp index b759aa91a8c1..25d77f1ac8a6 100644 --- a/AABB_tree/examples/AABB_tree/AABB_segment_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_segment_2_example.cpp @@ -4,11 +4,9 @@ #include #include #include -#include #include #include - typedef CGAL::Simple_cartesian K; typedef K::FT FT; @@ -16,23 +14,11 @@ typedef K::Segment_2 Segment; typedef K::Point_2 Point; typedef std::list SegmentRange; -typedef SegmentRange::iterator Iterator_seg; -typedef CGAL::AABB_segment_primitive_2 Primitive_seg; -typedef CGAL::AABB_traits_2 Traits_seg; -typedef CGAL::AABB_tree Tree_seg; - -typedef std::vector PointRange; -typedef PointRange::iterator Iterator_pr; -typedef CGAL::AABB_polyline_segment_primitive_2 Primitive_pr; -typedef CGAL::AABB_traits_2 Traits_pr; -typedef CGAL::AABB_tree Tree_pr; - -typedef CGAL::Polygon_2 Polygon; -typedef Polygon::iterator Iterator_poly; -typedef CGAL::AABB_polyline_segment_primitive_2 Primitive_poly; -typedef CGAL::AABB_traits_2 Traits_poly; -typedef CGAL::AABB_tree Tree_poly; - +typedef SegmentRange::iterator Iterator; +typedef CGAL::AABB_segment_primitive_2 Primitive; +typedef CGAL::AABB_traits_2 Traits; +typedef CGAL::AABB_tree Tree; +typedef Tree::Point_and_primitive_id Point_and_primitive_id; int main() { @@ -49,39 +35,25 @@ int main() seg.push_back(Segment(d, e)); seg.push_back(Segment(e, a)); - std::vector polyline = { a, b, c, d, e }; + // constructs the AABB tree and the internal search tree for + // efficient distance computations. + Tree tree(seg.begin(), seg.end()); + tree.build(); - Polygon poly(polyline.begin(), polyline.end()); - - // // constructs the AABB tree and the internal search tree for - // // efficient distance computations. - Tree_seg tree_seg(seg.begin(), seg.end()); - Tree_pr tree_pr(polyline.begin(), polyline.end(), polyline); - Tree_poly tree_poly(poly.begin(), poly.end(), poly); - - tree_seg.accelerate_distance_queries(); - tree_pr.accelerate_distance_queries(); - tree_poly.accelerate_distance_queries(); - - // // counts #intersections with a segment query + tree.accelerate_distance_queries(); + // counts #intersections with a segment query Segment segment_query(Point(1.0, 0.0), Point(0.0, 7.0)); - std::cout << tree_seg.number_of_intersected_primitives(segment_query) - << " intersections(s) with segment" << std::endl; - - std::cout << tree_pr.number_of_intersected_primitives(segment_query) - << " intersections(s) with segment" << std::endl; - - std::cout << tree_poly.number_of_intersected_primitives(segment_query) + std::cout << tree.number_of_intersected_primitives(segment_query) << " intersections(s) with segment" << std::endl; // computes the closest point from a point query Point point_query(1.5, 3.0); - Point closest = tree_seg.closest_point(point_query); - std::cerr << "closest point is: " << closest << std::endl; - closest = tree_pr.closest_point(point_query); - std::cerr << "closest point is: " << closest << std::endl; - closest = tree_poly.closest_point(point_query); + Point closest = tree.closest_point(point_query); std::cerr << "closest point is: " << closest << std::endl; + + Point_and_primitive_id id = tree.closest_point_and_primitive(point_query); + std::cout << id.second->source() << " " << id.second->target() << std::endl; + return EXIT_SUCCESS; } 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 8b3a4eb5178e..f24b33f0d337 100644 --- a/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h @@ -39,12 +39,11 @@ namespace internal { inline friend reference // Cannot return reference as the Segment does not exist, only the points exist. get(Self s, key_type it) { - typename Iterator::value_type& p = *it; - it++; - if (it == s.end) - return typename GeomTraits::Construct_segment_2()(p, *s.begin); + Iterator it2 = std::next(it); + if (it2 == s.end) + return typename GeomTraits::Construct_segment_2()(*it, *s.begin); else - return typename GeomTraits::Construct_segment_2()( p, *it ); + return typename GeomTraits::Construct_segment_2()(*it, *it2 ); } Iterator begin, end; @@ -54,16 +53,18 @@ namespace internal { /*! * \ingroup PkgAABBTreeRef - * Primitive type that uses as identifier an iterator with a 3D segment as `value_type`. + * Primitive type that uses as identifier an iterator with a 2D point 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. + * while the AABB tree holding the primitive is in use. The `Segment_2` is constructed on the fly using the `Point_2` + * the identifier is pointing to as source and the next `Point_2` as target. * * \cgalModels{AABBPrimitive} * * \tparam GeomTraits is a traits class providing the nested type `Point_2` and `Segment_2`. - * It also provides the functor `Construct_source_2` that has an operator taking a `Segment_2` - * and returning its source as a type convertible to `Point_2`. - * \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Segment_2` + * 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 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. @@ -71,13 +72,14 @@ namespace internal { * * \sa `AABBPrimitive` * \sa `AABB_primitive` + * \sa `AABB_segment_primitive_2` * \sa `AABB_triangle_primitive_3` * \sa `AABB_halfedge_graph_segment_primitive` * \sa `AABB_face_graph_triangle_primitive` */ -template < class PointRange, - class GeomTraits, +template < class GeomTraits, class Iterator, + class PointRange, class CacheDatum=Tag_false> class AABB_polyline_segment_primitive_2 #ifndef DOXYGEN_RUNNING diff --git a/AABB_tree/include/CGAL/AABB_segment_primitive_2.h b/AABB_tree/include/CGAL/AABB_segment_primitive_2.h index f0d2ed8e463b..af57ea5e211a 100644 --- a/AABB_tree/include/CGAL/AABB_segment_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_segment_primitive_2.h @@ -50,7 +50,7 @@ namespace internal { /*! * \ingroup PkgAABBTreeRef - * Primitive type that uses as identifier an iterator with a 3D segment as `value_type`. + * Primitive type that uses as identifier an iterator with a 2D segment 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. * From 0e8f9c8068afd1530b23d3145bddd7b8172ab2c7 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Fri, 8 Mar 2024 16:53:11 +0100 Subject: [PATCH 028/100] update doc in user manual --- AABB_tree/doc/AABB_tree/aabb_tree.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/AABB_tree/doc/AABB_tree/aabb_tree.txt b/AABB_tree/doc/AABB_tree/aabb_tree.txt index fcba3e318aae..45e3a574a252 100644 --- a/AABB_tree/doc/AABB_tree/aabb_tree.txt +++ b/AABB_tree/doc/AABB_tree/aabb_tree.txt @@ -163,12 +163,17 @@ handle. \subsection aabb_tree_examples_4 Tree of Segments for Intersection and Distance Queries - In the following example the segments are stored into a list, and the +In the following example the segments are stored into a list, and the AABB primitive wraps a segment as `datum` and an iterator in the list as `id`. We compute the number of intersections with plane and triangles queries, and the closest point from a point query. \cgalExample{AABB_tree/AABB_segment_3_example.cpp} +\subsectiom aabb_tree_examples_8 Tree of Polyline and Polygon Segments for Intersection and Distance Queries + +The following example uses segments given by a polyline and a polygon. The difference is that the polygon is closed. The `id` in this case is the iterator pointing to a `Point_2` in the polyline or the polygon. The datum, a `Segment_2`, is created on the fly from the points using the `id` as the source and the following `Point_2` as the target. We count the intersections with a `Segment_2` and the closest point and id from a point query. +\cgalExample{AABB_tree/AABB_polyline_segment_2_example.cpp} + \subsection aabb_tree_examples_5 Tree of Polyhedron Edge Segments for Intersection and Distance Queries In the following example the AABB primitive wraps a halfedge handle as From 83aa8cf6c15bba75257d7ae61e4df9cc0e06c2e2 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Sat, 9 Mar 2024 13:02:04 +0100 Subject: [PATCH 029/100] added AABB_indexed_triangle_primitive_2 --- .../doc/AABB_tree/PackageDescription.txt | 1 + AABB_tree/doc/AABB_tree/examples.txt | 1 + .../AABB_indexed_triangle_2_example.cpp | 55 ++++++++ .../CGAL/AABB_indexed_triangle_primitive_2.h | 128 ++++++++++++++++++ 4 files changed, 185 insertions(+) create mode 100644 AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp create mode 100644 AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h diff --git a/AABB_tree/doc/AABB_tree/PackageDescription.txt b/AABB_tree/doc/AABB_tree/PackageDescription.txt index 628074b747d4..2752b56af5de 100644 --- a/AABB_tree/doc/AABB_tree/PackageDescription.txt +++ b/AABB_tree/doc/AABB_tree/PackageDescription.txt @@ -39,6 +39,7 @@ \cgalCRPSection{Primitives} - `CGAL::AABB_triangle_primitive_2` +- `CGAL::AABB_indexed_triangle_primitive_2` - `CGAL::AABB_segment_primitive_2` - `CGAL::AABB_polyline_segment_primitive_2` - `CGAL::AABB_triangle_primitive_3` diff --git a/AABB_tree/doc/AABB_tree/examples.txt b/AABB_tree/doc/AABB_tree/examples.txt index 4e6213186f15..a98d2c35aafa 100644 --- a/AABB_tree/doc/AABB_tree/examples.txt +++ b/AABB_tree/doc/AABB_tree/examples.txt @@ -10,6 +10,7 @@ \example AABB_tree/AABB_polyline_segment_2_example.cpp \example AABB_tree/AABB_segment_3_example.cpp \example AABB_tree/AABB_ray_shooting_example.cpp +\example AABB_tree/AABB_indexed_triangle_2_example.cpp \example AABB_tree/AABB_triangle_3_example.cpp \example AABB_tree/AABB_halfedge_graph_edge_example.cpp \example AABB_tree/AABB_face_graph_triangle_example.cpp diff --git a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp new file mode 100644 index 000000000000..c9a6e4729743 --- /dev/null +++ b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp @@ -0,0 +1,55 @@ +// Author(s) : Camille Wormser, Pierre Alliez + +#include +#include + +#include +#include +#include +#include + +typedef CGAL::Simple_cartesian K; + +typedef K::FT FT; +typedef K::Point_2 Point; + +typedef std::vector >::iterator IndexIterator; +typedef std::vector PointRange; +typedef CGAL::AABB_indexed_triangle_primitive_2 Primitive; +typedef CGAL::AABB_traits_2 AABB_triangle_traits; +typedef CGAL::AABB_tree Tree; +typedef Tree::Point_and_primitive_id Point_and_primitive_id; + +int main() +{ + Point a(0.0, 0.0); + Point b(0.0, 1.0); + Point c(1.0, 0.0); + Point d(1.0, 1.0); + Point e(2.0, 0.0); + Point f(2.0, 1.0); + + std::vector points = { a, b, c, d, e, f }; + + std::vector > triangles; + triangles.push_back({ 0, 2, 1 }); + triangles.push_back({ 1, 2, 3 }); + triangles.push_back({ 3, 2, 4 }); + triangles.push_back({ 3, 4, 5 }); + + // constructs AABB tree + Tree tree(triangles.begin(), triangles.end(), points); + + // point sampling + Point_and_primitive_id id; + id = tree.closest_point_and_primitive(Point(0.5, 0.4)); + std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; + id = tree.closest_point_and_primitive(Point(0.5, 0.6)); + std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; + id = tree.closest_point_and_primitive(Point(1.5, 0.5)); + std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; + id = tree.closest_point_and_primitive(Point(1.5, 0.6)); + std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; + + return EXIT_SUCCESS; +} diff --git a/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h b/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h new file mode 100644 index 000000000000..a45c9e8e2574 --- /dev/null +++ b/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h @@ -0,0 +1,128 @@ +// Copyright (c) 2024 GeometryFactory (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) : Sven Oesau +// + + +#ifndef CGAL_AABB_INDEXED_TRIANGLE_PRIMITIVE_2_H_ +#define CGAL_AABB_INDEXED_TRIANGLE_PRIMITIVE_2_H_ + +#include + +#include +#include + +namespace CGAL { + +namespace internal { + template + struct Triangle_2_from_index_range_iterator_property_map { + //classical typedefs + typedef Iterator key_type; + typedef typename GeomTraits::Triangle_2 value_type; + typedef typename GeomTraits::Triangle_2& reference; + + typedef boost::readable_property_map_tag category; + typedef Triangle_2_from_index_range_iterator_property_map Self; + + Triangle_2_from_index_range_iterator_property_map() {} + Triangle_2_from_index_range_iterator_property_map(PointIterator b) : begin(b) {} + + inline friend value_type + get(Self s, key_type it) + { + return typename GeomTraits::Construct_triangle_2()(s.begin[(*it)[0]], s.begin[(*it)[1]], s.begin[(*it)[2]]); + } + + PointIterator begin; + }; + + template + struct Point_from_indexed_triangle_2_iterator_property_map { + //classical typedefs + typedef Iterator key_type; + typedef typename PointIterator::value_type value_type; + typedef const value_type& reference; + + typedef boost::readable_property_map_tag category; + typedef Point_from_indexed_triangle_2_iterator_property_map Self; + + Point_from_indexed_triangle_2_iterator_property_map() {} + Point_from_indexed_triangle_2_iterator_property_map(PointIterator b) : begin(b) {} + + inline friend reference + get(Self s, key_type it) + { + return s.begin[((*it)[0])]; + } + + PointIterator begin; + }; +}//namespace internal + + +/*! + * \ingroup PkgAABBTreeRef + * Primitive type that uses as identifier an iterator with a range of 3 indices 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_triangle_2` that has an operator taking 3 `Point_2` as + * parameters and returns a `Triangle_2` + * \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` with its value type being a `Point_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 IndexIterator, + class PointRange, + class CacheDatum=Tag_false> +class AABB_indexed_triangle_primitive_2 +#ifndef DOXYGEN_RUNNING + : public AABB_primitive< IndexIterator, + internal::Triangle_2_from_index_range_iterator_property_map, + internal::Point_from_indexed_triangle_2_iterator_property_map, + Tag_true, + CacheDatum > +#endif +{ + typedef AABB_primitive< IndexIterator, + internal::Triangle_2_from_index_range_iterator_property_map, + internal::Point_from_indexed_triangle_2_iterator_property_map, + Tag_true, + CacheDatum > Base; +public: + ///constructor from an iterator + AABB_indexed_triangle_primitive_2(IndexIterator it, PointRange &range) : Base(it) {} + + /// \internal + static typename Base::Shared_data construct_shared_data(PointRange &range) { + return std::make_pair( + internal::Triangle_2_from_index_range_iterator_property_map(range.begin()), + internal::Point_from_indexed_triangle_2_iterator_property_map(range.begin())); + } +}; + +} // end namespace CGAL + +#endif // CGAL_AABB_INDEXED_TRIANGLE_PRIMITIVE_2_H_ From b02c4092e764c9b6832c2cf4919e3790ae207f84 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 12 Mar 2024 15:56:45 +0100 Subject: [PATCH 030/100] polish examples --- .../examples/AABB_tree/AABB_indexed_triangle_2_example.cpp | 5 ++--- .../examples/AABB_tree/AABB_polyline_segment_2_example.cpp | 7 ++----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp index c9a6e4729743..98696e9e4180 100644 --- a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp @@ -1,7 +1,8 @@ // Author(s) : Camille Wormser, Pierre Alliez #include -#include +#include +#include #include #include @@ -9,8 +10,6 @@ #include typedef CGAL::Simple_cartesian K; - -typedef K::FT FT; typedef K::Point_2 Point; typedef std::vector >::iterator IndexIterator; diff --git a/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp index 0dc2be17b8c9..ec65b84f8107 100644 --- a/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include @@ -10,8 +10,6 @@ typedef CGAL::Simple_cartesian K; - -typedef K::FT FT; typedef K::Segment_2 Segment; typedef K::Point_2 Point; @@ -77,7 +75,6 @@ int main() // id_poly.second is of type Iterator_poly and points to the first point of the segment in the polygon point range. Point_and_primitive_id_pr id_pr = tree_pr.closest_point_and_primitive(point_query); - // id_pr.second is of type Iterator_poly and points to the first point of the segment in the point range. - + // id_pr.second is of type std::vector::iterator and points to the first point of the segment in the point range. return EXIT_SUCCESS; } From 2e4c5765cea704e5e8bf21866aec80090aee9f8f Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 12 Mar 2024 16:29:18 +0100 Subject: [PATCH 031/100] Fix typo --- AABB_tree/doc/AABB_tree/aabb_tree.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AABB_tree/doc/AABB_tree/aabb_tree.txt b/AABB_tree/doc/AABB_tree/aabb_tree.txt index 45e3a574a252..ec82d0c6d37c 100644 --- a/AABB_tree/doc/AABB_tree/aabb_tree.txt +++ b/AABB_tree/doc/AABB_tree/aabb_tree.txt @@ -169,7 +169,7 @@ list as `id`. We compute the number of intersections with plane and triangles queries, and the closest point from a point query. \cgalExample{AABB_tree/AABB_segment_3_example.cpp} -\subsectiom aabb_tree_examples_8 Tree of Polyline and Polygon Segments for Intersection and Distance Queries +\subsection aabb_tree_examples_8 Tree of Polyline and Polygon Segments for Intersection and Distance Queries The following example uses segments given by a polyline and a polygon. The difference is that the polygon is closed. The `id` in this case is the iterator pointing to a `Point_2` in the polyline or the polygon. The datum, a `Segment_2`, is created on the fly from the points using the `id` as the source and the following `Point_2` as the target. We count the intersections with a `Segment_2` and the closest point and id from a point query. \cgalExample{AABB_tree/AABB_polyline_segment_2_example.cpp} From f9e528555db9c1c7483318b371505b465912f99b Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 13 Mar 2024 14:26:37 +0100 Subject: [PATCH 032/100] Add AABBRayIntersectionGeomTraits_2.h and fix \sa --- .../AABBRayIntersectionGeomTraits_2.h | 66 +++++++++++++++++++ .../AABB_indexed_triangle_2_example.cpp | 2 - AABB_tree/include/CGAL/AABB_traits_2.h | 2 +- AABB_tree/include/CGAL/AABB_traits_3.h | 3 +- 4 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h new file mode 100644 index 000000000000..8e286e9699b6 --- /dev/null +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h @@ -0,0 +1,66 @@ +/*! +\ingroup PkgAABBTreeConcepts +\cgalConcept + +The concept `AABBRayIntersectionGeomTraits_3` is a refinement of the +concept `AABBGeomTraits`. In addition to the types required by +`AABBGeomTraits` it also requires types and functors necessary to +define the Intersection_distance functor. + +\cgalRefines{AABBGeomTraits} + +\cgalHasModelsBegin +\cgalHasModelsBare{All models of the concept `Kernel`} +\cgalHasModelsEnd + +\sa `CGAL::AABB_traits` +\sa `CGAL::AABB_tree` +\sa `AABBPrimitive` + +*/ +class AABBRayIntersectionGeomTraits_3 { +public: + /*! + Type of a 3D ray. + */ + typedef unspecified_type Ray_3; + + /*! + Type of a 3D vector. + */ + typedef unspecified_type Vector_3; + + /*! + A functor object to construct the source point of a ray. Provides the operator: + `Point_3 operator()(const Ray_3&);` + */ + typedef unspecified_type Construct_source_3; + + /*! + */ + Construct_source_3 construct_source_3_object(); + + /*! + A model of `CartesianConstIterator3`. + */ + typedef unspecified_type Cartesian_const_iterator_3; + + /*! + A model of `ConstructCartesianConstIterator3`. + */ + typedef unspecified_type Construct_cartesian_const_iterator_3; + + /*! + */ + Construct_source_3 construct_cartesian_const_iterator_3_object(); + + /*! + A functor object to construct a vector giving the direction of a ray. Provides the operator: + `Vector_3 operator()(const Ray_3&);` + */ + typedef unspecified_type Construct_vector_3; + + /*! + */ + Construct_source_3 construct_vector_3_object(); +}; diff --git a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp index 98696e9e4180..dec085855c91 100644 --- a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp @@ -1,5 +1,3 @@ -// Author(s) : Camille Wormser, Pierre Alliez - #include #include #include diff --git a/AABB_tree/include/CGAL/AABB_traits_2.h b/AABB_tree/include/CGAL/AABB_traits_2.h index f053513dab5d..21009163d9d8 100644 --- a/AABB_tree/include/CGAL/AABB_traits_2.h +++ b/AABB_tree/include/CGAL/AABB_traits_2.h @@ -141,7 +141,7 @@ class AABB_tree; /// member function `bbox()` that returns the bounding box of the primitive. /// /// If the argument `GeomTraits` is a model of the concept \ref -/// AABBRayIntersectionGeomTraits, this class is also a model of \ref +/// AABBRayIntersectionGeomTraits_2, this class is also a model of \ref /// AABBRayIntersectionTraits. /// /// \sa `AABBTraits` diff --git a/AABB_tree/include/CGAL/AABB_traits_3.h b/AABB_tree/include/CGAL/AABB_traits_3.h index 2bc1ec3b9454..5614b484ad42 100644 --- a/AABB_tree/include/CGAL/AABB_traits_3.h +++ b/AABB_tree/include/CGAL/AABB_traits_3.h @@ -215,7 +215,8 @@ class AABB_traits_3 /// Point query type. typedef typename GeomTraits::Point_3 Point_3; - typedef Point_3 Point; // AF: because the AABB_tree dimension agnostic + /// Poin type + typedef Point_3 Point; // because the AABB_tree is dimension agnostic /// additional types for the search tree, required by the RangeSearchTraits concept /// \bug This is not documented for now in the AABBTraits concept. From 6e4092a37e4c9fe3d773dbd6da017064a8201076 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 13 Mar 2024 14:32:47 +0100 Subject: [PATCH 033/100] replace _3 with _2 --- .../AABBRayIntersectionGeomTraits_2.h | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h index 8e286e9699b6..0800d966b2bb 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h @@ -1,10 +1,11 @@ +3 /*! \ingroup PkgAABBTreeConcepts \cgalConcept -The concept `AABBRayIntersectionGeomTraits_3` is a refinement of the -concept `AABBGeomTraits`. In addition to the types required by -`AABBGeomTraits` it also requires types and functors necessary to +The concept `AABBRayIntersectionGeomTraits_2` is a refinement of the +concept `AABBGeomTraits_2`. In addition to the types required by +`AABBGeomTraits_2` it also requires types and functors necessary to define the Intersection_distance functor. \cgalRefines{AABBGeomTraits} @@ -13,54 +14,54 @@ define the Intersection_distance functor. \cgalHasModelsBare{All models of the concept `Kernel`} \cgalHasModelsEnd -\sa `CGAL::AABB_traits` +\sa `CGAL::AABB_traits_` \sa `CGAL::AABB_tree` \sa `AABBPrimitive` */ -class AABBRayIntersectionGeomTraits_3 { +class AABBRayIntersectionGeomTraits_2 { public: /*! Type of a 3D ray. */ - typedef unspecified_type Ray_3; + typedef unspecified_type Ray_2; /*! Type of a 3D vector. */ - typedef unspecified_type Vector_3; + typedef unspecified_type Vector_2; /*! A functor object to construct the source point of a ray. Provides the operator: - `Point_3 operator()(const Ray_3&);` + `Point_2 operator()(const Ray_2&);` */ - typedef unspecified_type Construct_source_3; + typedef unspecified_type Construct_source_2; /*! */ - Construct_source_3 construct_source_3_object(); + Construct_source_2 construct_source_2_object(); /*! A model of `CartesianConstIterator3`. */ - typedef unspecified_type Cartesian_const_iterator_3; + typedef unspecified_type Cartesian_const_iterator_2; /*! A model of `ConstructCartesianConstIterator3`. */ - typedef unspecified_type Construct_cartesian_const_iterator_3; + typedef unspecified_type Construct_cartesian_const_iterator_2; /*! */ - Construct_source_3 construct_cartesian_const_iterator_3_object(); + Construct_source_2 construct_cartesian_const_iterator_2_object(); /*! A functor object to construct a vector giving the direction of a ray. Provides the operator: - `Vector_3 operator()(const Ray_3&);` + `Vector_2 operator()(const Ray_2&);` */ - typedef unspecified_type Construct_vector_3; + typedef unspecified_type Construct_vector_2; /*! */ - Construct_source_3 construct_vector_3_object(); + Construct_source_2 construct_vector_2_object(); }; From 69ce2c1c7c3b5d3f04a64c403e1df7153b7d08aa Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 13 Mar 2024 14:48:54 +0100 Subject: [PATCH 034/100] Add 2D to the chapter title --- AABB_tree/doc/AABB_tree/Doxyfile.in | 5 +---- AABB_tree/doc/AABB_tree/PackageDescription.txt | 2 +- AABB_tree/doc/AABB_tree/aabb_tree.txt | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Doxyfile.in b/AABB_tree/doc/AABB_tree/Doxyfile.in index b626c95c2da2..8f87e4f9202f 100644 --- a/AABB_tree/doc/AABB_tree/Doxyfile.in +++ b/AABB_tree/doc/AABB_tree/Doxyfile.in @@ -1,10 +1,7 @@ @INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS} -PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - 3D Fast Intersection and Distance Computation (AABB Tree)" +PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - 2D and 3D Fast Intersection and Distance Computation (AABB Tree)" EXTRACT_ALL = false HIDE_UNDOC_MEMBERS = true HIDE_UNDOC_CLASSES = true - - - diff --git a/AABB_tree/doc/AABB_tree/PackageDescription.txt b/AABB_tree/doc/AABB_tree/PackageDescription.txt index 2752b56af5de..3e78bb5404b2 100644 --- a/AABB_tree/doc/AABB_tree/PackageDescription.txt +++ b/AABB_tree/doc/AABB_tree/PackageDescription.txt @@ -9,7 +9,7 @@ \cgalPkgPicture{aabb-teaser-thumb.png} \cgalPkgSummaryBegin \cgalPkgAuthors{Pierre Alliez, Stéphane Tayeb, and Camille Wormser} -\cgalPkgDesc{The AABB (axis-aligned bounding box) tree component offers a static data structure and algorithms to perform efficient intersection and distance queries on sets of finite 3D geometric objects.} +\cgalPkgDesc{The AABB (axis-aligned bounding box) tree component offers a static data structure and algorithms to perform efficient intersection and distance queries on sets of finite 2D and 3D geometric objects.} \cgalPkgManuals{Chapter_Fast_Intersection_and_Distance_Computation,PkgAABBTreeRef} \cgalPkgSummaryEnd \cgalPkgShortInfoBegin diff --git a/AABB_tree/doc/AABB_tree/aabb_tree.txt b/AABB_tree/doc/AABB_tree/aabb_tree.txt index ec82d0c6d37c..031355126cd3 100644 --- a/AABB_tree/doc/AABB_tree/aabb_tree.txt +++ b/AABB_tree/doc/AABB_tree/aabb_tree.txt @@ -12,7 +12,7 @@ namespace CGAL { The AABB tree component offers a static data structure and algorithms to perform efficient intersection and distance queries against sets of -finite 3D geometric objects. The set of geometric objects stored in +finite 2D or 3D geometric objects. The set of geometric objects stored in the data structure can be queried for intersection detection, intersection computation and distance. The intersection queries can be of any type, provided that the corresponding intersection predicates From 76dff001a8abbe0644b31f5a7bd9de05621cd6cd Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 14 Mar 2024 12:24:32 +0100 Subject: [PATCH 035/100] Add for linking --- AABB_tree/doc/AABB_tree/aabb_tree.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AABB_tree/doc/AABB_tree/aabb_tree.txt b/AABB_tree/doc/AABB_tree/aabb_tree.txt index 031355126cd3..fd9f2292bf2f 100644 --- a/AABB_tree/doc/AABB_tree/aabb_tree.txt +++ b/AABB_tree/doc/AABB_tree/aabb_tree.txt @@ -431,7 +431,7 @@ initial ball radius to a small value still guaranteed to intersect the input primitives. This is achieved by constructing an internal secondary data structure which provides a good hint to the algorithm at the beginning of the traversal (done by default). -Calling `do_not_accelerate_distance_queries()` will disable +Calling `AABB_tree::do_not_accelerate_distance_queries()` will disable the construction and the usage of this internal secondary data structure. \section aabb_tree_history Design and Implementation History From 190608d15ab956de7a29d6626c6012e821cb5bec Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 14 Mar 2024 12:30:39 +0100 Subject: [PATCH 036/100] lowecase --- AABB_tree/include/CGAL/AABB_tree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AABB_tree/include/CGAL/AABB_tree.h b/AABB_tree/include/CGAL/AABB_tree.h index f8034bc4837e..25ad05d354d2 100644 --- a/AABB_tree/include/CGAL/AABB_tree.h +++ b/AABB_tree/include/CGAL/AABB_tree.h @@ -125,7 +125,7 @@ namespace CGAL { Self& operator=(const Self&) = delete; /** - * @brief Builds the data structure from a sequence of primitives. + * @brief builds the data structure from a sequence of primitives. * @param first iterator over first primitive to insert * @param beyond past-the-end iterator * From 7e543dc70138378f36075e4fe83f422bb087288d Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 14 Mar 2024 13:01:05 +0100 Subject: [PATCH 037/100] Add queries outside triangles --- .../examples/AABB_tree/AABB_indexed_triangle_2_example.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp index dec085855c91..28eceb1d289a 100644 --- a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp @@ -47,6 +47,10 @@ int main() std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; id = tree.closest_point_and_primitive(Point(1.5, 0.6)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; + id = tree.closest_point_and_primitive(Point(1.0, 0.0)); + std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; + id = tree.closest_point_and_primitive(Point(3.0, 0.5)); + std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; return EXIT_SUCCESS; } From e62f249a496766b2d0d538a2ae97abd08f3daf08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 15 Mar 2024 10:59:37 +0100 Subject: [PATCH 038/100] triangle is a not a ref --- AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 a45c9e8e2574..4eda27d4c83c 100644 --- a/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h @@ -28,7 +28,7 @@ namespace internal { //classical typedefs typedef Iterator key_type; typedef typename GeomTraits::Triangle_2 value_type; - typedef typename GeomTraits::Triangle_2& reference; + typedef typename GeomTraits::Triangle_2 reference; typedef boost::readable_property_map_tag category; typedef Triangle_2_from_index_range_iterator_property_map Self; @@ -37,7 +37,7 @@ namespace internal { Triangle_2_from_index_range_iterator_property_map(PointIterator b) : begin(b) {} inline friend value_type - get(Self s, key_type it) + get(Self s, key_type it) { return typename GeomTraits::Construct_triangle_2()(s.begin[(*it)[0]], s.begin[(*it)[1]], s.begin[(*it)[2]]); } @@ -113,7 +113,7 @@ class AABB_indexed_triangle_primitive_2 CacheDatum > Base; public: ///constructor from an iterator - AABB_indexed_triangle_primitive_2(IndexIterator it, PointRange &range) : Base(it) {} + AABB_indexed_triangle_primitive_2(IndexIterator it, PointRange&) : Base(it) {} /// \internal static typename Base::Shared_data construct_shared_data(PointRange &range) { From f231a3d812c688bdf5b1ea9001d4652d237281c2 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 15 Mar 2024 16:06:46 +0100 Subject: [PATCH 039/100] Enrich Projection_traits so that it can be used with AABB_traits_2 --- .../AABB_indexed_triangle_2_example.cpp | 28 +-- AABB_tree/include/CGAL/AABB_traits_2.h | 7 +- .../Kernel_23/internal/Projection_traits_3.h | 172 ++++++++++++++++++ 3 files changed, 193 insertions(+), 14 deletions(-) diff --git a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp index 28eceb1d289a..6e7e47c3df87 100644 --- a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp @@ -6,8 +6,10 @@ #include #include #include +#include -typedef CGAL::Simple_cartesian K; +typedef CGAL::Simple_cartesian SC; +typedef CGAL::Projection_traits_xy_3 K; typedef K::Point_2 Point; typedef std::vector >::iterator IndexIterator; @@ -19,12 +21,12 @@ typedef Tree::Point_and_primitive_id Point_and_primitive_id; int main() { - Point a(0.0, 0.0); - Point b(0.0, 1.0); - Point c(1.0, 0.0); - Point d(1.0, 1.0); - Point e(2.0, 0.0); - Point f(2.0, 1.0); + Point a(0.0, 0.0, 0.0); + Point b(0.0, 1.0, 0.0); + Point c(1.0, 0.0, 0.0); + Point d(1.0, 1.0, 0.0); + Point e(2.0, 0.0, 0.0); + Point f(2.0, 1.0, 0.0); std::vector points = { a, b, c, d, e, f }; @@ -39,17 +41,17 @@ int main() // point sampling Point_and_primitive_id id; - id = tree.closest_point_and_primitive(Point(0.5, 0.4)); + id = tree.closest_point_and_primitive(Point(0.5, 0.4, 0.0)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; - id = tree.closest_point_and_primitive(Point(0.5, 0.6)); + id = tree.closest_point_and_primitive(Point(0.5, 0.6, 0.0)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; - id = tree.closest_point_and_primitive(Point(1.5, 0.5)); + id = tree.closest_point_and_primitive(Point(1.5, 0.5, 0.0)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; - id = tree.closest_point_and_primitive(Point(1.5, 0.6)); + id = tree.closest_point_and_primitive(Point(1.5, 0.6, 0.0)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; - id = tree.closest_point_and_primitive(Point(1.0, 0.0)); + id = tree.closest_point_and_primitive(Point(1.0, 0.0, 0.0)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; - id = tree.closest_point_and_primitive(Point(3.0, 0.5)); + id = tree.closest_point_and_primitive(Point(3.0, 0.5, 0.0)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; return EXIT_SUCCESS; diff --git a/AABB_tree/include/CGAL/AABB_traits_2.h b/AABB_tree/include/CGAL/AABB_traits_2.h index 21009163d9d8..556b1a079359 100644 --- a/AABB_tree/include/CGAL/AABB_traits_2.h +++ b/AABB_tree/include/CGAL/AABB_traits_2.h @@ -192,6 +192,11 @@ class AABB_traits_2 /// Point query type. typedef typename GeomTraits::Point_2 Point_2; + /// + /// point type + /// + typedef Point_2 Point; + /// additional types for the search tree, required by the RangeSearchTraits concept /// \bug This is not documented for now in the AABBTraits concept. typedef typename GeomTraits::Iso_rectangle_2 Iso_rectangle_2; @@ -446,7 +451,7 @@ class AABB_traits_2 Bounding_box compute_bbox(const Primitive& pr, const Default&)const { - return internal::Primitive_helper::get_datum(pr,*this).bbox(); + return GeomTraits().construct_bbox_2_object()(internal::Primitive_helper::get_datum(pr, *this)); } /// Comparison functions diff --git a/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h b/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h index 1cc09421944d..8e57a4f46af2 100644 --- a/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h +++ b/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h @@ -87,13 +87,32 @@ struct Projector static const int y_index=1; }; +template +class Construct_cartesian_const_iterator_projected_3 { +public: + typedef typename R::Point_3 Point_3; + typedef typename R::Cartesian_const_iterator_3 Cartesian_const_iterator; + Cartesian_const_iterator operator()(const Point_3& p) const + { + return typename R::Construct_cartesian_const_iterator_3()(p); + } + Cartesian_const_iterator operator()(const Point_3& p, int) const + { + Cartesian_const_iterator it = typename R::Construct_cartesian_const_iterator_3()(p,0); + --it; + return it; + } +}; + template class Construct_bbox_projected_2 { public: typedef typename R::Point_3 Point; + typedef typename R::Triangle_3 Triangle_3; typedef Bbox_2 result_type; Bbox_2 operator()(const Point& p) const { typename R::Construct_bbox_3 bb; return Projector::bbox(bb(p)); } + Bbox_2 operator()(const Triangle_3& t) const { typename R::Construct_bbox_3 bb; return Projector::bbox(bb(t)); } }; template @@ -203,6 +222,108 @@ class Side_of_bounded_circle_projected_3 } }; +template +class Construct_center_3 +{ +public: + typedef typename R::Sphere_3 Sphere_3; + typedef typename R::Point_3 Point_3; + typedef typename R::Point_2 Point_2; + typedef typename R::FT RT; + typename R::FT x(const Point_3& p) const { return Projector::x(p); } + typename R::FT y(const Point_3& p) const { return Projector::y(p); } + + Point_2 project(const Point_3& p) const + { + return Point_2(x(p), y(p)); + } + + Point_2 operator()(const Sphere_3& s) const + { + Point_3 p = typename R::Construct_center_3()(s); + return project(p); + } +}; + +template +class Construct_projected_point_3 +{ +public: + typedef typename R::Point_3 Point_3; + typedef typename R::Point_2 Point_2; + typedef typename R::Triangle_3 Triangle_3; + typedef typename R::Triangle_2 Triangle_2; + typedef typename R::FT RT; + typename R::FT x(const Point_3& p) const { return Projector::x(p); } + typename R::FT y(const Point_3& p) const { return Projector::y(p); } + + Point_2 project(const Point_3& p) const + { + return Point_2(x(p), y(p)); + } + + Point_3 operator()(const Triangle_3& t, const Point_3& p) const + { + Point_2 p2 = typename R::Construct_projected_point_2()(Triangle_2(project(t.vertex(0)), project(t.vertex(1)), project(t.vertex(2))), + project(p)); + return Point_3(p.x(), p.y(), 0); + } + + template + Point_3 operator()(const T& t, const Point_3& p) const + { std::cout << "todo: implement Projection_traits_3::Construct_projected_point_3 for " << typeid(t).name() << " and Point_3" << std::endl; + return Point_3(); + } + +}; + + +template +class Construct_min_vertex_3 +{ +public: + typedef typename R::Iso_cuboid_3 Iso_cuboid_3; + typedef typename R::Point_3 Point_3; + typedef typename R::Point_2 Point_2; + typedef typename R::FT RT; + typename R::FT x(const Point_3& p) const { return Projector::x(p); } + typename R::FT y(const Point_3& p) const { return Projector::y(p); } + + Point_2 project(const Point_3& p) const + { + return Point_2(x(p), y(p)); + } + + Point_2 operator()(const Iso_cuboid_3& ic) const + { + Point_3 p = typename R::Construct_min_vertex_3()(ic); + return project(p); + } +}; + +template +class Construct_max_vertex_3 +{ +public: + typedef typename R::Iso_cuboid_3 Iso_cuboid_3; + typedef typename R::Point_3 Point_3; + typedef typename R::Point_2 Point_2; + typedef typename R::FT RT; + typename R::FT x(const Point_3& p) const { return Projector::x(p); } + typename R::FT y(const Point_3& p) const { return Projector::y(p); } + + Point_2 project(const Point_3& p) const + { + return Point_2(x(p), y(p)); + } + + Point_2 operator()(const Iso_cuboid_3& ic) const + { + Point_3 p = typename R::Construct_max_vertex_3()(ic); + return project(p); + } +}; + template class Compare_distance_projected_3 { @@ -401,6 +522,35 @@ class Compute_determinant_projected_3 } }; + +template +class Do_intersect_projected_3 +{ +public: + typedef typename R::Point_3 Point_3; + typedef typename R::Sphere_3 Sphere_3; + typedef typename R::Point_2 Point_2; + typedef typename R::Vector_2 Vector_2; + typedef typename R::Circle_2 Circle_2; + typedef typename R::FT FT; + + typename R::FT x(const Point_3& p) const { return Projector::x(p); } + typename R::FT y(const Point_3& p) const { return Projector::y(p); } + + Point_2 project(const Point_3& p) const + { + return Point_2(x(p), y(p)); + } + + bool operator()(const Sphere_3& s, const Bbox_2& bb) + { + Circle_2 circ(project(s.center()), s.squared_radius()); + + return R::Do_intersect_2()(circ,bb); + } +}; + + template class Intersect_projected_3 { @@ -927,6 +1077,9 @@ class Projection_traits_3 typedef typename Rp::Triangle_3 Triangle_2; typedef typename Rp::Line_3 Line_2; typedef typename Rp::Ray_3 Ray_2; + typedef typename Rp::Iso_cuboid_3 Iso_rectangle_2; + typedef typename Rp::Sphere_3 Circle_2; + typedef typename Rp::Cartesian_const_iterator_3 Cartesian_const_iterator_2; typedef typename Projector::Less_x_2 Less_x_2; typedef typename Projector::Less_y_2 Less_y_2; @@ -943,6 +1096,7 @@ class Projection_traits_3 typedef Collinear_are_ordered_along_line_projected_3 Collinear_are_ordered_along_line_2; typedef Squared_distance_projected_3 Compute_squared_distance_2; typedef Intersect_projected_3 Intersect_2; + typedef Do_intersect_projected_3 Do_intersect_2; typedef Compute_squared_radius_projected Compute_squared_radius_2; typedef Compute_scalar_product_projected_3 Compute_scalar_product_2; typedef Compute_squared_length_projected_3 Compute_squared_length_2; @@ -959,6 +1113,14 @@ class Projection_traits_3 typedef Construct_centroid_projected_3 Construct_centroid_2; typedef Compute_determinant_projected_3 Compute_determinant_2; + typedef Construct_min_vertex_3 Construct_min_vertex_2; + typedef Construct_max_vertex_3 Construct_max_vertex_2; + typedef Construct_center_3 Construct_center_2; + typedef Construct_projected_point_3 Construct_projected_point_2; + + typedef typename Rp::Construct_iso_cuboid_3 Construct_iso_rectangle_2; + typedef typename Rp::Construct_sphere_3 Construct_circle_2; + typedef Construct_cartesian_const_iterator_projected_3 Construct_cartesian_const_iterator_2; typedef typename Rp::Construct_point_3 Construct_point_2; typedef typename Rp::Construct_weighted_point_3 Construct_weighted_point_2; @@ -1136,6 +1298,16 @@ class Projection_traits_3 return Intersect_2(); } + Do_intersect_2 + do_intersect_2_object() const + { return Do_intersect_2();} + + Construct_projected_point_2 construct_projected_point_2_object() const + { return Construct_projected_point_2();} + + Construct_circle_2 construct_circle_2_object() const + { return Construct_circle_2();} + Construct_point_2 construct_point_2_object() const { return Construct_point_2();} From 40464539ad8116ed415a5c901d890f101e688ca8 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 15 Mar 2024 16:11:34 +0100 Subject: [PATCH 040/100] bug fix --- Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h b/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h index 8e57a4f46af2..96717ef4996a 100644 --- a/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h +++ b/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h @@ -266,7 +266,7 @@ class Construct_projected_point_3 { Point_2 p2 = typename R::Construct_projected_point_2()(Triangle_2(project(t.vertex(0)), project(t.vertex(1)), project(t.vertex(2))), project(p)); - return Point_3(p.x(), p.y(), 0); + return Point_3(p2.x(), p2.y(), 0); } template From a650d596329dcb47b9eb801e99a1be384cd3dae1 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 15 Mar 2024 16:23:12 +0100 Subject: [PATCH 041/100] whitespace --- .../include/CGAL/Kernel_23/internal/Projection_traits_3.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h b/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h index 96717ef4996a..9607351ee344 100644 --- a/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h +++ b/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h @@ -250,7 +250,7 @@ class Construct_projected_point_3 { public: typedef typename R::Point_3 Point_3; - typedef typename R::Point_2 Point_2; + typedef typename R::Point_2 Point_2; typedef typename R::Triangle_3 Triangle_3; typedef typename R::Triangle_2 Triangle_2; typedef typename R::FT RT; @@ -545,7 +545,7 @@ class Do_intersect_projected_3 bool operator()(const Sphere_3& s, const Bbox_2& bb) { Circle_2 circ(project(s.center()), s.squared_radius()); - + return R::Do_intersect_2()(circ,bb); } }; From b9b1ac4f3630cabce4bf1fb069e0fe795ac9131f Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Tue, 19 Mar 2024 13:34:08 +0100 Subject: [PATCH 042/100] fixing search tests --- .../CGAL/AABB_tree/internal/AABB_search_tree.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h index 2716a99b9050..f44130eda28b 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_search_tree.h @@ -27,6 +27,8 @@ struct AABB_search_tree { typedef typename Traits::Point_and_primitive_id Point_and_primitive_id; + typedef typename Point_and_primitive_id::first_type Point; + typedef typename Point_and_primitive_id::second_type Id; typedef First_of_pair_property_map Pmap; typedef Search_traits_adapter TreeTraits; typedef typename CGAL::Orthogonal_k_neighbor_search Neighbor_search; @@ -39,16 +41,21 @@ struct AABB_search_tree return p; } + Point_and_primitive_id get_p_and_p(const Point& p) + { + return Point_and_primitive_id(p, Id()); + } + public: template AABB_search_tree(ConstPointIterator begin, ConstPointIterator beyond) : m_tree{} { std::vector points; - while(begin != beyond) { - Point_and_primitive_id pp = get_p_and_p(*begin); - points.emplace_back(pp); - ++begin; + while (begin != beyond) { + Point_and_primitive_id pp = get_p_and_p(*begin); + points.emplace_back(pp); + ++begin; } m_tree.insert(points.begin(), points.end()); m_tree.build(); From c331dd398f1f2800e97772c87d738c1a73bb2411 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Wed, 20 Mar 2024 10:03:34 +0100 Subject: [PATCH 043/100] projection via pointmap --- .../AABB_indexed_triangle_2_example.cpp | 89 +++++++++++++++---- .../CGAL/AABB_indexed_triangle_primitive_2.h | 37 ++++---- 2 files changed, 92 insertions(+), 34 deletions(-) diff --git a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp index 6e7e47c3df87..3a95584da971 100644 --- a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp @@ -8,27 +8,82 @@ #include #include -typedef CGAL::Simple_cartesian SC; -typedef CGAL::Projection_traits_xy_3 K; +typedef CGAL::Simple_cartesian K; +typedef K::Point_3 Point_3; typedef K::Point_2 Point; +template +struct Projection_xy_point_map { + + typedef typename GeomTraits::Point_3 key_type; + typedef typename GeomTraits::Point_2 value_type; + typedef const value_type& reference; + + typedef boost::readable_property_map_tag category; + typedef Projection_xy_point_map Self; + + Projection_xy_point_map() {} + + inline friend value_type get(Self s, key_type p) + { + return value_type(p.x(), p.y()); + } +}; + +template +struct Projection_xz_point_map { + + typedef typename GeomTraits::Point_3 key_type; + typedef typename GeomTraits::Point_2 value_type; + typedef const value_type& reference; + + typedef boost::readable_property_map_tag category; + typedef Projection_xz_point_map Self; + + Projection_xz_point_map() {} + + inline friend value_type get(Self s, key_type p) + { + return value_type(p.x(), p.z()); + } +}; + +template +struct Projection_yz_point_map { + + typedef typename GeomTraits::Point_3 key_type; + typedef typename GeomTraits::Point_2 value_type; + typedef const value_type& reference; + + typedef boost::readable_property_map_tag category; + typedef Projection_yz_point_map Self; + + Projection_yz_point_map() {} + + inline friend value_type get(Self s, key_type p) + { + return value_type(p.y(), p.z()); + } +}; + typedef std::vector >::iterator IndexIterator; -typedef std::vector PointRange; -typedef CGAL::AABB_indexed_triangle_primitive_2 Primitive; +typedef std::vector PointRange; +typedef CGAL::AABB_indexed_triangle_primitive_2> Primitive; typedef CGAL::AABB_traits_2 AABB_triangle_traits; typedef CGAL::AABB_tree Tree; typedef Tree::Point_and_primitive_id Point_and_primitive_id; + int main() { - Point a(0.0, 0.0, 0.0); - Point b(0.0, 1.0, 0.0); - Point c(1.0, 0.0, 0.0); - Point d(1.0, 1.0, 0.0); - Point e(2.0, 0.0, 0.0); - Point f(2.0, 1.0, 0.0); + Point_3 a(0.0, 0.0, 0.0); + Point_3 b(0.0, 1.0, 0.0); + Point_3 c(1.0, 0.0, 0.0); + Point_3 d(1.0, 1.0, 0.0); + Point_3 e(2.0, 0.0, 0.0); + Point_3 f(2.0, 1.0, 0.0); - std::vector points = { a, b, c, d, e, f }; + std::vector points = { a, b, c, d, e, f }; std::vector > triangles; triangles.push_back({ 0, 2, 1 }); @@ -41,17 +96,17 @@ int main() // point sampling Point_and_primitive_id id; - id = tree.closest_point_and_primitive(Point(0.5, 0.4, 0.0)); + id = tree.closest_point_and_primitive(Point(0.5, 0.4)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; - id = tree.closest_point_and_primitive(Point(0.5, 0.6, 0.0)); + id = tree.closest_point_and_primitive(Point(0.5, 0.6)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; - id = tree.closest_point_and_primitive(Point(1.5, 0.5, 0.0)); + id = tree.closest_point_and_primitive(Point(1.5, 0.5)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; - id = tree.closest_point_and_primitive(Point(1.5, 0.6, 0.0)); + id = tree.closest_point_and_primitive(Point(1.5, 0.6)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; - id = tree.closest_point_and_primitive(Point(1.0, 0.0, 0.0)); + id = tree.closest_point_and_primitive(Point(1.0, 0.0)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; - id = tree.closest_point_and_primitive(Point(3.0, 0.5, 0.0)); + id = tree.closest_point_and_primitive(Point(3.0, 0.5)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; return EXIT_SUCCESS; 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 4eda27d4c83c..5887d85f6e3d 100644 --- a/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h @@ -23,7 +23,7 @@ namespace CGAL { namespace internal { - template + template struct Triangle_2_from_index_range_iterator_property_map { //classical typedefs typedef Iterator key_type; @@ -31,40 +31,42 @@ namespace internal { typedef typename GeomTraits::Triangle_2 reference; typedef boost::readable_property_map_tag category; - typedef Triangle_2_from_index_range_iterator_property_map Self; + typedef Triangle_2_from_index_range_iterator_property_map Self; Triangle_2_from_index_range_iterator_property_map() {} - Triangle_2_from_index_range_iterator_property_map(PointIterator b) : begin(b) {} + Triangle_2_from_index_range_iterator_property_map(PointIterator b, PointMap& pmap) : begin(b), pmap(pmap) {} inline friend value_type get(Self s, key_type it) { - return typename GeomTraits::Construct_triangle_2()(s.begin[(*it)[0]], s.begin[(*it)[1]], s.begin[(*it)[2]]); + return typename GeomTraits::Construct_triangle_2()(get(s.pmap, s.begin[(*it)[0]]), get(s.pmap, s.begin[(*it)[1]]), get(s.pmap, s.begin[(*it)[2]])); } PointIterator begin; + PointMap pmap; }; - template + template struct Point_from_indexed_triangle_2_iterator_property_map { //classical typedefs typedef Iterator key_type; - typedef typename PointIterator::value_type value_type; - typedef const value_type& reference; + typedef typename PointMap::value_type value_type; + typedef const value_type reference; typedef boost::readable_property_map_tag category; - typedef Point_from_indexed_triangle_2_iterator_property_map Self; + typedef Point_from_indexed_triangle_2_iterator_property_map Self; Point_from_indexed_triangle_2_iterator_property_map() {} - Point_from_indexed_triangle_2_iterator_property_map(PointIterator b) : begin(b) {} + Point_from_indexed_triangle_2_iterator_property_map(PointIterator b, PointMap &pmap) : begin(b), pmap(pmap) {} inline friend reference get(Self s, key_type it) { - return s.begin[((*it)[0])]; + return get(s.pmap, s.begin[((*it)[0])]); } PointIterator begin; + PointMap pmap; }; }//namespace internal @@ -96,19 +98,20 @@ namespace internal { template < class GeomTraits, class IndexIterator, class PointRange, + class PointMap=Identity_property_map, class CacheDatum=Tag_false> class AABB_indexed_triangle_primitive_2 #ifndef DOXYGEN_RUNNING : public AABB_primitive< IndexIterator, - internal::Triangle_2_from_index_range_iterator_property_map, - internal::Point_from_indexed_triangle_2_iterator_property_map, + internal::Triangle_2_from_index_range_iterator_property_map, + internal::Point_from_indexed_triangle_2_iterator_property_map, Tag_true, CacheDatum > #endif { typedef AABB_primitive< IndexIterator, - internal::Triangle_2_from_index_range_iterator_property_map, - internal::Point_from_indexed_triangle_2_iterator_property_map, + internal::Triangle_2_from_index_range_iterator_property_map, + internal::Point_from_indexed_triangle_2_iterator_property_map, Tag_true, CacheDatum > Base; public: @@ -116,10 +119,10 @@ class AABB_indexed_triangle_primitive_2 AABB_indexed_triangle_primitive_2(IndexIterator it, PointRange&) : Base(it) {} /// \internal - static typename Base::Shared_data construct_shared_data(PointRange &range) { + static typename Base::Shared_data construct_shared_data(PointRange &range, PointMap &pmap = PointMap()) { return std::make_pair( - internal::Triangle_2_from_index_range_iterator_property_map(range.begin()), - internal::Point_from_indexed_triangle_2_iterator_property_map(range.begin())); + internal::Triangle_2_from_index_range_iterator_property_map(range.begin(), pmap), + internal::Point_from_indexed_triangle_2_iterator_property_map(range.begin(), pmap)); } }; From 7403de39836b496fb8af59f46730ac33cb80ddc6 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Wed, 20 Mar 2024 10:39:36 +0100 Subject: [PATCH 044/100] Update AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp Co-authored-by: Sebastien Loriot --- .../examples/AABB_tree/AABB_indexed_triangle_2_example.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp index 3a95584da971..531cafb2f022 100644 --- a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp @@ -17,7 +17,7 @@ struct Projection_xy_point_map { typedef typename GeomTraits::Point_3 key_type; typedef typename GeomTraits::Point_2 value_type; - typedef const value_type& reference; + typedef value_type reference; typedef boost::readable_property_map_tag category; typedef Projection_xy_point_map Self; From 8583c4b1d87fe71e78c63d6719e0dcbe269fb860 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Wed, 20 Mar 2024 17:44:57 +0100 Subject: [PATCH 045/100] added wrapper to map ray/vector types from AABB_traits_2 --- .../AABB_indexed_triangle_2_example.cpp | 52 ++++++------------- AABB_tree/include/CGAL/AABB_traits_2.h | 4 +- .../internal/AABB_ray_intersection.h | 32 +++++++++--- .../internal/Is_ray_intersection_geomtraits.h | 33 ++++++++---- 4 files changed, 67 insertions(+), 54 deletions(-) diff --git a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp index 531cafb2f022..14480efece25 100644 --- a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp @@ -11,6 +11,8 @@ typedef CGAL::Simple_cartesian K; typedef K::Point_3 Point_3; typedef K::Point_2 Point; +typedef K::Vector_2 Vector; +typedef K::Ray_2 Ray; template struct Projection_xy_point_map { @@ -30,48 +32,13 @@ struct Projection_xy_point_map { } }; -template -struct Projection_xz_point_map { - - typedef typename GeomTraits::Point_3 key_type; - typedef typename GeomTraits::Point_2 value_type; - typedef const value_type& reference; - - typedef boost::readable_property_map_tag category; - typedef Projection_xz_point_map Self; - - Projection_xz_point_map() {} - - inline friend value_type get(Self s, key_type p) - { - return value_type(p.x(), p.z()); - } -}; - -template -struct Projection_yz_point_map { - - typedef typename GeomTraits::Point_3 key_type; - typedef typename GeomTraits::Point_2 value_type; - typedef const value_type& reference; - - typedef boost::readable_property_map_tag category; - typedef Projection_yz_point_map Self; - - Projection_yz_point_map() {} - - inline friend value_type get(Self s, key_type p) - { - return value_type(p.y(), p.z()); - } -}; - typedef std::vector >::iterator IndexIterator; typedef std::vector PointRange; -typedef CGAL::AABB_indexed_triangle_primitive_2> Primitive; +typedef CGAL::AABB_indexed_triangle_primitive_2> Primitive; typedef CGAL::AABB_traits_2 AABB_triangle_traits; typedef CGAL::AABB_tree Tree; typedef Tree::Point_and_primitive_id Point_and_primitive_id; +typedef std::optional::Type> Ray_intersection; int main() @@ -109,5 +76,16 @@ int main() id = tree.closest_point_and_primitive(Point(3.0, 0.5)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; + Ray ray(Point(5.5, 0.5), Point(1.5, 0.5)); + Ray_intersection intersection = tree.first_intersection(ray); + + if (!intersection) { + std::cout << "Ray does not intersect with triangles although it should!" << std::endl; + return EXIT_FAILURE; + } + else { + std::cout << std::distance(triangles.begin(), intersection->second) << ". triangle" << std::endl; + } + return EXIT_SUCCESS; } diff --git a/AABB_tree/include/CGAL/AABB_traits_2.h b/AABB_tree/include/CGAL/AABB_traits_2.h index 556b1a079359..2d6e366f36bb 100644 --- a/AABB_tree/include/CGAL/AABB_traits_2.h +++ b/AABB_tree/include/CGAL/AABB_traits_2.h @@ -38,7 +38,7 @@ namespace internal{ namespace AABB_tree { // AABB_traits_intersection_base brings in the Intersection_distance predicate, // if GeomTraits is a model RayIntersectionGeomTraits. -template ::value> +template ::value> struct AABB_traits_intersection_base_2; template @@ -77,7 +77,7 @@ struct AABB_traits_intersection_base_2{ Cartesian_const_iterator_2 source_iter = construct_cartesian_const_iterator_2(source); Cartesian_const_iterator_2 direction_iter = construct_cartesian_const_iterator_2(direction); - for(int i = 0; i < 3; ++i, ++source_iter, ++direction_iter) { + for(int i = 0; i < 2; ++i, ++source_iter, ++direction_iter) { if(*direction_iter == 0) { if((*source_iter < (bbox.min)(i)) || (*source_iter > (bbox.max)(i))) { return std::nullopt; diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h index fd11f41492c5..45610d84d9ae 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h @@ -33,10 +33,30 @@ namespace CGAL { +namespace internal { +template +struct Intersection_traits_wrapper {}; + +template +struct Intersection_traits_wrapper { + typedef typename GT::Ray_2 Ray; + typedef typename GT::Vector_2 Vector; +}; + +template +struct Intersection_traits_wrapper { + typedef typename GT::Ray_3 Ray; + typedef typename GT::Vector_3 Vector; +}; +} + template class AABB_ray_intersection { typedef typename AABBTree::AABB_traits AABB_traits; - typedef typename AABB_traits::Ray_3 Ray; + static const int dimension = typename AABB_traits::Point::Ambient_dimension::value; + typedef typename internal::Intersection_traits_wrapper::Ray Ray; + typedef typename internal::Intersection_traits_wrapper::Vector Vector; + typedef typename AABBTree::template Intersection_and_primitive_id::Type Ray_intersection_and_primitive_id; typedef typename Ray_intersection_and_primitive_id::first_type Ray_intersection; public: @@ -167,8 +187,8 @@ class AABB_ray_intersection { as_ray_param_visitor(const Ray* ray) : ray(ray), max_i(0) { - typename AABB_traits::Geom_traits::Vector_3 v = ray->to_vector(); - for (int i=1; i<3; ++i) + Vector v = ray->to_vector(); + for (int i=1; i CGAL::abs(v[max_i]) ) max_i = i; } @@ -184,8 +204,8 @@ class AABB_ray_intersection { } FT operator()(const Point& point) { - typename AABB_traits::Geom_traits::Vector_3 x(ray->source(), point); - typename AABB_traits::Geom_traits::Vector_3 v = ray->to_vector(); + Vector x(ray->source(), point); + Vector v = ray->to_vector(); return x[max_i] / v[max_i]; } @@ -200,7 +220,7 @@ template std::optional< typename AABB_tree::template Intersection_and_primitive_id::Type > AABB_tree::first_intersection(const Ray& query, const SkipFunctor& skip) const { - static_assert(std::is_same::value, + static_assert(std::is_same::value, "Ray and Ray_3 must be the same type"); switch(size()) // copy-paste from AABB_tree::traversal diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/Is_ray_intersection_geomtraits.h b/AABB_tree/include/CGAL/AABB_tree/internal/Is_ray_intersection_geomtraits.h index 3d02204b9d03..f77b59d60852 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/Is_ray_intersection_geomtraits.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/Is_ray_intersection_geomtraits.h @@ -24,18 +24,33 @@ namespace CGAL { namespace internal { namespace AABB_tree { -BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_ray_3,Ray_3,false) -BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_construct_source_3,Construct_source_3,false) -BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_vector_3,Construct_vector_3,false) -BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_construct_cartesian_const_iterator_3,Construct_cartesian_const_iterator_3,false) -BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_cartesian_const_iterator_3,Cartesian_const_iterator_3,false) +BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_ray_3, Ray_3, false) +BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_construct_source_3, Construct_source_3, false) +BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_vector_3, Construct_vector_3, false) +BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_construct_cartesian_const_iterator_3, Construct_cartesian_const_iterator_3, false) +BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_cartesian_const_iterator_3, Cartesian_const_iterator_3, false) + +BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_ray_2, Ray_2, false) +BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_construct_source_2, Construct_source_2, false) +BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_vector_2, Construct_vector_2, false) +BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_construct_cartesian_const_iterator_2, Construct_cartesian_const_iterator_2, false) +BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_cartesian_const_iterator_2, Cartesian_const_iterator_2, false) + +template +struct Is_ray_intersection_geomtraits_2 +: std::bool_constant< Has_ray_2::value && + Has_construct_source_2::value && + Has_vector_2::value && + Has_construct_cartesian_const_iterator_2::value && + Has_cartesian_const_iterator_2::value > +{}; template struct Is_ray_intersection_geomtraits -: std::bool_constant< Has_ray_3::value && - Has_construct_source_3::value && - Has_vector_3::value && - Has_construct_cartesian_const_iterator_3::value && +: std::bool_constant< Has_ray_3::value&& + Has_construct_source_3::value&& + Has_vector_3::value&& + Has_construct_cartesian_const_iterator_3::value&& Has_cartesian_const_iterator_3::value > {}; From 560e576488a4db697b34524f1f2eb18551b11ff4 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Wed, 20 Mar 2024 18:10:54 +0100 Subject: [PATCH 046/100] fix ci --- AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h | 2 +- .../include/CGAL/AABB_tree/internal/AABB_ray_intersection.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 5887d85f6e3d..8305941b931e 100644 --- a/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h @@ -98,7 +98,7 @@ namespace internal { template < class GeomTraits, class IndexIterator, class PointRange, - class PointMap=Identity_property_map, + class PointMap=Identity_property_map, class CacheDatum=Tag_false> class AABB_indexed_triangle_primitive_2 #ifndef DOXYGEN_RUNNING diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h index 45610d84d9ae..34bb26d7f90f 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h @@ -53,7 +53,7 @@ struct Intersection_traits_wrapper { template class AABB_ray_intersection { typedef typename AABBTree::AABB_traits AABB_traits; - static const int dimension = typename AABB_traits::Point::Ambient_dimension::value; + static const int dimension = AABB_traits::Point::Ambient_dimension::value; typedef typename internal::Intersection_traits_wrapper::Ray Ray; typedef typename internal::Intersection_traits_wrapper::Vector Vector; From bc3e8fa2358ec7a57fcc77870aa0697890c448ba Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 21 Mar 2024 08:17:47 +0100 Subject: [PATCH 047/100] removed type wrapper added Ray/Vector types in AABB_traits_2/3 --- AABB_tree/include/CGAL/AABB_traits_2.h | 3 ++- AABB_tree/include/CGAL/AABB_traits_3.h | 3 ++- .../internal/AABB_ray_intersection.h | 21 ++----------------- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_traits_2.h b/AABB_tree/include/CGAL/AABB_traits_2.h index 2d6e366f36bb..6300d4188bf3 100644 --- a/AABB_tree/include/CGAL/AABB_traits_2.h +++ b/AABB_tree/include/CGAL/AABB_traits_2.h @@ -47,10 +47,11 @@ struct AABB_traits_intersection_base_2{}; template struct AABB_traits_intersection_base_2{ typedef typename GeomTraits::Ray_2 Ray_2; + typedef typename GeomTraits::Ray_2 Ray; typedef typename GeomTraits::Point_2 Point_2; typedef typename GeomTraits::Point_2 Point; - typedef typename GeomTraits::Ray_2 Ray; typedef typename GeomTraits::Vector_2 Vector_2; + typedef typename GeomTraits::Vector_2 Vector; typedef typename GeomTraits::FT FT; typedef typename GeomTraits::Cartesian_const_iterator_2 Cartesian_const_iterator_2; typedef typename GeomTraits::Construct_cartesian_const_iterator_2 Construct_cartesian_const_iterator_2; diff --git a/AABB_tree/include/CGAL/AABB_traits_3.h b/AABB_tree/include/CGAL/AABB_traits_3.h index 5614b484ad42..9e9499b5971d 100644 --- a/AABB_tree/include/CGAL/AABB_traits_3.h +++ b/AABB_tree/include/CGAL/AABB_traits_3.h @@ -70,10 +70,11 @@ struct AABB_traits_intersection_base{}; template struct AABB_traits_intersection_base{ typedef typename GeomTraits::Ray_3 Ray_3; + typedef typename GeomTraits::Ray_3 Ray; typedef typename GeomTraits::Point_3 Point_3; typedef typename GeomTraits::Point_3 Point; - typedef typename GeomTraits::Ray_3 Ray; typedef typename GeomTraits::Vector_3 Vector_3; + typedef typename GeomTraits::Vector_3 Vector; typedef typename GeomTraits::FT FT; typedef typename GeomTraits::Cartesian_const_iterator_3 Cartesian_const_iterator_3; typedef typename GeomTraits::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator_3; diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h index 34bb26d7f90f..b670266e8a43 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h @@ -33,29 +33,12 @@ namespace CGAL { -namespace internal { -template -struct Intersection_traits_wrapper {}; - -template -struct Intersection_traits_wrapper { - typedef typename GT::Ray_2 Ray; - typedef typename GT::Vector_2 Vector; -}; - -template -struct Intersection_traits_wrapper { - typedef typename GT::Ray_3 Ray; - typedef typename GT::Vector_3 Vector; -}; -} - template class AABB_ray_intersection { typedef typename AABBTree::AABB_traits AABB_traits; static const int dimension = AABB_traits::Point::Ambient_dimension::value; - typedef typename internal::Intersection_traits_wrapper::Ray Ray; - typedef typename internal::Intersection_traits_wrapper::Vector Vector; + typedef typename AABB_traits::Ray Ray; + typedef typename AABB_traits::Vector Vector; typedef typename AABBTree::template Intersection_and_primitive_id::Type Ray_intersection_and_primitive_id; typedef typename Ray_intersection_and_primitive_id::first_type Ray_intersection; From c6ee406603defcc134120e667882b051aad11114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 21 Mar 2024 09:41:25 +0100 Subject: [PATCH 048/100] undo projection traits changes --- .../include/CGAL/Kernel/function_objects.h | 200 ------------------ .../Kernel_23/internal/Projection_traits_3.h | 172 --------------- .../include/CGAL/_test_fct_constructions_2.h | 26 +-- 3 files changed, 1 insertion(+), 397 deletions(-) diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index ba7db14d92be..084a6578913c 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -2874,206 +2874,6 @@ namespace CommonKernelFunctors { } }; - template - class Construct_projected_point_2 - { - bool - is_inside_triangle_2_aux( - const typename K::Point_2& p1, - const typename K::Point_2& p2, - const typename K::Point_2& q, - typename K::Point_2& result, - bool& outside, - const K& k) - { - typedef typename K::Vector_2 Vector_2; - typedef typename K::FT FT; - - typename K::Construct_vector_2 vector = - k.construct_vector_2_object(); - typename K::Construct_projected_point_2 projection = - k.construct_projected_point_2_object(); - typename K::Construct_line_2 line = - k.construct_line_2_object(); - typename K::Compute_scalar_product_2 scalar_product = - k.compute_scalar_product_2_object(); - typename K::Construct_direction_2 direction = - k.construct_direction_2_object(); - typename K::Construct_perpendicular_direction_2 perpendicular = - k.construct_perpendicular_direction_2_object(); - - // Check whether the point is cw or ccw with the triangle side (p1,p2) - Vector_2 orth = vector(p1, p2); - - if (scalar_product(vector(p1, q), vector(perpendicular(direction(orth), CGAL::COUNTERCLOCKWISE))) < FT(0)) - { - if (scalar_product(vector(p1, q), vector(p1, p2)) >= FT(0) - && scalar_product(vector(p2, q), vector(p2, p1)) >= FT(0)) - { - result = projection(line(p1, p2), q); - return true; - } - outside = true; - } - - return false; - } - - /** - * Returns the nearest point of p1,p2,p3 from origin - * @param origin the origin point - * @param p1 the first point - * @param p2 the second point - * @param p3 the third point - * @param k the kernel - * @return the nearest point from origin - */ - typename K::Point_2 - nearest_point_2(const typename K::Point_2& origin, - const typename K::Point_2& p1, - const typename K::Point_2& p2, - const typename K::Point_2& p3, - const K& k) - { - typedef typename K::FT FT; - - typename K::Compute_squared_distance_2 sq_distance = - k.compute_squared_distance_2_object(); - - const FT dist_origin_p1 = sq_distance(origin, p1); - const FT dist_origin_p2 = sq_distance(origin, p2); - const FT dist_origin_p3 = sq_distance(origin, p3); - - if (dist_origin_p2 >= dist_origin_p1 - && dist_origin_p3 >= dist_origin_p1) - { - return p1; - } - if (dist_origin_p3 >= dist_origin_p2) - { - return p2; - } - - return p3; - } - - /** - * @brief returns true if p is inside triangle t. If p is not inside t, - * result is the nearest point of t from p. - * @param p the reference point - * @param t the triangle - * @param result if p is not inside t, the nearest point of t from p - * @param k the kernel - * @return true if p is inside t - */ - bool - is_inside_triangle_2(const typename K::Point_2& p, - const typename K::Triangle_2& t, - typename K::Point_2& result, - const K& k) - { - typedef typename K::Point_2 Point_2; - - typename K::Construct_vertex_2 vertex_on = - k.construct_vertex_2_object(); - - const Point_2& t0 = vertex_on(t, 0); - const Point_2& t1 = vertex_on(t, 1); - const Point_2& t2 = vertex_on(t, 2); - - bool outside = false; - if (is_inside_triangle_2_aux(t0, t1, p, result, outside, k) - || is_inside_triangle_2_aux(t1, t2, p, result, outside, k) - || is_inside_triangle_2_aux(t2, t0, p, result, outside, k)) - { - return false; - } - - if (outside) - { - result = nearest_point_2(p, t0, t1, t2, k); - return false; - } - else - { - return true; - } - } - - public: - typename K::Point_2 - operator()(const typename K::Triangle_2& triangle, - const typename K::Point_2& origin, - const K& k) - { - typedef typename K::Point_2 Point_2; - typename K::Construct_vertex_2 vertex_on; - typename K::Construct_segment_2 segment; - - // Check if triangle is degenerated to call segment operator. - const Point_2& t0 = vertex_on(triangle, 0); - const Point_2& t1 = vertex_on(triangle, 1); - const Point_2& t2 = vertex_on(triangle, 2); - - if (t0 == t1) - return (*this)(segment(t1, t2), origin, k); - if (t1 == t2) - return (*this)(segment(t2, t0), origin, k); - if (t2 == t0) - return (*this)(segment(t0, t1), origin, k); - - Point_2 moved_point; - bool inside = is_inside_triangle_2(origin, triangle, moved_point, k); - - // If proj is inside triangle, return it - if (inside) - { - return origin; - } - - // Else return the constructed point - return moved_point; - } - - typename K::Point_2 - operator()(const typename K::Segment_2& s, - const typename K::Point_2& query, - const K& k) { - - typename K::Construct_vector_2 vector = - k.construct_vector_2_object(); - - typename K::Compute_scalar_product_2 scalar_product = - k.compute_scalar_product_2_object(); - - typename K::Construct_scaled_vector_2 scaled_vector = - k.construct_scaled_vector_2_object(); - - const typename K::Point_2& a = s.source(); - const typename K::Point_2& b = s.target(); - const typename K::Vector_2 d = vector(a, b); - - typename K::FT sqlen = scalar_product(d, d); - - // Degenerate segment - if (is_zero(sqlen)) - return a; - - const typename K::Vector_2 p = vector(a, query); - - typename K::FT proj = (scalar_product(p, d)) / sqlen; - - if (!is_positive(proj)) - return a; - - if (proj >= 1.0) - return b; - - typename K::Construct_point_2 construct_point_2; - return construct_point_2(a + scaled_vector(d, proj)); - } - }; - template class Construct_projected_point_3 { diff --git a/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h b/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h index 9607351ee344..1cc09421944d 100644 --- a/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h +++ b/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h @@ -87,32 +87,13 @@ struct Projector static const int y_index=1; }; -template -class Construct_cartesian_const_iterator_projected_3 { -public: - typedef typename R::Point_3 Point_3; - typedef typename R::Cartesian_const_iterator_3 Cartesian_const_iterator; - Cartesian_const_iterator operator()(const Point_3& p) const - { - return typename R::Construct_cartesian_const_iterator_3()(p); - } - Cartesian_const_iterator operator()(const Point_3& p, int) const - { - Cartesian_const_iterator it = typename R::Construct_cartesian_const_iterator_3()(p,0); - --it; - return it; - } -}; - template class Construct_bbox_projected_2 { public: typedef typename R::Point_3 Point; - typedef typename R::Triangle_3 Triangle_3; typedef Bbox_2 result_type; Bbox_2 operator()(const Point& p) const { typename R::Construct_bbox_3 bb; return Projector::bbox(bb(p)); } - Bbox_2 operator()(const Triangle_3& t) const { typename R::Construct_bbox_3 bb; return Projector::bbox(bb(t)); } }; template @@ -222,108 +203,6 @@ class Side_of_bounded_circle_projected_3 } }; -template -class Construct_center_3 -{ -public: - typedef typename R::Sphere_3 Sphere_3; - typedef typename R::Point_3 Point_3; - typedef typename R::Point_2 Point_2; - typedef typename R::FT RT; - typename R::FT x(const Point_3& p) const { return Projector::x(p); } - typename R::FT y(const Point_3& p) const { return Projector::y(p); } - - Point_2 project(const Point_3& p) const - { - return Point_2(x(p), y(p)); - } - - Point_2 operator()(const Sphere_3& s) const - { - Point_3 p = typename R::Construct_center_3()(s); - return project(p); - } -}; - -template -class Construct_projected_point_3 -{ -public: - typedef typename R::Point_3 Point_3; - typedef typename R::Point_2 Point_2; - typedef typename R::Triangle_3 Triangle_3; - typedef typename R::Triangle_2 Triangle_2; - typedef typename R::FT RT; - typename R::FT x(const Point_3& p) const { return Projector::x(p); } - typename R::FT y(const Point_3& p) const { return Projector::y(p); } - - Point_2 project(const Point_3& p) const - { - return Point_2(x(p), y(p)); - } - - Point_3 operator()(const Triangle_3& t, const Point_3& p) const - { - Point_2 p2 = typename R::Construct_projected_point_2()(Triangle_2(project(t.vertex(0)), project(t.vertex(1)), project(t.vertex(2))), - project(p)); - return Point_3(p2.x(), p2.y(), 0); - } - - template - Point_3 operator()(const T& t, const Point_3& p) const - { std::cout << "todo: implement Projection_traits_3::Construct_projected_point_3 for " << typeid(t).name() << " and Point_3" << std::endl; - return Point_3(); - } - -}; - - -template -class Construct_min_vertex_3 -{ -public: - typedef typename R::Iso_cuboid_3 Iso_cuboid_3; - typedef typename R::Point_3 Point_3; - typedef typename R::Point_2 Point_2; - typedef typename R::FT RT; - typename R::FT x(const Point_3& p) const { return Projector::x(p); } - typename R::FT y(const Point_3& p) const { return Projector::y(p); } - - Point_2 project(const Point_3& p) const - { - return Point_2(x(p), y(p)); - } - - Point_2 operator()(const Iso_cuboid_3& ic) const - { - Point_3 p = typename R::Construct_min_vertex_3()(ic); - return project(p); - } -}; - -template -class Construct_max_vertex_3 -{ -public: - typedef typename R::Iso_cuboid_3 Iso_cuboid_3; - typedef typename R::Point_3 Point_3; - typedef typename R::Point_2 Point_2; - typedef typename R::FT RT; - typename R::FT x(const Point_3& p) const { return Projector::x(p); } - typename R::FT y(const Point_3& p) const { return Projector::y(p); } - - Point_2 project(const Point_3& p) const - { - return Point_2(x(p), y(p)); - } - - Point_2 operator()(const Iso_cuboid_3& ic) const - { - Point_3 p = typename R::Construct_max_vertex_3()(ic); - return project(p); - } -}; - template class Compare_distance_projected_3 { @@ -522,35 +401,6 @@ class Compute_determinant_projected_3 } }; - -template -class Do_intersect_projected_3 -{ -public: - typedef typename R::Point_3 Point_3; - typedef typename R::Sphere_3 Sphere_3; - typedef typename R::Point_2 Point_2; - typedef typename R::Vector_2 Vector_2; - typedef typename R::Circle_2 Circle_2; - typedef typename R::FT FT; - - typename R::FT x(const Point_3& p) const { return Projector::x(p); } - typename R::FT y(const Point_3& p) const { return Projector::y(p); } - - Point_2 project(const Point_3& p) const - { - return Point_2(x(p), y(p)); - } - - bool operator()(const Sphere_3& s, const Bbox_2& bb) - { - Circle_2 circ(project(s.center()), s.squared_radius()); - - return R::Do_intersect_2()(circ,bb); - } -}; - - template class Intersect_projected_3 { @@ -1077,9 +927,6 @@ class Projection_traits_3 typedef typename Rp::Triangle_3 Triangle_2; typedef typename Rp::Line_3 Line_2; typedef typename Rp::Ray_3 Ray_2; - typedef typename Rp::Iso_cuboid_3 Iso_rectangle_2; - typedef typename Rp::Sphere_3 Circle_2; - typedef typename Rp::Cartesian_const_iterator_3 Cartesian_const_iterator_2; typedef typename Projector::Less_x_2 Less_x_2; typedef typename Projector::Less_y_2 Less_y_2; @@ -1096,7 +943,6 @@ class Projection_traits_3 typedef Collinear_are_ordered_along_line_projected_3 Collinear_are_ordered_along_line_2; typedef Squared_distance_projected_3 Compute_squared_distance_2; typedef Intersect_projected_3 Intersect_2; - typedef Do_intersect_projected_3 Do_intersect_2; typedef Compute_squared_radius_projected Compute_squared_radius_2; typedef Compute_scalar_product_projected_3 Compute_scalar_product_2; typedef Compute_squared_length_projected_3 Compute_squared_length_2; @@ -1113,14 +959,6 @@ class Projection_traits_3 typedef Construct_centroid_projected_3 Construct_centroid_2; typedef Compute_determinant_projected_3 Compute_determinant_2; - typedef Construct_min_vertex_3 Construct_min_vertex_2; - typedef Construct_max_vertex_3 Construct_max_vertex_2; - typedef Construct_center_3 Construct_center_2; - typedef Construct_projected_point_3 Construct_projected_point_2; - - typedef typename Rp::Construct_iso_cuboid_3 Construct_iso_rectangle_2; - typedef typename Rp::Construct_sphere_3 Construct_circle_2; - typedef Construct_cartesian_const_iterator_projected_3 Construct_cartesian_const_iterator_2; typedef typename Rp::Construct_point_3 Construct_point_2; typedef typename Rp::Construct_weighted_point_3 Construct_weighted_point_2; @@ -1298,16 +1136,6 @@ class Projection_traits_3 return Intersect_2(); } - Do_intersect_2 - do_intersect_2_object() const - { return Do_intersect_2();} - - Construct_projected_point_2 construct_projected_point_2_object() const - { return Construct_projected_point_2();} - - Construct_circle_2 construct_circle_2_object() const - { return Construct_circle_2();} - Construct_point_2 construct_point_2_object() const { return Construct_point_2();} diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_2.h index dcbb3fec1124..288d6a55dfd4 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_2.h @@ -20,7 +20,7 @@ template bool -_test_fct_constructions_2(const R& r) +_test_fct_constructions_2(const R&) { typedef typename R::RT RT; typedef CGAL::Point_2 Point; @@ -89,30 +89,6 @@ _test_fct_constructions_2(const R& r) assert( CGAL::weighted_circumcenter( wpnw_b, wpse_b, wpsw_b ) == psw); - Point a(0, 1); - Point b(3, 4); - Segment seg(a, b); - - assert(r.construct_projected_point_2_object()(seg, Point(0, 0)) == a); - assert(r.construct_projected_point_2_object()(seg, Point(5, 0)) == Point(2, 3)); - assert(r.construct_projected_point_2_object()(seg, Point(5, 4)) == b); - assert(r.construct_projected_point_2_object()(seg, Point(2, 4)) == Point(5, 7, 2)); - - Point c(2.0, 5.0); - Triangle tri(a, b, c); - assert(r.construct_projected_point_2_object()(tri, Point(0, 0)) == a); - assert(r.construct_projected_point_2_object()(tri, Point(0, 10)) == c); - assert(r.construct_projected_point_2_object()(tri, Point(7, 7, 2)) == b); - assert(r.construct_projected_point_2_object()(tri, Point(2, 1)) == Point(1, 2)); - assert(r.construct_projected_point_2_object()(tri, Point(2, 4)) == Point(2, 4)); - - Triangle dtri(a, b, a); - - assert(r.construct_projected_point_2_object()(dtri, Point(0, 0)) == a); - assert(r.construct_projected_point_2_object()(dtri, Point(5, 0)) == Point(2, 3)); - assert(r.construct_projected_point_2_object()(dtri, Point(5, 4)) == b); - assert(r.construct_projected_point_2_object()(dtri, Point(2, 4)) == Point(5, 7, 2)); - return true; } From ee0a90bd4d6198f891f094fc753423ede8346ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 21 Mar 2024 09:58:10 +0100 Subject: [PATCH 049/100] undo more changes --- .../include/CGAL/Homogeneous/function_objects.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h index e28450256a07..3028950d7aff 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h @@ -3373,8 +3373,6 @@ namespace HomogeneousKernelFunctors { typedef typename K::Point_2 Point_2; typedef typename K::Direction_2 Direction_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; @@ -3387,14 +3385,6 @@ namespace HomogeneousKernelFunctors { l2.a()*l.c() - l.a()*l2.c(), l.a()*l2.b() - l2.a()*l.b() ); } - - Point_2 - operator()(const Segment_2& s, const Point_2& p) const - { return CommonKernelFunctors::Construct_projected_point_2()(s, p, K()); } - - Point_2 - operator()(const Triangle_2& t, const Point_2& p) const - { return CommonKernelFunctors::Construct_projected_point_2()(t, p, K()); } }; template From cb21cbdf2d32ae9c9f3399c74abc2f8b7be2f7cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 21 Mar 2024 10:07:36 +0100 Subject: [PATCH 050/100] update changes --- Installation/CHANGES.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 01179cc55c75..7536918af7d5 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -16,6 +16,17 @@ Release date: October 2023 - **Breaking change**: The usage of `boost::variant` has been replaced by `std::variant`. Packages affected are 2D Arrangements, and the Kernel intersection. - **Breaking change**: The file CMake file `UseCGAL.cmake` has been removed from CGAL. Usages of the CMake variables `${CGAL_USE_FILE}` and `${CGAL_LIBRARIES}` must be replaced by a link to the imported target `CGAL::CGAL`, for example: `target_link_library(the_target PRIVATE CGAL::CGAL)`. +### [3D Fast Intersection and Distance Computation (AABB Tree)](https://doc.cgal.org/6.0/Manual/packages.html#PkgAABBTree) + +- **Breaking change**: The concept `AABBTraits` now should refine the `SearchTraits` concept. +- The AABB tree is not working with 2D and 3D primitives: + - Replacement of `AABBGeomTraits` concept by `AABBGeomTraits_3` and `AABBRayIntersectionGeomTraits` by `AABBRayIntersectionGeomTraits_3`. + - Addition of `AABBGeomTraits_2` and `AABBRayIntersectionGeomTraits_2` concepts + - `AABB_traits` is deprecated and replaced by `AABB_traits_3` + - `AABB_segment_primitive` is deprecated and replaced by `AABB_segment_primitive_3` + - `AABB_triangle_primitive` is deprecated and replaced by `AABB_triangle_primitive_3` + - Addition of 2D primitive classes: `AABB_segment_primitive_2`, `AABB_triangle_primitive_2`, ... + #### 2D Arrangements From 57062536c3a8c6f322f68ca2ec59ec90d22e9872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 21 Mar 2024 10:32:06 +0100 Subject: [PATCH 051/100] another forgotten revert --- .../include/CGAL/Cartesian/function_objects.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index e84312b95798..737a52dfc143 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3278,8 +3278,6 @@ 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; @@ -3291,14 +3289,6 @@ namespace CartesianKernelFunctors { line_project_pointC2(l.a(), l.b(), l.c(), p.x(), p.y(), x, y); return construct_point_2(x, y); } - - Point_2 - operator()( const Segment_2& s, const Point_2& p ) const - { return CommonKernelFunctors::Construct_projected_point_2()(s, p, K()); } - - Point_2 - operator()( const Triangle_2& t, const Point_2& p ) const - { return CommonKernelFunctors::Construct_projected_point_2()(t, p, K()); } }; From 8059230084e79c860103ad877deb14f6231a718a Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 21 Mar 2024 12:02:59 +0100 Subject: [PATCH 052/100] clean up --- .../examples/AABB_tree/AABB_indexed_triangle_2_example.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp index 14480efece25..2c428e07730e 100644 --- a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp @@ -6,12 +6,10 @@ #include #include #include -#include typedef CGAL::Simple_cartesian K; typedef K::Point_3 Point_3; -typedef K::Point_2 Point; -typedef K::Vector_2 Vector; +typedef K::Point_2 Point_2; typedef K::Ray_2 Ray; template From 86fe47c7f7f5c35043e282b8043b91767f2ec487 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 21 Mar 2024 12:03:57 +0100 Subject: [PATCH 053/100] re-add Construct_projected_point_2 for 2d closest point query --- .../include/CGAL/Cartesian/function_objects.h | 10 + .../include/CGAL/Kernel/function_objects.h | 198 ++++++++++++++++++ 2 files changed, 208 insertions(+) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index 737a52dfc143..8b0153f03e11 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3278,6 +3278,8 @@ 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; @@ -3289,6 +3291,14 @@ namespace CartesianKernelFunctors { line_project_pointC2(l.a(), l.b(), l.c(), p.x(), p.y(), x, y); return construct_point_2(x, y); } + + Point_2 + operator()(const Segment_2& s, const Point_2& p) const + { return CommonKernelFunctors::Construct_projected_point_2()(s, p, K()); } + + Point_2 + operator()(const Triangle_2& t, const Point_2& p) const + { return CommonKernelFunctors::Construct_projected_point_2()(t, p, K()); } }; diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index 084a6578913c..7efc0509023e 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -2872,6 +2872,204 @@ namespace CommonKernelFunctors { { return v.rep().cartesian_end(); } + }; template + class Construct_projected_point_2 + { + bool + is_inside_triangle_2_aux( + const typename K::Point_2& p1, + const typename K::Point_2& p2, + const typename K::Point_2& q, + typename K::Point_2& result, + bool& outside, + const K& k) + { + typedef typename K::Vector_2 Vector_2; + typedef typename K::FT FT; + + typename K::Construct_vector_2 vector = + k.construct_vector_2_object(); + typename K::Construct_projected_point_2 projection = + k.construct_projected_point_2_object(); + typename K::Construct_line_2 line = + k.construct_line_2_object(); + typename K::Compute_scalar_product_2 scalar_product = + k.compute_scalar_product_2_object(); + typename K::Construct_direction_2 direction = + k.construct_direction_2_object(); + typename K::Construct_perpendicular_direction_2 perpendicular = + k.construct_perpendicular_direction_2_object(); + + // Check whether the point is cw or ccw with the triangle side (p1,p2) + Vector_2 orth = vector(p1, p2); + + if (scalar_product(vector(p1, q), vector(perpendicular(direction(orth), CGAL::COUNTERCLOCKWISE))) < FT(0)) + { + if (scalar_product(vector(p1, q), vector(p1, p2)) >= FT(0) + && scalar_product(vector(p2, q), vector(p2, p1)) >= FT(0)) + { + result = projection(line(p1, p2), q); + return true; + } + outside = true; + } + + return false; + } + + /** + * Returns the nearest point of p1,p2,p3 from origin + * @param origin the origin point + * @param p1 the first point + * @param p2 the second point + * @param p3 the third point + * @param k the kernel + * @return the nearest point from origin + */ + typename K::Point_2 + nearest_point_2(const typename K::Point_2& origin, + const typename K::Point_2& p1, + const typename K::Point_2& p2, + const typename K::Point_2& p3, + const K& k) + { + typedef typename K::FT FT; + + typename K::Compute_squared_distance_2 sq_distance = + k.compute_squared_distance_2_object(); + + const FT dist_origin_p1 = sq_distance(origin, p1); + const FT dist_origin_p2 = sq_distance(origin, p2); + const FT dist_origin_p3 = sq_distance(origin, p3); + + if (dist_origin_p2 >= dist_origin_p1 + && dist_origin_p3 >= dist_origin_p1) + { + return p1; + } + if (dist_origin_p3 >= dist_origin_p2) + { + return p2; + } + + return p3; + } + + /** + * @brief returns true if p is inside triangle t. If p is not inside t, + * result is the nearest point of t from p. + * @param p the reference point + * @param t the triangle + * @param result if p is not inside t, the nearest point of t from p + * @param k the kernel + * @return true if p is inside t + */ + bool + is_inside_triangle_2(const typename K::Point_2& p, + const typename K::Triangle_2& t, + typename K::Point_2& result, + const K& k) + { + typedef typename K::Point_2 Point_2; + + typename K::Construct_vertex_2 vertex_on = + k.construct_vertex_2_object(); + + const Point_2& t0 = vertex_on(t, 0); + const Point_2& t1 = vertex_on(t, 1); + const Point_2& t2 = vertex_on(t, 2); + + bool outside = false; + if (is_inside_triangle_2_aux(t0, t1, p, result, outside, k) + || is_inside_triangle_2_aux(t1, t2, p, result, outside, k) + || is_inside_triangle_2_aux(t2, t0, p, result, outside, k)) + { + return false; + } + + if (outside) + { + result = nearest_point_2(p, t0, t1, t2, k); + return false; + } + else + { + return true; + } + } + + public: + typename K::Point_2 + operator()(const typename K::Triangle_2& triangle, + const typename K::Point_2& origin, + const K& k) + { + typedef typename K::Point_2 Point_2; + typename K::Construct_vertex_2 vertex_on; + typename K::Construct_segment_2 segment; + + // Check if triangle is degenerated to call segment operator. + const Point_2& t0 = vertex_on(triangle, 0); + const Point_2& t1 = vertex_on(triangle, 1); + const Point_2& t2 = vertex_on(triangle, 2); + + if (t0 == t1) + return (*this)(segment(t1, t2), origin, k); + if (t1 == t2) + return (*this)(segment(t2, t0), origin, k); + if (t2 == t0) + return (*this)(segment(t0, t1), origin, k); + + Point_2 moved_point; + bool inside = is_inside_triangle_2(origin, triangle, moved_point, k); + + // If proj is inside triangle, return it + if (inside) + { + return origin; + } + + // Else return the constructed point + return moved_point; + } + + typename K::Point_2 + operator()(const typename K::Segment_2& s, + const typename K::Point_2& query, + const K& k) { + + typename K::Construct_vector_2 vector = + k.construct_vector_2_object(); + + typename K::Compute_scalar_product_2 scalar_product = + k.compute_scalar_product_2_object(); + + typename K::Construct_scaled_vector_2 scaled_vector = + k.construct_scaled_vector_2_object(); + + const typename K::Point_2& a = s.source(); + const typename K::Point_2& b = s.target(); + const typename K::Vector_2 d = vector(a, b); + + typename K::FT sqlen = scalar_product(d, d); + + // Degenerate segment + if (is_zero(sqlen)) + return a; + + const typename K::Vector_2 p = vector(a, query); + + typename K::FT proj = (scalar_product(p, d)) / sqlen; + + if (!is_positive(proj)) + return a; + + if (proj >= 1.0) + return b; + + typename K::Construct_point_2 construct_point_2; + return construct_point_2(a + scaled_vector(d, proj)); + } }; template From 00a77dc2a7702c963baa7969e37de6004d819413 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 21 Mar 2024 14:29:38 +0100 Subject: [PATCH 054/100] cleaning types --- .../AABBRayIntersectionGeomTraits_2.h | 8 +++--- AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h | 2 +- AABB_tree/include/CGAL/AABB_traits_2.h | 25 +++++-------------- AABB_tree/include/CGAL/AABB_traits_3.h | 23 ++++------------- .../internal/AABB_ray_intersection.h | 2 +- .../internal/AABB_traversal_traits.h | 8 +++--- AABB_tree/test/AABB_tree/AABB_test_util.h | 2 +- 7 files changed, 22 insertions(+), 48 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h index 0800d966b2bb..eeb824d0f96a 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h @@ -22,12 +22,12 @@ define the Intersection_distance functor. class AABBRayIntersectionGeomTraits_2 { public: /*! - Type of a 3D ray. + Type of a 2D ray. */ typedef unspecified_type Ray_2; /*! - Type of a 3D vector. + Type of a 2D vector. */ typedef unspecified_type Vector_2; @@ -42,12 +42,12 @@ class AABBRayIntersectionGeomTraits_2 { Construct_source_2 construct_source_2_object(); /*! - A model of `CartesianConstIterator3`. + A model of `CartesianConstIterator2`. */ typedef unspecified_type Cartesian_const_iterator_2; /*! - A model of `ConstructCartesianConstIterator3`. + A model of `ConstructCartesianConstIterator2`. */ typedef unspecified_type Construct_cartesian_const_iterator_2; diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h index 685ce425d668..8fd9ef2458ec 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h @@ -28,7 +28,7 @@ Value type of the `Squared_distance` functor. typedef unspecified_type FT; /*! -Type of a 3D point. +Type of a point. */ typedef unspecified_type Point; diff --git a/AABB_tree/include/CGAL/AABB_traits_2.h b/AABB_tree/include/CGAL/AABB_traits_2.h index 6300d4188bf3..8ccc73fbcf37 100644 --- a/AABB_tree/include/CGAL/AABB_traits_2.h +++ b/AABB_tree/include/CGAL/AABB_traits_2.h @@ -46,11 +46,8 @@ struct AABB_traits_intersection_base_2{}; template struct AABB_traits_intersection_base_2{ - typedef typename GeomTraits::Ray_2 Ray_2; typedef typename GeomTraits::Ray_2 Ray; - typedef typename GeomTraits::Point_2 Point_2; typedef typename GeomTraits::Point_2 Point; - typedef typename GeomTraits::Vector_2 Vector_2; typedef typename GeomTraits::Vector_2 Vector; typedef typename GeomTraits::FT FT; typedef typename GeomTraits::Cartesian_const_iterator_2 Cartesian_const_iterator_2; @@ -65,7 +62,7 @@ struct AABB_traits_intersection_base_2{ typedef typename CGAL::Bbox_2 Bounding_box; struct Intersection_distance { - std::optional operator()(const Ray_2& ray, const Bounding_box& bbox) const { + std::optional operator()(const Ray& ray, const Bounding_box& bbox) const { FT t_near = -DBL_MAX; // std::numeric_limits::lowest(); C++1903 FT t_far = DBL_MAX; @@ -73,8 +70,8 @@ struct AABB_traits_intersection_base_2{ = GeomTraits().construct_cartesian_const_iterator_2_object(); const Construct_source_2 construct_source_2 = GeomTraits().construct_source_2_object(); const Construct_vector_2 construct_vector_2 = GeomTraits().construct_vector_2_object(); - const Point_2 source = construct_source_2(ray); - const Vector_2 direction = construct_vector_2(ray); + const Point source = construct_source_2(ray); + const Vector direction = construct_vector_2(ray); Cartesian_const_iterator_2 source_iter = construct_cartesian_const_iterator_2(source); Cartesian_const_iterator_2 direction_iter = construct_cartesian_const_iterator_2(direction); @@ -90,13 +87,6 @@ struct AABB_traits_intersection_base_2{ t_near = (std::max)(t_near, (std::min)(t1, t2)); t_far = (std::min)(t_far, (std::max)(t1, t2)); - // if(t1 > t2) - // std::swap(t1, t2); - // if(t1 > t_near) - // t_near = t1; - // if(t2 < t_far) - // t_far = t2; - if(t_near > t_far || t_far < FT(0.)) return std::nullopt; } @@ -190,13 +180,10 @@ class AABB_traits_2 /// \name Types /// @{ - /// Point query type. - typedef typename GeomTraits::Point_2 Point_2; - /// /// point type /// - typedef Point_2 Point; + typedef typename GeomTraits::Point_2 Point; /// additional types for the search tree, required by the RangeSearchTraits concept /// \bug This is not documented for now in the AABBTraits concept. @@ -360,7 +347,7 @@ class AABB_traits_2 // This should go down to the GeomTraits, i.e. the kernel class Closest_point { - typedef typename AT::Point_2 Point; + typedef typename AT::Point Point; typedef typename AT::Primitive Primitive; const AABB_traits_2& m_traits; public: @@ -384,7 +371,7 @@ class AABB_traits_2 // do_intersect to something like does_contain (this is what we compute, // this is not the same do_intersect as the spherical kernel) class Compare_distance { - typedef typename AT::Point_2 Point; + typedef typename AT::Point Point; typedef typename AT::FT FT; typedef typename AT::Primitive Primitive; public: diff --git a/AABB_tree/include/CGAL/AABB_traits_3.h b/AABB_tree/include/CGAL/AABB_traits_3.h index 9e9499b5971d..97d1a156def7 100644 --- a/AABB_tree/include/CGAL/AABB_traits_3.h +++ b/AABB_tree/include/CGAL/AABB_traits_3.h @@ -69,11 +69,8 @@ struct AABB_traits_intersection_base{}; template struct AABB_traits_intersection_base{ - typedef typename GeomTraits::Ray_3 Ray_3; typedef typename GeomTraits::Ray_3 Ray; - typedef typename GeomTraits::Point_3 Point_3; typedef typename GeomTraits::Point_3 Point; - typedef typename GeomTraits::Vector_3 Vector_3; typedef typename GeomTraits::Vector_3 Vector; typedef typename GeomTraits::FT FT; typedef typename GeomTraits::Cartesian_const_iterator_3 Cartesian_const_iterator_3; @@ -88,7 +85,7 @@ struct AABB_traits_intersection_base{ typedef typename CGAL::Bbox_3 Bounding_box; struct Intersection_distance { - std::optional operator()(const Ray_3& ray, const Bounding_box& bbox) const { + std::optional operator()(const Ray& ray, const Bounding_box& bbox) const { FT t_near = -DBL_MAX; // std::numeric_limits::lowest(); C++1903 FT t_far = DBL_MAX; @@ -113,13 +110,6 @@ struct AABB_traits_intersection_base{ t_near = (std::max)(t_near, (std::min)(t1, t2)); t_far = (std::min)(t_far, (std::max)(t1, t2)); - // if(t1 > t2) - // std::swap(t1, t2); - // if(t1 > t_near) - // t_near = t1; - // if(t2 < t_far) - // t_far = t2; - if(t_near > t_far || t_far < FT(0.)) return std::nullopt; } @@ -213,11 +203,8 @@ class AABB_traits_3 /// \name Types /// @{ - /// Point query type. - typedef typename GeomTraits::Point_3 Point_3; - - /// Poin type - typedef Point_3 Point; // because the AABB_tree is dimension agnostic + /// Point type + typedef typename GeomTraits::Point_3 Point; // because the AABB_tree is dimension agnostic /// additional types for the search tree, required by the RangeSearchTraits concept /// \bug This is not documented for now in the AABBTraits concept. @@ -384,7 +371,7 @@ class AABB_traits_3 // This should go down to the GeomTraits, i.e. the kernel class Closest_point { - typedef typename AT::Point_3 Point; + typedef typename AT::Point Point; typedef typename AT::Primitive Primitive; const AABB_traits_3& m_traits; public: @@ -408,7 +395,7 @@ class AABB_traits_3 // do_intersect to something like does_contain (this is what we compute, // this is not the same do_intersect as the spherical kernel) class Compare_distance { - typedef typename AT::Point_3 Point; + typedef typename AT::Point Point; typedef typename AT::FT FT; typedef typename AT::Primitive Primitive; public: diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h index b670266e8a43..9103b05e6b70 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h @@ -204,7 +204,7 @@ std::optional< typename AABB_tree::template Intersection_and_primiti AABB_tree::first_intersection(const Ray& query, const SkipFunctor& skip) const { static_assert(std::is_same::value, - "Ray and Ray_3 must be the same type"); + "Ray and AABBTraits::Ray must be the same type"); switch(size()) // copy-paste from AABB_tree::traversal { diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traversal_traits.h b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traversal_traits.h index cb421f42ba43..11fe903df932 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traversal_traits.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traversal_traits.h @@ -59,7 +59,7 @@ template class First_intersection_traits { typedef typename AABBTraits::FT FT; - typedef typename AABBTraits::Point_3 Point; + typedef typename AABBTraits::Point Point; typedef typename AABBTraits::Primitive Primitive; typedef typename AABBTraits::Bounding_box Bounding_box; typedef typename AABBTraits::Primitive::Id Primitive_id; @@ -108,7 +108,7 @@ template class Listing_intersection_traits { typedef typename AABBTraits::FT FT; - typedef typename AABBTraits::Point_3 Point; + typedef typename AABBTraits::Point Point; typedef typename AABBTraits::Primitive Primitive; typedef typename AABBTraits::Bounding_box Bounding_box; typedef typename AABBTraits::Primitive::Id Primitive_id; @@ -191,7 +191,7 @@ template class First_primitive_traits { typedef typename AABBTraits::FT FT; - typedef typename AABBTraits::Point_3 Point; + typedef typename AABBTraits::Point Point; typedef typename AABBTraits::Primitive Primitive; typedef typename AABBTraits::Bounding_box Bounding_box; typedef typename AABBTraits::Primitive::Id Primitive_id; @@ -237,7 +237,7 @@ template class Do_intersect_traits { typedef typename AABBTraits::FT FT; - typedef typename AABBTraits::Point_3 Point; + typedef typename AABBTraits::Point Point; typedef typename AABBTraits::Primitive Primitive; typedef typename AABBTraits::Bounding_box Bounding_box; typedef typename AABBTraits::Primitive::Id Primitive_id; diff --git a/AABB_tree/test/AABB_tree/AABB_test_util.h b/AABB_tree/test/AABB_tree/AABB_test_util.h index fae5abfe17c6..9bce2bd14563 100644 --- a/AABB_tree/test/AABB_tree/AABB_test_util.h +++ b/AABB_tree/test/AABB_tree/AABB_test_util.h @@ -322,7 +322,7 @@ class Naive_implementations typedef typename Traits::Object_and_primitive_id Object_and_primitive_id; typedef typename Pr::Id Primitive_id; typedef typename Traits::FT FT; - typedef typename Traits::Point_3 Point; + typedef typename Traits::Point Point; typedef typename Traits::Point_and_primitive_id Point_and_primitive_id; typedef std::optional Intersection_result; From bc24d14bb2c296dfaeed208025d8b9fe3ebd1a5e Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 21 Mar 2024 14:45:07 +0100 Subject: [PATCH 055/100] splitting example into declaration and test function --- .../AABB_polyline_segment_2_example.cpp | 54 ++++++++----------- 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp index ec65b84f8107..52ac14b11532 100644 --- a/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp @@ -27,6 +27,26 @@ typedef CGAL::AABB_traits_2 Traits_poly; typedef CGAL::AABB_tree Tree_poly; typedef Tree_poly::Point_and_primitive_id Point_and_primitive_id_poly; +template +void test(AABBTree& tree) { + tree.build(); + + tree.accelerate_distance_queries(); + + // counts #intersections with a segment query + Segment segment_query(Point(1.0, 0.0), Point(0.0, 7.0)); + + std::cout << tree.number_of_intersected_primitives(segment_query) + << " intersections(s) with segment" << std::endl; + + // computes the closest point from a point query + Point point_query(1.5, 3.0); + Point closest = tree.closest_point(point_query); + std::cerr << "closest point is: " << closest << std::endl; + + PPId id = tree.closest_point_and_primitive(point_query); +} + int main() { @@ -40,41 +60,11 @@ int main() Polygon poly(polyline.begin(), polyline.end()); - // constructs the AABB tree and the internal search tree for - // efficient distance computations. + test(Tree_poly(poly.begin(), poly.end(), poly)); // For a point range, the second iterator must be of the second-last point in the range. // If it points to the end of the range, to polyline is considered to be closed. - Tree_pr tree_pr(polyline.begin(), std::prev(polyline.end()), polyline); - Tree_poly tree_poly(poly.begin(), poly.end(), poly); - - tree_pr.build(); - tree_poly.build(); - - tree_pr.accelerate_distance_queries(); - tree_poly.accelerate_distance_queries(); - - // counts #intersections with a segment query - Segment segment_query(Point(1.0, 0.0), Point(0.0, 7.0)); - - std::cout << tree_pr.number_of_intersected_primitives(segment_query) - << " intersections(s) with segment" << std::endl; - - std::cout << tree_poly.number_of_intersected_primitives(segment_query) - << " intersections(s) with segment" << std::endl; - - // computes the closest point from a point query - Point point_query(1.5, 3.0); - Point closest = tree_pr.closest_point(point_query); - std::cerr << "closest point is: " << closest << std::endl; - - closest = tree_poly.closest_point(point_query); - std::cerr << "closest point is: " << closest << std::endl; - - Point_and_primitive_id_poly id_poly = tree_poly.closest_point_and_primitive(point_query); - // id_poly.second is of type Iterator_poly and points to the first point of the segment in the polygon point range. + test(Tree_pr(polyline.begin(), std::prev(polyline.end()), polyline)); - Point_and_primitive_id_pr id_pr = tree_pr.closest_point_and_primitive(point_query); - // id_pr.second is of type std::vector::iterator and points to the first point of the segment in the point range. return EXIT_SUCCESS; } From c193cea746a1944b3110ef6ba8663c90094617de Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 21 Mar 2024 14:54:32 +0100 Subject: [PATCH 056/100] moving PointMap to end of template parameters --- .../AABB_indexed_triangle_2_example.cpp | 20 ++++++++++--------- .../CGAL/AABB_indexed_triangle_primitive_2.h | 8 +++++--- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp index 2c428e07730e..4d60dc884f44 100644 --- a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp @@ -32,13 +32,12 @@ struct Projection_xy_point_map { typedef std::vector >::iterator IndexIterator; typedef std::vector PointRange; -typedef CGAL::AABB_indexed_triangle_primitive_2> Primitive; +typedef CGAL::AABB_indexed_triangle_primitive_2> Primitive; typedef CGAL::AABB_traits_2 AABB_triangle_traits; typedef CGAL::AABB_tree Tree; typedef Tree::Point_and_primitive_id Point_and_primitive_id; typedef std::optional::Type> Ray_intersection; - int main() { Point_3 a(0.0, 0.0, 0.0); @@ -61,20 +60,20 @@ int main() // point sampling Point_and_primitive_id id; - id = tree.closest_point_and_primitive(Point(0.5, 0.4)); + id = tree.closest_point_and_primitive(Point_2(0.5, 0.4)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; - id = tree.closest_point_and_primitive(Point(0.5, 0.6)); + id = tree.closest_point_and_primitive(Point_2(0.5, 0.6)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; - id = tree.closest_point_and_primitive(Point(1.5, 0.5)); + id = tree.closest_point_and_primitive(Point_2(1.5, 0.5)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; - id = tree.closest_point_and_primitive(Point(1.5, 0.6)); + id = tree.closest_point_and_primitive(Point_2(1.5, 0.6)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; - id = tree.closest_point_and_primitive(Point(1.0, 0.0)); + id = tree.closest_point_and_primitive(Point_2(1.0, 0.0)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; - id = tree.closest_point_and_primitive(Point(3.0, 0.5)); + id = tree.closest_point_and_primitive(Point_2(3.0, 0.5)); std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; - Ray ray(Point(5.5, 0.5), Point(1.5, 0.5)); + Ray ray(Point_2(5.5, 0.5), Point_2(1.5, 0.5)); Ray_intersection intersection = tree.first_intersection(ray); if (!intersection) { @@ -85,5 +84,8 @@ int main() std::cout << std::distance(triangles.begin(), intersection->second) << ". triangle" << std::endl; } + std::list intersections; + tree.all_intersections(ray, std::back_inserter(intersections)); + return EXIT_SUCCESS; } 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 8305941b931e..d53a0c4df721 100644 --- a/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h @@ -83,11 +83,13 @@ namespace internal { * It also provides the functor `Construct_triangle_2` that has an operator taking 3 `Point_2` as * parameters and returns a `Triangle_2` * \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` with its value type being a `Point_2`. + * \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). + * \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` @@ -98,8 +100,8 @@ namespace internal { template < class GeomTraits, class IndexIterator, class PointRange, - class PointMap=Identity_property_map, - class CacheDatum=Tag_false> + class CacheDatum = Tag_false, + class PointMap = Identity_property_map> class AABB_indexed_triangle_primitive_2 #ifndef DOXYGEN_RUNNING : public AABB_primitive< IndexIterator, From 0bc40dcdc63de75697ac81a7f6ce8a653740fd8f Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 21 Mar 2024 15:14:57 +0100 Subject: [PATCH 057/100] moving AABB_traits_base and Remove_optional into separate files --- AABB_tree/include/CGAL/AABB_traits_2.h | 5 ++- AABB_tree/include/CGAL/AABB_traits_3.h | 28 ++---------- .../AABB_tree/internal/AABB_traits_base.h | 45 +++++++++++++++++++ .../CGAL/AABB_tree/internal/Remove_optional.h | 33 ++++++++++++++ 4 files changed, 84 insertions(+), 27 deletions(-) create mode 100644 AABB_tree/include/CGAL/AABB_tree/internal/AABB_traits_base.h create mode 100644 AABB_tree/include/CGAL/AABB_tree/internal/Remove_optional.h diff --git a/AABB_tree/include/CGAL/AABB_traits_2.h b/AABB_tree/include/CGAL/AABB_traits_2.h index 8ccc73fbcf37..a1136e492f69 100644 --- a/AABB_tree/include/CGAL/AABB_traits_2.h +++ b/AABB_tree/include/CGAL/AABB_traits_2.h @@ -21,11 +21,12 @@ #include #include #include +#include #include #include #include +#include #include -#include // for Remove_optional #include #include @@ -172,7 +173,7 @@ class AABB_traits_2 std::declval())) Intersection_type; typedef std::pair< - typename internal::AABB_tree::Remove_optional::type, + typename internal::Remove_optional::type, typename Primitive::Id > Type; }; diff --git a/AABB_tree/include/CGAL/AABB_traits_3.h b/AABB_tree/include/CGAL/AABB_traits_3.h index 97d1a156def7..070e95eca383 100644 --- a/AABB_tree/include/CGAL/AABB_traits_3.h +++ b/AABB_tree/include/CGAL/AABB_traits_3.h @@ -21,9 +21,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -35,30 +37,6 @@ namespace CGAL { namespace internal{ namespace AABB_tree { -template -struct Remove_optional { typedef T type; }; - -template -struct Remove_optional< ::std::optional > { typedef T type; }; - -//helper controlling whether extra data should be stored in the AABB_tree traits class -template ::value> -struct AABB_traits_base; - -template -struct AABB_traits_base{}; - -template -struct AABB_traits_base{ - typename Primitive::Shared_data m_primitive_data; - - template - void set_shared_data(T&& ... t){ - m_primitive_data=Primitive::construct_shared_data(std::forward(t)...); - } - const typename Primitive::Shared_data& shared_data() const {return m_primitive_data;} -}; - // AABB_traits_intersection_base brings in the Intersection_distance predicate, // if GeomTraits is a model RayIntersectionGeomTraits. template ::value> @@ -195,7 +173,7 @@ class AABB_traits_3 std::declval())) Intersection_type; typedef std::pair< - typename internal::AABB_tree::Remove_optional::type, + typename internal::Remove_optional::type, typename Primitive::Id > Type; }; diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traits_base.h b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traits_base.h new file mode 100644 index 000000000000..a7d0e3ebcacb --- /dev/null +++ b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traits_base.h @@ -0,0 +1,45 @@ +// Copyright (c) 2024 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) : Stéphane Tayeb, Pierre Alliez, Camille Wormser +// + +#include + +#ifndef CGAL_AABB_TRAITS_BASE_H +#define CGAL_AABB_TRAITS_BASE_H + +namespace CGAL { +namespace internal { +namespace AABB_tree { + +//helper controlling whether extra data should be stored in the AABB_tree traits class +template ::value> +struct AABB_traits_base; + +template +struct AABB_traits_base {}; + +template +struct AABB_traits_base { + typename Primitive::Shared_data m_primitive_data; + + template + void set_shared_data(T&& ... t) { + m_primitive_data = Primitive::construct_shared_data(std::forward(t)...); + } + const typename Primitive::Shared_data& shared_data() const { return m_primitive_data; } +}; + +} +} +} + +#endif \ No newline at end of file diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/Remove_optional.h b/AABB_tree/include/CGAL/AABB_tree/internal/Remove_optional.h new file mode 100644 index 000000000000..18657f179cf0 --- /dev/null +++ b/AABB_tree/include/CGAL/AABB_tree/internal/Remove_optional.h @@ -0,0 +1,33 @@ +// Copyright (c) 2024 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) : Stéphane Tayeb, Pierre Alliez, Camille Wormser +// + +#ifndef CGAL_REMOVE_OPTIONAL_H_ +#define CGAL_REMOVE_OPTIONAL_H_ + +#include +#include + + +namespace CGAL { +namespace internal { + +template +struct Remove_optional { typedef T type; }; + +template +struct Remove_optional< ::std::optional > { typedef T type; }; + +} // end namespace internal +} // end namespace CGAL + +#endif \ No newline at end of file From 98e5e951bb400bbdea367795752345f16794d596 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 21 Mar 2024 15:20:46 +0100 Subject: [PATCH 058/100] license header fix --- .../include/CGAL/AABB_tree/internal/AABB_traits_base.h | 6 ++++-- AABB_tree/include/CGAL/AABB_tree/internal/Remove_optional.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traits_base.h b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traits_base.h index a7d0e3ebcacb..4011d2c57d33 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traits_base.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traits_base.h @@ -11,11 +11,13 @@ // Author(s) : Stéphane Tayeb, Pierre Alliez, Camille Wormser // -#include - #ifndef CGAL_AABB_TRAITS_BASE_H #define CGAL_AABB_TRAITS_BASE_H +#include + +#include + namespace CGAL { namespace internal { namespace AABB_tree { diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/Remove_optional.h b/AABB_tree/include/CGAL/AABB_tree/internal/Remove_optional.h index 18657f179cf0..f831d84fa9f1 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/Remove_optional.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/Remove_optional.h @@ -14,9 +14,9 @@ #ifndef CGAL_REMOVE_OPTIONAL_H_ #define CGAL_REMOVE_OPTIONAL_H_ -#include #include +#include namespace CGAL { namespace internal { From 3d87460083ce133f6a3919ce664c7b94da73eea5 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 21 Mar 2024 16:04:06 +0100 Subject: [PATCH 059/100] re-adding Point_2/3 to AABB_traits_2/3 for compatibility renaming AABB_traits_intersection_base to AABB_traits_intersection_base_3 --- AABB_tree/include/CGAL/AABB_traits_2.h | 1 + AABB_tree/include/CGAL/AABB_traits_3.h | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_traits_2.h b/AABB_tree/include/CGAL/AABB_traits_2.h index a1136e492f69..f91c7fdbea4e 100644 --- a/AABB_tree/include/CGAL/AABB_traits_2.h +++ b/AABB_tree/include/CGAL/AABB_traits_2.h @@ -185,6 +185,7 @@ class AABB_traits_2 /// point type /// typedef typename GeomTraits::Point_2 Point; + typedef typename GeomTraits::Point_2 Point_2; /// additional types for the search tree, required by the RangeSearchTraits concept /// \bug This is not documented for now in the AABBTraits concept. diff --git a/AABB_tree/include/CGAL/AABB_traits_3.h b/AABB_tree/include/CGAL/AABB_traits_3.h index 070e95eca383..f84a81c2c85d 100644 --- a/AABB_tree/include/CGAL/AABB_traits_3.h +++ b/AABB_tree/include/CGAL/AABB_traits_3.h @@ -37,16 +37,16 @@ namespace CGAL { namespace internal{ namespace AABB_tree { -// AABB_traits_intersection_base brings in the Intersection_distance predicate, +// AABB_traits_intersection_base_3 brings in the Intersection_distance predicate, // if GeomTraits is a model RayIntersectionGeomTraits. template ::value> -struct AABB_traits_intersection_base; +struct AABB_traits_intersection_base_3; template -struct AABB_traits_intersection_base{}; +struct AABB_traits_intersection_base_3{}; template -struct AABB_traits_intersection_base{ +struct AABB_traits_intersection_base_3{ typedef typename GeomTraits::Ray_3 Ray; typedef typename GeomTraits::Point_3 Point; typedef typename GeomTraits::Vector_3 Vector; @@ -145,7 +145,7 @@ template, - public internal::AABB_tree::AABB_traits_intersection_base, + public internal::AABB_tree::AABB_traits_intersection_base_3, public Search_traits_3 #endif { @@ -183,6 +183,7 @@ class AABB_traits_3 /// Point type typedef typename GeomTraits::Point_3 Point; // because the AABB_tree is dimension agnostic + typedef typename GeomTraits::Point_3 Point_3; /// additional types for the search tree, required by the RangeSearchTraits concept /// \bug This is not documented for now in the AABBTraits concept. From 12fab6bb09c7c3ebfd12b90858743e888278815b Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Fri, 22 Mar 2024 16:31:42 +0100 Subject: [PATCH 060/100] using functors from concept to access ray instead of using methods --- .../Concepts/AABBRayIntersectionTraits.h | 40 +++++++++++++++++- AABB_tree/include/CGAL/AABB_traits_2.h | 37 ++++++++++++----- AABB_tree/include/CGAL/AABB_traits_3.h | 41 +++++++++++++------ .../internal/AABB_ray_intersection.h | 10 ++--- 4 files changed, 98 insertions(+), 30 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h index e234eba160c2..e2385baac645 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h @@ -17,12 +17,50 @@ distance of an intersection along a ray. */ class AABBRayIntersectionTraits { public: - /*! Type of a ray. */ typedef unspecified_type Ray; + /*! + Type of a vector. + */ + typedef unspecified_type Vector; + + /*! + A functor object to construct the source point of a ray. Provides the operator: + `Point operator()(const Ray&);` + */ + typedef unspecified_type Construct_source; + + /*! + */ + Construct_source construct_source_object(); + + /*! + A model of `CartesianConstIterator2` or `CartesianConstIterator3`, must compatible with `Vector`. + */ + typedef unspecified_type Cartesian_const_iterator; + + /*! + A model of `ConstructCartesianConstIterator2` or `ConstructCartesianConstIterator3`, must compatible with `Vector`. + */ + typedef unspecified_type Construct_cartesian_const_iterator; + + /*! + */ + Construct_source construct_cartesian_const_iterator_object(); + + /*! + A functor object to construct a vector giving the direction of a ray. Provides the operator: + `Vector operator()(const Ray&);` + */ + typedef unspecified_type Construct_vector; + + /*! + */ + Construct_source construct_vector_object(); + /*! A functor object to compute the distance between the source of a ray and its diff --git a/AABB_tree/include/CGAL/AABB_traits_2.h b/AABB_tree/include/CGAL/AABB_traits_2.h index f91c7fdbea4e..480c00aa4f05 100644 --- a/AABB_tree/include/CGAL/AABB_traits_2.h +++ b/AABB_tree/include/CGAL/AABB_traits_2.h @@ -47,14 +47,17 @@ struct AABB_traits_intersection_base_2{}; template struct AABB_traits_intersection_base_2{ - typedef typename GeomTraits::Ray_2 Ray; +private: + typedef typename GeomTraits::FT FT; typedef typename GeomTraits::Point_2 Point; + +public: + typedef typename GeomTraits::Ray_2 Ray; typedef typename GeomTraits::Vector_2 Vector; - typedef typename GeomTraits::FT FT; - typedef typename GeomTraits::Cartesian_const_iterator_2 Cartesian_const_iterator_2; - typedef typename GeomTraits::Construct_cartesian_const_iterator_2 Construct_cartesian_const_iterator_2; - typedef typename GeomTraits::Construct_source_2 Construct_source_2; - typedef typename GeomTraits::Construct_vector_2 Construct_vector_2; + typedef typename GeomTraits::Cartesian_const_iterator_2 Cartesian_const_iterator; + typedef typename GeomTraits::Construct_cartesian_const_iterator_2 Construct_cartesian_const_iterator; + typedef typename GeomTraits::Construct_source_2 Construct_source; + typedef typename GeomTraits::Construct_vector_2 Construct_vector; // Defining Bounding_box and other types from the full AABB_traits_2 // here is might seem strange, but otherwise we would need to use @@ -62,19 +65,31 @@ struct AABB_traits_intersection_base_2{ // code more. typedef typename CGAL::Bbox_2 Bounding_box; + static Construct_cartesian_const_iterator construct_cartesian_const_iterator_object() { + return GeomTraits().construct_cartesian_const_iterator_2_object(); + } + + static Construct_source construct_source_object() { + return GeomTraits().construct_source_2_object(); + } + + static Construct_vector construct_vector_object() { + return GeomTraits().construct_vector_2_object(); + } + struct Intersection_distance { std::optional operator()(const Ray& ray, const Bounding_box& bbox) const { FT t_near = -DBL_MAX; // std::numeric_limits::lowest(); C++1903 FT t_far = DBL_MAX; - const Construct_cartesian_const_iterator_2 construct_cartesian_const_iterator_2 + const Construct_cartesian_const_iterator construct_cartesian_const_iterator_2 = GeomTraits().construct_cartesian_const_iterator_2_object(); - const Construct_source_2 construct_source_2 = GeomTraits().construct_source_2_object(); - const Construct_vector_2 construct_vector_2 = GeomTraits().construct_vector_2_object(); + const Construct_source construct_source_2 = GeomTraits().construct_source_2_object(); + const Construct_vector construct_vector_2 = GeomTraits().construct_vector_2_object(); const Point source = construct_source_2(ray); const Vector direction = construct_vector_2(ray); - Cartesian_const_iterator_2 source_iter = construct_cartesian_const_iterator_2(source); - Cartesian_const_iterator_2 direction_iter = construct_cartesian_const_iterator_2(direction); + Cartesian_const_iterator source_iter = construct_cartesian_const_iterator_2(source); + Cartesian_const_iterator direction_iter = construct_cartesian_const_iterator_2(direction); for(int i = 0; i < 2; ++i, ++source_iter, ++direction_iter) { if(*direction_iter == 0) { diff --git a/AABB_tree/include/CGAL/AABB_traits_3.h b/AABB_tree/include/CGAL/AABB_traits_3.h index f84a81c2c85d..5bd128cce329 100644 --- a/AABB_tree/include/CGAL/AABB_traits_3.h +++ b/AABB_tree/include/CGAL/AABB_traits_3.h @@ -47,14 +47,9 @@ struct AABB_traits_intersection_base_3{}; template struct AABB_traits_intersection_base_3{ - typedef typename GeomTraits::Ray_3 Ray; +private: typedef typename GeomTraits::Point_3 Point; - typedef typename GeomTraits::Vector_3 Vector; typedef typename GeomTraits::FT FT; - typedef typename GeomTraits::Cartesian_const_iterator_3 Cartesian_const_iterator_3; - typedef typename GeomTraits::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator_3; - typedef typename GeomTraits::Construct_source_3 Construct_source_3; - typedef typename GeomTraits::Construct_vector_3 Construct_vector_3; // Defining Bounding_box and other types from the full AABB_traits_3 // here is might seem strange, but otherwise we would need to use @@ -62,19 +57,39 @@ struct AABB_traits_intersection_base_3{ // code more. typedef typename CGAL::Bbox_3 Bounding_box; +public: + typedef typename GeomTraits::Ray_3 Ray; + typedef typename GeomTraits::Vector_3 Vector; + typedef typename GeomTraits::Cartesian_const_iterator_3 Cartesian_const_iterator; + typedef typename GeomTraits::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator; + typedef typename GeomTraits::Construct_source_3 Construct_source; + typedef typename GeomTraits::Construct_vector_3 Construct_vector; + + Construct_cartesian_const_iterator construct_cartesian_const_iterator_object() { + return GeomTraits().construct_cartesian_const_iterator_3_object(); + } + + Construct_source construct_source_object() { + return GeomTraits().construct_source_3_object(); + } + + Construct_vector construct_vector_object() { + return GeomTraits().construct_vector_3_object(); + } + struct Intersection_distance { std::optional operator()(const Ray& ray, const Bounding_box& bbox) const { FT t_near = -DBL_MAX; // std::numeric_limits::lowest(); C++1903 FT t_far = DBL_MAX; - const Construct_cartesian_const_iterator_3 construct_cartesian_const_iterator_3 + const Construct_cartesian_const_iterator construct_cartesian_const_iterator = GeomTraits().construct_cartesian_const_iterator_3_object(); - const Construct_source_3 construct_source_3 = GeomTraits().construct_source_3_object(); - const Construct_vector_3 construct_vector_3 = GeomTraits().construct_vector_3_object(); - const Point_3 source = construct_source_3(ray); - const Vector_3 direction = construct_vector_3(ray); - Cartesian_const_iterator_3 source_iter = construct_cartesian_const_iterator_3(source); - Cartesian_const_iterator_3 direction_iter = construct_cartesian_const_iterator_3(direction); + const Construct_source construct_source = GeomTraits().construct_source_3_object(); + const Construct_vector construct_vector = GeomTraits().construct_vector_3_object(); + const Point source = construct_source(ray); + const Vector direction = construct_vector(ray); + Cartesian_const_iterator source_iter = construct_cartesian_const_iterator(source); + Cartesian_const_iterator direction_iter = construct_cartesian_const_iterator(direction); for(int i = 0; i < 3; ++i, ++source_iter, ++direction_iter) { if(*direction_iter == 0) { diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h index 9103b05e6b70..9aa8ba6980ba 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h @@ -42,6 +42,7 @@ class AABB_ray_intersection { typedef typename AABBTree::template Intersection_and_primitive_id::Type Ray_intersection_and_primitive_id; typedef typename Ray_intersection_and_primitive_id::first_type Ray_intersection; + public: AABB_ray_intersection(const AABBTree& tree) : tree_(tree) {} @@ -51,8 +52,7 @@ class AABB_ray_intersection { // nb_primitives through a variable in each Node on the stack. In // BVH_node::traversal this is done through the function parameter // nb_primitives in the recursion. - typedef - boost::heap::priority_queue< Node_ptr_with_ft, boost::heap::compare< std::greater > > + typedef boost::heap::priority_queue< Node_ptr_with_ft, boost::heap::compare< std::greater > > Heap_type; typename AABB_traits::Intersection @@ -170,7 +170,7 @@ class AABB_ray_intersection { as_ray_param_visitor(const Ray* ray) : ray(ray), max_i(0) { - Vector v = ray->to_vector(); + Vector v = AABB_traits().construct_vector_object()(*ray); for (int i=1; i CGAL::abs(v[max_i]) ) max_i = i; @@ -187,8 +187,8 @@ class AABB_ray_intersection { } FT operator()(const Point& point) { - Vector x(ray->source(), point); - Vector v = ray->to_vector(); + Vector x = Vector(AABB_traits().construct_source_object()(*ray), point); + Vector v = AABB_traits().construct_vector_object()(*ray); return x[max_i] / v[max_i]; } From 4c48945048e2d1528bdfa5d680d0d6312b883795 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Fri, 22 Mar 2024 16:56:26 +0100 Subject: [PATCH 061/100] doc fix 2D/3D --- AABB_tree/doc/AABB_tree/Concepts/AABBPrimitive.h | 4 ++-- .../doc/AABB_tree/Concepts/AABBPrimitiveWithSharedData.h | 4 ++-- AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h | 2 +- AABB_tree/include/CGAL/AABB_traits_2.h | 5 ++--- AABB_tree/include/CGAL/AABB_tree.h | 9 ++++----- AABB_tree/include/CGAL/AABB_triangle_primitive_2.h | 2 +- AABB_tree/package_info/AABB_tree/description.txt | 2 +- AABB_tree/package_info/AABB_tree/long_description.txt | 2 +- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBPrimitive.h b/AABB_tree/doc/AABB_tree/Concepts/AABBPrimitive.h index 3abb0cf153bd..01dc1a229226 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBPrimitive.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBPrimitive.h @@ -28,7 +28,7 @@ class AABBPrimitive { /// @{ /*! -3D point type. +Point type. */ typedef unspecified_type Point; @@ -68,7 +68,7 @@ returns the corresponding identifier. This identifier is only used as a referenc Id id(); /*! -returns a 3D point located on the geometric object represented by the primitive. This function is used to sort the primitives during the AABB tree construction as well as to construct the search KD-tree internal to the AABB tree used to accelerate distance queries. +returns a point located on the geometric object represented by the primitive. This function is used to sort the primitives during the AABB tree construction as well as to construct the search KD-tree internal to the AABB tree used to accelerate distance queries. */ Point_reference reference_point(); diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBPrimitiveWithSharedData.h b/AABB_tree/doc/AABB_tree/Concepts/AABBPrimitiveWithSharedData.h index 416cc785468d..284c90b60386 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBPrimitiveWithSharedData.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBPrimitiveWithSharedData.h @@ -34,7 +34,7 @@ class AABBPrimitiveWithSharedData { /// \name Types /// @{ /*! -3D point type. +Point type. */ typedef unspecified_type Point; @@ -78,7 +78,7 @@ returns the corresponding identifier. This identifier is only used as a referenc Id id(); /*! -returns a 3D point located on the geometric object represented by the primitive. This function is used to sort the primitives during the AABB tree construction as well as to construct the search KD-tree internal to the AABB tree used to accelerate distance queries. +returns a point located on the geometric object represented by the primitive. This function is used to sort the primitives during the AABB tree construction as well as to construct the search KD-tree internal to the AABB tree used to accelerate distance queries. */ Point_reference reference_point(const Shared_data& data); diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h index 8fd9ef2458ec..3e2f56869bd0 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h @@ -44,7 +44,7 @@ Bounding box type. typedef unspecified_type Bounding_box; /*! -3D Point and Primitive Id type +Point and Primitive Id type */ typedef std::pair Point_and_primitive_id; diff --git a/AABB_tree/include/CGAL/AABB_traits_2.h b/AABB_tree/include/CGAL/AABB_traits_2.h index 480c00aa4f05..6cc94837f833 100644 --- a/AABB_tree/include/CGAL/AABB_traits_2.h +++ b/AABB_tree/include/CGAL/AABB_traits_2.h @@ -128,7 +128,7 @@ template< typename AABBTraits> class AABB_tree; -/// This traits class handles any type of 3D geometric +/// This traits class handles any type of 2D geometric /// primitives provided that the proper intersection tests and /// constructions are implemented. It handles points, rays, lines and /// segments as query types for intersection detection and @@ -165,8 +165,8 @@ class AABB_traits_2 #endif { typedef typename CGAL::Object Object; -public: typedef GeomTraits Geom_traits; +public: typedef AABB_traits_2 AT; // AABBTraits concept types @@ -200,7 +200,6 @@ class AABB_traits_2 /// point type /// typedef typename GeomTraits::Point_2 Point; - typedef typename GeomTraits::Point_2 Point_2; /// additional types for the search tree, required by the RangeSearchTraits concept /// \bug This is not documented for now in the AABBTraits concept. diff --git a/AABB_tree/include/CGAL/AABB_tree.h b/AABB_tree/include/CGAL/AABB_tree.h index 25ad05d354d2..c63fdf38679d 100644 --- a/AABB_tree/include/CGAL/AABB_tree.h +++ b/AABB_tree/include/CGAL/AABB_tree.h @@ -41,9 +41,9 @@ namespace CGAL { /** * Static data structure for efficient - * intersection and distance computations in 3D. It builds a + * intersection and distance computations in 2D and 3D. It builds a * hierarchy of axis-aligned bounding boxes (an AABB tree) from a set - * of 3D geometric objects, and can receive intersection and distance + * of geometric objects, and can receive intersection and distance * queries, provided that the corresponding predicates are * implemented in the traits class AABBTraits. * An instance of the class `AABBTraits` is internally stored. @@ -74,8 +74,7 @@ namespace CGAL { /// Number type returned by the distance queries. typedef typename AABBTraits::FT FT; - - /// Type of 3D point. + /// Type of point. typedef typename AABBTraits::Point Point; /// Type of input primitive. @@ -86,7 +85,7 @@ namespace CGAL { typedef typename Primitives::size_type size_type; /// Type of bounding box. typedef typename AABBTraits::Bounding_box Bounding_box; - /// 3D Point and Primitive Id type + /// Point and Primitive Id type typedef typename AABBTraits::Point_and_primitive_id Point_and_primitive_id; /// \deprecated typedef typename AABBTraits::Object_and_primitive_id Object_and_primitive_id; diff --git a/AABB_tree/include/CGAL/AABB_triangle_primitive_2.h b/AABB_tree/include/CGAL/AABB_triangle_primitive_2.h index 393d8517cff0..a371ca96196a 100644 --- a/AABB_tree/include/CGAL/AABB_triangle_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_triangle_primitive_2.h @@ -51,7 +51,7 @@ namespace internal { /*! * \ingroup PkgAABBTreeRef - * Primitive type that uses as identifier an iterator with a 3D triangle as `value_type`. + * Primitive type that uses as identifier an iterator with a 2D 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. * diff --git a/AABB_tree/package_info/AABB_tree/description.txt b/AABB_tree/package_info/AABB_tree/description.txt index 0f6f1e2664c2..4defc25a8582 100644 --- a/AABB_tree/package_info/AABB_tree/description.txt +++ b/AABB_tree/package_info/AABB_tree/description.txt @@ -1 +1 @@ -Data structure for efficient intersection and distance queries over sets of 3D geometric primitives. +Data structure for efficient intersection and distance queries over sets of 2D and 3D geometric primitives. diff --git a/AABB_tree/package_info/AABB_tree/long_description.txt b/AABB_tree/package_info/AABB_tree/long_description.txt index ad49fc371b0e..73985b7a90fa 100644 --- a/AABB_tree/package_info/AABB_tree/long_description.txt +++ b/AABB_tree/package_info/AABB_tree/long_description.txt @@ -1 +1 @@ -This component implements a hierarchy of axis-aligned bounding boxes (a AABB tree) for efficient intersection and distance computations between 3D queries and sets of input 3D geometric objects. +This component implements a hierarchy of axis-aligned bounding boxes (a AABB tree) for efficient intersection and distance computations between 2D/3D queries and sets of input 2D/3D geometric objects. From cee30fb51a3f5c519e04b52a90af5423f028a8a7 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Tue, 26 Mar 2024 14:31:02 +0100 Subject: [PATCH 062/100] cleanup traits --- .../doc/AABB_tree/PackageDescription.txt | 3 ++ AABB_tree/doc/AABB_tree/examples.txt | 2 + .../AABB_tree/AABB_triangle_2_example.cpp | 52 +++++++++++++++++++ AABB_tree/include/CGAL/AABB_traits_2.h | 26 +++++----- AABB_tree/include/CGAL/AABB_traits_3.h | 22 +++++--- 5 files changed, 85 insertions(+), 20 deletions(-) create mode 100644 AABB_tree/examples/AABB_tree/AABB_triangle_2_example.cpp diff --git a/AABB_tree/doc/AABB_tree/PackageDescription.txt b/AABB_tree/doc/AABB_tree/PackageDescription.txt index 3e78bb5404b2..961b8ae6c05d 100644 --- a/AABB_tree/doc/AABB_tree/PackageDescription.txt +++ b/AABB_tree/doc/AABB_tree/PackageDescription.txt @@ -33,6 +33,7 @@ - `AABBRayIntersectionTraits` \cgalCRPSection{Classes} +- `CGAL::AABB_traits` (deprecated, use `CGAL::AABB_traits_3`) - `CGAL::AABB_traits_2` - `CGAL::AABB_traits_3` - `CGAL::AABB_tree` @@ -42,7 +43,9 @@ - `CGAL::AABB_indexed_triangle_primitive_2` - `CGAL::AABB_segment_primitive_2` - `CGAL::AABB_polyline_segment_primitive_2` +- `CGAL::AABB_triangle_primitive` (deprecated, use `CGAL::AABB_triangle_primitive_3`) - `CGAL::AABB_triangle_primitive_3` +- `CGAL::AABB_segment_primitive` (deprecated, use `CGAL::AABB_segment_primitive_3`) - `CGAL::AABB_segment_primitive_3` - `CGAL::AABB_primitive` - `CGAL::AABB_halfedge_graph_segment_primitive` diff --git a/AABB_tree/doc/AABB_tree/examples.txt b/AABB_tree/doc/AABB_tree/examples.txt index a98d2c35aafa..d986357796cd 100644 --- a/AABB_tree/doc/AABB_tree/examples.txt +++ b/AABB_tree/doc/AABB_tree/examples.txt @@ -9,8 +9,10 @@ \example AABB_tree/AABB_polyhedron_facet_intersection_example.cpp \example AABB_tree/AABB_polyline_segment_2_example.cpp \example AABB_tree/AABB_segment_3_example.cpp +\example AABB_tree/AABB_segment_2_example.cpp \example AABB_tree/AABB_ray_shooting_example.cpp \example AABB_tree/AABB_indexed_triangle_2_example.cpp +\example AABB_tree/AABB_triangle_2_example.cpp \example AABB_tree/AABB_triangle_3_example.cpp \example AABB_tree/AABB_halfedge_graph_edge_example.cpp \example AABB_tree/AABB_face_graph_triangle_example.cpp diff --git a/AABB_tree/examples/AABB_tree/AABB_triangle_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_triangle_2_example.cpp new file mode 100644 index 000000000000..631990224e90 --- /dev/null +++ b/AABB_tree/examples/AABB_tree/AABB_triangle_2_example.cpp @@ -0,0 +1,52 @@ +// Author(s) : Camille Wormser, Pierre Alliez + +#include +#include + +#include +#include +#include +#include + +typedef CGAL::Simple_cartesian K; + +typedef K::FT FT; +typedef K::Ray_2 Ray; +typedef K::Point_2 Point; +typedef K::Triangle_2 Triangle; + +typedef std::list::iterator Iterator; +typedef CGAL::AABB_triangle_primitive_2 Primitive; +typedef CGAL::AABB_traits_2 AABB_triangle_traits; +typedef CGAL::AABB_tree Tree; + +int main() +{ + Point a(1.0, 0.0); + Point b(0.0, 1.0); + Point c(1.0, 1.0); + Point d(0.0, 0.0); + + std::list triangles; + triangles.push_back(Triangle(a,b,c)); + triangles.push_back(Triangle(a,b,d)); + triangles.push_back(Triangle(a,d,c)); + + // constructs AABB tree + Tree tree(triangles.begin(),triangles.end()); + + // counts #intersections + Ray ray_query(a,b); + std::cout << tree.number_of_intersected_primitives(ray_query) + << " intersections(s) with ray query" << std::endl; + + // compute closest point and squared distance + Point point_query(2.0, 2.0); + Point closest_point = tree.closest_point(point_query); + std::cerr << "closest point is: " << closest_point << std::endl; + + FT sqd = tree.squared_distance(point_query); + std::cout << "squared distance: " << sqd << std::endl; + + return EXIT_SUCCESS; +} diff --git a/AABB_tree/include/CGAL/AABB_traits_2.h b/AABB_tree/include/CGAL/AABB_traits_2.h index 6cc94837f833..673ead172fbb 100644 --- a/AABB_tree/include/CGAL/AABB_traits_2.h +++ b/AABB_tree/include/CGAL/AABB_traits_2.h @@ -47,28 +47,24 @@ struct AABB_traits_intersection_base_2{}; template struct AABB_traits_intersection_base_2{ + template + friend class AABB_ray_intersection; private: typedef typename GeomTraits::FT FT; typedef typename GeomTraits::Point_2 Point; - -public: - typedef typename GeomTraits::Ray_2 Ray; - typedef typename GeomTraits::Vector_2 Vector; typedef typename GeomTraits::Cartesian_const_iterator_2 Cartesian_const_iterator; typedef typename GeomTraits::Construct_cartesian_const_iterator_2 Construct_cartesian_const_iterator; - typedef typename GeomTraits::Construct_source_2 Construct_source; - typedef typename GeomTraits::Construct_vector_2 Construct_vector; - - // Defining Bounding_box and other types from the full AABB_traits_2 - // here is might seem strange, but otherwise we would need to use - // CRTP to get access to the derived class, which would bloat the - // code more. - typedef typename CGAL::Bbox_2 Bounding_box; static Construct_cartesian_const_iterator construct_cartesian_const_iterator_object() { return GeomTraits().construct_cartesian_const_iterator_2_object(); } +public: + typedef typename GeomTraits::Ray_2 Ray; + typedef typename GeomTraits::Vector_2 Vector; + typedef typename GeomTraits::Construct_source_2 Construct_source; + typedef typename GeomTraits::Construct_vector_2 Construct_vector; + static Construct_source construct_source_object() { return GeomTraits().construct_source_2_object(); } @@ -77,6 +73,12 @@ struct AABB_traits_intersection_base_2{ return GeomTraits().construct_vector_2_object(); } + // Defining Bounding_box and other types from the full AABB_traits_2 + // here is might seem strange, but otherwise we would need to use + // CRTP to get access to the derived class, which would bloat the + // code more. + typedef typename CGAL::Bbox_2 Bounding_box; + struct Intersection_distance { std::optional operator()(const Ray& ray, const Bounding_box& bbox) const { FT t_near = -DBL_MAX; // std::numeric_limits::lowest(); C++1903 diff --git a/AABB_tree/include/CGAL/AABB_traits_3.h b/AABB_tree/include/CGAL/AABB_traits_3.h index 5bd128cce329..d7e0b0d17afd 100644 --- a/AABB_tree/include/CGAL/AABB_traits_3.h +++ b/AABB_tree/include/CGAL/AABB_traits_3.h @@ -35,7 +35,9 @@ namespace CGAL { -namespace internal{ namespace AABB_tree { +namespace internal { + +namespace AABB_tree { // AABB_traits_intersection_base_3 brings in the Intersection_distance predicate, // if GeomTraits is a model RayIntersectionGeomTraits. @@ -46,7 +48,10 @@ template struct AABB_traits_intersection_base_3{}; template -struct AABB_traits_intersection_base_3{ +struct AABB_traits_intersection_base_3 { + template + friend class AABB_ray_intersection; + private: typedef typename GeomTraits::Point_3 Point; typedef typename GeomTraits::FT FT; @@ -57,18 +62,19 @@ struct AABB_traits_intersection_base_3{ // code more. typedef typename CGAL::Bbox_3 Bounding_box; -public: - typedef typename GeomTraits::Ray_3 Ray; - typedef typename GeomTraits::Vector_3 Vector; typedef typename GeomTraits::Cartesian_const_iterator_3 Cartesian_const_iterator; typedef typename GeomTraits::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator; - typedef typename GeomTraits::Construct_source_3 Construct_source; - typedef typename GeomTraits::Construct_vector_3 Construct_vector; Construct_cartesian_const_iterator construct_cartesian_const_iterator_object() { return GeomTraits().construct_cartesian_const_iterator_3_object(); } +public: + typedef typename GeomTraits::Ray_3 Ray; + typedef typename GeomTraits::Vector_3 Vector; + typedef typename GeomTraits::Construct_source_3 Construct_source; + typedef typename GeomTraits::Construct_vector_3 Construct_vector; + Construct_source construct_source_object() { return GeomTraits().construct_source_3_object(); } @@ -198,7 +204,7 @@ class AABB_traits_3 /// Point type typedef typename GeomTraits::Point_3 Point; // because the AABB_tree is dimension agnostic - typedef typename GeomTraits::Point_3 Point_3; + typedef typename GeomTraits::Point_3 Point_3; // kept for backward compatibility /// additional types for the search tree, required by the RangeSearchTraits concept /// \bug This is not documented for now in the AABBTraits concept. From 65be6133d8a4adf845ff70fac39fccc94595ad89 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Tue, 26 Mar 2024 15:56:45 +0100 Subject: [PATCH 063/100] removing deprecated AABB types --- AABB_tree/benchmark/AABB_tree/test.cpp | 9 +++++---- AABB_tree/demo/AABB_tree/Scene.cpp | 10 +++++----- AABB_tree/demo/AABB_tree/Scene.h | 6 +++--- AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h | 2 +- AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h | 2 +- AABB_tree/doc/AABB_tree/Concepts/AABBPrimitive.h | 6 ++++-- .../Concepts/AABBRayIntersectionGeomTraits_2.h | 2 +- .../Concepts/AABBRayIntersectionGeomTraits_3.h | 2 +- .../AABB_tree/Concepts/AABBRayIntersectionTraits.h | 3 ++- AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h | 6 ++++-- .../examples/AABB_tree/AABB_cached_bbox_example.cpp | 6 +++--- AABB_tree/examples/AABB_tree/AABB_custom_example.cpp | 4 ++-- ...ABB_custom_indexed_triangle_set_array_example.cpp | 4 ++-- .../AABB_custom_indexed_triangle_set_example.cpp | 4 ++-- .../AABB_tree/AABB_custom_triangle_soup_example.cpp | 4 ++-- .../AABB_tree/AABB_face_graph_triangle_example.cpp | 4 ++-- .../AABB_tree/AABB_halfedge_graph_edge_example.cpp | 4 ++-- .../examples/AABB_tree/AABB_insertion_example.cpp | 4 ++-- .../AABB_tree/AABB_polyhedron_edge_example.cpp | 4 ++-- .../AABB_polyhedron_facet_distance_example.cpp | 4 ++-- .../AABB_polyhedron_facet_intersection_example.cpp | 4 ++-- .../examples/AABB_tree/AABB_ray_shooting_example.cpp | 4 ++-- .../examples/AABB_tree/AABB_segment_3_example.cpp | 8 ++++---- .../examples/AABB_tree/AABB_triangle_3_example.cpp | 9 ++++----- .../include/CGAL/AABB_indexed_triangle_primitive_2.h | 3 +++ .../include/CGAL/AABB_polyline_segment_primitive_2.h | 2 ++ AABB_tree/include/CGAL/AABB_primitive.h | 2 ++ AABB_tree/include/CGAL/AABB_segment_primitive_2.h | 2 ++ AABB_tree/include/CGAL/AABB_segment_primitive_3.h | 2 ++ .../AABB_tree/internal/triangle_datum_covering.h | 4 ++-- AABB_tree/test/AABB_tree/AABB_test_util.h | 4 ++-- AABB_tree/test/AABB_tree/aabb_any_all_benchmark.cpp | 4 ++-- .../AABB_tree/aabb_correctness_triangle_test.cpp | 4 ++-- AABB_tree/test/AABB_tree/aabb_distance_edge_test.cpp | 2 +- .../AABB_tree/aabb_distance_triangle_hint_test.cpp | 2 +- .../test/AABB_tree/aabb_distance_triangle_test.cpp | 2 +- .../AABB_tree/aabb_intersection_triangle_test.cpp | 2 +- .../aabb_naive_vs_tree_distance_segment_test.cpp | 2 +- .../aabb_naive_vs_tree_distance_triangle_test.cpp | 2 +- .../AABB_tree/aabb_naive_vs_tree_triangle_test.cpp | 2 +- .../aabb_test_all_intersected_primitives_tree.cpp | 6 +++--- AABB_tree/test/AABB_tree/aabb_test_datum.cpp | 10 +++++----- AABB_tree/test/AABB_tree/aabb_test_empty_tree.cpp | 8 ++++---- .../test/AABB_tree/aabb_test_move_constructor.cpp | 12 ++++++------ AABB_tree/test/AABB_tree/aabb_test_multi_mesh.cpp | 6 +++--- .../test/AABB_tree/aabb_test_ray_intersection.cpp | 4 ++-- .../test/AABB_tree/aabb_test_singleton_tree.cpp | 8 ++++---- .../test/AABB_tree/aabb_triangle_datum_covering.cpp | 6 +++--- .../benchmark/Alpha_wrap_3/Quality/distance_utils.h | 4 ++-- .../include/CGAL/Alpha_wrap_3/internal/Oracle_base.h | 2 +- .../CGAL/Alpha_wrap_3/internal/splitting_helper.h | 2 +- Mesh_3/benchmark/Mesh_3/StdAfx.h | 2 +- .../experimental/AABB_filtered_projection_traits.h | 2 +- .../experimental/Lipschitz_sizing_polyhedron.h | 2 +- Mesh_3/test/Mesh_3/test_meshing_utilities.h | 2 +- .../rotated_aabb_tree_example.cpp | 4 ++-- .../poisson_reconstruction.cpp | 4 ++-- .../Polygon_mesh_processing/polygon_mesh_slicer.cpp | 4 ++-- .../Polygon_mesh_processing/locate_example.cpp | 4 ++-- .../Polygon_mesh_processing/mesh_slicer_example.cpp | 4 ++-- .../Polygon_mesh_processing/internal/Snapping/snap.h | 2 +- .../include/CGAL/Polygon_mesh_slicer.h | 2 +- .../polygon_mesh_slicer_test.cpp | 4 ++-- .../demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp | 2 +- .../Point_set/Point_set_to_mesh_distance_plugin.cpp | 4 ++-- Surface_mesh/examples/Surface_mesh/sm_aabbtree.cpp | 4 ++-- .../Surface_mesh_segmentation/internal/AABB_traits.h | 2 +- .../shortest_path_with_locate.cpp | 4 ++-- .../Surface_mesh_shortest_path_test_3.cpp | 4 ++-- .../Surface_mesh_shortest_path_test_4.cpp | 4 ++-- .../Surface_mesh_shortest_path_test_6.cpp | 4 ++-- .../test_edge_collapse_bounded_distance.cpp | 4 ++-- 72 files changed, 154 insertions(+), 138 deletions(-) diff --git a/AABB_tree/benchmark/AABB_tree/test.cpp b/AABB_tree/benchmark/AABB_tree/test.cpp index eb2bb6318e4b..d3e9b88af4fb 100644 --- a/AABB_tree/benchmark/AABB_tree/test.cpp +++ b/AABB_tree/benchmark/AABB_tree/test.cpp @@ -6,8 +6,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -18,7 +18,8 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Surface_mesh Surface_mesh; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; -typedef CGAL::AABB_do_intersect_transform_traits Traits; +typedef CGAL::AABB_traits_3 Traits; +//typedef CGAL::AABB_do_intersect_transform_traits Traits; typedef CGAL::AABB_tree Tree; namespace PMP = CGAL::Polygon_mesh_processing; @@ -33,7 +34,7 @@ void naive_test(int k, const char* fname, CGAL::Aff_transformation_3 init1(CGAL::SCALING, 6.0); PMP::transform(init1, tm); CGAL::Bbox_3 box = PMP::bbox(tm); - typedef CGAL::AABB_tree > Tree; + typedef CGAL::AABB_tree Tree; Tree tmTree(tm.faces_begin(), tm.faces_end(), tm); Tree tmTree2(tm2.faces_begin(), tm2.faces_end(), tm2); CGAL::Aff_transformation_3 init2(CGAL::TRANSLATION, - K::Vector_3( diff --git a/AABB_tree/demo/AABB_tree/Scene.cpp b/AABB_tree/demo/AABB_tree/Scene.cpp index 41e11ac62091..a84d9d3f2542 100644 --- a/AABB_tree/demo/AABB_tree/Scene.cpp +++ b/AABB_tree/demo/AABB_tree/Scene.cpp @@ -867,7 +867,7 @@ void Scene::generate_points_in(const unsigned int nb_points, } typedef CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; std::cout << "Construct AABB tree..."; @@ -920,7 +920,7 @@ void Scene::generate_inside_points(const unsigned int nb_points) } typedef CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; std::cout << "Construct AABB tree..."; @@ -962,7 +962,7 @@ void Scene::generate_boundary_segments(const unsigned int nb_slices) } typedef CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; typedef Tree::Object_and_primitive_id Object_and_primitive_id; @@ -1012,7 +1012,7 @@ void Scene::generate_boundary_points(const unsigned int nb_points) } typedef CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; typedef Tree::Object_and_primitive_id Object_and_primitive_id; @@ -1062,7 +1062,7 @@ void Scene::generate_edge_points(const unsigned int nb_points) } typedef CGAL::AABB_halfedge_graph_segment_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; typedef Tree::Object_and_primitive_id Object_and_primitive_id; diff --git a/AABB_tree/demo/AABB_tree/Scene.h b/AABB_tree/demo/AABB_tree/Scene.h index ae898f43daa4..7f737c8e20d6 100644 --- a/AABB_tree/demo/AABB_tree/Scene.h +++ b/AABB_tree/demo/AABB_tree/Scene.h @@ -9,7 +9,7 @@ #include "Color_ramp.h" #include -#include +#include #include #include #include @@ -62,11 +62,11 @@ class Scene : public QObject private: typedef CGAL::AABB_face_graph_triangle_primitive Facet_Primitive; - typedef CGAL::AABB_traits Facet_Traits; + typedef CGAL::AABB_traits_3 Facet_Traits; typedef CGAL::AABB_tree Facet_tree; typedef CGAL::AABB_halfedge_graph_segment_primitive Edge_Primitive; - typedef CGAL::AABB_traits Edge_Traits; + typedef CGAL::AABB_traits_3 Edge_Traits; typedef CGAL::AABB_tree Edge_tree; typedef CGAL::qglviewer::ManipulatedFrame ManipulatedFrame; diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h index 17000ef1a6ad..648331f767cd 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h @@ -15,7 +15,7 @@ and the primitives stored in the AABB tree. \cgalHasModelsBare{All models of the concept `Kernel`} \cgalHasModelsEnd -\sa `CGAL::AABB_traits` +\sa `CGAL::AABB_traits_2` \sa `CGAL::AABB_tree` \sa `AABBPrimitive` diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h index 19763cfba82b..39f36cb16c85 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h @@ -15,7 +15,7 @@ and the primitives stored in the AABB tree. \cgalHasModelsBare{All models of the concept `Kernel`} \cgalHasModelsEnd -\sa `CGAL::AABB_traits` +\sa `CGAL::AABB_traits_3` \sa `CGAL::AABB_tree` \sa `AABBPrimitive` diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBPrimitive.h b/AABB_tree/doc/AABB_tree/Concepts/AABBPrimitive.h index 01dc1a229226..5d8e1246a7c8 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBPrimitive.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBPrimitive.h @@ -14,8 +14,10 @@ The `Primitive` type can be, e.g., a wrapper around a `Handle`. Assume for insta \cgalHasModelsBegin \cgalHasModels{CGAL::AABB_primitive} -\cgalHasModels{CGAL::AABB_segment_primitive} -\cgalHasModels{CGAL::AABB_triangle_primitive} +\cgalHasModels{CGAL::AABB_segment_primitive_2} +\cgalHasModels{CGAL::AABB_segment_primitive_3} +\cgalHasModels{CGAL::AABB_triangle_primitive_2} +\cgalHasModels{CGAL::AABB_triangle_primitive_3} \cgalHasModels{CGAL::AABB_halfedge_graph_segment_primitive} \cgalHasModels{CGAL::AABB_face_graph_triangle_primitive} \cgalHasModelsEnd diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h index eeb824d0f96a..786a9bab2042 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h @@ -14,7 +14,7 @@ define the Intersection_distance functor. \cgalHasModelsBare{All models of the concept `Kernel`} \cgalHasModelsEnd -\sa `CGAL::AABB_traits_` +\sa `CGAL::AABB_traits_2` \sa `CGAL::AABB_tree` \sa `AABBPrimitive` diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h index 8e286e9699b6..c001f675ae7d 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h @@ -13,7 +13,7 @@ define the Intersection_distance functor. \cgalHasModelsBare{All models of the concept `Kernel`} \cgalHasModelsEnd -\sa `CGAL::AABB_traits` +\sa `CGAL::AABB_traits_3` \sa `CGAL::AABB_tree` \sa `AABBPrimitive` diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h index e2385baac645..933b73766339 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h @@ -8,7 +8,8 @@ The concept `AABBRayIntersectionTraits` is a refinement of the concept distance of an intersection along a ray. \cgalHasModelsBegin -\cgalHasModels{CGAL::AABB_traits} +\cgalHasModels{CGAL::AABB_traits_2} +\cgalHasModels{CGAL::AABB_traits_3} \cgalHasModelsEnd \sa `CGAL::AABB_tree` diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h index 3e2f56869bd0..49f34be90d1b 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h @@ -6,12 +6,14 @@ The concept `AABBTraits` provides the geometric primitive types and methods for the class `CGAL::AABB_tree`. \cgalHasModelsBegin -\cgalHasModels{CGAL::AABB_traits} +\cgalHasModels{CGAL::AABB_traits_2} +\cgalHasModels{CGAL::AABB_traits_3} \cgalHasModelsEnd \cgalRefines{SearchTraits} -\sa `CGAL::AABB_traits` +\sa `CGAL::AABB_traits_2` +\sa `CGAL::AABB_traits_3` \sa `CGAL::AABB_tree` \sa `AABBPrimitive` diff --git a/AABB_tree/examples/AABB_tree/AABB_cached_bbox_example.cpp b/AABB_tree/examples/AABB_tree/AABB_cached_bbox_example.cpp index b8af3f3f442c..129d3e65c1de 100644 --- a/AABB_tree/examples/AABB_tree/AABB_cached_bbox_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_cached_bbox_example.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include #include @@ -23,7 +23,7 @@ template void triangle_mesh(std::string fname) { typedef CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; TriangleMesh tmesh; @@ -56,7 +56,7 @@ void surface_mesh_cache_bbox(std::string fname) typedef boost::graph_traits::face_descriptor face_descriptor; typedef Surface_mesh::Property_map Bbox_pmap; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; Surface_mesh tmesh; diff --git a/AABB_tree/examples/AABB_tree/AABB_custom_example.cpp b/AABB_tree/examples/AABB_tree/AABB_custom_example.cpp index 5f225eef950c..60696a0d144b 100644 --- a/AABB_tree/examples/AABB_tree/AABB_custom_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_custom_example.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include @@ -91,7 +91,7 @@ struct My_triangle_primitive { -typedef CGAL::AABB_traits My_AABB_traits; +typedef CGAL::AABB_traits_3 My_AABB_traits; typedef CGAL::AABB_tree Tree; int main() diff --git a/AABB_tree/examples/AABB_tree/AABB_custom_indexed_triangle_set_array_example.cpp b/AABB_tree/examples/AABB_tree/AABB_custom_indexed_triangle_set_array_example.cpp index ab8f529f54c5..0952cc15146f 100644 --- a/AABB_tree/examples/AABB_tree/AABB_custom_indexed_triangle_set_array_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_custom_indexed_triangle_set_array_example.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include @@ -97,7 +97,7 @@ struct My_triangle_primitive { // types -typedef CGAL::AABB_traits My_AABB_traits; +typedef CGAL::AABB_traits_3 My_AABB_traits; typedef CGAL::AABB_tree Tree; const double* My_triangle_primitive::point_container = nullptr; diff --git a/AABB_tree/examples/AABB_tree/AABB_custom_indexed_triangle_set_example.cpp b/AABB_tree/examples/AABB_tree/AABB_custom_indexed_triangle_set_example.cpp index b864c08adbac..f778a06edf82 100644 --- a/AABB_tree/examples/AABB_tree/AABB_custom_indexed_triangle_set_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_custom_indexed_triangle_set_example.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include @@ -104,7 +104,7 @@ struct My_triangle_primitive { // types -typedef CGAL::AABB_traits My_AABB_traits; +typedef CGAL::AABB_traits_3 My_AABB_traits; typedef CGAL::AABB_tree Tree; const std::vector* My_triangle_primitive::point_container = nullptr; diff --git a/AABB_tree/examples/AABB_tree/AABB_custom_triangle_soup_example.cpp b/AABB_tree/examples/AABB_tree/AABB_custom_triangle_soup_example.cpp index 0fe8ffb713ad..62361baba69f 100644 --- a/AABB_tree/examples/AABB_tree/AABB_custom_triangle_soup_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_custom_triangle_soup_example.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include @@ -95,7 +95,7 @@ struct My_triangle_primitive { }; // types -typedef CGAL::AABB_traits My_AABB_traits; +typedef CGAL::AABB_traits_3 My_AABB_traits; typedef CGAL::AABB_tree Tree; int main() diff --git a/AABB_tree/examples/AABB_tree/AABB_face_graph_triangle_example.cpp b/AABB_tree/examples/AABB_tree/AABB_face_graph_triangle_example.cpp index 244909cb1b16..2ce90dd2cfd1 100644 --- a/AABB_tree/examples/AABB_tree/AABB_face_graph_triangle_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_face_graph_triangle_example.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include @@ -14,7 +14,7 @@ typedef K::Point_3 Point; typedef K::Segment_3 Segment; typedef CGAL::Polyhedron_3 Polyhedron; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; -typedef CGAL::AABB_traits Traits; +typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; template diff --git a/AABB_tree/examples/AABB_tree/AABB_halfedge_graph_edge_example.cpp b/AABB_tree/examples/AABB_tree/AABB_halfedge_graph_edge_example.cpp index 57eade14b284..76cb7eec1777 100644 --- a/AABB_tree/examples/AABB_tree/AABB_halfedge_graph_edge_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_halfedge_graph_edge_example.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include @@ -14,7 +14,7 @@ typedef K::Point_3 Point; typedef K::Triangle_3 Triangle; typedef CGAL::Polyhedron_3 Polyhedron; typedef CGAL::AABB_halfedge_graph_segment_primitive Primitive; -typedef CGAL::AABB_traits Traits; +typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; template diff --git a/AABB_tree/examples/AABB_tree/AABB_insertion_example.cpp b/AABB_tree/examples/AABB_tree/AABB_insertion_example.cpp index 90719fda49f9..a4db367629d5 100644 --- a/AABB_tree/examples/AABB_tree/AABB_insertion_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_insertion_example.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include @@ -13,7 +13,7 @@ typedef K::Point_3 Point; typedef K::Segment_3 Segment; typedef CGAL::Polyhedron_3 Polyhedron; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; -typedef CGAL::AABB_traits Traits; +typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; typedef Tree::Point_and_primitive_id Point_and_primitive_id; diff --git a/AABB_tree/examples/AABB_tree/AABB_polyhedron_edge_example.cpp b/AABB_tree/examples/AABB_tree/AABB_polyhedron_edge_example.cpp index 8e8c776032ca..cd4c959c4ac6 100644 --- a/AABB_tree/examples/AABB_tree/AABB_polyhedron_edge_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_polyhedron_edge_example.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include @@ -14,7 +14,7 @@ typedef K::Point_3 Point; typedef K::Triangle_3 Triangle; typedef CGAL::Polyhedron_3 Polyhedron; typedef CGAL::AABB_halfedge_graph_segment_primitive Primitive; -typedef CGAL::AABB_traits Traits; +typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; int main() diff --git a/AABB_tree/examples/AABB_tree/AABB_polyhedron_facet_distance_example.cpp b/AABB_tree/examples/AABB_tree/AABB_polyhedron_facet_distance_example.cpp index 5da2e15bd849..416954a86852 100644 --- a/AABB_tree/examples/AABB_tree/AABB_polyhedron_facet_distance_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_polyhedron_facet_distance_example.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include @@ -15,7 +15,7 @@ typedef K::Point_3 Point; typedef K::Segment_3 Segment; typedef CGAL::Polyhedron_3 Polyhedron; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; -typedef CGAL::AABB_traits Traits; +typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; typedef Tree::Point_and_primitive_id Point_and_primitive_id; diff --git a/AABB_tree/examples/AABB_tree/AABB_polyhedron_facet_intersection_example.cpp b/AABB_tree/examples/AABB_tree/AABB_polyhedron_facet_intersection_example.cpp index 6ced34c02340..fa7d6e19bf5c 100644 --- a/AABB_tree/examples/AABB_tree/AABB_polyhedron_facet_intersection_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_polyhedron_facet_intersection_example.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include @@ -17,7 +17,7 @@ typedef K::Segment_3 Segment; typedef K::Ray_3 Ray; typedef CGAL::Polyhedron_3 Polyhedron; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; -typedef CGAL::AABB_traits Traits; +typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; typedef std::optional< Tree::Intersection_and_primitive_id::Type > Segment_intersection; typedef std::optional< Tree::Intersection_and_primitive_id::Type > Plane_intersection; diff --git a/AABB_tree/examples/AABB_tree/AABB_ray_shooting_example.cpp b/AABB_tree/examples/AABB_tree/AABB_ray_shooting_example.cpp index e9ed0fe87c5d..cd19eb947566 100644 --- a/AABB_tree/examples/AABB_tree/AABB_ray_shooting_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_ray_shooting_example.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include @@ -21,7 +21,7 @@ typedef boost::graph_traits::face_descriptor face_descriptor; typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; -typedef CGAL::AABB_traits Traits; +typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; typedef std::optional::Type> Ray_intersection; diff --git a/AABB_tree/examples/AABB_tree/AABB_segment_3_example.cpp b/AABB_tree/examples/AABB_tree/AABB_segment_3_example.cpp index 73b4d56e2d03..f3dd2ed5802d 100644 --- a/AABB_tree/examples/AABB_tree/AABB_segment_3_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_segment_3_example.cpp @@ -5,8 +5,8 @@ #include #include -#include -#include +#include +#include typedef CGAL::Simple_cartesian K; @@ -17,8 +17,8 @@ typedef K::Segment_3 Segment; typedef K::Triangle_3 Triangle; typedef std::list::iterator Iterator; -typedef CGAL::AABB_segment_primitive Primitive; -typedef CGAL::AABB_traits Traits; +typedef CGAL::AABB_segment_primitive_3 Primitive; +typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; int main() diff --git a/AABB_tree/examples/AABB_tree/AABB_triangle_3_example.cpp b/AABB_tree/examples/AABB_tree/AABB_triangle_3_example.cpp index 1898ccc4edfb..5bafd37873a0 100644 --- a/AABB_tree/examples/AABB_tree/AABB_triangle_3_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_triangle_3_example.cpp @@ -5,20 +5,19 @@ #include #include -#include -#include +#include +#include typedef CGAL::Simple_cartesian K; typedef K::FT FT; typedef K::Ray_3 Ray; -typedef K::Line_3 Line; typedef K::Point_3 Point; typedef K::Triangle_3 Triangle; typedef std::list::iterator Iterator; -typedef CGAL::AABB_triangle_primitive Primitive; -typedef CGAL::AABB_traits AABB_triangle_traits; +typedef CGAL::AABB_triangle_primitive_3 Primitive; +typedef CGAL::AABB_traits_3 AABB_triangle_traits; typedef CGAL::AABB_tree Tree; int main() 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 d53a0c4df721..61ad6ae95eb8 100644 --- a/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h @@ -94,6 +94,9 @@ namespace internal { * \sa `AABBPrimitive` * \sa `AABB_primitive` * \sa `AABB_segment_primitive_2` + * \sa `AABB_segment_primitive_3` + * \sa `AABB_segment_triangle_2` + * \sa `AABB_segment_triangle_3` * \sa `AABB_halfedge_graph_segment_primitive` * \sa `AABB_face_graph_triangle_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 f24b33f0d337..660da7d55330 100644 --- a/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h @@ -73,6 +73,8 @@ namespace internal { * \sa `AABBPrimitive` * \sa `AABB_primitive` * \sa `AABB_segment_primitive_2` + * \sa `AABB_segment_primitive_3` + * \sa `AABB_triangle_primitive_2` * \sa `AABB_triangle_primitive_3` * \sa `AABB_halfedge_graph_segment_primitive` * \sa `AABB_face_graph_triangle_primitive` diff --git a/AABB_tree/include/CGAL/AABB_primitive.h b/AABB_tree/include/CGAL/AABB_primitive.h index 31d0d77181b5..c08a31898136 100644 --- a/AABB_tree/include/CGAL/AABB_primitive.h +++ b/AABB_tree/include/CGAL/AABB_primitive.h @@ -71,7 +71,9 @@ struct AABB_primitive_base * it is constructed on the fly to reduce the memory footprint. * The default is `CGAL::Tag_false` (datum is not stored). * + * \sa `AABB_segment_primitive_2` * \sa `AABB_segment_primitive_3` + * \sa `AABB_triangle_primitive_2` * \sa `AABB_triangle_primitive_3` * \sa `AABB_halfedge_graph_segment_primitive` * \sa `AABB_face_graph_triangle_primitive` diff --git a/AABB_tree/include/CGAL/AABB_segment_primitive_2.h b/AABB_tree/include/CGAL/AABB_segment_primitive_2.h index af57ea5e211a..55ef73397f3c 100644 --- a/AABB_tree/include/CGAL/AABB_segment_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_segment_primitive_2.h @@ -67,6 +67,8 @@ namespace internal { * * \sa `AABBPrimitive` * \sa `AABB_primitive` + * \sa `AABB_segment_primitive_3` + * \sa `AABB_triangle_primitive_2` * \sa `AABB_triangle_primitive_3` * \sa `AABB_halfedge_graph_segment_primitive` * \sa `AABB_face_graph_triangle_primitive` diff --git a/AABB_tree/include/CGAL/AABB_segment_primitive_3.h b/AABB_tree/include/CGAL/AABB_segment_primitive_3.h index 9f76c66844b6..38f880e0f6d2 100644 --- a/AABB_tree/include/CGAL/AABB_segment_primitive_3.h +++ b/AABB_tree/include/CGAL/AABB_segment_primitive_3.h @@ -67,6 +67,8 @@ namespace internal { * * \sa `AABBPrimitive` * \sa `AABB_primitive` + * \sa `AABB_segment_primitive_2` + * \sa `AABB_triangle_primitive_2` * \sa `AABB_triangle_primitive_3` * \sa `AABB_halfedge_graph_segment_primitive` * \sa `AABB_face_graph_triangle_primitive` diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/triangle_datum_covering.h b/AABB_tree/include/CGAL/AABB_tree/internal/triangle_datum_covering.h index 69babb2c160c..ca017919e3ff 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/triangle_datum_covering.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/triangle_datum_covering.h @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include @@ -161,7 +161,7 @@ struct AABB_covered_triangle_tree_traits CGAL::Tag_false /*no caching*/>; using AABB_geom_traits = Kernel; - using AABB_traits = CGAL::AABB_traits; + using AABB_traits = CGAL::AABB_traits_3; using AABB_tree = CGAL::AABB_tree; }; diff --git a/AABB_tree/test/AABB_tree/AABB_test_util.h b/AABB_tree/test/AABB_tree/AABB_test_util.h index 9bce2bd14563..a0cbef01e49f 100644 --- a/AABB_tree/test/AABB_tree/AABB_test_util.h +++ b/AABB_tree/test/AABB_tree/AABB_test_util.h @@ -246,7 +246,7 @@ void test(const std::string filename, typedef CGAL::Polyhedron_3 Polyhedron; typedef Primitive_generator Pr_generator; typedef typename Pr_generator::Primitive Pr; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; Polyhedron polyhedron; @@ -316,7 +316,7 @@ class Naive_implementations { typedef Primitive_generator Pr_generator; typedef typename Pr_generator::Primitive Pr; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_traits_3 Traits; typedef typename Pr_generator::iterator Polyhedron_primitive_iterator; typedef unsigned int size_type; typedef typename Traits::Object_and_primitive_id Object_and_primitive_id; diff --git a/AABB_tree/test/AABB_tree/aabb_any_all_benchmark.cpp b/AABB_tree/test/AABB_tree/aabb_any_all_benchmark.cpp index eb6fef9082a5..d4af45426aa8 100644 --- a/AABB_tree/test/AABB_tree/aabb_any_all_benchmark.cpp +++ b/AABB_tree/test/AABB_tree/aabb_any_all_benchmark.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include @@ -64,7 +64,7 @@ std::tuple test(const char* name) { typedef CGAL::Polyhedron_3 Polyhedron; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; std::ifstream ifs(name); diff --git a/AABB_tree/test/AABB_tree/aabb_correctness_triangle_test.cpp b/AABB_tree/test/AABB_tree/aabb_correctness_triangle_test.cpp index 54ef4c600f6b..39a1cfc9baac 100644 --- a/AABB_tree/test/AABB_tree/aabb_correctness_triangle_test.cpp +++ b/AABB_tree/test/AABB_tree/aabb_correctness_triangle_test.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include template @@ -43,7 +43,7 @@ int test() // construct tree from facets typedef typename CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef typename CGAL::AABB_traits Traits; + typedef typename CGAL::AABB_traits_3 Traits; typedef typename CGAL::AABB_tree Tree; typedef typename Tree::Object_and_primitive_id Object_and_primitive_id; Tree tree(faces(polyhedron).first, faces(polyhedron).second, polyhedron); diff --git a/AABB_tree/test/AABB_tree/aabb_distance_edge_test.cpp b/AABB_tree/test/AABB_tree/aabb_distance_edge_test.cpp index 36c3ab9f83ab..de9ec85e7641 100644 --- a/AABB_tree/test/AABB_tree/aabb_distance_edge_test.cpp +++ b/AABB_tree/test/AABB_tree/aabb_distance_edge_test.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include diff --git a/AABB_tree/test/AABB_tree/aabb_distance_triangle_hint_test.cpp b/AABB_tree/test/AABB_tree/aabb_distance_triangle_hint_test.cpp index 28186a346c88..5d1c7cf12719 100644 --- a/AABB_tree/test/AABB_tree/aabb_distance_triangle_hint_test.cpp +++ b/AABB_tree/test/AABB_tree/aabb_distance_triangle_hint_test.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include diff --git a/AABB_tree/test/AABB_tree/aabb_distance_triangle_test.cpp b/AABB_tree/test/AABB_tree/aabb_distance_triangle_test.cpp index 4bc056680f1c..6e52a364d927 100644 --- a/AABB_tree/test/AABB_tree/aabb_distance_triangle_test.cpp +++ b/AABB_tree/test/AABB_tree/aabb_distance_triangle_test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include "AABB_test_util.h" diff --git a/AABB_tree/test/AABB_tree/aabb_intersection_triangle_test.cpp b/AABB_tree/test/AABB_tree/aabb_intersection_triangle_test.cpp index 366820567009..b335cd5adfed 100644 --- a/AABB_tree/test/AABB_tree/aabb_intersection_triangle_test.cpp +++ b/AABB_tree/test/AABB_tree/aabb_intersection_triangle_test.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include "AABB_test_util.h" diff --git a/AABB_tree/test/AABB_tree/aabb_naive_vs_tree_distance_segment_test.cpp b/AABB_tree/test/AABB_tree/aabb_naive_vs_tree_distance_segment_test.cpp index 24d7ae9f5024..85507b16b55e 100644 --- a/AABB_tree/test/AABB_tree/aabb_naive_vs_tree_distance_segment_test.cpp +++ b/AABB_tree/test/AABB_tree/aabb_naive_vs_tree_distance_segment_test.cpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include "AABB_test_util.h" diff --git a/AABB_tree/test/AABB_tree/aabb_naive_vs_tree_distance_triangle_test.cpp b/AABB_tree/test/AABB_tree/aabb_naive_vs_tree_distance_triangle_test.cpp index dc63bbb52534..ceea242df176 100644 --- a/AABB_tree/test/AABB_tree/aabb_naive_vs_tree_distance_triangle_test.cpp +++ b/AABB_tree/test/AABB_tree/aabb_naive_vs_tree_distance_triangle_test.cpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include "AABB_test_util.h" diff --git a/AABB_tree/test/AABB_tree/aabb_naive_vs_tree_triangle_test.cpp b/AABB_tree/test/AABB_tree/aabb_naive_vs_tree_triangle_test.cpp index 2d8b5e7a3ac4..4c1660be97e5 100644 --- a/AABB_tree/test/AABB_tree/aabb_naive_vs_tree_triangle_test.cpp +++ b/AABB_tree/test/AABB_tree/aabb_naive_vs_tree_triangle_test.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include "AABB_test_util.h" diff --git a/AABB_tree/test/AABB_tree/aabb_test_all_intersected_primitives_tree.cpp b/AABB_tree/test/AABB_tree/aabb_test_all_intersected_primitives_tree.cpp index c0c7d160fd0a..d3d735a6d65d 100644 --- a/AABB_tree/test/AABB_tree/aabb_test_all_intersected_primitives_tree.cpp +++ b/AABB_tree/test/AABB_tree/aabb_test_all_intersected_primitives_tree.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include #include @@ -24,8 +24,8 @@ CGAL::Tag_false> S_Primitive; typedef CGAL::AABB_face_graph_triangle_primitive T_Primitive; -typedef CGAL::AABB_traits T_Traits; -typedef CGAL::AABB_traits S_Traits; +typedef CGAL::AABB_traits_3 T_Traits; +typedef CGAL::AABB_traits_3 S_Traits; typedef CGAL::AABB_tree T_Tree; typedef CGAL::AABB_tree S_Tree; typedef T_Tree::Primitive_id T_Primitive_id; diff --git a/AABB_tree/test/AABB_tree/aabb_test_datum.cpp b/AABB_tree/test/AABB_tree/aabb_test_datum.cpp index dc732d402656..5cac9a6f3f28 100644 --- a/AABB_tree/test/AABB_tree/aabb_test_datum.cpp +++ b/AABB_tree/test/AABB_tree/aabb_test_datum.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include @@ -15,22 +15,22 @@ typedef K::Point_3 Point; typedef K::Triangle_3 Triangle; typedef CGAL::Surface_mesh Mesh; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; -typedef CGAL::AABB_traits Traits; +typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; typedef CGAL::AABB_face_graph_triangle_primitive Primitive2; -typedef CGAL::AABB_traits Traits2; +typedef CGAL::AABB_traits_3 Traits2; typedef CGAL::AABB_tree Tree2; typedef CGAL::AABB_face_graph_triangle_primitive Primitive3; -typedef CGAL::AABB_traits Traits3; +typedef CGAL::AABB_traits_3 Traits3; typedef CGAL::AABB_tree Tree3; typedef CGAL::AABB_face_graph_triangle_primitive Primitive4; -typedef CGAL::AABB_traits Traits4; +typedef CGAL::AABB_traits_3 Traits4; typedef CGAL::AABB_tree Tree4; int main(void) diff --git a/AABB_tree/test/AABB_tree/aabb_test_empty_tree.cpp b/AABB_tree/test/AABB_tree/aabb_test_empty_tree.cpp index c10ea5f1acf6..9c939a58314e 100644 --- a/AABB_tree/test/AABB_tree/aabb_test_empty_tree.cpp +++ b/AABB_tree/test/AABB_tree/aabb_test_empty_tree.cpp @@ -3,8 +3,8 @@ #include #include -#include -#include +#include +#include #include typedef CGAL::Simple_cartesian K; @@ -16,8 +16,8 @@ typedef K::Segment_3 Segment; typedef K::Triangle_3 Triangle; typedef std::vector::iterator Iterator; -typedef CGAL::AABB_segment_primitive Primitive; -typedef CGAL::AABB_traits Traits; +typedef CGAL::AABB_segment_primitive_3 Primitive; +typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; int main() diff --git a/AABB_tree/test/AABB_tree/aabb_test_move_constructor.cpp b/AABB_tree/test/AABB_tree/aabb_test_move_constructor.cpp index 7f61faf6b7c7..b9e61b4ece2c 100644 --- a/AABB_tree/test/AABB_tree/aabb_test_move_constructor.cpp +++ b/AABB_tree/test/AABB_tree/aabb_test_move_constructor.cpp @@ -6,8 +6,8 @@ #include #include -#include -#include +#include +#include #include #include #include @@ -32,8 +32,8 @@ class TestCase<0> typedef K::Segment_3 Segment; typedef K::Triangle_3 Triangle; typedef std::vector::iterator Iterator; - typedef CGAL::AABB_segment_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_segment_primitive_3 Primitive; + typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; public: @@ -106,8 +106,8 @@ class TestCase<1> typedef CGAL::AABB_face_graph_triangle_primitive T_Primitive; - typedef CGAL::AABB_traits T_Traits; - typedef CGAL::AABB_traits S_Traits; + typedef CGAL::AABB_traits_3 T_Traits; + typedef CGAL::AABB_traits_3 S_Traits; typedef CGAL::AABB_tree T_Tree; typedef CGAL::AABB_tree S_Tree; typedef T_Tree::Primitive_id T_Primitive_id; diff --git a/AABB_tree/test/AABB_tree/aabb_test_multi_mesh.cpp b/AABB_tree/test/AABB_tree/aabb_test_multi_mesh.cpp index 3b2307a134b5..858db52e1b40 100644 --- a/AABB_tree/test/AABB_tree/aabb_test_multi_mesh.cpp +++ b/AABB_tree/test/AABB_tree/aabb_test_multi_mesh.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -25,14 +25,14 @@ typedef CGAL::Surface_mesh > Mesh; typedef CGAL::AABB_face_graph_triangle_primitive T_Primitive; -typedef CGAL::AABB_traits T_Traits; +typedef CGAL::AABB_traits_3 T_Traits; typedef CGAL::AABB_tree T_Tree; typedef T_Tree::Primitive_id T_Primitive_id; typedef CGAL::AABB_halfedge_graph_segment_primitive E_Primitive; -typedef CGAL::AABB_traits E_Traits; +typedef CGAL::AABB_traits_3 E_Traits; typedef CGAL::AABB_tree E_Tree; typedef E_Tree::Primitive_id E_Primitive_id; diff --git a/AABB_tree/test/AABB_tree/aabb_test_ray_intersection.cpp b/AABB_tree/test/AABB_tree/aabb_test_ray_intersection.cpp index 8ca781ff1142..aa4668273aa1 100644 --- a/AABB_tree/test/AABB_tree/aabb_test_ray_intersection.cpp +++ b/AABB_tree/test/AABB_tree/aabb_test_ray_intersection.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include @@ -23,7 +23,7 @@ typedef K::Segment_3 Segment; typedef K::Ray_3 Ray; typedef CGAL::Polyhedron_3 Polyhedron; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; -typedef CGAL::AABB_traits Traits; +typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; typedef Tree::Primitive_id Primitive_id; typedef CGAL::Timer Timer; diff --git a/AABB_tree/test/AABB_tree/aabb_test_singleton_tree.cpp b/AABB_tree/test/AABB_tree/aabb_test_singleton_tree.cpp index cc26689d64e1..84e5cd5d934a 100644 --- a/AABB_tree/test/AABB_tree/aabb_test_singleton_tree.cpp +++ b/AABB_tree/test/AABB_tree/aabb_test_singleton_tree.cpp @@ -3,8 +3,8 @@ #include #include -#include -#include +#include +#include #include typedef CGAL::Simple_cartesian K; @@ -16,8 +16,8 @@ typedef K::Segment_3 Segment; typedef K::Triangle_3 Triangle; typedef std::vector::iterator Iterator; -typedef CGAL::AABB_segment_primitive Primitive; -typedef CGAL::AABB_traits Traits; +typedef CGAL::AABB_segment_primitive_3 Primitive; +typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; int main() diff --git a/AABB_tree/test/AABB_tree/aabb_triangle_datum_covering.cpp b/AABB_tree/test/AABB_tree/aabb_triangle_datum_covering.cpp index bfd756fd0ae7..e13416a98886 100644 --- a/AABB_tree/test/AABB_tree/aabb_triangle_datum_covering.cpp +++ b/AABB_tree/test/AABB_tree/aabb_triangle_datum_covering.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include @@ -29,7 +29,7 @@ void test_no_cover(const Mesh& mesh) using Line_3 = typename GT::Line_3; using Primitive = CGAL::AABB_face_graph_triangle_primitive; - using Traits = CGAL::AABB_traits; + using Traits = CGAL::AABB_traits_3; using Tree = CGAL::AABB_tree; // Build @@ -99,7 +99,7 @@ void test_cover(const Mesh& mesh, using AABB_tree = CGAL::AABB_trees::internal::AABB_covered_triangle_tree; using FG_Primitive = CGAL::AABB_face_graph_triangle_primitive; - using FG_Traits = CGAL::AABB_traits; + using FG_Traits = CGAL::AABB_traits_3; using FG_Tree = CGAL::AABB_tree; CGAL::Bbox_3 bbox = CGAL::Polygon_mesh_processing::bbox(mesh); diff --git a/Alpha_wrap_3/benchmark/Alpha_wrap_3/Quality/distance_utils.h b/Alpha_wrap_3/benchmark/Alpha_wrap_3/Quality/distance_utils.h index 379573e9c90a..28af30181d49 100644 --- a/Alpha_wrap_3/benchmark/Alpha_wrap_3/Quality/distance_utils.h +++ b/Alpha_wrap_3/benchmark/Alpha_wrap_3/Quality/distance_utils.h @@ -15,7 +15,7 @@ #define CGAL_ALPHA_WRAP_3_BENCHMARK_ALPHA_WRAP_3_QUALITY_DISTANCE_H_ #include -#include +#include #include #include #include @@ -87,7 +87,7 @@ inline double approximate_distance(const TriangleMesh& tm1, using Point_3 = typename GT::Point_3; using Primitive = CGAL::AABB_face_graph_triangle_primitive; - using AABB_traits = CGAL::AABB_traits; + using AABB_traits = CGAL::AABB_traits_3; using AABB_tree = CGAL::AABB_tree; using CGAL::parameters::choose_parameter; diff --git a/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Oracle_base.h b/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Oracle_base.h index 7f3534a484cf..5e105f830477 100644 --- a/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Oracle_base.h +++ b/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/Oracle_base.h @@ -49,7 +49,7 @@ struct AABB_tree_oracle_helper using GT = typename AABB_traits::Geom_traits; using FT = typename AABB_traits::FT; - using Point_3 = typename AABB_traits::Point_3; + using Point_3 = typename AABB_traits::Point; template static bool do_intersect(const Query& query, diff --git a/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/splitting_helper.h b/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/splitting_helper.h index 0495bca9fb42..4f72b5583ed8 100644 --- a/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/splitting_helper.h +++ b/Alpha_wrap_3/include/CGAL/Alpha_wrap_3/internal/splitting_helper.h @@ -83,7 +83,7 @@ struct Splitter_traversal_traits : public CGAL::internal::AABB_tree::Projection_traits { using Base = CGAL::internal::AABB_tree::Projection_traits; - using Point = typename AABBTraits::Point_3; + using Point = typename AABBTraits::Point; using Primitive = typename AABBTraits::Primitive; std::unordered_set visited_data; diff --git a/Mesh_3/benchmark/Mesh_3/StdAfx.h b/Mesh_3/benchmark/Mesh_3/StdAfx.h index 9648697498aa..e7ee9da0a034 100644 --- a/Mesh_3/benchmark/Mesh_3/StdAfx.h +++ b/Mesh_3/benchmark/Mesh_3/StdAfx.h @@ -141,7 +141,7 @@ #include // CGAL -//#include +//#include //#include #include #include diff --git a/Mesh_3/include/CGAL/Mesh_3/experimental/AABB_filtered_projection_traits.h b/Mesh_3/include/CGAL/Mesh_3/experimental/AABB_filtered_projection_traits.h index ac5c1d304968..d14daec010ba 100644 --- a/Mesh_3/include/CGAL/Mesh_3/experimental/AABB_filtered_projection_traits.h +++ b/Mesh_3/include/CGAL/Mesh_3/experimental/AABB_filtered_projection_traits.h @@ -37,7 +37,7 @@ template #include -#include +#include #include diff --git a/Mesh_3/test/Mesh_3/test_meshing_utilities.h b/Mesh_3/test/Mesh_3/test_meshing_utilities.h index 2e7571eb41d3..5b5fbc613164 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_utilities.h +++ b/Mesh_3/test/Mesh_3/test_meshing_utilities.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include diff --git a/Optimal_bounding_box/examples/Optimal_bounding_box/rotated_aabb_tree_example.cpp b/Optimal_bounding_box/examples/Optimal_bounding_box/rotated_aabb_tree_example.cpp index f16c2ab3f4a3..0ce81603de8d 100644 --- a/Optimal_bounding_box/examples/Optimal_bounding_box/rotated_aabb_tree_example.cpp +++ b/Optimal_bounding_box/examples/Optimal_bounding_box/rotated_aabb_tree_example.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include @@ -52,7 +52,7 @@ int main(int argc, char** argv) // rotated AABB tree typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; - typedef CGAL::AABB_traits AABB_face_graph_traits; + typedef CGAL::AABB_traits_3 AABB_face_graph_traits; CGAL::AABB_tree tree(faces(sm).begin(), faces(sm).end(), sm, aff_tr_vpm); diff --git a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction.cpp b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction.cpp index f552cf357dcf..19b2afb49423 100644 --- a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction.cpp +++ b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction.cpp @@ -10,7 +10,7 @@ // CGAL #include // must be included before kernel -#include +#include #include #include #include @@ -57,7 +57,7 @@ typedef CGAL::Poisson_implicit_surface_3 Primitive; -typedef CGAL::AABB_traits AABB_traits; +typedef CGAL::AABB_traits_3 AABB_traits; typedef CGAL::AABB_tree AABB_tree; struct Counter { diff --git a/Polygon_mesh_processing/benchmark/Polygon_mesh_processing/polygon_mesh_slicer.cpp b/Polygon_mesh_processing/benchmark/Polygon_mesh_processing/polygon_mesh_slicer.cpp index ae1fd002a92f..efc64fae2d7b 100644 --- a/Polygon_mesh_processing/benchmark/Polygon_mesh_processing/polygon_mesh_slicer.cpp +++ b/Polygon_mesh_processing/benchmark/Polygon_mesh_processing/polygon_mesh_slicer.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include @@ -34,7 +34,7 @@ typedef CGAL::Polyhedron_3 Mesh; #endif typedef CGAL::AABB_halfedge_graph_segment_primitive HGSP; -typedef CGAL::AABB_traits AABB_traits; +typedef CGAL::AABB_traits_3 AABB_traits; typedef CGAL::AABB_tree AABB_tree; typedef std::vector Polyline; typedef std::list< Polyline > Polylines; diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/locate_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/locate_example.cpp index 829af8a5da39..d765f8692af3 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/locate_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/locate_example.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include @@ -58,7 +58,7 @@ int main(int /*argc*/, char** /*argv*/) // The AABB tree can be cached in case many queries are performed (otherwise, it is rebuilt // on each call, which is expensive). typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; - typedef CGAL::AABB_traits AABB_face_graph_traits; + typedef CGAL::AABB_traits_3 AABB_face_graph_traits; CGAL::AABB_tree tree; PMP::build_AABB_tree(tm, tree); diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/mesh_slicer_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/mesh_slicer_example.cpp index 5f4b1cd78d5a..1957c103596e 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/mesh_slicer_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/mesh_slicer_example.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include @@ -20,7 +20,7 @@ typedef std::vector Polyline_type; typedef std::list Polylines; typedef CGAL::AABB_halfedge_graph_segment_primitive HGSP; -typedef CGAL::AABB_traits AABB_traits; +typedef CGAL::AABB_traits_3 AABB_traits; typedef CGAL::AABB_tree AABB_tree; namespace PMP = CGAL::Polygon_mesh_processing; diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap.h index 7fbf5fd1902a..5641878fc1af 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Snapping/snap.h @@ -227,7 +227,7 @@ template ::%type`. /// \tparam AABBTree must be an instantiation of `CGAL::AABB_tree` able to handle /// the edges of `TriangleMesh`, having its `edge_descriptor` as primitive id. -/// The default is `CGAL::AABB_tree > >` /// \tparam UseParallelPlaneOptimization if `true`, the code will use specific /// predicates and constructions in case the functor is called with a plane diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/polygon_mesh_slicer_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/polygon_mesh_slicer_test.cpp index d74eb2fba20a..79d4a68fdfce 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/polygon_mesh_slicer_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/polygon_mesh_slicer_test.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include @@ -50,7 +50,7 @@ int test_slicer() #endif typedef CGAL::AABB_halfedge_graph_segment_primitive HGSP; - typedef CGAL::AABB_traits AABB_traits; + typedef CGAL::AABB_traits_3 AABB_traits; typedef CGAL::AABB_tree AABB_tree; typedef std::vector Polyline_type; typedef std::vector< Polyline_type > Polylines; diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp index e0cc78af9d36..be21f7bf7811 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp @@ -136,7 +136,7 @@ class Scene_distance_polyhedron_item: public Scene_item_rendering_helper Tree tree( faces(m).first, faces(m).second, m); tree.build(); boost::graph_traits::vertex_descriptor vd = *(vertices(m).first); - Traits::Point_3 hint = get(CGAL::vertex_point,m, vd); + Traits::Point hint = get(CGAL::vertex_point,m, vd); #if !defined(CGAL_LINKED_WITH_TBB) double hdist = 0; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_plugin.cpp index 608a8b5d3a4d..0afab979ef82 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_to_mesh_distance_plugin.cpp @@ -80,7 +80,7 @@ double compute_distances(const Mesh& m, tree.build(); typedef typename boost::property_map::const_type VPMap; VPMap vpmap = get(boost::vertex_point, m); - typename Traits::Point_3 hint = get(vpmap, *vertices(m).begin()); + typename Traits::Point hint = get(vpmap, *vertices(m).begin()); #if !defined(CGAL_LINKED_WITH_TBB) double hdist = 0; @@ -97,7 +97,7 @@ double compute_distances(const Mesh& m, #else std::atomic distance; distance.store(0); - Distance_computation f(tree, hint, point_set, &distance, out); + Distance_computation f(tree, hint, point_set, &distance, out); tbb::parallel_for(tbb::blocked_range(point_set.begin(), point_set.end()), f); return distance; #endif diff --git a/Surface_mesh/examples/Surface_mesh/sm_aabbtree.cpp b/Surface_mesh/examples/Surface_mesh/sm_aabbtree.cpp index eba06f7b5780..50c512c19d66 100644 --- a/Surface_mesh/examples/Surface_mesh/sm_aabbtree.cpp +++ b/Surface_mesh/examples/Surface_mesh/sm_aabbtree.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include @@ -14,7 +14,7 @@ typedef K::Vector_3 Vector; typedef K::Segment_3 Segment; typedef CGAL::Surface_mesh Mesh; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; -typedef CGAL::AABB_traits Traits; +typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; typedef std::optional< Tree::Intersection_and_primitive_id::Type > Segment_intersection; typedef std::optional< Tree::Intersection_and_primitive_id::Type > Plane_intersection; diff --git a/Surface_mesh_segmentation/include/CGAL/Surface_mesh_segmentation/internal/AABB_traits.h b/Surface_mesh_segmentation/include/CGAL/Surface_mesh_segmentation/internal/AABB_traits.h index 01a1cba7ec6a..2bac1f138890 100644 --- a/Surface_mesh_segmentation/include/CGAL/Surface_mesh_segmentation/internal/AABB_traits.h +++ b/Surface_mesh_segmentation/include/CGAL/Surface_mesh_segmentation/internal/AABB_traits.h @@ -32,7 +32,7 @@ class AABB_traits_SDF : public: typedef AABB_traits_3 Base_traits; typedef typename Base_traits::Bounding_box Bounding_box; - typedef typename Base_traits::Point_3 Point_3; + typedef typename Base_traits::Point Point_3; class Do_intersect : public Base_traits::Do_intersect diff --git a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_with_locate.cpp b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_with_locate.cpp index b984075eb2eb..6ee95b209dc6 100644 --- a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_with_locate.cpp +++ b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_with_locate.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include @@ -27,7 +27,7 @@ typedef typename Surface_mesh_shortest_path::Barycentric_coordinates Barycent typedef typename Surface_mesh_shortest_path::Face_location Face_location; typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; -typedef CGAL::AABB_traits AABB_face_graph_traits; +typedef CGAL::AABB_traits_3 AABB_face_graph_traits; typedef CGAL::AABB_tree AABB_tree; int main(int argc, char** argv) diff --git a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_3.cpp b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_3.cpp index 2f1c8790fd1e..26da5f2d9158 100644 --- a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_3.cpp +++ b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_3.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include @@ -40,7 +40,7 @@ int main(int argc, char* argv[]) typedef boost::property_map::const_type FIM; typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; - typedef CGAL::AABB_traits AABB_face_graph_traits; + typedef CGAL::AABB_traits_3 AABB_face_graph_traits; Traits traits; diff --git a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_4.cpp b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_4.cpp index 2eb7248f38d9..1774d928a24a 100644 --- a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_4.cpp +++ b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_4.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include @@ -43,7 +43,7 @@ int main(int argc, char* argv[]) typedef boost::property_map::const_type FIM; typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; - typedef CGAL::AABB_traits AABB_face_graph_traits; + typedef CGAL::AABB_traits_3 AABB_face_graph_traits; Traits traits; diff --git a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_6.cpp b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_6.cpp index 8ee21f598e9d..bce2226d839b 100644 --- a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_6.cpp +++ b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_6.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include @@ -21,7 +21,7 @@ typedef CGAL::Surface_mesh_shortest_path Surface_mesh_shortest_path; typedef boost::property_map::const_type VPM; typedef CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; -typedef CGAL::AABB_traits AABB_face_graph_traits; +typedef CGAL::AABB_traits_3 AABB_face_graph_traits; void test_all_pairs() { diff --git a/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_bounded_distance.cpp b/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_bounded_distance.cpp index f6cd535bf505..bdf57a591b7c 100644 --- a/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_bounded_distance.cpp +++ b/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_bounded_distance.cpp @@ -10,7 +10,7 @@ //AABB_tree #include -#include +#include #include //bbox @@ -30,7 +30,7 @@ typedef SMS::LindstromTurk_cost Cost; typedef SMS::LindstromTurk_placement Placement; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; -typedef CGAL::AABB_traits Traits; +typedef CGAL::AABB_traits_3 Traits; typedef CGAL::AABB_tree Tree; typedef SMS::Bounded_distance_placement Filtered_placement; From 30d5ca75ee4659b6130651a05292822cd41b9ffb Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Wed, 27 Mar 2024 14:43:39 +0100 Subject: [PATCH 064/100] added vertex point map --- .../CGAL/AABB_indexed_triangle_primitive_2.h | 8 +-- .../CGAL/AABB_polyline_segment_primitive_2.h | 58 ++++++++++++++----- 2 files changed, 46 insertions(+), 20 deletions(-) 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 61ad6ae95eb8..d5e0359fdc8f 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 660da7d55330..7022478a1ff5 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)); } }; From d788500386a08dcc6e629d40e5c027cb339d0908 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Wed, 27 Mar 2024 14:44:56 +0100 Subject: [PATCH 065/100] doc fix --- AABB_tree/include/CGAL/AABB_traits_3.h | 1 + 1 file changed, 1 insertion(+) diff --git a/AABB_tree/include/CGAL/AABB_traits_3.h b/AABB_tree/include/CGAL/AABB_traits_3.h index d7e0b0d17afd..52757a358472 100644 --- a/AABB_tree/include/CGAL/AABB_traits_3.h +++ b/AABB_tree/include/CGAL/AABB_traits_3.h @@ -204,6 +204,7 @@ class AABB_traits_3 /// Point type typedef typename GeomTraits::Point_3 Point; // because the AABB_tree is dimension agnostic + /// Deprecated point type typedef typename GeomTraits::Point_3 Point_3; // kept for backward compatibility /// additional types for the search tree, required by the RangeSearchTraits concept From 149e63f713d609eba575407cdcfe9214d53fb2c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 28 Mar 2024 13:29:19 +0100 Subject: [PATCH 066/100] doc alias --- AABB_tree/include/CGAL/AABB_traits.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/AABB_tree/include/CGAL/AABB_traits.h b/AABB_tree/include/CGAL/AABB_traits.h index c991aa32c77a..9b70f622c76f 100644 --- a/AABB_tree/include/CGAL/AABB_traits.h +++ b/AABB_tree/include/CGAL/AABB_traits.h @@ -24,12 +24,23 @@ #include +/// \file AABB_traits.h + + namespace CGAL { + + +/// \addtogroup PkgAABBTreeRef +/// @{ + +/// template alias for backward compatibility template using AABB_traits = AABB_traits_3; +///@} + } // namespace CGAL #endif // CGAL_NO_DEPRECATED_CODE From 8180546e32a8a1230d9b2d0475665db86a5114db Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 28 Mar 2024 15:31:51 +0100 Subject: [PATCH 067/100] added doc for deprecated types removed AABB_polyhedron_segment_primitive.h --- AABB_tree/doc/AABB_tree/dependencies | 1 + .../CGAL/AABB_indexed_triangle_primitive_2.h | 6 +- .../CGAL/AABB_polyhedron_segment_primitive.h | 158 ------------------ .../CGAL/AABB_polyline_segment_primitive_2.h | 2 +- .../include/CGAL/AABB_segment_primitive.h | 12 +- .../include/CGAL/AABB_triangle_primitive.h | 10 ++ 6 files changed, 26 insertions(+), 163 deletions(-) delete mode 100644 AABB_tree/include/CGAL/AABB_polyhedron_segment_primitive.h diff --git a/AABB_tree/doc/AABB_tree/dependencies b/AABB_tree/doc/AABB_tree/dependencies index 81058527aaf9..6c6aa39dfe36 100644 --- a/AABB_tree/doc/AABB_tree/dependencies +++ b/AABB_tree/doc/AABB_tree/dependencies @@ -8,3 +8,4 @@ Box_intersection_d Polyhedron BGL Spatial_searching +Property_map 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 d5e0359fdc8f..99439e1dba21 100644 --- a/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h @@ -89,14 +89,14 @@ namespace internal { * 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 \link Identity_property_map `CGAL::Identity_property_map`\endlink. * * \sa `AABBPrimitive` * \sa `AABB_primitive` * \sa `AABB_segment_primitive_2` * \sa `AABB_segment_primitive_3` - * \sa `AABB_segment_triangle_2` - * \sa `AABB_segment_triangle_3` + * \sa `AABB_triangle_primitive_2` + * \sa `AABB_triangle_primitive_3` * \sa `AABB_halfedge_graph_segment_primitive` * \sa `AABB_face_graph_triangle_primitive` */ diff --git a/AABB_tree/include/CGAL/AABB_polyhedron_segment_primitive.h b/AABB_tree/include/CGAL/AABB_polyhedron_segment_primitive.h deleted file mode 100644 index 7b8b72697f9a..000000000000 --- a/AABB_tree/include/CGAL/AABB_polyhedron_segment_primitive.h +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright (c) 2009 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) : Pierre Alliez, Stephane Tayeb -// -//****************************************************************************** -// File Description : -// -//****************************************************************************** - -#ifndef CGAL_AABB_POLYHEDRON_SEGMENT_PRIMITIVE_H_ -#define CGAL_AABB_POLYHEDRON_SEGMENT_PRIMITIVE_H_ - -#include - -#include - -#define CGAL_DEPRECATED_HEADER "" -#define CGAL_REPLACEMENT_HEADER "" -#include - -#include - -namespace CGAL { - -/// \addtogroup PkgAABBTreeRef -/// @{ - /// \deprecated This class is deprecated since \cgal 4.3, the class - /// `AABB_halfedge_graph_segment_primitive` should be used instead. - /// - /// Primitive type that wraps a halfedge handle of a - /// polyhedron, which is used as id, and allows the construction - /// of the datum on the fly. Since only the halfedge handle is - /// stored in this primitive, the polyhedron from which the - /// AABB tree is built should not be deleted while the AABB tree - /// is in use. - /// - /// \cgalModels{AABBPrimitive} - /// \tparam GeomTraits must provide a \c %Point_3 - /// type, used as \c Point, and a \c %Segment_3 type, used as \c - /// Datum and constructible from two arguments of type \c - /// Point. - /// \tparam Polyhedron must be a - /// \c CGAL::Polyhedron_3 whose points have type \c Point. - /// - /// \sa `AABBPrimitive` - /// \sa `AABB_polyhedron_triangle_primitive` - template - class AABB_polyhedron_segment_primitive - { - public: - // AABBTrianglePrimitive types - typedef typename GeomTraits::Point_3 Point; - - /// \name Types - /// @{ - - /// Geometric data type. - typedef typename GeomTraits::Segment_3 Datum; - /// Id type. - typedef typename Polyhedron::Halfedge_handle Id; - /// @} - - // Self - typedef AABB_polyhedron_segment_primitive Self; - - // Constructor - AABB_polyhedron_segment_primitive() {} - AABB_polyhedron_segment_primitive(const Id& handle) - : m_halfedge_handle(handle) { }; - AABB_polyhedron_segment_primitive(const Id* ptr) - : m_halfedge_handle(*ptr) { }; - template - AABB_polyhedron_segment_primitive( Iterator it, - std::enable_if_t< - std::is_same::value - >* =0 - ) : m_halfedge_handle(*it) { } - - AABB_polyhedron_segment_primitive(const Self& primitive) - : m_halfedge_handle(primitive.m_halfedge_handle) {} - - // Default destructor, copy constructor and assignment operator are ok - - // Returns by constructing on the fly the geometric datum wrapped by the primitive - Datum datum() const - { - const Point& a = m_halfedge_handle->vertex()->point(); - const Point& b = m_halfedge_handle->opposite()->vertex()->point(); - return Datum(a,b); // returns a 3D segment - } - - // Returns the identifier - Id& id() { return m_halfedge_handle; } - const Id& id() const { return m_halfedge_handle; } - - // Returns a point on the primitive - Point reference_point() const - { - return m_halfedge_handle->vertex()->point(); - } - - private: - // Id, here a polyhedron halfedge handle - Id m_halfedge_handle; - }; // end class AABB_polyhedron_segment_primitive - - ///@} - - template - class AABB_const_polyhedron_edge_primitive - { - public: - /// AABBTrianglePrimitive types - typedef typename GeomTraits::Point_3 Point; - typedef typename GeomTraits::Segment_3 Datum; - typedef typename Polyhedron::Halfedge_const_handle Id; - - /// Constructor - AABB_const_polyhedron_edge_primitive(const Id& handle) - : m_halfedge_handle(handle) { }; - - // Default destructor, copy constructor and assignment operator are ok - - /// Returns by constructing on the fly the geometric datum wrapped by the primitive - Datum datum() const - { - const Point& a = m_halfedge_handle->vertex()->point(); - const Point& b = m_halfedge_handle->opposite()->vertex()->point(); - return Datum(a,b); // returns a 3D segment - } - - /// Returns the identifier - const Id id() const { return m_halfedge_handle; } - - /// Returns a point on the primitive - Point reference_point() const - { - return m_halfedge_handle->vertex()->point(); - } - - private: - /// Id, here a polyhedron halfedge handle - Id m_halfedge_handle; - }; // end class AABB_const_polyhedron_edge_primitive - -} // end namespace CGAL - -#include - -#endif // CGAL_AABB_POLYHEDRON_SEGMENT_PRIMITIVE_H_ 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 7022478a1ff5..8b474a9de563 100644 --- a/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h @@ -93,7 +93,7 @@ namespace internal { * 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 \link Identity_property_map `CGAL::Identity_property_map`\endlink. * * \sa `AABBPrimitive` * \sa `AABB_primitive` diff --git a/AABB_tree/include/CGAL/AABB_segment_primitive.h b/AABB_tree/include/CGAL/AABB_segment_primitive.h index b9b0ca3c7fe1..2ecb294c83cb 100644 --- a/AABB_tree/include/CGAL/AABB_segment_primitive.h +++ b/AABB_tree/include/CGAL/AABB_segment_primitive.h @@ -24,13 +24,23 @@ #include -namespace CGAL{ +/// \file AABB_segment_primitive.h + +namespace CGAL { + + +/// \addtogroup PkgAABBTreeRef +/// @{ + +/// template alias for backward compatibility template < class GeomTraits, class Iterator, class CacheDatum=Tag_false> using AABB_segment_primitive = AABB_segment_primitive_3; +///@} + } // CGAL namespace #endif // CGAL_NO_DEPRECATED_CODE diff --git a/AABB_tree/include/CGAL/AABB_triangle_primitive.h b/AABB_tree/include/CGAL/AABB_triangle_primitive.h index edf1c94299cf..f37a3540d92b 100644 --- a/AABB_tree/include/CGAL/AABB_triangle_primitive.h +++ b/AABB_tree/include/CGAL/AABB_triangle_primitive.h @@ -24,13 +24,23 @@ #include +/// \file AABB_triangle_primitive.h + namespace CGAL { + +/// \addtogroup PkgAABBTreeRef +/// @{ + +/// template alias for backward compatibility + template < class GeomTraits, class Iterator, class CacheDatum=Tag_false> using AABB_triangle_primitive = AABB_triangle_primitive_3; +///@} + } //CGAL namespace #endif // CGAL_NO_DEPRECATED_CODE From 340de38133d0598adb676cc25d1d527f7ad648f0 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Sun, 31 Mar 2024 08:41:31 +0200 Subject: [PATCH 068/100] updated reference page --- AABB_tree/doc/AABB_tree/PackageDescription.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/PackageDescription.txt b/AABB_tree/doc/AABB_tree/PackageDescription.txt index 961b8ae6c05d..c71a506292b9 100644 --- a/AABB_tree/doc/AABB_tree/PackageDescription.txt +++ b/AABB_tree/doc/AABB_tree/PackageDescription.txt @@ -40,9 +40,9 @@ \cgalCRPSection{Primitives} - `CGAL::AABB_triangle_primitive_2` -- `CGAL::AABB_indexed_triangle_primitive_2` +- `CGAL::AABB_indexed_triangle_primitive_2` - `CGAL::AABB_segment_primitive_2` -- `CGAL::AABB_polyline_segment_primitive_2` +- `CGAL::AABB_polyline_segment_primitive_2` - `CGAL::AABB_triangle_primitive` (deprecated, use `CGAL::AABB_triangle_primitive_3`) - `CGAL::AABB_triangle_primitive_3` - `CGAL::AABB_segment_primitive` (deprecated, use `CGAL::AABB_segment_primitive_3`) From 3152519594edbbb361c062ad2f4d43b464d73104 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 3 Apr 2024 15:37:13 +0200 Subject: [PATCH 069/100] Update Installation/CHANGES.md --- Installation/CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 7cc93157d13e..b42cbd1a1fb4 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -28,7 +28,7 @@ Release date: October 2023 ### [2D and 3D Fast Intersection and Distance Computation (AABB Tree)](https://doc.cgal.org/6.0/Manual/packages.html#PkgAABBTree) -- **Breaking change**: The concept `AABBTraits` now should refine the `SearchTraits` concept. +- **Breaking change**: The concept `AABBTraits` now refines the `SearchTraits` concept. - The AABB tree is now working with 2D and 3D primitives: - Replacement of `AABBGeomTraits` concept by `AABBGeomTraits_3` and `AABBRayIntersectionGeomTraits` by `AABBRayIntersectionGeomTraits_3`. - Addition of `AABBGeomTraits_2` and `AABBRayIntersectionGeomTraits_2` concepts From 5edf512b7b02d6ea2a427b7a5b23228c5ab187f0 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 10 Apr 2024 12:08:45 +0200 Subject: [PATCH 070/100] Update AABB_tree/benchmark/AABB_tree/test.cpp Co-authored-by: Mael --- AABB_tree/benchmark/AABB_tree/test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AABB_tree/benchmark/AABB_tree/test.cpp b/AABB_tree/benchmark/AABB_tree/test.cpp index d3e9b88af4fb..e01307974706 100644 --- a/AABB_tree/benchmark/AABB_tree/test.cpp +++ b/AABB_tree/benchmark/AABB_tree/test.cpp @@ -34,7 +34,7 @@ void naive_test(int k, const char* fname, CGAL::Aff_transformation_3 init1(CGAL::SCALING, 6.0); PMP::transform(init1, tm); CGAL::Bbox_3 box = PMP::bbox(tm); - typedef CGAL::AABB_tree Tree; + typedef CGAL::AABB_tree Tree; Tree tmTree(tm.faces_begin(), tm.faces_end(), tm); Tree tmTree2(tm2.faces_begin(), tm2.faces_end(), tm2); CGAL::Aff_transformation_3 init2(CGAL::TRANSLATION, - K::Vector_3( From 1a3e163a88220fd333165ddc6744e443a09f4e03 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 10 Apr 2024 12:08:56 +0200 Subject: [PATCH 071/100] Update AABB_tree/demo/AABB_tree/Scene.h Co-authored-by: Mael --- AABB_tree/demo/AABB_tree/Scene.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AABB_tree/demo/AABB_tree/Scene.h b/AABB_tree/demo/AABB_tree/Scene.h index 7f737c8e20d6..86854e4b9885 100644 --- a/AABB_tree/demo/AABB_tree/Scene.h +++ b/AABB_tree/demo/AABB_tree/Scene.h @@ -66,7 +66,7 @@ class Scene : public QObject typedef CGAL::AABB_tree Facet_tree; typedef CGAL::AABB_halfedge_graph_segment_primitive Edge_Primitive; - typedef CGAL::AABB_traits_3 Edge_Traits; + typedef CGAL::AABB_traits_3 Edge_Traits; typedef CGAL::AABB_tree Edge_tree; typedef CGAL::qglviewer::ManipulatedFrame ManipulatedFrame; From 99cca0f86473aac49fc7f1683c5cee0fbe8212bb Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 10 Apr 2024 12:09:20 +0200 Subject: [PATCH 072/100] Update AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h Co-authored-by: Mael --- .../doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h index 786a9bab2042..492477b4a0ff 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h @@ -8,7 +8,7 @@ concept `AABBGeomTraits_2`. In addition to the types required by `AABBGeomTraits_2` it also requires types and functors necessary to define the Intersection_distance functor. -\cgalRefines{AABBGeomTraits} +\cgalRefines{AABBGeomTraits_2} \cgalHasModelsBegin \cgalHasModelsBare{All models of the concept `Kernel`} From ed05a4e64bd3435d42fc8471434d6f0769d96c2b Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 10 Apr 2024 12:09:48 +0200 Subject: [PATCH 073/100] Apply suggestions from code review Co-authored-by: Mael --- .../AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h index 492477b4a0ff..da3ebb8e99b8 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h @@ -42,18 +42,18 @@ class AABBRayIntersectionGeomTraits_2 { Construct_source_2 construct_source_2_object(); /*! - A model of `CartesianConstIterator2`. + A model of `CartesianConstIterator_2`. */ typedef unspecified_type Cartesian_const_iterator_2; /*! - A model of `ConstructCartesianConstIterator2`. + A model of `ConstructCartesianConstIterator_2`. */ typedef unspecified_type Construct_cartesian_const_iterator_2; /*! */ - Construct_source_2 construct_cartesian_const_iterator_2_object(); + Construct_cartesian_const_iterator_2 construct_cartesian_const_iterator_2_object(); /*! A functor object to construct a vector giving the direction of a ray. Provides the operator: @@ -63,5 +63,5 @@ class AABBRayIntersectionGeomTraits_2 { /*! */ - Construct_source_2 construct_vector_2_object(); + Construct_vector_2 construct_vector_2_object(); }; From f498daad1ebfe86c93ccea94c447cbb0c863ecc8 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 10 Apr 2024 12:11:19 +0200 Subject: [PATCH 074/100] Apply suggestions from code review Co-authored-by: Mael --- .../AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h | 2 +- .../doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h | 6 +++--- AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h | 4 ++-- AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h index c001f675ae7d..79d38f5a367c 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h @@ -13,7 +13,7 @@ define the Intersection_distance functor. \cgalHasModelsBare{All models of the concept `Kernel`} \cgalHasModelsEnd -\sa `CGAL::AABB_traits_3` +\sa `CGAL::AABB_traits_3` \sa `CGAL::AABB_tree` \sa `AABBPrimitive` diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h index 933b73766339..7f02a72d8e97 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h @@ -8,8 +8,8 @@ The concept `AABBRayIntersectionTraits` is a refinement of the concept distance of an intersection along a ray. \cgalHasModelsBegin -\cgalHasModels{CGAL::AABB_traits_2} -\cgalHasModels{CGAL::AABB_traits_3} +\cgalHasModels{CGAL::AABB_traits_2} +\cgalHasModels{CGAL::AABB_traits_3} \cgalHasModelsEnd \sa `CGAL::AABB_tree` @@ -53,7 +53,7 @@ class AABBRayIntersectionTraits { Construct_source construct_cartesian_const_iterator_object(); /*! - A functor object to construct a vector giving the direction of a ray. Provides the operator: + A functor object to construct a vector having the same direction as a ray. Provides the operator: `Vector operator()(const Ray&);` */ typedef unspecified_type Construct_vector; diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h index 49f34be90d1b..684c2af8d029 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h @@ -6,8 +6,8 @@ The concept `AABBTraits` provides the geometric primitive types and methods for the class `CGAL::AABB_tree`. \cgalHasModelsBegin -\cgalHasModels{CGAL::AABB_traits_2} -\cgalHasModels{CGAL::AABB_traits_3} +\cgalHasModels{CGAL::AABB_traits_2} +\cgalHasModels{CGAL::AABB_traits_3} \cgalHasModelsEnd \cgalRefines{SearchTraits} 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 99439e1dba21..6debb50da5c2 100644 --- a/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h @@ -73,14 +73,14 @@ namespace internal { /*! * \ingroup PkgAABBTreeRef - * Primitive type that uses as identifier an iterator with a range of 3 indices as `value_type`. + * Primitive type that uses as identifier an iterator with a range of three indices 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_triangle_2` that has an operator taking 3 `Point_2` as + * It also provides the functor `Construct_triangle_2` that has an operator taking three `Point_2` as * parameters and returns a `Triangle_2` * \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. From 22496a830888bb2326e6b820bd4708ea1f4343bd Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 10 Apr 2024 12:12:32 +0200 Subject: [PATCH 075/100] Apply suggestions from code review Co-authored-by: Mael --- .../doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h | 2 +- AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h | 2 +- AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h | 2 +- AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h index 79d38f5a367c..a217a0e148d9 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h @@ -3,7 +3,7 @@ \cgalConcept The concept `AABBRayIntersectionGeomTraits_3` is a refinement of the -concept `AABBGeomTraits`. In addition to the types required by +concept `AABBGeomTraits_3`. In addition to the types required by `AABBGeomTraits` it also requires types and functors necessary to define the Intersection_distance functor. diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h index 684c2af8d029..5ec13b605212 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h @@ -137,7 +137,7 @@ A functor object to compute distance comparisons between the query and the nodes typedef unspecified_type Compare_distance; /*! -A functor object to compute closest point from the query on a primitive. Provides the operator: +A functor object to compute the closest point from the query on a primitive. Provides the operator: `Point operator()(const Query& query, const Primitive& primitive, const Point & closest);` which returns the closest point to `query`, among `closest` and all points of the primitive. */ typedef unspecified_type Closest_point; 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 6debb50da5c2..8921b1e42be7 100644 --- a/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h @@ -83,7 +83,7 @@ namespace internal { * It also provides the functor `Construct_triangle_2` that has an operator taking three `Point_2` as * parameters and returns a `Triangle_2` * \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 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. 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 8b474a9de563..121645d65db9 100644 --- a/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h @@ -86,13 +86,13 @@ namespace internal { * \tparam GeomTraits is a traits class providing the nested type `Point_2` and `Segment_2`. * 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 Iterator is a model of `ForwardIterator` whose value type is 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). - * \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`. + * \tparam PointMap is a model of `ReadablePropertyMap` whose key type is the value type of `PointRange` and whose value type is `Point_2`. * The default is \link Identity_property_map `CGAL::Identity_property_map`\endlink. * * \sa `AABBPrimitive` From 0e9327efa886445cd42425ddaea763118b6643d0 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 10 Apr 2024 11:39:48 +0100 Subject: [PATCH 076/100] fixes after review --- .../Concepts/AABBRayIntersectionGeomTraits_2.h | 2 +- .../Concepts/AABBRayIntersectionGeomTraits_3.h | 12 ++++++------ .../AABB_tree/Concepts/AABBRayIntersectionTraits.h | 6 ++++-- AABB_tree/doc/AABB_tree/PackageDescription.txt | 2 +- .../CGAL/AABB_tree/internal/AABB_traits_base.h | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h index da3ebb8e99b8..d4670be5862f 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h @@ -56,7 +56,7 @@ class AABBRayIntersectionGeomTraits_2 { Construct_cartesian_const_iterator_2 construct_cartesian_const_iterator_2_object(); /*! - A functor object to construct a vector giving the direction of a ray. Provides the operator: + A functor object to construct a vector having the direction as a ray. Provides the operator: `Vector_2 operator()(const Ray_2&);` */ typedef unspecified_type Construct_vector_2; diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h index a217a0e148d9..5a762a4a3768 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h @@ -4,10 +4,10 @@ The concept `AABBRayIntersectionGeomTraits_3` is a refinement of the concept `AABBGeomTraits_3`. In addition to the types required by -`AABBGeomTraits` it also requires types and functors necessary to +`AABBGeomTraits_3` it also requires types and functors necessary to define the Intersection_distance functor. -\cgalRefines{AABBGeomTraits} +\cgalRefines{AABBGeomTraits_3} \cgalHasModelsBegin \cgalHasModelsBare{All models of the concept `Kernel`} @@ -46,21 +46,21 @@ class AABBRayIntersectionGeomTraits_3 { typedef unspecified_type Cartesian_const_iterator_3; /*! - A model of `ConstructCartesianConstIterator3`. + A model of `ConstructCartesianConstIterator_33`. */ typedef unspecified_type Construct_cartesian_const_iterator_3; /*! */ - Construct_source_3 construct_cartesian_const_iterator_3_object(); + Construct_cartesian_const_iterator_3 construct_cartesian_const_iterator_3_object(); /*! - A functor object to construct a vector giving the direction of a ray. Provides the operator: + A functor object to construct a vector having the same direction as a ray. Provides the operator: `Vector_3 operator()(const Ray_3&);` */ typedef unspecified_type Construct_vector_3; /*! */ - Construct_source_3 construct_vector_3_object(); + Construct_vector_3 construct_vector_3_object(); }; diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h index 7f02a72d8e97..bad402323b22 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h @@ -7,6 +7,8 @@ The concept `AABBRayIntersectionTraits` is a refinement of the concept `AABBTraits` it also requires function objects to calculate the distance of an intersection along a ray. +\cgalRefines{AABBTraits} + \cgalHasModelsBegin \cgalHasModels{CGAL::AABB_traits_2} \cgalHasModels{CGAL::AABB_traits_3} @@ -50,7 +52,7 @@ class AABBRayIntersectionTraits { /*! */ - Construct_source construct_cartesian_const_iterator_object(); + Construct_cartesian_const_iterator construct_cartesian_const_iterator_object(); /*! A functor object to construct a vector having the same direction as a ray. Provides the operator: @@ -60,7 +62,7 @@ class AABBRayIntersectionTraits { /*! */ - Construct_source construct_vector_object(); + Construct_vector construct_vector_object(); /*! diff --git a/AABB_tree/doc/AABB_tree/PackageDescription.txt b/AABB_tree/doc/AABB_tree/PackageDescription.txt index c71a506292b9..4aea07e8e6a4 100644 --- a/AABB_tree/doc/AABB_tree/PackageDescription.txt +++ b/AABB_tree/doc/AABB_tree/PackageDescription.txt @@ -5,7 +5,7 @@ /*! \addtogroup PkgAABBTreeRef -\cgalPkgDescriptionBegin{Fast Intersection and Distance Computation,PkgAABBTree} +\cgalPkgDescriptionBegin{2D and 3D Fast Intersection and Distance Computation,PkgAABBTree} \cgalPkgPicture{aabb-teaser-thumb.png} \cgalPkgSummaryBegin \cgalPkgAuthors{Pierre Alliez, Stéphane Tayeb, and Camille Wormser} diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traits_base.h b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traits_base.h index 4011d2c57d33..3fc4968c3c62 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traits_base.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traits_base.h @@ -44,4 +44,4 @@ struct AABB_traits_base { } } -#endif \ No newline at end of file +#endif From 4015b2b5c593e5bc6200c8d8c5598e4f2b3cd9c2 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 10 Apr 2024 11:52:33 +0100 Subject: [PATCH 077/100] fixes after review --- AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h | 2 +- AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h | 2 +- .../doc/Polygon_mesh_processing/Concepts/PMPDistanceTraits.h | 4 ++-- .../Concepts/SegmentationGeomTraits.h | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h index 648331f767cd..03f4fb4ef3c3 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h @@ -78,7 +78,7 @@ A functor object to compare the distance of two points wrt a third one. Provides `CGAL::Comparison_result operator()(const Point_2& p1, const Point_2& p2, const Point_2& p3)`, -which compares the distance between `p1` and `p2`, and between `p2` and `p3`. +which compares the distance between `p1` and `p2`, to the squared distance between `p2` and `p3`. */ typedef unspecified_type Compare_distance_2; diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h index 39f36cb16c85..d3f9cb33ec35 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h @@ -78,7 +78,7 @@ A functor object to compare the distance of two points wrt a third one. Provides `CGAL::Comparison_result operator()(const Point_3& p1, const Point_3& p2, const Point_3& p3)`, -which compares the distance between `p1` and `p2`, and between `p2` and `p3`. +which compares the distance between `p1` and `p2`, to the distance between `p2` and `p3`. */ typedef unspecified_type Compare_distance_3; diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Concepts/PMPDistanceTraits.h b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Concepts/PMPDistanceTraits.h index 8c153a122ac6..96e6d276d683 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Concepts/PMPDistanceTraits.h +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Concepts/PMPDistanceTraits.h @@ -2,11 +2,11 @@ /// \cgalConcept /// /// The concept `PMPDistanceTraits` is a refinement of the -/// concepts `AABBGeomTraits` and `SpatialSortingTraits_3`. In addition to the types required by +/// concepts `AABBGeomTraits_3` and `SpatialSortingTraits_3`. In addition to the types required by /// those concepts, it also requires types and functors needed by the functions `approximate_max_distance_to_point_set()`, /// `sample_triangle_mesh()`, `approximate_Hausdorff_distance()` and `max_distance_to_triangle_mesh()` /// -/// \cgalRefines{AABBGeomTraits,SpatialSortingTraits_3} +/// \cgalRefines{AABBGeomTraits_3, SpatialSortingTraits_3} /// \cgalHasModelsBegin /// \cgalHasModelsBare{Any 3D Kernel is a model of this concept} /// \cgalHasModelsEnd diff --git a/Surface_mesh_segmentation/doc/Surface_mesh_segmentation/Concepts/SegmentationGeomTraits.h b/Surface_mesh_segmentation/doc/Surface_mesh_segmentation/Concepts/SegmentationGeomTraits.h index 81e7848328b1..5bc4502ca4b2 100644 --- a/Surface_mesh_segmentation/doc/Surface_mesh_segmentation/Concepts/SegmentationGeomTraits.h +++ b/Surface_mesh_segmentation/doc/Surface_mesh_segmentation/Concepts/SegmentationGeomTraits.h @@ -9,7 +9,7 @@ of the geometric traits needed by the segmentation functions. \cgalHasModelsBare{All models of the \cgal concept `Kernel`} \cgalHasModelsEnd -\cgalRefines{AABBGeomTraits} +\cgalRefines{AABBGeomTraits_3} */ @@ -130,4 +130,3 @@ collinear_3_object()const /// @} }; /* end SegmentationGeomTraits */ - From 5364629633b77fe5dc64754aa3ce1a22a8cf1816 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 10 Apr 2024 11:56:11 +0100 Subject: [PATCH 078/100] fixes after review --- AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h | 2 +- AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h index 03f4fb4ef3c3..050b89bace2b 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h @@ -78,7 +78,7 @@ A functor object to compare the distance of two points wrt a third one. Provides `CGAL::Comparison_result operator()(const Point_2& p1, const Point_2& p2, const Point_2& p3)`, -which compares the distance between `p1` and `p2`, to the squared distance between `p2` and `p3`. +which compares the distance between `p1` and `p2`, to the distance between `p1` and `p3`. */ typedef unspecified_type Compare_distance_2; diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h index d3f9cb33ec35..59d9d96a3371 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h @@ -78,7 +78,7 @@ A functor object to compare the distance of two points wrt a third one. Provides `CGAL::Comparison_result operator()(const Point_3& p1, const Point_3& p2, const Point_3& p3)`, -which compares the distance between `p1` and `p2`, to the distance between `p2` and `p3`. +which compares the distance between `p1` and `p2`, to the distance between `p1` and `p3`. */ typedef unspecified_type Compare_distance_3; From 725c69b6776c09049de35bad2c1bbc4ce489ca5a Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 10 Apr 2024 12:08:20 +0100 Subject: [PATCH 079/100] fixes after review --- AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h | 8 ++++---- AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h index 050b89bace2b..1205a9b1b746 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h @@ -31,13 +31,13 @@ class AABBGeomTraits_2 { A functor object to detect intersections between two geometric objects. Provides the following operators: -`bool operator()(Query, Bbox_2)`, +`bool operator()(const Query& q, const Bbox_2& b)`, -`bool operator()(Query, Primitive::Datum)`, +`bool operator()(const Query& q, const Primitive::Datum& d)`, -`bool operator()(Circle_2, Bbox_2)`. +`bool operator()(const Circle_2& c, const Bbox_2& b)`. -The operator returns `true` iff there exists a non-empty intersection. +The operator returns `true` iff there is an intersection. */ typedef unspecified_type Do_intersect_2; diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h index 59d9d96a3371..27a1beb63ecb 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h @@ -31,13 +31,13 @@ class AABBGeomTraits_3 { A functor object to detect intersections between two geometric objects. Provides the following operators: -`bool operator()(Query, Bbox_3)`, +`bool operator()(const Query& q, const Bbox_3& b)`, -`bool operator()(Query, Primitive::Datum)`, +`bool operator()(const Query& q, const Primitive::Datum& d)`, -`bool operator()(Sphere_3, Bbox_3)`. +`bool operator()(const Sphere_3& s, const Bbox_3& b)`. -The operator returns `true` iff there exists a non-empty intersection. +The operator returns `true` iff there is an intersection. */ typedef unspecified_type Do_intersect_3; From 3d90915d87c20aaad73c6fe91145c5ca70c9e0a1 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 10 Apr 2024 12:23:48 +0100 Subject: [PATCH 080/100] fixes after review --- .../doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h | 3 +++ .../doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h | 3 +++ AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h | 3 +++ 3 files changed, 9 insertions(+) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h index d4670be5862f..40d8135ae73a 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h @@ -38,6 +38,7 @@ class AABBRayIntersectionGeomTraits_2 { typedef unspecified_type Construct_source_2; /*! + returns the `Construct_source_2` functor. */ Construct_source_2 construct_source_2_object(); @@ -52,6 +53,7 @@ class AABBRayIntersectionGeomTraits_2 { typedef unspecified_type Construct_cartesian_const_iterator_2; /*! + returns the `Construct_cartesian_const_iterator_2` functor. */ Construct_cartesian_const_iterator_2 construct_cartesian_const_iterator_2_object(); @@ -62,6 +64,7 @@ class AABBRayIntersectionGeomTraits_2 { typedef unspecified_type Construct_vector_2; /*! + returns the `Construct_vector_2` functor. */ Construct_vector_2 construct_vector_2_object(); }; diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h index 5a762a4a3768..84ef6de2260e 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h @@ -37,6 +37,7 @@ class AABBRayIntersectionGeomTraits_3 { typedef unspecified_type Construct_source_3; /*! + returns the `Construct_source_3` functor. */ Construct_source_3 construct_source_3_object(); @@ -51,6 +52,7 @@ class AABBRayIntersectionGeomTraits_3 { typedef unspecified_type Construct_cartesian_const_iterator_3; /*! + returns the `Construct_cartesian_const_iterator_3` functor. */ Construct_cartesian_const_iterator_3 construct_cartesian_const_iterator_3_object(); @@ -61,6 +63,7 @@ class AABBRayIntersectionGeomTraits_3 { typedef unspecified_type Construct_vector_3; /*! + returns the `Construct_vector_3` functor. */ Construct_vector_3 construct_vector_3_object(); }; diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h index bad402323b22..b7189d2f4065 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h @@ -37,6 +37,7 @@ class AABBRayIntersectionTraits { typedef unspecified_type Construct_source; /*! + returns the `Construct_source` functor. */ Construct_source construct_source_object(); @@ -51,6 +52,7 @@ class AABBRayIntersectionTraits { typedef unspecified_type Construct_cartesian_const_iterator; /*! + returns the `Construct_cartesian_const_iterator` functor. */ Construct_cartesian_const_iterator construct_cartesian_const_iterator_object(); @@ -61,6 +63,7 @@ class AABBRayIntersectionTraits { typedef unspecified_type Construct_vector; /*! + returns the `Construct_vector` functor. */ Construct_vector construct_vector_object(); From a393b8b0e36e2ee3c7ee85648eb062680078b771 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 10 Apr 2024 12:30:26 +0100 Subject: [PATCH 081/100] fixes after review --- .../doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h | 2 +- AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h index 40d8135ae73a..b193d505fbd1 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h @@ -58,7 +58,7 @@ class AABBRayIntersectionGeomTraits_2 { Construct_cartesian_const_iterator_2 construct_cartesian_const_iterator_2_object(); /*! - A functor object to construct a vector having the direction as a ray. Provides the operator: + A functor object to construct a vector having the same direction as a ray. Provides the operator: `Vector_2 operator()(const Ray_2&);` */ typedef unspecified_type Construct_vector_2; diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h index b7189d2f4065..74b59825fd40 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h @@ -42,12 +42,12 @@ class AABBRayIntersectionTraits { Construct_source construct_source_object(); /*! - A model of `CartesianConstIterator2` or `CartesianConstIterator3`, must compatible with `Vector`. + A model of `CartesianConstIterator_2` or `CartesianConstIterator_3`, depending on the dimension of `Vector`. */ typedef unspecified_type Cartesian_const_iterator; /*! - A model of `ConstructCartesianConstIterator2` or `ConstructCartesianConstIterator3`, must compatible with `Vector`. + A model of `ConstructCartesianConstIterator_2` or `ConstructCartesianConstIterator_3`, depending on the dimension of `Vector`. */ typedef unspecified_type Construct_cartesian_const_iterator; From f00844e7b8e499024a4e409899e83a846acf5caf Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 10 Apr 2024 12:44:30 +0100 Subject: [PATCH 082/100] fixes after review --- AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h index 5ec13b605212..40413193d549 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h @@ -12,8 +12,6 @@ The concept `AABBTraits` provides the geometric primitive types and methods for \cgalRefines{SearchTraits} -\sa `CGAL::AABB_traits_2` -\sa `CGAL::AABB_traits_3` \sa `CGAL::AABB_tree` \sa `AABBPrimitive` @@ -224,4 +222,3 @@ const Primitive::Shared_data& shared_data() const; }; /* end AABBTraits */ - From aad631a53351a909d9fdf3b3ec519956699b4ad5 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 11 Apr 2024 10:40:46 +0100 Subject: [PATCH 083/100] fixes after review --- .../doc/AABB_tree/Concepts/AABBGeomTraits_2.h | 14 +-- .../doc/AABB_tree/Concepts/AABBGeomTraits_3.h | 2 +- .../Concepts/AABBRayIntersectionTraits.h | 5 + AABB_tree/doc/AABB_tree/Doxyfile.in | 2 +- .../CGAL/AABB_indexed_triangle_primitive_2.h | 91 ++++++++++--------- .../CGAL/AABB_polyline_segment_primitive_2.h | 2 +- Installation/CHANGES.md | 12 +-- .../Concepts/FunctionObjectConcepts.h | 12 +++ .../include/CGAL/Kernel/function_objects.h | 8 +- 9 files changed, 78 insertions(+), 70 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h index 1205a9b1b746..4fadb1643e4e 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h @@ -64,7 +64,7 @@ which returns the circle centered at `p` with `sr` as squared radius. typedef unspecified_type Construct_circle_2; /*! -A functor object to compute the point on a geometric primitive which is closest from a query. +A functor object to compute the point on a geometric primitive which is closest from a query point. Provides the operator: `Point_2 operator()(const Primitive::Datum& d, const Point_2& p)`, @@ -119,14 +119,6 @@ which returns `true` iff the y-coordinate of `p` is smaller than the y-coordinat */ typedef unspecified_type Less_y_2; -/*! -A functor object to compare the z-coordinates of two points. Provides the operator: - -`bool operator()(const Point_2& p, const Point_2& q)`, - -which returns `true` iff the z-coordinate of `p` is smaller than the z-coordinate of `q`. -*/ -typedef unspecified_type Less_z_2; /*! A functor object to compare two points. Provides the operator: @@ -187,10 +179,6 @@ returns the `Less_y_2` predicate. */ Less_y_2 less_y_2_object(); -/*! -returns the `Less_z_2` predicate. -*/ -Less_z_2 less_z_2_object(); /*! returns the equal predicate. diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h index 27a1beb63ecb..737d5c3e17cc 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h @@ -64,7 +64,7 @@ which returns the sphere centered at `p` with `sr` as squared radius. typedef unspecified_type Construct_sphere_3; /*! -A functor object to compute the point on a geometric primitive which is closest from a query. +A functor object to compute the point on a geometric primitive which is closest from a query point. Provides the operator: `Point_3 operator()(const Primitive::Datum& d, const Point_3& p)`, diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h index 74b59825fd40..3940817c7abd 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h @@ -30,6 +30,11 @@ class AABBRayIntersectionTraits { */ typedef unspecified_type Vector; + /*! + Type of bounding box. + */ + typedef AABBTraits::Bounding_box Bounding_box; + /*! A functor object to construct the source point of a ray. Provides the operator: `Point operator()(const Ray&);` diff --git a/AABB_tree/doc/AABB_tree/Doxyfile.in b/AABB_tree/doc/AABB_tree/Doxyfile.in index 8f87e4f9202f..fb005db4f918 100644 --- a/AABB_tree/doc/AABB_tree/Doxyfile.in +++ b/AABB_tree/doc/AABB_tree/Doxyfile.in @@ -1,6 +1,6 @@ @INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS} -PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - 2D and 3D Fast Intersection and Distance Computation (AABB Tree)" +PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - Fast Intersection and Distance Computation (AABB Tree)" EXTRACT_ALL = false HIDE_UNDOC_MEMBERS = true 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 8921b1e42be7..8c1a5848b5f3 100644 --- a/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h @@ -23,51 +23,52 @@ namespace CGAL { namespace internal { - template - struct Triangle_2_from_index_range_iterator_property_map { - //classical typedefs - typedef Iterator key_type; - typedef typename GeomTraits::Triangle_2 value_type; - typedef typename GeomTraits::Triangle_2 reference; - - typedef boost::readable_property_map_tag category; - typedef Triangle_2_from_index_range_iterator_property_map Self; - - Triangle_2_from_index_range_iterator_property_map() {} - Triangle_2_from_index_range_iterator_property_map(PointIterator b, PointMap& pmap) : begin(b), pmap(pmap) {} - - inline friend value_type - get(Self s, key_type it) - { - return typename GeomTraits::Construct_triangle_2()(get(s.pmap, s.begin[(*it)[0]]), get(s.pmap, s.begin[(*it)[1]]), get(s.pmap, s.begin[(*it)[2]])); - } - - PointIterator begin; - PointMap pmap; - }; - - template - struct Point_from_indexed_triangle_2_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_indexed_triangle_2_iterator_property_map Self; - - Point_from_indexed_triangle_2_iterator_property_map() {} - Point_from_indexed_triangle_2_iterator_property_map(PointIterator b, PointMap &pmap) : begin(b), pmap(pmap) {} - - inline friend reference - get(Self s, key_type it) - { - return get(s.pmap, s.begin[((*it)[0])]); - } - - PointIterator begin; - PointMap pmap; - }; + +template +struct Triangle_2_from_index_range_iterator_property_map { + //classical typedefs + typedef Iterator key_type; + typedef typename GeomTraits::Triangle_2 value_type; + typedef typename GeomTraits::Triangle_2 reference; + + typedef boost::readable_property_map_tag category; + typedef Triangle_2_from_index_range_iterator_property_map Self; + + Triangle_2_from_index_range_iterator_property_map() {} + Triangle_2_from_index_range_iterator_property_map(PointIterator b, PointMap& pmap) : begin(b), pmap(pmap) {} + + inline friend value_type + get(Self s, key_type it) + { + return typename GeomTraits::Construct_triangle_2()(get(s.pmap, s.begin[(*it)[0]]), get(s.pmap, s.begin[(*it)[1]]), get(s.pmap, s.begin[(*it)[2]])); + } + + PointIterator begin; + PointMap pmap; +}; + +template +struct Point_from_indexed_triangle_2_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_indexed_triangle_2_iterator_property_map Self; + + Point_from_indexed_triangle_2_iterator_property_map() {} + Point_from_indexed_triangle_2_iterator_property_map(PointIterator b, PointMap &pmap) : begin(b), pmap(pmap) {} + + inline friend reference + get(Self s, key_type it) + { + return get(s.pmap, s.begin[((*it)[0])]); + } + + PointIterator begin; + PointMap pmap; +}; }//namespace internal 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 121645d65db9..b6eff15bfba2 100644 --- a/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h @@ -79,7 +79,7 @@ namespace internal { * Primitive type that uses as identifier an iterator with a 2D point 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. The `Segment_2` is constructed on the fly using the `Point_2` - * the identifier is pointing to as source and the next `Point_2` as target. + * the identifier is pointing to as source and the `Point_2` the next identifier is pointing to as target. * * \cgalModels{AABBPrimitive} * diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index b42cbd1a1fb4..38eeb311f303 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -25,18 +25,18 @@ Release date: October 2023 - This package provides functions to repair polygons, polygons with holes, and multipolygons with holes using the odd-even heuristic. - + ### [2D and 3D Fast Intersection and Distance Computation (AABB Tree)](https://doc.cgal.org/6.0/Manual/packages.html#PkgAABBTree) - **Breaking change**: The concept `AABBTraits` now refines the `SearchTraits` concept. - The AABB tree is now working with 2D and 3D primitives: - Replacement of `AABBGeomTraits` concept by `AABBGeomTraits_3` and `AABBRayIntersectionGeomTraits` by `AABBRayIntersectionGeomTraits_3`. - Addition of `AABBGeomTraits_2` and `AABBRayIntersectionGeomTraits_2` concepts - - `AABB_traits` is deprecated and replaced by `AABB_traits_3` - - Addition of `AABB_traits_2` - - `AABB_segment_primitive` is deprecated and replaced by `AABB_segment_primitive_3` - - `AABB_triangle_primitive` is deprecated and replaced by `AABB_triangle_primitive_3` - - Addition of 2D primitive classes: `AABB_segment_primitive_2`, `AABB_polyline_segment_primitive_2`, `AABB_triangle_primitive_2`, `AABB_indexed_triangle_primitive_2` + - `CGAL::AABB_traits` is deprecated and replaced by `CGAL::AABB_traits_3` + - Addition of `CGAL::AABB_traits_2` + - `CGAL::AABB_segment_primitive` is deprecated and replaced by `CGAL::AABB_segment_primitive_3` + - `CGAL::AABB_triangle_primitive` is deprecated and replaced by `CGAL::AABB_triangle_primitive_3` + - Addition of 2D primitive classes: `CGAL::AABB_segment_primitive_2`, `CGAL::AABB_polyline_segment_primitive_2`, `CGAL::AABB_triangle_primitive_2`, `CGAL::AABB_indexed_triangle_primitive_2` #### 2D Arrangements diff --git a/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h b/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h index 7e4e66615233..77cd20715adb 100644 --- a/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h +++ b/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h @@ -6078,6 +6078,18 @@ class ConstructProjectedPoint_2 { Kernel::Point_2 operator()(const Kernel::Line_2& l, const Kernel::Point_2& p); + /*! + returns the point of `s` that is the closest to `p`. + */ + Kernel::Point_2 operator()(const Kernel::Segment_2& s, + const Kernel::Point_2& p); + + /*! + returns the point of `t` that is the closest to `p`. + */ + Kernel::Point_2 operator()(const Kernel::Triangle_2& t, + const Kernel::Point_3& p); + /// @} }; /* end Kernel::ConstructProjectedPoint_2 */ diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index 7efc0509023e..71e56de4785e 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -2872,8 +2872,10 @@ namespace CommonKernelFunctors { { return v.rep().cartesian_end(); } - }; template - class Construct_projected_point_2 + }; + + template + class Construct_projected_point_2 { bool is_inside_triangle_2_aux( @@ -2918,7 +2920,7 @@ namespace CommonKernelFunctors { } /** - * Returns the nearest point of p1,p2,p3 from origin + * Returns the nearest point of `p1`, `p2`, `p3` from origin * @param origin the origin point * @param p1 the first point * @param p2 the second point From 78883c69d907ba51f6f73a6fc236ca360d5e1a0f Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 11 Apr 2024 11:28:49 +0100 Subject: [PATCH 084/100] fixes after review --- AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h | 13 ------------- AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h | 13 ------------- 2 files changed, 26 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h index 4fadb1643e4e..797b7451df7e 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h @@ -82,15 +82,6 @@ which compares the distance between `p1` and `p2`, to the distance between `p1` */ typedef unspecified_type Compare_distance_2; -/*! -A functor object to compute the squared radius of a circle. -Provides the operator: - -`FT operator()(const Circle_2& s),` - -which returns the squared radius of `s`. -*/ -typedef unspecified_type Compute_squared_radius_2; /*! A functor object to compute the squared distance between two points. Provides the operator: @@ -159,10 +150,6 @@ returns the compare distance predicate. */ Compare_distance_2 compare_distance_2_object(); -/*! -returns the squared radius functor. -*/ -Compute_squared_radius_2 compute_squared_radius_2_object(); /*! returns the squared distance functor. diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h index 737d5c3e17cc..affafe8609a7 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h @@ -82,15 +82,6 @@ which compares the distance between `p1` and `p2`, to the distance between `p1` */ typedef unspecified_type Compare_distance_3; -/*! -A functor object to compute the squared radius of a sphere. -Provides the operator: - -`FT operator()(const Sphere_3& s),` - -which returns the squared radius of `s`. -*/ -typedef unspecified_type Compute_squared_radius_3; /*! A functor object to compute the squared distance between two points. Provides the operator: @@ -167,10 +158,6 @@ returns the compare distance predicate. */ Compare_distance_3 compare_distance_3_object(); -/*! -returns the squared radius functor. -*/ -Compute_squared_radius_3 compute_squared_radius_3_object(); /*! returns the squared distance functor. From 3cd93680a5633c49797dfd4fb049176ae545076f Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Mon, 15 Apr 2024 11:21:21 +0200 Subject: [PATCH 085/100] added tests for deprecated classes/traits --- .../aabb_deprecated_segment_test.cpp | 56 +++++++++++++++++++ ...abb_deprecated_triangle_primitive_test.cpp | 48 ++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 AABB_tree/test/AABB_tree/aabb_deprecated_segment_test.cpp create mode 100644 AABB_tree/test/AABB_tree/aabb_deprecated_triangle_primitive_test.cpp diff --git a/AABB_tree/test/AABB_tree/aabb_deprecated_segment_test.cpp b/AABB_tree/test/AABB_tree/aabb_deprecated_segment_test.cpp new file mode 100644 index 000000000000..f7f13eaf7b56 --- /dev/null +++ b/AABB_tree/test/AABB_tree/aabb_deprecated_segment_test.cpp @@ -0,0 +1,56 @@ +#include + +#include +#include + +#include +#include +#include +#include + +typedef CGAL::Simple_cartesian K; + +typedef K::FT FT; +typedef K::Point_3 Point; +typedef K::Plane_3 Plane; +typedef K::Segment_3 Segment; +typedef K::Triangle_3 Triangle; + +typedef std::list::iterator Iterator; +typedef CGAL::AABB_segment_primitive Primitive; +typedef CGAL::AABB_traits Traits; +typedef CGAL::AABB_tree Tree; + +int main() +{ + Point a(1.0, 0.0, 0.0); + Point b(0.0, 1.0, 0.0); + Point c(0.0, 0.0, 1.0); + Point d(0.0, 0.0, 0.0); + + std::list segments; + segments.push_back(Segment(a,b)); + segments.push_back(Segment(a,c)); + segments.push_back(Segment(c,d)); + + // constructs the AABB tree and the internal search tree for + // efficient distance computations. + Tree tree(segments.begin(),segments.end()); + + // counts #intersections with a plane query + Plane plane_query(a,b,d); + std::cout << tree.number_of_intersected_primitives(plane_query) + << " intersections(s) with plane" << std::endl; + + // counts #intersections with a triangle query + Triangle triangle_query(a,b,c); + std::cout << tree.number_of_intersected_primitives(triangle_query) + << " intersections(s) with triangle" << std::endl; + + // computes the closest point from a point query + Point point_query(2.0, 2.0, 2.0); + Point closest = tree.closest_point(point_query); + + std::cerr << "closest point is: " << closest << std::endl; + return EXIT_SUCCESS; +} diff --git a/AABB_tree/test/AABB_tree/aabb_deprecated_triangle_primitive_test.cpp b/AABB_tree/test/AABB_tree/aabb_deprecated_triangle_primitive_test.cpp new file mode 100644 index 000000000000..2847c6aad367 --- /dev/null +++ b/AABB_tree/test/AABB_tree/aabb_deprecated_triangle_primitive_test.cpp @@ -0,0 +1,48 @@ +#include + +#include +#include + +#include +#include +#include +#include + +typedef CGAL::Simple_cartesian K; + +typedef K::FT FT; +typedef K::Ray_3 Ray; +typedef K::Point_3 Point; +typedef K::Triangle_3 Triangle; + +typedef std::list::iterator Iterator; +typedef CGAL::AABB_triangle_primitive Primitive; +typedef CGAL::AABB_traits AABB_triangle_traits; +typedef CGAL::AABB_tree Tree; + +int main() +{ + Point a(1.0, 0.0, 0.0); + Point b(0.0, 1.0, 0.0); + Point c(0.0, 0.0, 1.0); + Point d(0.0, 0.0, 0.0); + + std::list triangles; + triangles.push_back(Triangle(a,b,c)); + triangles.push_back(Triangle(a,b,d)); + triangles.push_back(Triangle(a,d,c)); + + // constructs AABB tree + Tree tree(triangles.begin(),triangles.end()); + + // counts #intersections + Ray ray_query(a,b); + assert(tree.number_of_intersected_primitives(ray_query) != 0); + + // compute closest point and squared distance + Point point_query(2.0, 2.0, 2.0); + Point closest_point = tree.closest_point(point_query); + FT sqd = tree.squared_distance(point_query); + + return EXIT_SUCCESS; +} From d9cd44e30c7d3be9df0397514bfcfc748140d577 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Mon, 15 Apr 2024 11:59:00 +0200 Subject: [PATCH 086/100] AABBGeomTraits -> AABBGeomTraits_3 --- Polygon_mesh_processing/include/CGAL/Polygon_mesh_slicer.h | 2 +- .../test/Polygon_mesh_processing/test_pmp_distance.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_slicer.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_slicer.h index 65cc20f22cfc..2edb5a70391a 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_slicer.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_slicer.h @@ -41,7 +41,7 @@ namespace CGAL { /// a triangulated surface mesh. /// /// \tparam TriangleMesh a triangulated surface mesh, model of `FaceGraph` and `HalfedgeListGraph` -/// \tparam Traits a model of `AABBGeomTraits` +/// \tparam Traits a model of `AABBGeomTraits_3` /// \tparam VertexPointMap a model of `ReadablePropertyMap` with /// `boost::graph_traits::%vertex_descriptor` as key and /// `Traits::Point_3` as value type. diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_distance.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_distance.cpp index 5ecd9b9530b4..b2b8aa26f596 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_distance.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_distance.cpp @@ -85,7 +85,7 @@ struct Custom_traits_Hausdorff Compute_squared_area_3 compute_squared_area_3_object(){return Compute_squared_area_3();} // } end of new requirements -// requirements from AABBGeomTraits { +// requirements from AABBGeomTraits_3 { struct Sphere_3 {}; @@ -144,7 +144,7 @@ struct Custom_traits_Hausdorff Compute_squared_distance_3 compute_squared_distance_3_object() const {return Compute_squared_distance_3();} Do_intersect_3 do_intersect_3_object() const {return Do_intersect_3();} Equal_3 equal_3_object() const {return Equal_3();} -// } end of requirements from AABBGeomTraits +// } end of requirements from AABBGeomTraits_3 // requirements from SearchGeomTraits_3 { From 69f5f2314efb1906c3f4c3c38fa03e53e6b8d97b Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Mon, 15 Apr 2024 12:53:48 +0200 Subject: [PATCH 087/100] fix comment ConstRange -> Range --- AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b6eff15bfba2..9ea64c58c2a0 100644 --- a/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h @@ -87,7 +87,7 @@ 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` whose value type is 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 PointRange is a model of `Range`. 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. From 8e7b7da17c06ef1c8b1f82aeed5fa5d68edc91bf Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Mon, 15 Apr 2024 13:06:10 +0200 Subject: [PATCH 088/100] fix doc --- AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9ea64c58c2a0..38a47e6b901e 100644 --- a/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h @@ -87,7 +87,7 @@ 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` whose value type is convertible to `GeomTraits::Point_2` - * \tparam PointRange is a model of `Range`. Its value type needs to be compatible to PointMap or `Point_2` in the default case. + * \tparam PointRange is a model of `ConstRange` whose iterator is a model of `ForwardIterator`. 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. From 7dd2d0be13994fe36f4f6cb691ff0e898947a827 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Tue, 16 Apr 2024 14:49:24 +0200 Subject: [PATCH 089/100] fixed benchmark by switching to Rigid_triangle_mesh_collision_detection --- AABB_tree/benchmark/AABB_tree/test.cpp | 58 +++++++++++++------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/AABB_tree/benchmark/AABB_tree/test.cpp b/AABB_tree/benchmark/AABB_tree/test.cpp index e01307974706..623b608da019 100644 --- a/AABB_tree/benchmark/AABB_tree/test.cpp +++ b/AABB_tree/benchmark/AABB_tree/test.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include @@ -19,12 +19,11 @@ typedef CGAL::Surface_mesh Surface_mesh; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; typedef CGAL::AABB_traits_3 Traits; -//typedef CGAL::AABB_do_intersect_transform_traits Traits; typedef CGAL::AABB_tree Tree; namespace PMP = CGAL::Polygon_mesh_processing; -void naive_test(int k, const char* fname, +void naive_test(int k, const std::string& fname, int& nb_inter, int& nb_no_inter, int& nb_include) { std::ifstream input(fname); @@ -34,7 +33,7 @@ void naive_test(int k, const char* fname, CGAL::Aff_transformation_3 init1(CGAL::SCALING, 6.0); PMP::transform(init1, tm); CGAL::Bbox_3 box = PMP::bbox(tm); - typedef CGAL::AABB_tree Tree; + Tree tmTree(tm.faces_begin(), tm.faces_end(), tm); Tree tmTree2(tm2.faces_begin(), tm2.faces_end(), tm2); CGAL::Aff_transformation_3 init2(CGAL::TRANSLATION, - K::Vector_3( @@ -87,7 +86,8 @@ void naive_test(int k, const char* fname, T0 = CGAL::Aff_transformation_3(CGAL::TRANSLATION, -i*unit_vec); } } -void test_no_collision(int k, const char* fname, + +void test_no_collision(int k, const std::string &fname, int& nb_inter, int& nb_no_inter, int& nb_include) { std::ifstream input(fname); @@ -98,9 +98,11 @@ void test_no_collision(int k, const char* fname, PMP::transform(init1, tm); CGAL::Bbox_3 box = PMP::bbox(tm); Tree tmTree(tm.faces_begin(), tm.faces_end(), tm); + Tree tmTree2(tm2.faces_begin(), tm2.faces_end(), tm2); CGAL::Aff_transformation_3 init2(CGAL::TRANSLATION, - K::Vector_3( (box.xmax()-box.xmin()),0,0)); + PMP::transform(init2, tm2); tmTree.build(); @@ -114,6 +116,12 @@ void test_no_collision(int k, const char* fname, CGAL::Side_of_triangle_mesh sotm1(tmTree); + + CGAL::Rigid_triangle_mesh_collision_detection collision_detection; + + collision_detection.add_mesh(tm); + collision_detection.add_mesh(tm2); + for(int i=1; i T1 = CGAL::Aff_transformation_3(CGAL::TRANSLATION, i*unit_vec); CGAL::Aff_transformation_3 transfo = R*T1; - tmTree2.traits().set_transformation(transfo); - CGAL::Interval_nt_advanced::Protector protector; - if(tmTree2.do_intersect(tmTree)) + + collision_detection.set_transformation(1, transfo); + + std::vector< std::pair > res = collision_detection.get_all_intersections_and_inclusions(0); + + if (res.empty()) + nb_no_inter++; + else if(!res[0].second) ++nb_inter; else - { - if(sotm1(transfo.transform(vpm2[*tm2.vertices().begin()])) != CGAL::ON_UNBOUNDED_SIDE) - { - ++nb_include; - } - else - { - CGAL::Side_of_triangle_mesh sotm2(tmTree2); - if(sotm2(tm.point(*tm.vertices().begin())) != CGAL::ON_UNBOUNDED_SIDE) - ++nb_include; - else - ++nb_no_inter; - } - } + ++nb_include; } } int main(int argc, const char** argv) { - int k = (argc>1) ? atoi(argv[1]) : 10; - const char* path = (argc>2)?argv[2]:"data/handle" - ".off"; + int k = (argc>1) ? atoi(argv[1]) : 20; + std::string path = (argc>2)?argv[2]: CGAL::data_file_path("meshes/handle.off"); std::cout<< k<<" steps in "<(end - start).count() << "μs." << std::endl; + std::cout<<"Naive test : "<(end - start).count() << " ms." << std::endl; start = std::chrono::steady_clock::now(); test_no_collision(k, path,nb_inter, nb_no_inter, nb_include); end = std::chrono::steady_clock::now(); std::cout<<"With transform_traits: "<(end - start).count() << "μs." << std::endl; + <(end - start).count() << " ms." << std::endl; return 0; } From a933bf3e2e9ae65175432f80423c6dd9e25c088a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 16 Apr 2024 18:22:33 +0200 Subject: [PATCH 090/100] fix warnings and compilation issues + build maps for no caching case --- .../AABB_tree/AABB_indexed_triangle_2_example.cpp | 2 +- .../AABB_tree/AABB_polyline_segment_2_example.cpp | 3 ++- .../CGAL/AABB_indexed_triangle_primitive_2.h | 2 +- .../CGAL/AABB_polyline_segment_primitive_2.h | 13 +++++++++---- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp index 4d60dc884f44..c8979d6ae950 100644 --- a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp @@ -24,7 +24,7 @@ struct Projection_xy_point_map { Projection_xy_point_map() {} - inline friend value_type get(Self s, key_type p) + inline friend value_type get(Self, key_type p) { return value_type(p.x(), p.y()); } diff --git a/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp index 52ac14b11532..fa2c2d358576 100644 --- a/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp @@ -28,7 +28,7 @@ typedef CGAL::AABB_tree Tree_poly; typedef Tree_poly::Point_and_primitive_id Point_and_primitive_id_poly; template -void test(AABBTree& tree) { +void test(AABBTree tree) { tree.build(); tree.accelerate_distance_queries(); @@ -45,6 +45,7 @@ void test(AABBTree& tree) { std::cerr << "closest point is: " << closest << std::endl; PPId id = tree.closest_point_and_primitive(point_query); + std::cout << id.first << "\n"; } 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 8c1a5848b5f3..71d1c561db5a 100644 --- a/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h @@ -125,7 +125,7 @@ class AABB_indexed_triangle_primitive_2 AABB_indexed_triangle_primitive_2(IndexIterator it, PointRange&) : Base(it) {} /// \internal - static typename Base::Shared_data construct_shared_data(PointRange &range, PointMap &pmap = PointMap()) { + static typename Base::Shared_data construct_shared_data(PointRange &range, PointMap pmap = PointMap()) { return std::make_pair( internal::Triangle_2_from_index_range_iterator_property_map(range.begin(), pmap), internal::Point_from_indexed_triangle_2_iterator_property_map(range.begin(), pmap)); 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 38a47e6b901e..ec8e46e14686 100644 --- a/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h @@ -87,7 +87,7 @@ 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` whose value type is convertible to `GeomTraits::Point_2` - * \tparam PointRange is a model of `ConstRange` whose iterator is a model of `ForwardIterator`. Its value type needs to be compatible to PointMap or `Point_2` in the default case. + * \tparam PointRange is a model of `ConstRange` whose iterator is a model of `ForwardIterator`. Its value type needs to be the key type of `PointMap`. * \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. @@ -118,13 +118,18 @@ class AABB_polyline_segment_primitive_2 CacheDatum > #endif { + typedef internal::Segment_2_from_point_iterator_property_map Segment_map; + typedef internal::Point_from_iterator_property_map Point_primitive_map; typedef AABB_primitive< Iterator, - internal::Segment_2_from_point_iterator_property_map, - internal::Point_from_iterator_property_map, + Segment_map, + Point_primitive_map, Tag_true, CacheDatum > Base; + public: - AABB_polyline_segment_primitive_2(Iterator it, PointRange& poly) : Base(it) {} + AABB_polyline_segment_primitive_2(Iterator it, PointRange& poly, PointMap pmap = PointMap()) + : Base(it,Segment_map(poly.begin(), poly.end(), pmap), Point_primitive_map(pmap)) + {} /// \internal static typename Base::Shared_data construct_shared_data(PointRange& range, PointMap pmap = PointMap()) { From d9ff3db30736caea6656a2decb6444fe9e28b895 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Wed, 17 Apr 2024 09:53:39 +0200 Subject: [PATCH 091/100] rename Polygon to Polygon_2 to avoid name collision --- .../AABB_tree/AABB_polyline_segment_2_example.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp index fa2c2d358576..af4d4dcdd186 100644 --- a/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp @@ -20,9 +20,9 @@ typedef CGAL::AABB_traits_2 Traits_pr; typedef CGAL::AABB_tree Tree_pr; typedef Tree_pr::Point_and_primitive_id Point_and_primitive_id_pr; -typedef CGAL::Polygon_2 Polygon; -typedef Polygon::iterator Iterator_poly; -typedef CGAL::AABB_polyline_segment_primitive_2 Primitive_poly; +typedef CGAL::Polygon_2 Polygon_2; +typedef Polygon_2::iterator Iterator_poly; +typedef CGAL::AABB_polyline_segment_primitive_2 Primitive_poly; typedef CGAL::AABB_traits_2 Traits_poly; typedef CGAL::AABB_tree Tree_poly; typedef Tree_poly::Point_and_primitive_id Point_and_primitive_id_poly; @@ -59,7 +59,7 @@ int main() std::vector polyline = { a, b, c, d, e }; - Polygon poly(polyline.begin(), polyline.end()); + Polygon_2 poly(polyline.begin(), polyline.end()); test(Tree_poly(poly.begin(), poly.end(), poly)); From bbafe6d1203777f4cf9211888838eea756d961df Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Wed, 17 Apr 2024 11:01:11 +0200 Subject: [PATCH 092/100] cleaned /sa section in primitives --- .../CGAL/AABB_face_graph_triangle_primitive.h | 2 +- .../AABB_halfedge_graph_segment_primitive.h | 3 +- .../CGAL/AABB_indexed_triangle_primitive_2.h | 9 +- .../CGAL/AABB_polyhedron_triangle_primitive.h | 154 ------------------ .../CGAL/AABB_polyline_segment_primitive_2.h | 9 +- AABB_tree/include/CGAL/AABB_primitive.h | 12 +- .../include/CGAL/AABB_segment_primitive_2.h | 7 +- .../include/CGAL/AABB_segment_primitive_3.h | 8 +- .../include/CGAL/AABB_triangle_primitive_2.h | 5 +- .../include/CGAL/AABB_triangle_primitive_3.h | 6 +- 10 files changed, 25 insertions(+), 190 deletions(-) delete mode 100644 AABB_tree/include/CGAL/AABB_polyhedron_triangle_primitive.h diff --git a/AABB_tree/include/CGAL/AABB_face_graph_triangle_primitive.h b/AABB_tree/include/CGAL/AABB_face_graph_triangle_primitive.h index 021cdc6270ab..0a826f8c24c4 100644 --- a/AABB_tree/include/CGAL/AABB_face_graph_triangle_primitive.h +++ b/AABB_tree/include/CGAL/AABB_face_graph_triangle_primitive.h @@ -48,7 +48,7 @@ namespace CGAL { * The default is `CGAL::Tag_false` (datum is not stored). *\sa `AABBPrimitive` *\sa `AABB_primitive` - *\sa `AABB_halfedge_graph_segment_primitive` + *\sa `AABB_halfedge_graph_segment_primitive` */ template < class FaceGraph, class VertexPointPMap = Default, diff --git a/AABB_tree/include/CGAL/AABB_halfedge_graph_segment_primitive.h b/AABB_tree/include/CGAL/AABB_halfedge_graph_segment_primitive.h index 3f5481d0cfe1..d8005eb4558d 100644 --- a/AABB_tree/include/CGAL/AABB_halfedge_graph_segment_primitive.h +++ b/AABB_tree/include/CGAL/AABB_halfedge_graph_segment_primitive.h @@ -60,7 +60,8 @@ namespace CGAL { * * \sa `AABBPrimitive` * \sa `AABB_primitive` - * \sa `AABB_face_graph_triangle_primitive` + * \sa `AABB_face_graph_triangle_primitive` + * \sa `AABB_segment_primitive_3` * \sa \link BGLPolyGT `boost::graph_traits` \endlink */ template < class HalfedgeGraph, 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 71d1c561db5a..400cfb6cac82 100644 --- a/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_indexed_triangle_primitive_2.h @@ -94,12 +94,9 @@ struct Point_from_indexed_triangle_2_iterator_property_map { * * \sa `AABBPrimitive` * \sa `AABB_primitive` - * \sa `AABB_segment_primitive_2` - * \sa `AABB_segment_primitive_3` - * \sa `AABB_triangle_primitive_2` - * \sa `AABB_triangle_primitive_3` - * \sa `AABB_halfedge_graph_segment_primitive` - * \sa `AABB_face_graph_triangle_primitive` + * \sa `AABB_segment_primitive_2` + * \sa `AABB_triangle_primitive_2` + * \sa `AABB_triangle_primitive_3` */ template < class GeomTraits, class IndexIterator, diff --git a/AABB_tree/include/CGAL/AABB_polyhedron_triangle_primitive.h b/AABB_tree/include/CGAL/AABB_polyhedron_triangle_primitive.h deleted file mode 100644 index 647ae48b4156..000000000000 --- a/AABB_tree/include/CGAL/AABB_polyhedron_triangle_primitive.h +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright (c) 2009 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) : Stéphane Tayeb, Pierre Alliez -// - -#ifndef CGAL_AABB_POLYHEDRON_TRIANGLE_PRIMITIVE_H_ -#define CGAL_AABB_POLYHEDRON_TRIANGLE_PRIMITIVE_H_ - -#include - -#include - -#define CGAL_DEPRECATED_HEADER "" -#define CGAL_REPLACEMENT_HEADER "" -#include - -#include - -namespace CGAL { - /// \ingroup PkgAABBTreeRef - /// \deprecated This class is deprecated since \cgal 4.3, the class - /// `AABB_face_graph_triangle_primitive` should be used instead. - /// - /// Primitive type that wraps a facet handle of a polyhedron, - /// which is used as id, and allows the construction of the datum on - /// the fly. Since only the facet handle is stored in this primitive, - /// the polyhedron from which the AABB tree is built should not be - /// deleted while the AABB tree is in use. - /// - /// \cgalModels{AABBPrimitive} - /// \tparam GeomTraits must provides a \c %Point_3 - /// type, used as \c Point, and a \c %Triangle_3 type, used as \c - /// Datum and constructible from three arguments of type \c - /// Point. - /// \tparam Polyhedron must be a - /// \c CGAL::Polyhedron_3 whose points have type \c Point. - /// - /// \sa `AABBPrimitive` - /// \sa `AABB_polyhedron_segment_primitive` - template - class AABB_polyhedron_triangle_primitive - { - public: - typedef typename GeomTraits::Point_3 Point; - /// \name Types - /// @{ - - /// Id type. - typedef typename Polyhedron::Facet_handle Id; - /// Geometric data type. - typedef typename GeomTraits::Triangle_3 Datum; - - /// @} - - // Self - typedef AABB_polyhedron_triangle_primitive Self; - - // Constructors - AABB_polyhedron_triangle_primitive() {} - AABB_polyhedron_triangle_primitive(const AABB_polyhedron_triangle_primitive& primitive) - { - m_facet_handle = primitive.id(); - } - AABB_polyhedron_triangle_primitive(const Id& handle) - : m_facet_handle(handle) { }; - AABB_polyhedron_triangle_primitive(const Id* ptr) - : m_facet_handle(*ptr) { }; - template - AABB_polyhedron_triangle_primitive( Iterator it, - std::enable_if_t< - std::is_same::value - >* =0 - ) : m_facet_handle(*it) { } - - - // Default destructor, copy constructor and assignment operator are ok - - // Returns by constructing on the fly the geometric datum wrapped by the primitive - Datum datum() const - { - const Point& a = m_facet_handle->halfedge()->vertex()->point(); - const Point& b = m_facet_handle->halfedge()->next()->vertex()->point(); - const Point& c = m_facet_handle->halfedge()->next()->next()->vertex()->point(); - return Datum(a,b,c); - } - - // Returns a point on the primitive - Point reference_point() const - { - return m_facet_handle->halfedge()->vertex()->point(); - } - - // Returns the identifier - const Id& id() const { return m_facet_handle; } - Id& id() { return m_facet_handle; } - - private: - /// The id, here a polyhedron facet handle - Id m_facet_handle; - }; // end class AABB_polyhedron_triangle_primitive - - template - class AABB_const_polyhedron_triangle_primitive - { - public: - /// AABBPrimitive types - typedef typename GeomTraits::Point_3 Point; - typedef typename GeomTraits::Triangle_3 Datum; - typedef typename Polyhedron::Facet_const_handle Id; - - /// Constructors - AABB_const_polyhedron_triangle_primitive(const Id& handle) - : m_facet_handle(handle) { }; - - // Default destructor, copy constructor and assignment operator are ok - - /// Returns by constructing on the fly the geometric datum wrapped by the primitive - Datum datum() const - { - const Point& a = m_facet_handle->halfedge()->vertex()->point(); - const Point& b = m_facet_handle->halfedge()->next()->vertex()->point(); - const Point& c = m_facet_handle->halfedge()->next()->next()->vertex()->point(); - return Datum(a,b,c); - } - - /// Returns a point on the primitive - Point reference_point() const - { - return m_facet_handle->halfedge()->vertex()->point(); - } - - /// Returns the identifier - Id id() const { return m_facet_handle; } - - private: - /// The id, here a polyhedron facet handle - Id m_facet_handle; - }; // end class AABB_polyhedron_triangle_primitive - - - -} // end namespace CGAL - -#include - -#endif // CGAL_AABB_POLYHEDRON_TRIANGLE_PRIMITIVE_H_ 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 ec8e46e14686..696d3c9b31ab 100644 --- a/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_polyline_segment_primitive_2.h @@ -97,12 +97,9 @@ namespace internal { * * \sa `AABBPrimitive` * \sa `AABB_primitive` - * \sa `AABB_segment_primitive_2` - * \sa `AABB_segment_primitive_3` - * \sa `AABB_triangle_primitive_2` - * \sa `AABB_triangle_primitive_3` - * \sa `AABB_halfedge_graph_segment_primitive` - * \sa `AABB_face_graph_triangle_primitive` + * \sa `AABB_segment_primitive_2` + * \sa `AABB_segment_primitive_3` + * \sa `AABB_halfedge_graph_segment_primitive` */ template < class GeomTraits, class Iterator, diff --git a/AABB_tree/include/CGAL/AABB_primitive.h b/AABB_tree/include/CGAL/AABB_primitive.h index c08a31898136..de71fb89b8ef 100644 --- a/AABB_tree/include/CGAL/AABB_primitive.h +++ b/AABB_tree/include/CGAL/AABB_primitive.h @@ -71,12 +71,12 @@ struct AABB_primitive_base * it is constructed on the fly to reduce the memory footprint. * The default is `CGAL::Tag_false` (datum is not stored). * - * \sa `AABB_segment_primitive_2` - * \sa `AABB_segment_primitive_3` - * \sa `AABB_triangle_primitive_2` - * \sa `AABB_triangle_primitive_3` - * \sa `AABB_halfedge_graph_segment_primitive` - * \sa `AABB_face_graph_triangle_primitive` + * \sa `AABB_segment_primitive_2` + * \sa `AABB_segment_primitive_3` + * \sa `AABB_triangle_primitive_2` + * \sa `AABB_triangle_primitive_3` + * \sa `AABB_halfedge_graph_segment_primitive` + * \sa `AABB_face_graph_triangle_primitive` */ template < class Id, class ObjectPropertyMap, diff --git a/AABB_tree/include/CGAL/AABB_segment_primitive_2.h b/AABB_tree/include/CGAL/AABB_segment_primitive_2.h index 55ef73397f3c..71e76f72cdee 100644 --- a/AABB_tree/include/CGAL/AABB_segment_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_segment_primitive_2.h @@ -67,11 +67,8 @@ namespace internal { * * \sa `AABBPrimitive` * \sa `AABB_primitive` - * \sa `AABB_segment_primitive_3` - * \sa `AABB_triangle_primitive_2` - * \sa `AABB_triangle_primitive_3` - * \sa `AABB_halfedge_graph_segment_primitive` - * \sa `AABB_face_graph_triangle_primitive` + * \sa `AABB_segment_primitive_3` + * \sa `AABB_triangle_primitive_2` */ template < class GeomTraits, class Iterator, diff --git a/AABB_tree/include/CGAL/AABB_segment_primitive_3.h b/AABB_tree/include/CGAL/AABB_segment_primitive_3.h index 38f880e0f6d2..a1af115ae28b 100644 --- a/AABB_tree/include/CGAL/AABB_segment_primitive_3.h +++ b/AABB_tree/include/CGAL/AABB_segment_primitive_3.h @@ -67,11 +67,9 @@ namespace internal { * * \sa `AABBPrimitive` * \sa `AABB_primitive` - * \sa `AABB_segment_primitive_2` - * \sa `AABB_triangle_primitive_2` - * \sa `AABB_triangle_primitive_3` - * \sa `AABB_halfedge_graph_segment_primitive` - * \sa `AABB_face_graph_triangle_primitive` + * \sa `AABB_segment_primitive_2` + * \sa `AABB_triangle_primitive_3` + * \sa `AABB_halfedge_graph_segment_primitive` */ template < class GeomTraits, class Iterator, diff --git a/AABB_tree/include/CGAL/AABB_triangle_primitive_2.h b/AABB_tree/include/CGAL/AABB_triangle_primitive_2.h index a371ca96196a..0472b4ab08a1 100644 --- a/AABB_tree/include/CGAL/AABB_triangle_primitive_2.h +++ b/AABB_tree/include/CGAL/AABB_triangle_primitive_2.h @@ -68,9 +68,8 @@ namespace internal { * * \sa `AABBPrimitive` * \sa `AABB_primitive` - * \sa `AABB_segment_primitive_2` - * \sa `AABB_halfedge_graph_segment_primitive` - * \sa `AABB_face_graph_triangle_primitive` + * \sa `AABB_segment_primitive_2` + * \sa `AABB_triangle_primitive_3` */ template < class GeomTraits, class Iterator, diff --git a/AABB_tree/include/CGAL/AABB_triangle_primitive_3.h b/AABB_tree/include/CGAL/AABB_triangle_primitive_3.h index 8c1116f45109..0b709d855d6b 100644 --- a/AABB_tree/include/CGAL/AABB_triangle_primitive_3.h +++ b/AABB_tree/include/CGAL/AABB_triangle_primitive_3.h @@ -68,9 +68,9 @@ namespace internal { * * \sa `AABBPrimitive` * \sa `AABB_primitive` - * \sa `AABB_segment_primitive_3` - * \sa `AABB_halfedge_graph_segment_primitive` - * \sa `AABB_face_graph_triangle_primitive` + * \sa `AABB_segment_primitive_3` + * \sa `AABB_triangle_primitive_2` + * \sa `AABB_face_graph_triangle_primitive` */ template < class GeomTraits, class Iterator, From 8cd4e299d454ce7f33c9f8d797803b909c37d862 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Wed, 17 Apr 2024 14:57:33 +0200 Subject: [PATCH 093/100] update doc --- AABB_tree/doc/AABB_tree/aabb_tree.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/aabb_tree.txt b/AABB_tree/doc/AABB_tree/aabb_tree.txt index fd9f2292bf2f..fce1e4ba3ac6 100644 --- a/AABB_tree/doc/AABB_tree/aabb_tree.txt +++ b/AABB_tree/doc/AABB_tree/aabb_tree.txt @@ -123,7 +123,7 @@ the squared distance from a point query. \subsection aabb_tree_examples_2 Tree of Polyhedron Triangle Facets for Intersection Queries - In the following example the AABB primitive wraps a facet handle of a +In the following example the AABB primitive wraps a facet handle of a triangle polyhedral surface as `id` and the corresponding 3D triangle as geometric object. From a segment query we test the intersections, then compute the number of intersections, compute the @@ -238,7 +238,7 @@ subdivision scheme which multiplies the number of triangles by four. \subsection aabb_tree_perf_mem Memory When using the polyhedron triangle facet primitive (defined in -`AABB_polyhedron_triangle_primitive.h`) the AABB tree occupies +`AABB_face_graph_triangle_primitive.h`) the AABB tree occupies approximately 61 bytes per primitive (without constructing the internal KD-tree). It increases to approximately 150 bytes per primitive when constructing the internal KD-tree with one reference From 2c41686943dec1c003a7967170b95580f0e46cdf Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Wed, 17 Apr 2024 17:12:21 +0200 Subject: [PATCH 094/100] added tests for untested aabb primitives --- .../AABB_indexed_triangle_2_example.cpp | 16 ++-- .../AABB_polyline_segment_2_example.cpp | 4 +- .../AABB_tree/AABB_segment_2_example.cpp | 2 +- .../AABB_tree/AABB_triangle_3_example.cpp | 2 +- .../aabb_test_indexed_triangle_2.cpp | 88 +++++++++++++++++++ .../aabb_test_polyline_segment_2.cpp | 66 ++++++++++++++ .../test/AABB_tree/aabb_test_segment_2.cpp | 58 ++++++++++++ .../test/AABB_tree/aabb_test_triangle_2.cpp | 50 +++++++++++ .../test/AABB_tree/aabb_test_triangle_3.cpp | 49 +++++++++++ 9 files changed, 323 insertions(+), 12 deletions(-) create mode 100644 AABB_tree/test/AABB_tree/aabb_test_indexed_triangle_2.cpp create mode 100644 AABB_tree/test/AABB_tree/aabb_test_polyline_segment_2.cpp create mode 100644 AABB_tree/test/AABB_tree/aabb_test_segment_2.cpp create mode 100644 AABB_tree/test/AABB_tree/aabb_test_triangle_2.cpp create mode 100644 AABB_tree/test/AABB_tree/aabb_test_triangle_3.cpp diff --git a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp index c8979d6ae950..053c49467a48 100644 --- a/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_indexed_triangle_2_example.cpp @@ -30,7 +30,7 @@ struct Projection_xy_point_map { } }; -typedef std::vector >::iterator IndexIterator; +typedef std::vector >::const_iterator IndexIterator; typedef std::vector PointRange; typedef CGAL::AABB_indexed_triangle_primitive_2> Primitive; typedef CGAL::AABB_traits_2 AABB_triangle_traits; @@ -61,17 +61,17 @@ int main() // point sampling Point_and_primitive_id id; id = tree.closest_point_and_primitive(Point_2(0.5, 0.4)); - std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; + std::cout << std::distance(triangles.cbegin(), id.second) << ". triangle" << std::endl; id = tree.closest_point_and_primitive(Point_2(0.5, 0.6)); - std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; + std::cout << std::distance(triangles.cbegin(), id.second) << ". triangle" << std::endl; id = tree.closest_point_and_primitive(Point_2(1.5, 0.5)); - std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; + std::cout << std::distance(triangles.cbegin(), id.second) << ". triangle" << std::endl; id = tree.closest_point_and_primitive(Point_2(1.5, 0.6)); - std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; + std::cout << std::distance(triangles.cbegin(), id.second) << ". triangle" << std::endl; id = tree.closest_point_and_primitive(Point_2(1.0, 0.0)); - std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; + std::cout << std::distance(triangles.cbegin(), id.second) << ". triangle" << std::endl; id = tree.closest_point_and_primitive(Point_2(3.0, 0.5)); - std::cout << std::distance(triangles.begin(), id.second) << ". triangle" << std::endl; + std::cout << std::distance(triangles.cbegin(), id.second) << ". triangle" << std::endl; Ray ray(Point_2(5.5, 0.5), Point_2(1.5, 0.5)); Ray_intersection intersection = tree.first_intersection(ray); @@ -81,7 +81,7 @@ int main() return EXIT_FAILURE; } else { - std::cout << std::distance(triangles.begin(), intersection->second) << ". triangle" << std::endl; + std::cout << std::distance(triangles.cbegin(), intersection->second) << ". triangle" << std::endl; } std::list intersections; diff --git a/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp index af4d4dcdd186..74d2f6c03210 100644 --- a/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_polyline_segment_2_example.cpp @@ -14,14 +14,14 @@ typedef K::Segment_2 Segment; typedef K::Point_2 Point; typedef std::vector PointRange; -typedef PointRange::iterator Iterator_pr; +typedef PointRange::const_iterator Iterator_pr; typedef CGAL::AABB_polyline_segment_primitive_2 Primitive_pr; typedef CGAL::AABB_traits_2 Traits_pr; typedef CGAL::AABB_tree Tree_pr; typedef Tree_pr::Point_and_primitive_id Point_and_primitive_id_pr; typedef CGAL::Polygon_2 Polygon_2; -typedef Polygon_2::iterator Iterator_poly; +typedef Polygon_2::const_iterator Iterator_poly; typedef CGAL::AABB_polyline_segment_primitive_2 Primitive_poly; typedef CGAL::AABB_traits_2 Traits_poly; typedef CGAL::AABB_tree Tree_poly; diff --git a/AABB_tree/examples/AABB_tree/AABB_segment_2_example.cpp b/AABB_tree/examples/AABB_tree/AABB_segment_2_example.cpp index 25d77f1ac8a6..a599f01ff6c2 100644 --- a/AABB_tree/examples/AABB_tree/AABB_segment_2_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_segment_2_example.cpp @@ -14,7 +14,7 @@ typedef K::Segment_2 Segment; typedef K::Point_2 Point; typedef std::list SegmentRange; -typedef SegmentRange::iterator Iterator; +typedef SegmentRange::const_iterator Iterator; typedef CGAL::AABB_segment_primitive_2 Primitive; typedef CGAL::AABB_traits_2 Traits; typedef CGAL::AABB_tree Tree; diff --git a/AABB_tree/examples/AABB_tree/AABB_triangle_3_example.cpp b/AABB_tree/examples/AABB_tree/AABB_triangle_3_example.cpp index 5bafd37873a0..6b963379b3bd 100644 --- a/AABB_tree/examples/AABB_tree/AABB_triangle_3_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_triangle_3_example.cpp @@ -15,7 +15,7 @@ typedef K::Ray_3 Ray; typedef K::Point_3 Point; typedef K::Triangle_3 Triangle; -typedef std::list::iterator Iterator; +typedef std::list::const_iterator Iterator; typedef CGAL::AABB_triangle_primitive_3 Primitive; typedef CGAL::AABB_traits_3 AABB_triangle_traits; typedef CGAL::AABB_tree Tree; diff --git a/AABB_tree/test/AABB_tree/aabb_test_indexed_triangle_2.cpp b/AABB_tree/test/AABB_tree/aabb_test_indexed_triangle_2.cpp new file mode 100644 index 000000000000..8ef740118db0 --- /dev/null +++ b/AABB_tree/test/AABB_tree/aabb_test_indexed_triangle_2.cpp @@ -0,0 +1,88 @@ +#include +#include +#include + +#include +#include +#include +#include + +typedef CGAL::Simple_cartesian K; +typedef K::Point_3 Point_3; +typedef K::Point_2 Point_2; +typedef K::Ray_2 Ray; + +template +struct Projection_xy_point_map { + + typedef typename GeomTraits::Point_3 key_type; + typedef typename GeomTraits::Point_2 value_type; + typedef value_type reference; + + typedef boost::readable_property_map_tag category; + typedef Projection_xy_point_map Self; + + Projection_xy_point_map() {} + + inline friend value_type get(Self, key_type p) + { + return value_type(p.x(), p.y()); + } +}; + +typedef std::vector >::const_iterator IndexIterator; +typedef std::vector PointRange; +typedef CGAL::AABB_indexed_triangle_primitive_2> Primitive; +typedef CGAL::AABB_traits_2 AABB_triangle_traits; +typedef CGAL::AABB_tree Tree; +typedef Tree::Point_and_primitive_id Point_and_primitive_id; +typedef std::optional::Type> Ray_intersection; + +int main() +{ + Point_3 a(0.0, 0.0, 0.0); + Point_3 b(0.0, 1.0, 0.0); + Point_3 c(1.0, 0.0, 0.0); + Point_3 d(1.0, 1.0, 0.0); + Point_3 e(2.0, 0.0, 0.0); + Point_3 f(2.0, 1.0, 0.0); + + std::vector points = { a, b, c, d, e, f }; + + std::vector > triangles; + triangles.push_back({ 0, 2, 1 }); + triangles.push_back({ 1, 2, 3 }); + triangles.push_back({ 3, 2, 4 }); + triangles.push_back({ 3, 4, 5 }); + + // constructs AABB tree + Tree tree(triangles.begin(), triangles.end(), points); + + // point sampling + Point_and_primitive_id id; + id = tree.closest_point_and_primitive(Point_2(0.5, 0.4)); + assert(std::distance(triangles.cbegin(), id.second) == 0); + id = tree.closest_point_and_primitive(Point_2(0.5, 0.6)); + assert(std::distance(triangles.cbegin(), id.second) == 1); + id = tree.closest_point_and_primitive(Point_2(1.5, 0.5)); + assert(std::distance(triangles.cbegin(), id.second) == 2); + id = tree.closest_point_and_primitive(Point_2(1.5, 0.6)); + assert(std::distance(triangles.cbegin(), id.second) == 3); + id = tree.closest_point_and_primitive(Point_2(1.0, 0.0)); + assert(std::distance(triangles.cbegin(), id.second) == 0); + id = tree.closest_point_and_primitive(Point_2(3.0, 0.5)); + assert(std::distance(triangles.cbegin(), id.second) == 3); + + Ray ray(Point_2(5.5, 0.5), Point_2(1.5, 0.5)); + Ray_intersection intersection = tree.first_intersection(ray); + + assert(intersection.has_value()); + + assert(std::distance(triangles.cbegin(), intersection->second) == 3); + + std::list intersections; + tree.all_intersections(ray, std::back_inserter(intersections)); + assert(intersections.size() == 4); + + return EXIT_SUCCESS; +} diff --git a/AABB_tree/test/AABB_tree/aabb_test_polyline_segment_2.cpp b/AABB_tree/test/AABB_tree/aabb_test_polyline_segment_2.cpp new file mode 100644 index 000000000000..63df363e357b --- /dev/null +++ b/AABB_tree/test/AABB_tree/aabb_test_polyline_segment_2.cpp @@ -0,0 +1,66 @@ +#include +#include + +#include +#include +#include +#include +#include +#include + +typedef CGAL::Simple_cartesian K; +typedef K::Segment_2 Segment; +typedef K::Point_2 Point; + +typedef std::vector PointRange; +typedef PointRange::const_iterator Iterator_pr; +typedef CGAL::AABB_polyline_segment_primitive_2 Primitive_pr; +typedef CGAL::AABB_traits_2 Traits_pr; +typedef CGAL::AABB_tree Tree_pr; +typedef Tree_pr::Point_and_primitive_id Point_and_primitive_id_pr; + +typedef CGAL::Polygon_2 Polygon_2; +typedef Polygon_2::const_iterator Iterator_poly; +typedef CGAL::AABB_polyline_segment_primitive_2 Primitive_poly; +typedef CGAL::AABB_traits_2 Traits_poly; +typedef CGAL::AABB_tree Tree_poly; +typedef Tree_poly::Point_and_primitive_id Point_and_primitive_id_poly; + +template +void test(AABBTree tree) { + tree.build(); + + tree.accelerate_distance_queries(); + + // counts #intersections with a segment query + Segment segment_query(Point(1.0, 0.0), Point(0.0, 7.0)); + + assert(tree.number_of_intersected_primitives(segment_query) == 2); + + // computes the closest point from a point query + Point point_query(4.0, 5.0); + Point closest = tree.closest_point(point_query); + assert(closest == Point(3.0, 4.0)); + + PPId id = tree.closest_point_and_primitive(point_query); + assert(id.first == closest); +} + +int main() +{ + Point a(0.0, 0.0); + Point b(2.0, 1.0); + Point c(3.0, 4.0); + Point d(1.0, 6.0); + Point e(-1.0, 3.0); + + std::vector polyline = { a, b, c, d, e }; + + Polygon_2 poly(polyline.begin(), polyline.end()); + + test(Tree_poly(poly.begin(), poly.end(), poly)); + + test(Tree_pr(polyline.begin(), std::prev(polyline.end()), polyline)); + + return EXIT_SUCCESS; +} diff --git a/AABB_tree/test/AABB_tree/aabb_test_segment_2.cpp b/AABB_tree/test/AABB_tree/aabb_test_segment_2.cpp new file mode 100644 index 000000000000..2ccfa1f2f973 --- /dev/null +++ b/AABB_tree/test/AABB_tree/aabb_test_segment_2.cpp @@ -0,0 +1,58 @@ +#include +#include + +#include +#include +#include +#include +#include + +typedef CGAL::Simple_cartesian K; + +typedef K::FT FT; +typedef K::Segment_2 Segment; +typedef K::Point_2 Point; + +typedef std::list SegmentRange; +typedef SegmentRange::const_iterator Iterator; +typedef CGAL::AABB_segment_primitive_2 Primitive; +typedef CGAL::AABB_traits_2 Traits; +typedef CGAL::AABB_tree Tree; +typedef Tree::Point_and_primitive_id Point_and_primitive_id; + +int main() +{ + Point a(0.0, 0.0); + Point b(2.0, 1.0); + Point c(3.0, 4.0); + Point d(1.0, 6.0); + Point e(-1.0, 3.0); + + std::list seg; + seg.push_back(Segment(a, b)); + seg.push_back(Segment(b, c)); + seg.push_back(Segment(c, d)); + seg.push_back(Segment(d, e)); + seg.push_back(Segment(e, a)); + + // constructs the AABB tree and the internal search tree for + // efficient distance computations. + Tree tree(seg.begin(), seg.end()); + tree.build(); + + tree.accelerate_distance_queries(); + + // counts #intersections with a segment query + Segment segment_query(Point(1.0, 0.0), Point(0.0, 7.0)); + assert(tree.number_of_intersected_primitives(segment_query) == 2); + + // computes the closest point from a point query + Point point_query(5.0, 5.0); + Point closest = tree.closest_point(point_query); + assert(closest == c); + + Point_and_primitive_id id = tree.closest_point_and_primitive(Point(1.5, 3.0)); + assert(id.second->source() == b && id.second->target() == c); + + return EXIT_SUCCESS; +} diff --git a/AABB_tree/test/AABB_tree/aabb_test_triangle_2.cpp b/AABB_tree/test/AABB_tree/aabb_test_triangle_2.cpp new file mode 100644 index 000000000000..ede2cc4d2af1 --- /dev/null +++ b/AABB_tree/test/AABB_tree/aabb_test_triangle_2.cpp @@ -0,0 +1,50 @@ +// Author(s) : Camille Wormser, Pierre Alliez + +#include +#include + +#include +#include +#include +#include + +typedef CGAL::Simple_cartesian K; + +typedef K::FT FT; +typedef K::Ray_2 Ray; +typedef K::Point_2 Point; +typedef K::Triangle_2 Triangle; + +typedef std::list::const_iterator Iterator; +typedef CGAL::AABB_triangle_primitive_2 Primitive; +typedef CGAL::AABB_traits_2 AABB_triangle_traits; +typedef CGAL::AABB_tree Tree; + +int main() +{ + Point a(1.0, 0.0); + Point b(0.0, 1.0); + Point c(1.0, 1.0); + Point d(0.0, 0.0); + + std::list triangles; + triangles.push_back(Triangle(a, b, c)); + triangles.push_back(Triangle(a, b, d)); + triangles.push_back(Triangle(a, d, c)); + + // constructs AABB tree + Tree tree(triangles.begin(), triangles.end()); + + // counts #intersections + Ray ray_query(a, b); + assert(tree.number_of_intersected_primitives(ray_query) == 3); + + // compute closest point and squared distance + Point point_query(2.0, 2.0); + Point closest_point = tree.closest_point(point_query); + assert(closest_point == c); + + assert(tree.squared_distance(point_query) == 2); + + return EXIT_SUCCESS; +} diff --git a/AABB_tree/test/AABB_tree/aabb_test_triangle_3.cpp b/AABB_tree/test/AABB_tree/aabb_test_triangle_3.cpp new file mode 100644 index 000000000000..12c2366260e3 --- /dev/null +++ b/AABB_tree/test/AABB_tree/aabb_test_triangle_3.cpp @@ -0,0 +1,49 @@ +// Author(s) : Camille Wormser, Pierre Alliez + +#include +#include + +#include +#include +#include +#include + +typedef CGAL::Simple_cartesian K; + +typedef K::FT FT; +typedef K::Ray_3 Ray; +typedef K::Point_3 Point; +typedef K::Triangle_3 Triangle; + +typedef std::list::const_iterator Iterator; +typedef CGAL::AABB_triangle_primitive_3 Primitive; +typedef CGAL::AABB_traits_3 AABB_triangle_traits; +typedef CGAL::AABB_tree Tree; + +int main() +{ + Point a(1.0, 0.0, 0.0); + Point b(0.0, 1.0, 0.0); + Point c(0.0, 0.0, 1.0); + Point d(0.0, 0.0, 0.0); + + std::list triangles; + triangles.push_back(Triangle(a, b, c)); + triangles.push_back(Triangle(a, b, d)); + triangles.push_back(Triangle(a, d, c)); + + // constructs AABB tree + Tree tree(triangles.begin(), triangles.end()); + + // counts #intersections + Ray ray_query(a, b); + assert(tree.number_of_intersected_primitives(ray_query) == 3); + + // compute closest point and squared distance + Point point_query(3.0, 2.0, 2.0); + Point closest_point = tree.closest_point(point_query); + assert(closest_point == a); + assert(tree.squared_distance(point_query) == 12); + + return EXIT_SUCCESS; +} From 0439ea29fa1e693cb683340f03c05780238e00fd Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 18 Apr 2024 08:13:36 +0200 Subject: [PATCH 095/100] fix warnings --- .../test/AABB_tree/aabb_deprecated_triangle_primitive_test.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AABB_tree/test/AABB_tree/aabb_deprecated_triangle_primitive_test.cpp b/AABB_tree/test/AABB_tree/aabb_deprecated_triangle_primitive_test.cpp index 2847c6aad367..4881e0a8f8b4 100644 --- a/AABB_tree/test/AABB_tree/aabb_deprecated_triangle_primitive_test.cpp +++ b/AABB_tree/test/AABB_tree/aabb_deprecated_triangle_primitive_test.cpp @@ -42,7 +42,10 @@ int main() // compute closest point and squared distance Point point_query(2.0, 2.0, 2.0); Point closest_point = tree.closest_point(point_query); + std::cout << closest_point << std::endl; + FT sqd = tree.squared_distance(point_query); + std::cout << sqd << std::endl; return EXIT_SUCCESS; } From a5e78368937523946eaa7e930d3b147d1df48588 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 18 Apr 2024 08:17:06 +0200 Subject: [PATCH 096/100] fix test --- AABB_tree/test/AABB_tree/aabb_test_indexed_triangle_2.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/AABB_tree/test/AABB_tree/aabb_test_indexed_triangle_2.cpp b/AABB_tree/test/AABB_tree/aabb_test_indexed_triangle_2.cpp index 8ef740118db0..3f7b5fc5bb1f 100644 --- a/AABB_tree/test/AABB_tree/aabb_test_indexed_triangle_2.cpp +++ b/AABB_tree/test/AABB_tree/aabb_test_indexed_triangle_2.cpp @@ -64,16 +64,14 @@ int main() assert(std::distance(triangles.cbegin(), id.second) == 0); id = tree.closest_point_and_primitive(Point_2(0.5, 0.6)); assert(std::distance(triangles.cbegin(), id.second) == 1); - id = tree.closest_point_and_primitive(Point_2(1.5, 0.5)); + id = tree.closest_point_and_primitive(Point_2(1.5, 0.4)); assert(std::distance(triangles.cbegin(), id.second) == 2); id = tree.closest_point_and_primitive(Point_2(1.5, 0.6)); assert(std::distance(triangles.cbegin(), id.second) == 3); - id = tree.closest_point_and_primitive(Point_2(1.0, 0.0)); - assert(std::distance(triangles.cbegin(), id.second) == 0); id = tree.closest_point_and_primitive(Point_2(3.0, 0.5)); assert(std::distance(triangles.cbegin(), id.second) == 3); - Ray ray(Point_2(5.5, 0.5), Point_2(1.5, 0.5)); + Ray ray(Point_2(5.5, 0.5), Point_2(1.5, 0.4)); Ray_intersection intersection = tree.first_intersection(ray); assert(intersection.has_value()); From b49b2a8def68b16a3c1a1923ce4f5624b8340e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 22 Apr 2024 14:15:16 +0200 Subject: [PATCH 097/100] update history --- AABB_tree/doc/AABB_tree/aabb_tree.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/aabb_tree.txt b/AABB_tree/doc/AABB_tree/aabb_tree.txt index fce1e4ba3ac6..ca5f84e2fbfa 100644 --- a/AABB_tree/doc/AABB_tree/aabb_tree.txt +++ b/AABB_tree/doc/AABB_tree/aabb_tree.txt @@ -442,9 +442,14 @@ implementing both intersection and distance queries, and for generic queries and primitives was developed by Camille Wormser. In 2009, Pierre Alliez, Stéphane Tayeb and Camille Wormser made the implementation CGAL-compliant, with the help of Laurent Rineau for -optimizing the tree construction. The authors wish to thank Andreas -Fabri, Jane Tournois, Mariette Yvinec and Sylvain Lefèbvre for -helpful comments and discussions. +optimizing the tree construction. Additionally, Andreas +Fabri, Jane Tournois, Mariette Yvinec and Sylvain Lefèbvre are +given thanks for helpful comments and discussions during that period. +Later, Sébastien Loriot contributed several improvements: +thread-safe queries, introduction of shared data stored in the traits +for lighter primitive types, ... +In 2024, the package was made compatible with 2D and 3D primitives by +Andreas Fabri, Sébastien Loriot, and Sven Oesau. */ From 696683ff49f70bbcdd088882db7756370cae07e9 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Mon, 22 Apr 2024 15:20:16 +0200 Subject: [PATCH 098/100] Apply suggestions from code review Co-authored-by: Mael --- .../doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h | 5 ++--- .../doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h index b193d505fbd1..15e3050edee5 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_2.h @@ -1,12 +1,11 @@ -3 /*! \ingroup PkgAABBTreeConcepts \cgalConcept The concept `AABBRayIntersectionGeomTraits_2` is a refinement of the -concept `AABBGeomTraits_2`. In addition to the types required by +concept `AABBGeomTraits_2`. In addition to the types and functors required by `AABBGeomTraits_2` it also requires types and functors necessary to -define the Intersection_distance functor. +define the Intersection_distance functor (see `AABBRayIntersectionTraits`). \cgalRefines{AABBGeomTraits_2} diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h index 84ef6de2260e..1f6468c52b78 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h @@ -47,7 +47,7 @@ class AABBRayIntersectionGeomTraits_3 { typedef unspecified_type Cartesian_const_iterator_3; /*! - A model of `ConstructCartesianConstIterator_33`. + A model of `ConstructCartesianConstIterator_3`. */ typedef unspecified_type Construct_cartesian_const_iterator_3; From 4f5bcc6bbfec5b0556fb48b88a7d277c36cb89be Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 25 Apr 2024 09:05:41 +0200 Subject: [PATCH 099/100] doc fixes --- AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h | 2 +- AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h | 2 +- .../doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h index 797b7451df7e..82ab0e5a2e0c 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_2.h @@ -54,7 +54,7 @@ must be a `std::optional` of a `std::variant` of the possible intersection types typedef unspecified_type Intersect_2; /*! -A functor object to construct the circle centered at one point and passing through another one. +A functor object to construct the circle specified by its center and squared radius. Provides the operator: `Circle_2 operator()(const Point_2& p, const FT & sr)`, diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h index affafe8609a7..2f453f54670b 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits_3.h @@ -54,7 +54,7 @@ must be a `std::optional` of a `std::variant` of the possible intersection types typedef unspecified_type Intersect_3; /*! -A functor object to construct the sphere centered at one point and passing through another one. +A functor object to construct the sphere specified by its center and squared radius. Provides the operator: `Sphere_3 operator()(const Point_3& p, const FT & sr)`, diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h index 1f6468c52b78..508b656d1cd2 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionGeomTraits_3.h @@ -42,7 +42,7 @@ class AABBRayIntersectionGeomTraits_3 { Construct_source_3 construct_source_3_object(); /*! - A model of `CartesianConstIterator3`. + A model of `CartesianConstIterator_3`. */ typedef unspecified_type Cartesian_const_iterator_3; From 6727f780e82db755432cf5277c71cc5b6cf312c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 2 May 2024 11:00:09 +0200 Subject: [PATCH 100/100] Fix tiny doc issues --- AABB_tree/include/CGAL/AABB_traits_2.h | 4 ++-- AABB_tree/include/CGAL/AABB_traits_3.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_traits_2.h b/AABB_tree/include/CGAL/AABB_traits_2.h index 673ead172fbb..fe863e2d0084 100644 --- a/AABB_tree/include/CGAL/AABB_traits_2.h +++ b/AABB_tree/include/CGAL/AABB_traits_2.h @@ -37,7 +37,7 @@ namespace CGAL { namespace internal{ namespace AABB_tree { -// AABB_traits_intersection_base brings in the Intersection_distance predicate, +// AABB_traits_intersection_base_2 brings in the Intersection_distance predicate, // if GeomTraits is a model RayIntersectionGeomTraits. template ::value> struct AABB_traits_intersection_base_2; @@ -74,7 +74,7 @@ struct AABB_traits_intersection_base_2{ } // Defining Bounding_box and other types from the full AABB_traits_2 - // here is might seem strange, but otherwise we would need to use + // here might seem strange, but otherwise we would need to use // CRTP to get access to the derived class, which would bloat the // code more. typedef typename CGAL::Bbox_2 Bounding_box; diff --git a/AABB_tree/include/CGAL/AABB_traits_3.h b/AABB_tree/include/CGAL/AABB_traits_3.h index 52757a358472..30a3fa77cd3f 100644 --- a/AABB_tree/include/CGAL/AABB_traits_3.h +++ b/AABB_tree/include/CGAL/AABB_traits_3.h @@ -57,7 +57,7 @@ struct AABB_traits_intersection_base_3 { typedef typename GeomTraits::FT FT; // Defining Bounding_box and other types from the full AABB_traits_3 - // here is might seem strange, but otherwise we would need to use + // here might seem strange, but otherwise we would need to use // CRTP to get access to the derived class, which would bloat the // code more. typedef typename CGAL::Bbox_3 Bounding_box;