Merge remote-tracking branch 'cgal/master'

This commit is contained in:
Sébastien Loriot 2024-05-24 14:18:24 +02:00
commit ddbd2e6818
1199 changed files with 389907 additions and 13507 deletions

4
.github/test.sh vendored
View File

@ -2,8 +2,8 @@
/usr/local/bin/cmake --version
FACTOR=$1
set -ex
cd Polyhedron/demo
/usr/local/bin/cmake -S Polyhedron -B build -DCGAL_DIR=$2
cd Lab/demo
/usr/local/bin/cmake -S Lab -B build -DCGAL_DIR=$2
LIST_OF_PLUGINS=$(/usr/local/bin/cmake --build build -t help | egrep 'plugin$' |& cut -d\ -f2)
PLUGINS_ARRAY=(${LIST_OF_PLUGINS});
NB_OF_PLUGINS=${#PLUGINS_ARRAY[@]}

View File

@ -1,4 +1,4 @@
name: Test Polyhedron Demo
name: Compile CGAL Lab
on: [push, pull_request,workflow_dispatch]

View File

@ -1,4 +1,4 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/intersection.h>
@ -6,8 +6,8 @@
#include <CGAL/boost/graph/copy_face_graph.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/Polygon_mesh_processing/internal/AABB_do_intersect_transform_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Rigid_triangle_mesh_collision_detection.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/Side_of_triangle_mesh.h>
@ -18,12 +18,12 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Surface_mesh;
typedef CGAL::AABB_face_graph_triangle_primitive<Surface_mesh> Primitive;
typedef CGAL::AABB_do_intersect_transform_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> 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);
@ -33,7 +33,7 @@ void naive_test(int k, const char* fname,
CGAL::Aff_transformation_3<K> init1(CGAL::SCALING, 6.0);
PMP::transform(init1, tm);
CGAL::Bbox_3 box = PMP::bbox(tm);
typedef CGAL::AABB_tree<CGAL::AABB_traits<K, Primitive> > Tree;
Tree tmTree(tm.faces_begin(), tm.faces_end(), tm);
Tree tmTree2(tm2.faces_begin(), tm2.faces_end(), tm2);
CGAL::Aff_transformation_3<K> init2(CGAL::TRANSLATION, - K::Vector_3(
@ -86,7 +86,8 @@ void naive_test(int k, const char* fname,
T0 = CGAL::Aff_transformation_3<K>(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);
@ -97,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<K> init2(CGAL::TRANSLATION, - K::Vector_3(
(box.xmax()-box.xmin()),0,0));
PMP::transform(init2, tm2);
tmTree.build();
@ -113,6 +116,12 @@ void test_no_collision(int k, const char* fname,
CGAL::Side_of_triangle_mesh<Surface_mesh, K,
VPM, Tree> sotm1(tmTree);
CGAL::Rigid_triangle_mesh_collision_detection<Surface_mesh> collision_detection;
collision_detection.add_mesh(tm);
collision_detection.add_mesh(tm2);
for(int i=1; i<k+1; ++i)
{
K::FT rot[9];
@ -130,34 +139,24 @@ void test_no_collision(int k, const char* fname,
rot[6], rot[7], rot[8]);
CGAL::Aff_transformation_3<K> T1 = CGAL::Aff_transformation_3<K>(CGAL::TRANSLATION, i*unit_vec);
CGAL::Aff_transformation_3<K> 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<std::size_t, bool> > 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<Surface_mesh, K,
VPM, Tree> 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 "<<path<<std::endl;
int nb_inter(0), nb_no_inter(0), nb_include(0),
@ -165,12 +164,12 @@ int main(int argc, const char** argv)
auto start = std::chrono::steady_clock::now();
naive_test(k, path, naive_inter, naive_no_inter, naive_include);
auto end = std::chrono::steady_clock::now();
std::cout<<"Naive test :"<<naive_inter<<" collisions, "<<naive_include<<" inclusions, "<<naive_no_inter<<" no collision, calculated in "
<<std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() << "μs." << std::endl;
std::cout<<"Naive test : "<<naive_inter<<" collisions, "<<naive_include<<" inclusions, "<<naive_no_inter<<" no collision, calculated in "
<<std::chrono::duration_cast<std::chrono::milliseconds>(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: "<<nb_inter<<" collisions, "<<nb_include<<" inclusions, "<<nb_no_inter<<" no collision, calculated in "
<<std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() << "μs." << std::endl;
<<std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << " ms." << std::endl;
return 0;
}

View File

@ -867,7 +867,7 @@ void Scene::generate_points_in(const unsigned int nb_points,
}
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
typedef CGAL::AABB_traits_3<Kernel, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> 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<Polyhedron> Primitive;
typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
typedef CGAL::AABB_traits_3<Kernel, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> 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<Polyhedron> Primitive;
typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
typedef CGAL::AABB_traits_3<Kernel, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> 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<Polyhedron> Primitive;
typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
typedef CGAL::AABB_traits_3<Kernel, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> 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<Polyhedron> Primitive;
typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
typedef CGAL::AABB_traits_3<Kernel, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef Tree::Object_and_primitive_id Object_and_primitive_id;

View File

@ -9,7 +9,7 @@
#include "Color_ramp.h"
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
#include <CGAL/AABB_halfedge_graph_segment_primitive.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
@ -62,11 +62,11 @@ public:
private:
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Facet_Primitive;
typedef CGAL::AABB_traits<Kernel, Facet_Primitive> Facet_Traits;
typedef CGAL::AABB_traits_3<Kernel, Facet_Primitive> Facet_Traits;
typedef CGAL::AABB_tree<Facet_Traits> Facet_tree;
typedef CGAL::AABB_halfedge_graph_segment_primitive<Polyhedron> Edge_Primitive;
typedef CGAL::AABB_traits<Kernel, Edge_Primitive> Edge_Traits;
typedef CGAL::AABB_traits_3<Kernel, Edge_Primitive> Edge_Traits;
typedef CGAL::AABB_tree<Edge_Traits> Edge_tree;
typedef CGAL::qglviewer::ManipulatedFrame ManipulatedFrame;

View File

@ -0,0 +1,177 @@
/*!
\ingroup PkgAABBTreeConcepts
\cgalConcept
The concept `AABBGeomTraits_2` defines the requirements for the first template parameter of the class
`CGAL::AABB_traits_2<AABBGeomTraits_2, AABBPrimitive>`. 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_2<AABBGeomTraits_2,AABBPrimitive>`
\sa `CGAL::AABB_tree<AABBTraits>`
\sa `AABBPrimitive`
*/
class AABBGeomTraits_2 {
public:
/// \name Types
/// @{
/*!
A functor object to detect intersections between two geometric objects.
Provides the following operators:
`bool operator()(const Query& q, const Bbox_2& b)`,
`bool operator()(const Query& q, const Primitive::Datum& d)`,
`bool operator()(const Circle_2& c, const Bbox_2& b)`.
The operator returns `true` iff there is an 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 specified by its center and squared radius.
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 point.
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`, to the distance between `p1` and `p3`.
*/
typedef unspecified_type Compare_distance_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 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 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 equal predicate.
*/
Equal_2 equal_2_object();
/// @}
}; /* end AABBGeomTraits_2 */

View File

@ -3,8 +3,8 @@
\ingroup PkgAABBTreeConcepts
\cgalConcept
The concept `AABBGeomTraits` defines the requirements for the first template parameter of the class
`CGAL::AABB_traits<AABBGeomTraits, AABBPrimitive>`. 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_3<AABBGeomTraits_3, AABBPrimitive>`. 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<AABBGeomTraits,AABBPrimitive>`
\sa `CGAL::AABB_traits_3<AABBGeomTraits_3,AABBPrimitive>`
\sa `CGAL::AABB_tree<AABBTraits>`
\sa `AABBPrimitive`
*/
class AABBGeomTraits {
class AABBGeomTraits_3 {
public:
/// \name Types
@ -31,13 +31,13 @@ public:
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;
@ -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)`,
@ -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)`,
@ -78,19 +78,10 @@ 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 `p1` and `p3`.
*/
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.
@ -199,5 +186,4 @@ Equal_3 equal_3_object();
/// @}
}; /* end AABBGeomTraits */
}; /* end AABBGeomTraits_3 */

View File

@ -14,8 +14,10 @@ The `Primitive` type can be, e.g., a wrapper around a `Handle`. Assume for insta
\cgalHasModelsBegin
\cgalHasModels{CGAL::AABB_primitive<Id,ObjectPropertyMap,PointPropertyMap,Tag_false,CacheDatum>}
\cgalHasModels{CGAL::AABB_segment_primitive<Iterator,CacheDatum>}
\cgalHasModels{CGAL::AABB_triangle_primitive<Iterator,CacheDatum>}
\cgalHasModels{CGAL::AABB_segment_primitive_2<Iterator,CacheDatum>}
\cgalHasModels{CGAL::AABB_segment_primitive_3<Iterator,CacheDatum>}
\cgalHasModels{CGAL::AABB_triangle_primitive_2<Iterator,CacheDatum>}
\cgalHasModels{CGAL::AABB_triangle_primitive_3<Iterator,CacheDatum>}
\cgalHasModels{CGAL::AABB_halfedge_graph_segment_primitive<HalfedgeGraph,VertexPointPMap,Tag_false,CacheDatum>}
\cgalHasModels{CGAL::AABB_face_graph_triangle_primitive<FaceGraph,VertexPointPMap,Tag_false,CacheDatum>}
\cgalHasModelsEnd
@ -28,7 +30,7 @@ public:
/// @{
/*!
3D point type.
Point type.
*/
typedef unspecified_type Point;
@ -68,7 +70,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();

View File

@ -34,7 +34,7 @@ public:
/// \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);

View File

@ -0,0 +1,69 @@
/*!
\ingroup PkgAABBTreeConcepts
\cgalConcept
The concept `AABBRayIntersectionGeomTraits_2` is a refinement of the
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 (see `AABBRayIntersectionTraits`).
\cgalRefines{AABBGeomTraits_2}
\cgalHasModelsBegin
\cgalHasModelsBare{All models of the concept `Kernel`}
\cgalHasModelsEnd
\sa `CGAL::AABB_traits_2<AABBGeomTraits_2,AABBPrimitive>`
\sa `CGAL::AABB_tree<AABBTraits>`
\sa `AABBPrimitive`
*/
class AABBRayIntersectionGeomTraits_2 {
public:
/*!
Type of a 2D ray.
*/
typedef unspecified_type Ray_2;
/*!
Type of a 2D vector.
*/
typedef unspecified_type Vector_2;
/*!
A functor object to construct the source point of a ray. Provides the operator:
`Point_2 operator()(const Ray_2&);`
*/
typedef unspecified_type Construct_source_2;
/*!
returns the `Construct_source_2` functor.
*/
Construct_source_2 construct_source_2_object();
/*!
A model of `CartesianConstIterator_2`.
*/
typedef unspecified_type Cartesian_const_iterator_2;
/*!
A model of `ConstructCartesianConstIterator_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();
/*!
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;
/*!
returns the `Construct_vector_2` functor.
*/
Construct_vector_2 construct_vector_2_object();
};

View File

@ -2,23 +2,23 @@
\ingroup PkgAABBTreeConcepts
\cgalConcept
The concept `AABBRayIntersectionGeomTraits` 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_3` is a refinement of the
concept `AABBGeomTraits_3`. In addition to the types required by
`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`}
\cgalHasModelsEnd
\sa `CGAL::AABB_traits<AABBGeomTraits,AABBPrimitive>`
\sa `CGAL::AABB_traits_3<AABBGeomTraits_3,AABBPrimitive>`
\sa `CGAL::AABB_tree<AABBTraits>`
\sa `AABBPrimitive`
*/
class AABBRayIntersectionGeomTraits {
class AABBRayIntersectionGeomTraits_3 {
public:
/*!
Type of a 3D ray.
@ -37,30 +37,33 @@ public:
typedef unspecified_type Construct_source_3;
/*!
returns the `Construct_source_3` functor.
*/
Construct_source_3 construct_source_3_object();
/*!
A model of `CartesianConstIterator3`.
A model of `CartesianConstIterator_3`.
*/
typedef unspecified_type Cartesian_const_iterator_3;
/*!
A model of `ConstructCartesianConstIterator3`.
A model of `ConstructCartesianConstIterator_3`.
*/
typedef unspecified_type Construct_cartesian_const_iterator_3;
/*!
returns the `Construct_cartesian_const_iterator_3` functor.
*/
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;
/*!
returns the `Construct_vector_3` functor.
*/
Construct_source_3 construct_vector_3_object();
Construct_vector_3 construct_vector_3_object();
};

View File

@ -7,8 +7,11 @@ 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<AABBGeomTraits,AABBPrimitive>}
\cgalHasModels{CGAL::AABB_traits_2<AABBGeomTraits_2,AABBPrimitive>}
\cgalHasModels{CGAL::AABB_traits_3<AABBGeomTraits_3,AABBPrimitive>}
\cgalHasModelsEnd
\sa `CGAL::AABB_tree<AABBTraits>`
@ -17,11 +20,57 @@ distance of an intersection along a ray.
*/
class AABBRayIntersectionTraits {
public:
/*!
Type of a ray.
*/
typedef unspecified_type Ray;
/*!
Type of a 3D ray.
Type of a vector.
*/
typedef unspecified_type Ray_3;
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&);`
*/
typedef unspecified_type Construct_source;
/*!
returns the `Construct_source` functor.
*/
Construct_source construct_source_object();
/*!
A model of `CartesianConstIterator_2` or `CartesianConstIterator_3`, depending on the dimension of `Vector`.
*/
typedef unspecified_type Cartesian_const_iterator;
/*!
A model of `ConstructCartesianConstIterator_2` or `ConstructCartesianConstIterator_3`, depending on the dimension of `Vector`.
*/
typedef unspecified_type Construct_cartesian_const_iterator;
/*!
returns the `Construct_cartesian_const_iterator` functor.
*/
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:
`Vector operator()(const Ray&);`
*/
typedef unspecified_type Construct_vector;
/*!
returns the `Construct_vector` functor.
*/
Construct_vector construct_vector_object();
/*!
@ -34,9 +83,9 @@ public:
respectively.
Provides the operators:
`std::optional<FT> operator()(const Ray_3& r, const Bounding_box& bbox)`.
`std::optional<std::pair<FT, Intersection_and_primitive_id<Ray_3>::%Type > >
operator()(const Ray_3& r, const Primitive& primitive)`.
`std::optional<FT> operator()(const Ray& r, const Bounding_box& bbox)`.
`std::optional<std::pair<FT, Intersection_and_primitive_id<Ray>::%Type > >
operator()(const Ray& r, const Primitive& primitive)`.
A common algorithm to compute the intersection between a bounding box and a ray is <A
HREF="https://education.siggraph.org/static/HyperGraph/raytrace/rtinter3.htm">the

View File

@ -6,12 +6,12 @@
The concept `AABBTraits` provides the geometric primitive types and methods for the class `CGAL::AABB_tree<AABBTraits>`.
\cgalHasModelsBegin
\cgalHasModels{CGAL::AABB_traits<AABBGeomTraits,AABBPrimitive>}
\cgalHasModels{CGAL::AABB_traits_2<AABBGeomTraits_2,AABBPrimitive>}
\cgalHasModels{CGAL::AABB_traits_3<AABBGeomTraits_3,AABBPrimitive>}
\cgalHasModelsEnd
\cgalRefines{SearchGeomTraits_3}
\cgalRefines{SearchTraits}
\sa `CGAL::AABB_traits<AABBGeomTraits,AABBPrimitive>`
\sa `CGAL::AABB_tree<AABBTraits>`
\sa `AABBPrimitive`
@ -28,9 +28,9 @@ Value type of the `Squared_distance` functor.
typedef unspecified_type FT;
/*!
Type of a 3D point.
Type of a 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
Point and Primitive Id type
*/
typedef std::pair<Point_3, Primitive::Id> Point_and_primitive_id;
typedef std::pair<Point, Primitive::Id> Point_and_primitive_id;
/*!
\deprecated
@ -144,22 +135,22 @@ 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:
`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.
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;
/*!
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();
/// @}
@ -231,4 +222,3 @@ const Primitive::Shared_data& shared_data() const;
}; /* end AABBTraits */

View File

@ -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} - Fast Intersection and Distance Computation (AABB Tree)"
EXTRACT_ALL = false
HIDE_UNDOC_MEMBERS = true
HIDE_UNDOC_CLASSES = true

View File

@ -5,12 +5,12 @@
/*!
\addtogroup PkgAABBTreeRef
\cgalPkgDescriptionBegin{3D 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}
\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}
\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
\cgalPkgSince{3.5}
@ -25,18 +25,28 @@
\cgalCRPSection{Concepts}
- `AABBPrimitive`
- `AABBPrimitiveWithSharedData`
- `AABBGeomTraits`
- `AABBGeomTraits_2`
- `AABBGeomTraits_3`
- `AABBTraits`
- `AABBRayIntersectionGeomTraits`
- `AABBRayIntersectionGeomTraits_2`
- `AABBRayIntersectionGeomTraits_3`
- `AABBRayIntersectionTraits`
\cgalCRPSection{Classes}
- `CGAL::AABB_traits<GeomTraits,Primitive>`
- `CGAL::AABB_traits<GeomTraits,Primitive>` (deprecated, use `CGAL::AABB_traits_3<GeomTraits,Primitive>`)
- `CGAL::AABB_traits_2<GeomTraits,Primitive>`
- `CGAL::AABB_traits_3<GeomTraits,Primitive>`
- `CGAL::AABB_tree<AT>`
\cgalCRPSection{Primitives}
- `CGAL::AABB_triangle_primitive<GeomTraits, Iterator, CacheDatum>`
- `CGAL::AABB_segment_primitive<GeomTraits, Iterator, CacheDatum>`
- `CGAL::AABB_triangle_primitive_2<GeomTraits, Iterator, CacheDatum>`
- `CGAL::AABB_indexed_triangle_primitive_2<GeomTraits, IndexIterator, PointRange, CacheDatum, PointMap>`
- `CGAL::AABB_segment_primitive_2<GeomTraits, Iterator, CacheDatum>`
- `CGAL::AABB_polyline_segment_primitive_2<GeomTraits, Iterator, PointRange, CacheDatum, PointMap>`
- `CGAL::AABB_triangle_primitive<GeomTraits, Iterator, CacheDatum>` (deprecated, use `CGAL::AABB_triangle_primitive_3<GeomTraits, Iterator, CacheDatum>`)
- `CGAL::AABB_triangle_primitive_3<GeomTraits, Iterator, CacheDatum>`
- `CGAL::AABB_segment_primitive<GeomTraits, Iterator, CacheDatum>` (deprecated, use `CGAL::AABB_segment_primitive_3<GeomTraits, Iterator, CacheDatum>`)
- `CGAL::AABB_segment_primitive_3<GeomTraits, Iterator, CacheDatum>`
- `CGAL::AABB_primitive<Id,ObjectPropertyMap,PointPropertyMap,ExternalPropertyMaps,CacheDatum>`
- `CGAL::AABB_halfedge_graph_segment_primitive<HalfedgeGraph,Vpm,OneHalfedgeGraphPerTree,CacheDatum>`
- `CGAL::AABB_face_graph_triangle_primitive<FaceGraph,Vpm,OneFaceGraphPerTree,CacheDatum>`

View File

@ -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
@ -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
@ -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
@ -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}
\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}
\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
@ -233,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
@ -426,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
@ -437,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.
*/

View File

@ -8,3 +8,4 @@ Box_intersection_d
Polyhedron
BGL
Spatial_searching
Property_map

View File

@ -7,8 +7,12 @@
\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_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

View File

@ -1,7 +1,7 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
@ -23,7 +23,7 @@ template <typename TriangleMesh>
void triangle_mesh(std::string fname)
{
typedef CGAL::AABB_face_graph_triangle_primitive<TriangleMesh> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
TriangleMesh tmesh;
@ -56,7 +56,7 @@ void surface_mesh_cache_bbox(std::string fname)
typedef boost::graph_traits<Surface_mesh>::face_descriptor face_descriptor;
typedef Surface_mesh::Property_map<face_descriptor,Bbox_3> Bbox_pmap;
typedef CGAL::AABB_face_graph_triangle_primitive<Surface_mesh> Primitive;
typedef CGAL::AABB_traits<K, Primitive,Bbox_pmap> Traits;
typedef CGAL::AABB_traits_3<K, Primitive,Bbox_pmap> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
Surface_mesh tmesh;

View File

@ -5,7 +5,7 @@
#include <list>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
@ -91,7 +91,7 @@ public:
typedef CGAL::AABB_traits<K, My_triangle_primitive> My_AABB_traits;
typedef CGAL::AABB_traits_3<K, My_triangle_primitive> My_AABB_traits;
typedef CGAL::AABB_tree<My_AABB_traits> Tree;
int main()

View File

@ -3,7 +3,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
@ -97,7 +97,7 @@ public:
// types
typedef CGAL::AABB_traits<K, My_triangle_primitive> My_AABB_traits;
typedef CGAL::AABB_traits_3<K, My_triangle_primitive> My_AABB_traits;
typedef CGAL::AABB_tree<My_AABB_traits> Tree;
const double* My_triangle_primitive::point_container = nullptr;

View File

@ -7,7 +7,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
@ -104,7 +104,7 @@ public:
// types
typedef CGAL::AABB_traits<K, My_triangle_primitive> My_AABB_traits;
typedef CGAL::AABB_traits_3<K, My_triangle_primitive> My_AABB_traits;
typedef CGAL::AABB_tree<My_AABB_traits> Tree;
const std::vector<My_point>* My_triangle_primitive::point_container = nullptr;

View File

@ -9,7 +9,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
@ -95,7 +95,7 @@ public:
};
// types
typedef CGAL::AABB_traits<K, My_triangle_primitive> My_AABB_traits;
typedef CGAL::AABB_traits_3<K, My_triangle_primitive> My_AABB_traits;
typedef CGAL::AABB_tree<My_AABB_traits> Tree;
int main()

View File

@ -4,7 +4,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
@ -14,7 +14,7 @@ typedef K::Point_3 Point;
typedef K::Segment_3 Segment;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
template <class Kernel, class FaceGraph>

View File

@ -4,7 +4,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_halfedge_graph_segment_primitive.h>
@ -14,7 +14,7 @@ typedef K::Point_3 Point;
typedef K::Triangle_3 Triangle;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_halfedge_graph_segment_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
template <class Kernel, class HalfedgeGraph>

View File

@ -0,0 +1,91 @@
#include <iostream>
#include <vector>
#include <array>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits_2.h>
#include <CGAL/AABB_indexed_triangle_primitive_2.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::Point_3 Point_3;
typedef K::Point_2 Point_2;
typedef K::Ray_2 Ray;
template <class GeomTraits>
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<GeomTraits> Self;
Projection_xy_point_map() {}
inline friend value_type get(Self, key_type p)
{
return value_type(p.x(), p.y());
}
};
typedef std::vector<std::array<uint8_t, 3> >::const_iterator IndexIterator;
typedef std::vector<Point_3> PointRange;
typedef CGAL::AABB_indexed_triangle_primitive_2<K, IndexIterator, PointRange, CGAL::Tag_false, Projection_xy_point_map<K>> Primitive;
typedef CGAL::AABB_traits_2<K, Primitive> AABB_triangle_traits;
typedef CGAL::AABB_tree<AABB_triangle_traits> Tree;
typedef Tree::Point_and_primitive_id Point_and_primitive_id;
typedef std::optional<Tree::Intersection_and_primitive_id<Ray>::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<Point_3> points = { a, b, c, d, e, f };
std::vector<std::array<uint8_t, 3> > 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));
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.cbegin(), id.second) << ". triangle" << std::endl;
id = tree.closest_point_and_primitive(Point_2(1.5, 0.5));
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.cbegin(), id.second) << ". triangle" << std::endl;
id = tree.closest_point_and_primitive(Point_2(1.0, 0.0));
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.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);
if (!intersection) {
std::cout << "Ray does not intersect with triangles although it should!" << std::endl;
return EXIT_FAILURE;
}
else {
std::cout << std::distance(triangles.cbegin(), intersection->second) << ". triangle" << std::endl;
}
std::list<Ray_intersection> intersections;
tree.all_intersections(ray, std::back_inserter(intersections));
return EXIT_SUCCESS;
}

View File

@ -2,7 +2,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
@ -13,7 +13,7 @@ typedef K::Point_3 Point;
typedef K::Segment_3 Segment;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron, CGAL::Default, CGAL::Tag_false> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef Tree::Point_and_primitive_id Point_and_primitive_id;

View File

@ -4,7 +4,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_halfedge_graph_segment_primitive.h>
@ -14,7 +14,7 @@ typedef K::Point_3 Point;
typedef K::Triangle_3 Triangle;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_halfedge_graph_segment_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
int main()

View File

@ -5,7 +5,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
@ -15,7 +15,7 @@ typedef K::Point_3 Point;
typedef K::Segment_3 Segment;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef Tree::Point_and_primitive_id Point_and_primitive_id;

View File

@ -5,7 +5,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
@ -17,7 +17,7 @@ typedef K::Segment_3 Segment;
typedef K::Ray_3 Ray;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef std::optional< Tree::Intersection_and_primitive_id<Segment>::Type > Segment_intersection;
typedef std::optional< Tree::Intersection_and_primitive_id<Plane>::Type > Plane_intersection;

View File

@ -0,0 +1,71 @@
#include <iostream>
#include <vector>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits_2.h>
#include <CGAL/AABB_polyline_segment_primitive_2.h>
#include <CGAL/AABB_segment_primitive_2.h>
#include <CGAL/Polygon_2.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::Segment_2 Segment;
typedef K::Point_2 Point;
typedef std::vector<Point> PointRange;
typedef PointRange::const_iterator Iterator_pr;
typedef CGAL::AABB_polyline_segment_primitive_2<K, Iterator_pr, PointRange> Primitive_pr;
typedef CGAL::AABB_traits_2<K, Primitive_pr> Traits_pr;
typedef CGAL::AABB_tree<Traits_pr> Tree_pr;
typedef Tree_pr::Point_and_primitive_id Point_and_primitive_id_pr;
typedef CGAL::Polygon_2<K> Polygon_2;
typedef Polygon_2::const_iterator Iterator_poly;
typedef CGAL::AABB_polyline_segment_primitive_2<K, Iterator_poly, Polygon_2> Primitive_poly;
typedef CGAL::AABB_traits_2<K, Primitive_poly> Traits_poly;
typedef CGAL::AABB_tree<Traits_poly> Tree_poly;
typedef Tree_poly::Point_and_primitive_id Point_and_primitive_id_poly;
template<class AABBTree, class PPId>
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);
std::cout << id.first << "\n";
}
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<Point> polyline = { a, b, c, d, e };
Polygon_2 poly(polyline.begin(), polyline.end());
test<Tree_poly, Point_and_primitive_id_poly>(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.
test<Tree_pr, Point_and_primitive_id_pr>(Tree_pr(polyline.begin(), std::prev(polyline.end()), polyline));
return EXIT_SUCCESS;
}

View File

@ -2,7 +2,7 @@
#include <CGAL/Surface_mesh.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
#include <CGAL/Polygon_mesh_processing/orientation.h>
@ -21,7 +21,7 @@ typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
typedef CGAL::AABB_face_graph_triangle_primitive<Mesh> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef std::optional<Tree::Intersection_and_primitive_id<Ray>::Type> Ray_intersection;

View File

@ -0,0 +1,59 @@
#include <iostream>
#include <list>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits_2.h>
#include <CGAL/AABB_segment_primitive_2.h>
#include <CGAL/Polygon_2.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::FT FT;
typedef K::Segment_2 Segment;
typedef K::Point_2 Point;
typedef std::list<Segment> SegmentRange;
typedef SegmentRange::const_iterator Iterator;
typedef CGAL::AABB_segment_primitive_2<K, Iterator> Primitive;
typedef CGAL::AABB_traits_2<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> 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<Segment> 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));
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;
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;
}

View File

@ -5,8 +5,8 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_segment_primitive.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_segment_primitive_3.h>
typedef CGAL::Simple_cartesian<double> K;
@ -17,8 +17,8 @@ typedef K::Segment_3 Segment;
typedef K::Triangle_3 Triangle;
typedef std::list<Segment>::iterator Iterator;
typedef CGAL::AABB_segment_primitive<K, Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_segment_primitive_3<K, Iterator> Primitive;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
int main()

View File

@ -0,0 +1,52 @@
// Author(s) : Camille Wormser, Pierre Alliez
#include <iostream>
#include <list>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits_2.h>
#include <CGAL/AABB_triangle_primitive_2.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::FT FT;
typedef K::Ray_2 Ray;
typedef K::Point_2 Point;
typedef K::Triangle_2 Triangle;
typedef std::list<Triangle>::iterator Iterator;
typedef CGAL::AABB_triangle_primitive_2<K, Iterator> Primitive;
typedef CGAL::AABB_traits_2<K, Primitive> AABB_triangle_traits;
typedef CGAL::AABB_tree<AABB_triangle_traits> 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<Triangle> 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;
}

View File

@ -5,20 +5,19 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_triangle_primitive.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_triangle_primitive_3.h>
typedef CGAL::Simple_cartesian<double> 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<Triangle>::iterator Iterator;
typedef CGAL::AABB_triangle_primitive<K, Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> AABB_triangle_traits;
typedef std::list<Triangle>::const_iterator Iterator;
typedef CGAL::AABB_triangle_primitive_3<K, Iterator> Primitive;
typedef CGAL::AABB_traits_3<K, Primitive> AABB_triangle_traits;
typedef CGAL::AABB_tree<AABB_triangle_traits> Tree;
int main()

View File

@ -48,7 +48,7 @@ namespace CGAL {
* The default is `CGAL::Tag_false` (datum is not stored).
*\sa `AABBPrimitive`
*\sa `AABB_primitive<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
*\sa `AABB_halfedge_graph_segment_primitive<HalfedgeGraph,OneHalfedgeGraphPerTree,CacheDatum>`
*\sa `AABB_halfedge_graph_segment_primitive<HalfedgeGraph,VertexPointPMap,OneHalfedgeGraphPerTree,CacheDatum>`
*/
template < class FaceGraph,
class VertexPointPMap = Default,

View File

@ -60,7 +60,8 @@ namespace CGAL {
*
* \sa `AABBPrimitive`
* \sa `AABB_primitive<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
* \sa `AABB_face_graph_triangle_primitive<FaceGraph,OneFaceGraphPerTree,CacheDatum>`
* \sa `AABB_face_graph_triangle_primitive<FaceGraph,VertexPointPMap,OneFaceGraphPerTree,CacheDatum>`
* \sa `AABB_segment_primitive_3<Iterator,CacheDatum>`
* \sa \link BGLPolyGT `boost::graph_traits<Polyhedron>` \endlink
*/
template < class HalfedgeGraph,

View File

@ -0,0 +1,134 @@
// 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 <CGAL/license/AABB_tree.h>
#include <CGAL/AABB_primitive.h>
#include <iterator>
namespace CGAL {
namespace internal {
template <class GeomTraits, class Iterator, class PointIterator, class PointMap>
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<GeomTraits, Iterator, PointIterator, PointMap> 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 <class GeomTraits, class Iterator, class PointIterator, class PointMap>
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<GeomTraits, Iterator, PointIterator, PointMap> 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
/*!
* \ingroup PkgAABBTreeRef
* 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 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 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 \link Identity_property_map `CGAL::Identity_property_map`\endlink<PointRange::value_type>.
*
* \sa `AABBPrimitive`
* \sa `AABB_primitive<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
* \sa `AABB_segment_primitive_2<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_triangle_primitive_2<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_triangle_primitive_3<GeomTraits,Iterator,CacheDatum>`
*/
template < class GeomTraits,
class IndexIterator,
class PointRange,
class CacheDatum = Tag_false,
class PointMap = Identity_property_map<typename PointRange::value_type>>
class AABB_indexed_triangle_primitive_2
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< IndexIterator,
internal::Triangle_2_from_index_range_iterator_property_map<GeomTraits, IndexIterator, typename PointRange::iterator, PointMap>,
internal::Point_from_indexed_triangle_2_iterator_property_map<GeomTraits, IndexIterator, typename PointRange::iterator, PointMap>,
Tag_true,
CacheDatum >
#endif
{
typedef AABB_primitive< IndexIterator,
internal::Triangle_2_from_index_range_iterator_property_map<GeomTraits, IndexIterator, typename PointRange::iterator, PointMap>,
internal::Point_from_indexed_triangle_2_iterator_property_map<GeomTraits, IndexIterator, typename PointRange::iterator, PointMap>,
Tag_true,
CacheDatum > Base;
public:
///constructor from an iterator
AABB_indexed_triangle_primitive_2(IndexIterator it, PointRange&) : Base(it) {}
/// \internal
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<GeomTraits, IndexIterator, typename PointRange::iterator, PointMap>(range.begin(), pmap),
internal::Point_from_indexed_triangle_2_iterator_property_map<GeomTraits, IndexIterator, typename PointRange::iterator, PointMap>(range.begin(), pmap));
}
};
} // end namespace CGAL
#endif // CGAL_AABB_INDEXED_TRIANGLE_PRIMITIVE_2_H_

View File

@ -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 <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#define CGAL_DEPRECATED_HEADER "<CGAL/AABB_polyhedron_segment_primitive.h>"
#define CGAL_REPLACEMENT_HEADER "<CGAL/AABB_halfedge_graph_segment_primitive.h>"
#include <CGAL/Installation/internal/deprecation_warning.h>
#include <type_traits>
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<typename GeomTraits, typename Polyhedron>
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<GeomTraits,Polyhedron> 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 <class Iterator>
AABB_polyhedron_segment_primitive( Iterator it,
std::enable_if_t<
std::is_same<Id,typename Iterator::value_type>::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<typename GeomTraits, typename Polyhedron>
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 <CGAL/enable_warnings.h>
#endif // CGAL_AABB_POLYHEDRON_SEGMENT_PRIMITIVE_H_

View File

@ -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 <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#define CGAL_DEPRECATED_HEADER "<CGAL/AABB_polyhedron_triangle_primitive.h>"
#define CGAL_REPLACEMENT_HEADER "<CGAL/AABB_face_graph_triangle_primitive.h>"
#include <CGAL/Installation/internal/deprecation_warning.h>
#include <type_traits>
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<typename GeomTraits, typename Polyhedron>
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<GeomTraits, Polyhedron> 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 <class Iterator>
AABB_polyhedron_triangle_primitive( Iterator it,
std::enable_if_t<
std::is_same<Id,typename Iterator::value_type>::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<typename GeomTraits, typename Polyhedron>
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 <CGAL/enable_warnings.h>
#endif // CGAL_AABB_POLYHEDRON_TRIANGLE_PRIMITIVE_H_

View File

@ -0,0 +1,140 @@
// 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) : Sven Oesau
//
#ifndef CGAL_AABB_POLYLINE_SEGMENT_PRIMITIVE_2_H_
#define CGAL_AABB_POLYLINE_SEGMENT_PRIMITIVE_2_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/AABB_primitive.h>
#include <iterator>
namespace CGAL {
namespace internal {
template <class GeomTraits, class Iterator, class PointMap>
struct Segment_2_from_point_iterator_property_map {
//classical typedefs
typedef Iterator key_type;
typedef typename GeomTraits::Segment_2 value_type;
typedef typename GeomTraits::Segment_2 reference; // The segments are created on the fly, so working with references is not possible.
typedef boost::readable_property_map_tag category;
typedef Segment_2_from_point_iterator_property_map<GeomTraits, Iterator, PointMap> Self;
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.
get(Self s, key_type it)
{
Iterator it2 = std::next(it);
if (it2 == s.end)
return typename GeomTraits::Construct_segment_2()(get(s.pmap, *it), get(s.pmap, *s.begin));
else
return typename GeomTraits::Construct_segment_2()(get(s.pmap, *it), get(s.pmap, *it2));
}
Iterator begin, end;
PointMap pmap;
};
template <class GeomTraits, class Iterator, class PointMap>
struct Point_from_iterator_property_map {
//classical typedefs
typedef Iterator key_type;
typedef typename PointMap::value_type value_type;
typedef const value_type reference;
typedef boost::readable_property_map_tag category;
typedef Point_from_iterator_property_map<GeomTraits, Iterator, PointMap> Self;
Point_from_iterator_property_map() {}
Point_from_iterator_property_map(PointMap& pmap) : pmap(pmap) {}
inline friend reference
get(Self s, key_type it)
{
return get(s.pmap, *it);
}
PointMap pmap;
};
}//namespace internal
/*!
* \ingroup PkgAABBTreeRef
* 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 `Point_2` the next identifier is pointing to 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_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 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.
* The default is `CGAL::Tag_false` (datum is not stored).
* \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<PointRange::value_type>.
*
* \sa `AABBPrimitive`
* \sa `AABB_primitive<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
* \sa `AABB_segment_primitive_2<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_segment_primitive_3<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_halfedge_graph_segment_primitive<HalfedgeGraph,VertexPointPMap,OneHalfedgeGraphPerTree,CacheDatum>`
*/
template < class GeomTraits,
class Iterator,
class PointRange,
class CacheDatum = Tag_false,
class PointMap = Identity_property_map<typename PointRange::value_type>>
class AABB_polyline_segment_primitive_2
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< Iterator,
internal::Segment_2_from_point_iterator_property_map<GeomTraits, Iterator, PointMap>,
internal::Point_from_iterator_property_map<GeomTraits, Iterator, PointMap>,
Tag_true,
CacheDatum >
#endif
{
typedef internal::Segment_2_from_point_iterator_property_map<GeomTraits, Iterator, PointMap> Segment_map;
typedef internal::Point_from_iterator_property_map<GeomTraits, Iterator, PointMap> Point_primitive_map;
typedef AABB_primitive< Iterator,
Segment_map,
Point_primitive_map,
Tag_true,
CacheDatum > Base;
public:
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()) {
return std::make_pair(internal::Segment_2_from_point_iterator_property_map<GeomTraits, Iterator, PointMap>(range.begin(), range.end(), pmap), internal::Point_from_iterator_property_map<GeomTraits, Iterator, PointMap>(pmap));
}
};
} // end namespace CGAL
#endif // CGAL_AABB_POLYLINE_SEGMENT_PRIMITIVE_2_H_

View File

@ -71,10 +71,12 @@ public:
* 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<Iterator,CacheDatum>`
* \sa `AABB_triangle_primitive<Iterator,CacheDatum>`
* \sa `AABB_halfedge_graph_segment_primitive<HalfedgeGraph,OneHalfedgeGraphPerTree,CacheDatum>`
* \sa `AABB_face_graph_triangle_primitive<FaceGraph,OneFaceGraphPerTree,CacheDatum>`
* \sa `AABB_segment_primitive_2<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_segment_primitive_3<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_triangle_primitive_2<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_triangle_primitive_3<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_halfedge_graph_segment_primitive<HalfedgeGraph,VertexPointPMap,OneHalfedgeGraphPerTree,CacheDatum>`
* \sa `AABB_face_graph_triangle_primitive<FaceGraph,VertexPointPMap,OneFaceGraphPerTree,CacheDatum>`
*/
template < class Id,
class ObjectPropertyMap,
@ -251,4 +253,3 @@ public:
#include <CGAL/enable_warnings.h>
#endif // CGAL_AABB_PRIMITIVE_H

View File

@ -1,4 +1,4 @@
// Copyright (c) 2012 INRIA Sophia-Antipolis (France).
// Copyright (c) 2024 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
@ -11,91 +11,38 @@
// Author(s) : Sebastien Loriot
//
#ifndef CGAL_AABB_SEGMENT_PRIMITIVE_H_
#define CGAL_AABB_SEGMENT_PRIMITIVE_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#define CGAL_DEPRECATED_HEADER "<CGAL/AABB_segment_primitive.h>"
#define CGAL_REPLACEMENT_HEADER "<CGAL/AABB_segment_primitive_3.h>"
#include <CGAL/Installation/internal/deprecation_warning.h>
#include <CGAL/AABB_primitive.h>
#include <iterator>
#ifndef CGAL_NO_DEPRECATED_CODE
#include <CGAL/AABB_segment_primitive_3.h>
/// \file AABB_segment_primitive.h
namespace CGAL {
namespace internal {
template <class GeomTraits, class Iterator>
struct Source_of_segment_3_iterator_property_map{
//classical typedefs
typedef Iterator key_type;
typedef typename GeomTraits::Point_3 value_type;
// typedef decltype(
// std::declval<typename GeomTraits::Construct_source_3>()(
// std::declval<typename GeomTraits::Segment_3>())) reference;
typedef decltype(
typename GeomTraits::Construct_source_3()(
*std::declval<key_type&>())) reference;
typedef boost::readable_property_map_tag category;
typedef Source_of_segment_3_iterator_property_map<GeomTraits, Iterator> Self;
inline friend reference
get(Self, key_type it)
{
return typename GeomTraits::Construct_source_3()( *it );
}
};
}//namespace internal
/// \addtogroup PkgAABBTreeRef
/// @{
/// template alias for backward compatibility
/*!
* \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_3` and `Segment_3`.
* It also provides the functor `Construct_source_3` that has an operator taking a `Segment_3`
* and returning its source as a type convertible to `Point_3`.
* \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Segment_3`
* \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<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
* \sa `AABB_triangle_primitive<Iterator,CacheDatum>`
* \sa `AABB_halfedge_graph_segment_primitive<HalfedgeGraph,OneHalfedgeGraphPerTree,CacheDatum>`
* \sa `AABB_face_graph_triangle_primitive<FaceGraph,OneFaceGraphPerTree,CacheDatum>`
*/
template < class GeomTraits,
class Iterator,
class CacheDatum=Tag_false>
class AABB_segment_primitive
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Source_of_segment_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum >
#endif
{
typedef AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Source_of_segment_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum > Base;
public:
///constructor from an iterator
AABB_segment_primitive(Iterator it) : Base(it){}
};
using AABB_segment_primitive = AABB_segment_primitive_3<GeomTraits, Iterator, CacheDatum>;
} // end namespace CGAL
///@}
#include <CGAL/enable_warnings.h>
} // CGAL namespace
#endif // CGAL_AABB_SEGMENT_PRIMITIVE_H_
#endif // CGAL_NO_DEPRECATED_CODE
#endif //CGAL_AABB_SEGMENT_PRIMITIVE_H_

View File

@ -0,0 +1,99 @@
// 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 <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#include <CGAL/AABB_primitive.h>
#include <iterator>
namespace CGAL {
namespace internal {
template <class GeomTraits, class Iterator>
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<typename GeomTraits::Construct_source_2>()(
// std::declval<typename GeomTraits::Segment_2>())) reference;
typedef decltype(
typename GeomTraits::Construct_source_2()(
*std::declval<key_type&>())) reference;
typedef boost::readable_property_map_tag category;
typedef Source_of_segment_2_iterator_property_map<GeomTraits, Iterator> 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 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.
*
* \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<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
* \sa `AABB_segment_primitive_3<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_triangle_primitive_2<GeomTraits,Iterator,CacheDatum>`
*/
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<Iterator>,
internal::Source_of_segment_2_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum >
#endif
{
typedef AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Source_of_segment_2_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum > Base;
public:
///constructor from an iterator
AABB_segment_primitive_2(Iterator it) : Base(it){}
};
} // end namespace CGAL
#include <CGAL/enable_warnings.h>
#endif // CGAL_AABB_SEGMENT_PRIMITIVE_2_H_

View File

@ -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_3_H_
#define CGAL_AABB_SEGMENT_PRIMITIVE_3_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#include <CGAL/AABB_primitive.h>
#include <iterator>
namespace CGAL {
namespace internal {
template <class GeomTraits, class Iterator>
struct Source_of_segment_3_iterator_property_map{
//classical typedefs
typedef Iterator key_type;
typedef typename GeomTraits::Point_3 value_type;
// typedef decltype(
// std::declval<typename GeomTraits::Construct_source_3>()(
// std::declval<typename GeomTraits::Segment_3>())) reference;
typedef decltype(
typename GeomTraits::Construct_source_3()(
*std::declval<key_type&>())) reference;
typedef boost::readable_property_map_tag category;
typedef Source_of_segment_3_iterator_property_map<GeomTraits, Iterator> Self;
inline friend reference
get(Self, key_type it)
{
return typename GeomTraits::Construct_source_3()( *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_3` and `Segment_3`.
* It also provides the functor `Construct_source_3` that has an operator taking a `Segment_3`
* and returning its source as a type convertible to `Point_3`.
* \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Segment_3`
* \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<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
* \sa `AABB_segment_primitive_2<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_triangle_primitive_3<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_halfedge_graph_segment_primitive<HalfedgeGraph,VertexPointPMap,OneHalfedgeGraphPerTree,CacheDatum>`
*/
template < class GeomTraits,
class Iterator,
class CacheDatum=Tag_false>
class AABB_segment_primitive_3
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Source_of_segment_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum >
#endif
{
typedef AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Source_of_segment_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum > Base;
public:
///constructor from an iterator
AABB_segment_primitive_3(Iterator it) : Base(it){}
};
} // end namespace CGAL
#include <CGAL/enable_warnings.h>
#endif // CGAL_AABB_SEGMENT_PRIMITIVE_3_H_

View File

@ -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,35 @@
#ifndef CGAL_AABB_TRAITS_H_
#define CGAL_AABB_TRAITS_H_
#define CGAL_DEPRECATED_HEADER "<CGAL/AABB_traits.h>"
#define CGAL_REPLACEMENT_HEADER "<CGAL/AABB_traits_3.h>"
#include <CGAL/Installation/internal/deprecation_warning.h>
#ifndef CGAL_NO_DEPRECATED_CODE
#include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#include <CGAL/Bbox_3.h>
#include <CGAL/Default.h>
#include <CGAL/intersections.h>
#include <CGAL/AABB_tree/internal/Has_nested_type_Shared_data.h>
#include <CGAL/AABB_tree/internal/Is_ray_intersection_geomtraits.h>
#include <CGAL/AABB_tree/internal/Primitive_helper.h>
#include <CGAL/Kernel_23/internal/Has_boolean_tags.h>
#include <optional>
#include <CGAL/AABB_traits_3.h>
/// \file AABB_traits.h
namespace CGAL {
namespace internal{ namespace AABB_tree {
namespace CGAL
{
template <class T>
struct Remove_optional { typedef T type; };
template <class T>
struct Remove_optional< ::std::optional<T> > { typedef T type; };
//helper controlling whether extra data should be stored in the AABB_tree traits class
template <class Primitive, bool has_shared_data=Has_nested_type_Shared_data<Primitive>::value>
struct AABB_traits_base;
template <class Primitive>
struct AABB_traits_base<Primitive,false>{};
template <class Primitive>
struct AABB_traits_base<Primitive,true>{
typename Primitive::Shared_data m_primitive_data;
template <typename ... T>
void set_shared_data(T&& ... t){
m_primitive_data=Primitive::construct_shared_data(std::forward<T>(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 <typename GeomTraits, bool ray_intersection_geom_traits=Is_ray_intersection_geomtraits<GeomTraits>::value>
struct AABB_traits_base_2;
template <typename GeomTraits>
struct AABB_traits_base_2<GeomTraits,false>{};
template <typename GeomTraits>
struct AABB_traits_base_2<GeomTraits,true>{
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<FT> operator()(const Ray_3& ray, const Bounding_box& bbox) const {
FT t_near = -DBL_MAX; // std::numeric_limits<FT>::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;
/// template alias for backward compatibility
template<typename GeomTraits, typename AABBPrimitive, typename BboxMap = Default>
using AABB_traits = AABB_traits_3<GeomTraits, AABBPrimitive, BboxMap>;
///@}
/// 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`
} // namespace CGAL
template<typename GeomTraits, typename AABBPrimitive, typename BboxMap = Default>
class AABB_traits
#ifndef DOXYGEN_RUNNING
: public internal::AABB_tree::AABB_traits_base<AABBPrimitive>,
public internal::AABB_tree::AABB_traits_base_2<GeomTraits>
#endif
{
typedef typename CGAL::Object Object;
public:
typedef GeomTraits Geom_traits;
typedef AABB_traits<GeomTraits, AABBPrimitive, BboxMap> AT;
// AABBTraits concept types
typedef typename GeomTraits::FT FT;
typedef AABBPrimitive Primitive;
typedef typename std::pair<Object,typename Primitive::Id> Object_and_primitive_id;
typedef typename std::pair<typename GeomTraits::Point_3, typename Primitive::Id> Point_and_primitive_id;
/// `Intersection_and_primitive_id<Query>::%Type::first_type` is found according to
/// the result type of `GeomTraits::Intersect_3::operator()`. If it is
/// `std::optional<T>` then it is `T`, and the result type otherwise.
template<typename Query>
struct Intersection_and_primitive_id {
typedef decltype(
std::declval<typename GeomTraits::Intersect_3>()(
std::declval<Query>(),
std::declval<typename Primitive::Datum>())) Intersection_type;
typedef std::pair<
typename internal::AABB_tree::Remove_optional<Intersection_type>::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() { }
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 `<dim>_less_than` (dim in {x,y,z})
*/
class Split_primitives
{
typedef AABB_traits<GeomTraits,AABBPrimitive,BboxMap> Traits;
const Traits& m_traits;
public:
Split_primitives(const AABB_traits<GeomTraits,AABBPrimitive,BboxMap>& traits)
: m_traits(traits) {}
typedef void result_type;
template<typename PrimitiveIterator>
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<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
public:
Compute_bbox(const AABB_traits<GeomTraits,AABBPrimitive, BboxMap>& traits)
:m_traits (traits) {}
template<typename ConstPrimitiveIterator>
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<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
public:
Do_intersect(const AABB_traits<GeomTraits,AABBPrimitive, BboxMap>& traits)
:m_traits(traits) {}
template<typename Query>
bool operator()(const Query& q, const Bounding_box& bbox) const
{
return GeomTraits().do_intersect_3_object()(q, bbox);
}
template<typename Query>
bool operator()(const Query& q, const Primitive& pr) const
{
return GeomTraits().do_intersect_3_object()(q, internal::Primitive_helper<AT>::get_datum(pr,m_traits));
}
// intersection with AABB-tree
template<typename AABBTraits>
bool operator()(const CGAL::AABB_tree<AABBTraits>& other_tree, const Primitive& pr) const
{
return other_tree.do_intersect( internal::Primitive_helper<AT>::get_datum(pr,m_traits) );
}
template<typename AABBTraits>
bool operator()(const CGAL::AABB_tree<AABBTraits>& 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<GeomTraits,AABBPrimitive,BboxMap>& m_traits;
public:
Intersection(const AABB_traits<GeomTraits,AABBPrimitive,BboxMap>& traits)
:m_traits(traits) {}
template<typename Query>
std::optional< typename Intersection_and_primitive_id<Query>::Type >
operator()(const Query& query, const typename AT::Primitive& primitive) const {
auto inter_res = GeomTraits().intersect_3_object()(query, internal::Primitive_helper<AT>::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<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
public:
Closest_point(const AABB_traits<GeomTraits,AABBPrimitive, BboxMap>& 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<AT>::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<internal::Has_static_filters<GeomTraits>::value>());
}
// The following functions seem unused...?
template <class Solid>
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 <class Solid>
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 <typename PM>
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<AT>::get_datum(pr,*this).bbox();
}
/// Comparison functions
static bool less_x(const Primitive& pr1, const Primitive& pr2,const AABB_traits<GeomTraits,AABBPrimitive, BboxMap>& traits)
{
return GeomTraits().less_x_3_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
}
static bool less_y(const Primitive& pr1, const Primitive& pr2,const AABB_traits<GeomTraits,AABBPrimitive, BboxMap>& traits)
{
return GeomTraits().less_y_3_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
}
static bool less_z(const Primitive& pr1, const Primitive& pr2,const AABB_traits<GeomTraits,AABBPrimitive, BboxMap>& traits)
{
return GeomTraits().less_z_3_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
}
}; // end class AABB_traits
//-------------------------------------------------------
// Private methods
//-------------------------------------------------------
template<typename GT, typename P, typename B>
typename AABB_traits<GT,P,B>::Axis
AABB_traits<GT,P,B>::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 <CGAL/enable_warnings.h>
#endif // CGAL_NO_DEPRECATED_CODE
#endif // CGAL_AABB_TRAITS_H_

View File

@ -0,0 +1,504 @@
// 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 <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/Default.h>
#include <CGAL/intersections.h>
#include <CGAL/AABB_tree/internal/AABB_traits_base.h>
#include <CGAL/AABB_tree/internal/Has_nested_type_Shared_data.h>
#include <CGAL/AABB_tree/internal/Is_ray_intersection_geomtraits.h>
#include <CGAL/AABB_tree/internal/Primitive_helper.h>
#include <CGAL/AABB_tree/internal/Remove_optional.h>
#include <CGAL/Kernel_23/internal/Has_boolean_tags.h>
#include <CGAL/Search_traits_2.h>
#include <optional>
/// \file AABB_traits_2.h
namespace CGAL {
namespace internal{ namespace AABB_tree {
// AABB_traits_intersection_base_2 brings in the Intersection_distance predicate,
// if GeomTraits is a model RayIntersectionGeomTraits.
template <typename GeomTraits, bool ray_intersection_geom_traits=Is_ray_intersection_geomtraits_2<GeomTraits>::value>
struct AABB_traits_intersection_base_2;
template <typename GeomTraits>
struct AABB_traits_intersection_base_2<GeomTraits,false>{};
template <typename GeomTraits>
struct AABB_traits_intersection_base_2<GeomTraits,true>{
template<typename AABBTree, typename SkipFunctor>
friend class AABB_ray_intersection;
private:
typedef typename GeomTraits::FT FT;
typedef typename GeomTraits::Point_2 Point;
typedef typename GeomTraits::Cartesian_const_iterator_2 Cartesian_const_iterator;
typedef typename GeomTraits::Construct_cartesian_const_iterator_2 Construct_cartesian_const_iterator;
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();
}
static Construct_vector construct_vector_object() {
return GeomTraits().construct_vector_2_object();
}
// Defining Bounding_box and other types from the full AABB_traits_2
// 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;
struct Intersection_distance {
std::optional<FT> operator()(const Ray& ray, const Bounding_box& bbox) const {
FT t_near = -DBL_MAX; // std::numeric_limits<FT>::lowest(); C++1903
FT t_far = DBL_MAX;
const Construct_cartesian_const_iterator construct_cartesian_const_iterator_2
= GeomTraits().construct_cartesian_const_iterator_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 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) {
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(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 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
/// 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_2, this class is also a model of \ref
/// AABBRayIntersectionTraits.
///
/// \sa `AABBTraits`
/// \sa `AABB_tree`
/// \sa `AABBPrimitive`
/// \sa `AABBPrimitiveWithSharedData`
template<typename GeomTraits, typename AABBPrimitive, typename BboxMap = Default>
class AABB_traits_2
#ifndef DOXYGEN_RUNNING
: public internal::AABB_tree::AABB_traits_base<AABBPrimitive>,
public internal::AABB_tree::AABB_traits_intersection_base_2<GeomTraits>,
public Search_traits_2<GeomTraits>
#endif
{
typedef typename CGAL::Object Object;
typedef GeomTraits Geom_traits;
public:
typedef AABB_traits_2<GeomTraits, AABBPrimitive, BboxMap> AT;
// AABBTraits concept types
typedef typename GeomTraits::FT FT;
typedef AABBPrimitive Primitive;
typedef typename std::pair<Object,typename Primitive::Id> Object_and_primitive_id;
typedef typename std::pair<typename GeomTraits::Point_2, typename Primitive::Id> Point_and_primitive_id;
/// `Intersection_and_primitive_id<Query>::%Type::first_type` is found according to
/// the result type of `GeomTraits::Intersect_2::operator()`. If it is
/// `std::optional<T>` then it is `T`, and the result type otherwise.
template<typename Query>
struct Intersection_and_primitive_id {
typedef decltype(
std::declval<typename GeomTraits::Intersect_2>()(
std::declval<Query>(),
std::declval<typename Primitive::Datum>())) Intersection_type;
typedef std::pair<
typename internal::Remove_optional<Intersection_type>::type,
typename Primitive::Id > Type;
};
// types for search tree
/// \name Types
/// @{
/// <summary>
/// point type
/// </summary>
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.
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 `<dim>_less_than` (dim in {x,y,z})
*/
class Split_primitives
{
typedef AABB_traits_2<GeomTraits,AABBPrimitive,BboxMap> Traits;
const Traits& m_traits;
public:
Split_primitives(const AABB_traits_2<GeomTraits,AABBPrimitive,BboxMap>& traits)
: m_traits(traits) {}
typedef void result_type;
template<typename PrimitiveIterator>
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<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
public:
Compute_bbox(const AABB_traits_2<GeomTraits,AABBPrimitive, BboxMap>& traits)
:m_traits (traits) {}
template<typename ConstPrimitiveIterator>
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<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
public:
Do_intersect(const AABB_traits_2<GeomTraits,AABBPrimitive, BboxMap>& traits)
:m_traits(traits) {}
template<typename Query>
bool operator()(const Query& q, const Bounding_box& bbox) const
{
return GeomTraits().do_intersect_2_object()(q, bbox);
}
template<typename Query>
bool operator()(const Query& q, const Primitive& pr) const
{
return GeomTraits().do_intersect_2_object()(q, internal::Primitive_helper<AT>::get_datum(pr,m_traits));
}
// intersection with AABB-tree
template<typename AABBTraits>
bool operator()(const CGAL::AABB_tree<AABBTraits>& other_tree, const Primitive& pr) const
{
return other_tree.do_intersect( internal::Primitive_helper<AT>::get_datum(pr,m_traits) );
}
template<typename AABBTraits>
bool operator()(const CGAL::AABB_tree<AABBTraits>& 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<GeomTraits,AABBPrimitive,BboxMap>& m_traits;
public:
Intersection(const AABB_traits_2<GeomTraits,AABBPrimitive,BboxMap>& traits)
:m_traits(traits) {}
template<typename Query>
std::optional< typename Intersection_and_primitive_id<Query>::Type >
operator()(const Query& query, const typename AT::Primitive& primitive) const {
auto inter_res = GeomTraits().intersect_2_object()(query, internal::Primitive_helper<AT>::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 Point;
typedef typename AT::Primitive Primitive;
const AABB_traits_2<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
public:
Closest_point(const AABB_traits_2<GeomTraits,AABBPrimitive, BboxMap>& 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<AT>::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 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<internal::Has_static_filters<GeomTraits>::value>());
}
// The following functions seem unused...?
template <class Solid>
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 <class Solid>
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 <typename PM>
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 GeomTraits().construct_bbox_2_object()(internal::Primitive_helper<AT>::get_datum(pr, *this));
}
/// Comparison functions
static bool less_x(const Primitive& pr1, const Primitive& pr2,const AABB_traits_2<GeomTraits,AABBPrimitive, BboxMap>& traits)
{
return GeomTraits().less_x_2_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
}
static bool less_y(const Primitive& pr1, const Primitive& pr2,const AABB_traits_2<GeomTraits,AABBPrimitive, BboxMap>& traits)
{
return GeomTraits().less_y_2_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
}
}; // end class AABB_traits_2
//-------------------------------------------------------
// Private methods
//-------------------------------------------------------
template<typename GT, typename P, typename B>
typename AABB_traits_2<GT,P,B>::Axis
AABB_traits_2<GT,P,B>::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 <CGAL/enable_warnings.h>
#endif // CGAL_AABB_TRAITS_2_H_

View File

@ -0,0 +1,532 @@
// 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 <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#include <CGAL/Bbox_3.h>
#include <CGAL/Default.h>
#include <CGAL/intersections.h>
#include <CGAL/AABB_tree/internal/AABB_traits_base.h>
#include <CGAL/AABB_tree/internal/Has_nested_type_Shared_data.h>
#include <CGAL/AABB_tree/internal/Is_ray_intersection_geomtraits.h>
#include <CGAL/AABB_tree/internal/Primitive_helper.h>
#include <CGAL/AABB_tree/internal/Remove_optional.h>
#include <CGAL/Kernel_23/internal/Has_boolean_tags.h>
#include <CGAL/Search_traits_3.h>
#include <optional>
/// \file AABB_traits_3.h
namespace CGAL {
namespace internal {
namespace AABB_tree {
// AABB_traits_intersection_base_3 brings in the Intersection_distance predicate,
// if GeomTraits is a model RayIntersectionGeomTraits.
template <typename GeomTraits, bool ray_intersection_geom_traits=Is_ray_intersection_geomtraits<GeomTraits>::value>
struct AABB_traits_intersection_base_3;
template <typename GeomTraits>
struct AABB_traits_intersection_base_3<GeomTraits,false>{};
template <typename GeomTraits>
struct AABB_traits_intersection_base_3<GeomTraits, true> {
template<class, class>
friend class AABB_ray_intersection;
private:
typedef typename GeomTraits::Point_3 Point;
typedef typename GeomTraits::FT FT;
// Defining Bounding_box and other types from the full AABB_traits_3
// 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;
typedef typename GeomTraits::Cartesian_const_iterator_3 Cartesian_const_iterator;
typedef typename GeomTraits::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator;
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();
}
Construct_vector construct_vector_object() {
return GeomTraits().construct_vector_3_object();
}
struct Intersection_distance {
std::optional<FT> operator()(const Ray& ray, const Bounding_box& bbox) const {
FT t_near = -DBL_MAX; // std::numeric_limits<FT>::lowest(); C++1903
FT t_far = DBL_MAX;
const Construct_cartesian_const_iterator construct_cartesian_const_iterator
= GeomTraits().construct_cartesian_const_iterator_3_object();
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) {
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(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_3, this class is also a model of \ref
/// AABBRayIntersectionTraits.
///
/// \sa `AABBTraits`
/// \sa `AABB_tree`
/// \sa `AABBPrimitive`
/// \sa `AABBPrimitiveWithSharedData`
template<typename GeomTraits, typename AABBPrimitive, typename BboxMap = Default>
class AABB_traits_3
#ifndef DOXYGEN_RUNNING
: public internal::AABB_tree::AABB_traits_base<AABBPrimitive>,
public internal::AABB_tree::AABB_traits_intersection_base_3<GeomTraits>,
public Search_traits_3<GeomTraits>
#endif
{
typedef typename CGAL::Object Object;
public:
typedef GeomTraits Geom_traits;
typedef AABB_traits_3<GeomTraits, AABBPrimitive, BboxMap> AT;
// AABBTraits concept types
typedef typename GeomTraits::FT FT;
typedef AABBPrimitive Primitive;
typedef typename std::pair<Object,typename Primitive::Id> Object_and_primitive_id;
typedef typename std::pair<typename GeomTraits::Point_3, typename Primitive::Id> Point_and_primitive_id;
/// `Intersection_and_primitive_id<Query>::%Type::first_type` is found according to
/// the result type of `GeomTraits::Intersect_3::operator()`. If it is
/// `std::optional<T>` then it is `T`, and the result type otherwise.
template<typename Query>
struct Intersection_and_primitive_id {
typedef decltype(
std::declval<typename GeomTraits::Intersect_3>()(
std::declval<Query>(),
std::declval<typename Primitive::Datum>())) Intersection_type;
typedef std::pair<
typename internal::Remove_optional<Intersection_type>::type,
typename Primitive::Id > Type;
};
// types for search tree
/// \name Types
/// @{
/// 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
/// \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;
Equal equal_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 `<dim>_less_than` (dim in {x,y,z})
*/
class Split_primitives
{
typedef AABB_traits_3<GeomTraits,AABBPrimitive,BboxMap> Traits;
const Traits& m_traits;
public:
Split_primitives(const AABB_traits_3<GeomTraits,AABBPrimitive,BboxMap>& traits)
: m_traits(traits) {}
typedef void result_type;
template<typename PrimitiveIterator>
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<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
public:
Compute_bbox(const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
:m_traits (traits) {}
template<typename ConstPrimitiveIterator>
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<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
public:
Do_intersect(const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
:m_traits(traits) {}
template<typename Query>
bool operator()(const Query& q, const Bounding_box& bbox) const
{
return GeomTraits().do_intersect_3_object()(q, bbox);
}
template<typename Query>
bool operator()(const Query& q, const Primitive& pr) const
{
return GeomTraits().do_intersect_3_object()(q, internal::Primitive_helper<AT>::get_datum(pr,m_traits));
}
// intersection with AABB-tree
template<typename AABBTraits>
bool operator()(const CGAL::AABB_tree<AABBTraits>& other_tree, const Primitive& pr) const
{
return other_tree.do_intersect( internal::Primitive_helper<AT>::get_datum(pr,m_traits) );
}
template<typename AABBTraits>
bool operator()(const CGAL::AABB_tree<AABBTraits>& 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<GeomTraits,AABBPrimitive,BboxMap>& m_traits;
public:
Intersection(const AABB_traits_3<GeomTraits,AABBPrimitive,BboxMap>& traits)
:m_traits(traits) {}
template<typename Query>
std::optional< typename Intersection_and_primitive_id<Query>::Type >
operator()(const Query& query, const typename AT::Primitive& primitive) const {
auto inter_res = GeomTraits().intersect_3_object()(query, internal::Primitive_helper<AT>::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 Point;
typedef typename AT::Primitive Primitive;
const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
public:
Closest_point(const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& 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<AT>::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 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<internal::Has_static_filters<GeomTraits>::value>());
}
// The following functions seem unused...?
template <class Solid>
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 <class Solid>
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 <typename PM>
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<AT>::get_datum(pr,*this).bbox();
}
/// Comparison functions
static bool less_x(const Primitive& pr1, const Primitive& pr2,const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
{
return GeomTraits().less_x_3_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
}
static bool less_y(const Primitive& pr1, const Primitive& pr2,const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
{
return GeomTraits().less_y_3_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
}
static bool less_z(const Primitive& pr1, const Primitive& pr2,const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
{
return GeomTraits().less_z_3_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
}
}; // end class AABB_traits_3
//-------------------------------------------------------
// Private methods
//-------------------------------------------------------
template<typename GT, typename P, typename B>
typename AABB_traits_3<GT,P,B>::Axis
AABB_traits_3<GT,P,B>::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 <CGAL/enable_warnings.h>
#endif // CGAL_AABB_TRAITS_3_H_

View File

@ -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,9 +74,8 @@ namespace CGAL {
/// Number type returned by the distance queries.
typedef typename AABBTraits::FT FT;
/// Type of 3D point.
typedef typename AABBTraits::Point_3 Point;
/// Type of point.
typedef typename AABBTraits::Point Point;
/// Type of input primitive.
typedef typename AABBTraits::Primitive 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;
@ -125,7 +124,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
*
@ -300,7 +299,7 @@ public:
/// 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 +330,7 @@ public:
/// 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

View File

@ -36,9 +36,13 @@ namespace CGAL {
template<typename AABBTree, typename SkipFunctor>
class AABB_ray_intersection {
typedef typename AABBTree::AABB_traits AABB_traits;
typedef typename AABB_traits::Ray_3 Ray;
static const int dimension = AABB_traits::Point::Ambient_dimension::value;
typedef typename AABB_traits::Ray Ray;
typedef typename AABB_traits::Vector Vector;
typedef typename AABBTree::template Intersection_and_primitive_id<Ray>::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) {}
@ -48,8 +52,7 @@ public:
// 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<Node_ptr_with_ft> > >
typedef boost::heap::priority_queue< Node_ptr_with_ft, boost::heap::compare< std::greater<Node_ptr_with_ft> > >
Heap_type;
typename AABB_traits::Intersection
@ -167,8 +170,8 @@ private:
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 = AABB_traits().construct_vector_object()(*ray);
for (int i=1; i<dimension; ++i)
if( CGAL::abs(v[i]) > CGAL::abs(v[max_i]) )
max_i = i;
}
@ -184,8 +187,8 @@ private:
}
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 = Vector(AABB_traits().construct_source_object()(*ray), point);
Vector v = AABB_traits().construct_vector_object()(*ray);
return x[max_i] / v[max_i];
}
@ -200,8 +203,8 @@ template<typename Ray, typename SkipFunctor>
std::optional< typename AABB_tree<AABBTraits>::template Intersection_and_primitive_id<Ray>::Type >
AABB_tree<AABBTraits>::first_intersection(const Ray& query,
const SkipFunctor& skip) const {
static_assert(std::is_same<Ray, typename AABBTraits::Ray_3>::value,
"Ray and Ray_3 must be the same type");
static_assert(std::is_same<Ray, typename AABBTraits::Ray>::value,
"Ray and AABBTraits::Ray must be the same type");
switch(size()) // copy-paste from AABB_tree::traversal
{

View File

@ -15,110 +15,60 @@
#include <CGAL/license/AABB_tree.h>
#include <CGAL/Orthogonal_k_neighbor_search.h>
#include <CGAL/Search_traits_3.h>
#include <CGAL/Search_traits_adapter.h>
#include <CGAL/property_map.h>
namespace CGAL
{
template <class Underlying, class Id>
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) {}
template <class Traits>
struct AABB_search_tree
{
// 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) {}
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<Point_and_primitive_id> Pmap;
typedef Search_traits_adapter<Point_and_primitive_id, Pmap, Traits> TreeTraits;
typedef typename CGAL::Orthogonal_k_neighbor_search<TreeTraits> Neighbor_search;
typedef typename Neighbor_search::Tree Tree;
private:
Tree m_tree;
Decorated_point(const typename Underlying::Point_3& p,
const Id& id)
: Underlying::Point_3(p)
, m_id(id)
, m_is_id_initialized(true) {}
Point_and_primitive_id get_p_and_p(const Point_and_primitive_id& p)
{
return p;
}
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;
}
Point_and_primitive_id get_p_and_p(const Point& p)
{
return Point_and_primitive_id(p, Id());
}
Decorated_point& operator=(const Decorated_point&)=default;
private:
Id m_id;
public:
template <class ConstPointIterator>
AABB_search_tree(ConstPointIterator begin, ConstPointIterator beyond)
: m_tree{}
{
std::vector<Point_and_primitive_id> 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();
}
// 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 Traits>
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<Add_decorated_point<Traits, typename Traits::Primitive::Id> > TreeTraits;
typedef typename CGAL::Orthogonal_k_neighbor_search<TreeTraits> 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 <class ConstPointIterator>
AABB_search_tree(ConstPointIterator begin, ConstPointIterator beyond)
: m_tree{}
{
typedef typename Add_decorated_point<Traits,typename Traits::Primitive::Id>::Point_3 Decorated_point;
std::vector<Decorated_point> 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<Point>(search.begin()->first), search.begin()->first.id());
}
};
template <typename Point>
Point_and_primitive_id closest_point(const Point& query) const
{
Neighbor_search search(m_tree, query, 1);
return search.begin()->first;
}
};
}
#endif // CGAL_AABB_SEARCH_TREE_H

View File

@ -0,0 +1,47 @@
// 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_AABB_TRAITS_BASE_H
#define CGAL_AABB_TRAITS_BASE_H
#include <CGAL/license/AABB_tree.h>
#include <CGAL/AABB_tree/internal/Has_nested_type_Shared_data.h>
namespace CGAL {
namespace internal {
namespace AABB_tree {
//helper controlling whether extra data should be stored in the AABB_tree traits class
template <class Primitive, bool has_shared_data = Has_nested_type_Shared_data<Primitive>::value>
struct AABB_traits_base;
template <class Primitive>
struct AABB_traits_base<Primitive, false> {};
template <class Primitive>
struct AABB_traits_base<Primitive, true> {
typename Primitive::Shared_data m_primitive_data;
template <typename ... T>
void set_shared_data(T&& ... t) {
m_primitive_data = Primitive::construct_shared_data(std::forward<T>(t)...);
}
const typename Primitive::Shared_data& shared_data() const { return m_primitive_data; }
};
}
}
}
#endif

View File

@ -59,7 +59,7 @@ template<typename AABBTraits, typename Query>
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<typename AABBTraits, typename Query, typename Output_iterator>
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;
@ -151,7 +151,7 @@ template<typename AABBTraits, typename Query, typename Output_iterator>
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;
@ -191,7 +191,7 @@ template<typename AABBTraits, typename Query>
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<typename AABBTraits, typename Query>
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;
@ -278,7 +278,7 @@ template <typename AABBTraits>
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 @@ public:
{
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

View File

@ -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<typename GeomTraits>
struct Is_ray_intersection_geomtraits_2
: std::bool_constant< Has_ray_2<GeomTraits>::value &&
Has_construct_source_2<GeomTraits>::value &&
Has_vector_2<GeomTraits>::value &&
Has_construct_cartesian_const_iterator_2<GeomTraits>::value &&
Has_cartesian_const_iterator_2<GeomTraits>::value >
{};
template<typename GeomTraits>
struct Is_ray_intersection_geomtraits
: std::bool_constant< Has_ray_3<GeomTraits>::value &&
Has_construct_source_3<GeomTraits>::value &&
Has_vector_3<GeomTraits>::value &&
Has_construct_cartesian_const_iterator_3<GeomTraits>::value &&
: std::bool_constant< Has_ray_3<GeomTraits>::value&&
Has_construct_source_3<GeomTraits>::value&&
Has_vector_3<GeomTraits>::value&&
Has_construct_cartesian_const_iterator_3<GeomTraits>::value&&
Has_cartesian_const_iterator_3<GeomTraits>::value >
{};

View File

@ -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 <CGAL/license/AABB_tree.h>
#include <optional>
namespace CGAL {
namespace internal {
template <class T>
struct Remove_optional { typedef T type; };
template <class T>
struct Remove_optional< ::std::optional<T> > { typedef T type; };
} // end namespace internal
} // end namespace CGAL
#endif

View File

@ -19,7 +19,7 @@
#include <CGAL/AABB_tree/internal/AABB_traversal_traits.h>
#include <CGAL/AABB_primitive.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/array.h>
#include <CGAL/Bbox_3.h>
@ -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<AABB_geom_traits, Primitive, BPM>;
using AABB_traits = CGAL::AABB_traits_3<AABB_geom_traits, Primitive, BPM>;
using AABB_tree = CGAL::AABB_tree<AABB_traits>;
};

View File

@ -1,4 +1,4 @@
// Copyright (c) 2012 INRIA Sophia-Antipolis (France).
// Copyright (c) 2024 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
@ -11,92 +11,38 @@
// Author(s) : Sebastien Loriot
//
#ifndef CGAL_AABB_TRIANGLE_PRIMITIVE_H_
#define CGAL_AABB_TRIANGLE_PRIMITIVE_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#define CGAL_DEPRECATED_HEADER "<CGAL/AABB_triangle_primitive.h>"
#define CGAL_REPLACEMENT_HEADER "<CGAL/AABB_triangle_primitive_3.h>"
#include <CGAL/Installation/internal/deprecation_warning.h>
#include <CGAL/AABB_primitive.h>
#include <iterator>
#ifndef CGAL_NO_DEPRECATED_CODE
#include <CGAL/AABB_triangle_primitive_3.h>
/// \file AABB_triangle_primitive.h
namespace CGAL {
namespace internal {
template <class GeomTraits, class Iterator>
struct Point_from_triangle_3_iterator_property_map{
//classical typedefs
typedef Iterator key_type;
typedef typename GeomTraits::Point_3 value_type;
// typedef decltype(
// std::declval<typename GeomTraits::Construct_vertex_3>()(
// std::declval<typename GeomTraits::Triangle_3>(),
// std::declval<int>())) reference;
typedef decltype(
typename GeomTraits::Construct_vertex_3()(
*std::declval<key_type&>(), 0)) reference;
typedef boost::readable_property_map_tag category;
typedef Point_from_triangle_3_iterator_property_map<GeomTraits, Iterator> Self;
inline friend reference
get(Self, key_type it)
{
return typename GeomTraits::Construct_vertex_3()( *it, 0 );
}
};
}//namespace internal
/// \addtogroup PkgAABBTreeRef
/// @{
/// template alias for backward compatibility
/*!
* \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_3` and `Triangle_3`.
* It also provides the functor `Construct_vertex_3` that has an operator taking a `Triangle_3`
* and an integer as parameters and returning a triangle point as a type convertible to `Point_3`.
* \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Triangle_3`
* \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<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
* \sa `AABB_segment_primitive<Iterator,CacheDatum>`
* \sa `AABB_halfedge_graph_segment_primitive<HalfedgeGraph,OneHalfedgeGraphPerTree,CacheDatum>`
* \sa `AABB_face_graph_triangle_primitive<FaceGraph,OneFaceGraphPerTree,CacheDatum>`
*/
template < class GeomTraits,
class Iterator,
class CacheDatum=Tag_false>
class AABB_triangle_primitive
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Point_from_triangle_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum >
#endif
{
typedef AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Point_from_triangle_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum > Base;
public:
///constructor from an iterator
AABB_triangle_primitive(Iterator it) : Base(it){}
};
using AABB_triangle_primitive = AABB_triangle_primitive_3<GeomTraits, Iterator, CacheDatum>;
} // end namespace CGAL
///@}
#include <CGAL/enable_warnings.h>
} //CGAL namespace
#endif // CGAL_AABB_TRIANGLE_PRIMITIVE_H_
#endif // CGAL_NO_DEPRECATED_CODE
#endif //CGAL_AABB_TRIANGLE_PRIMITIVE_H_

View File

@ -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_TRIANGLE_PRIMITIVE_2_H_
#define CGAL_AABB_TRIANGLE_PRIMITIVE_2_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#include <CGAL/AABB_primitive.h>
#include <iterator>
namespace CGAL {
namespace internal {
template <class GeomTraits, class Iterator>
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<typename GeomTraits::Construct_vertex_2>()(
// std::declval<typename GeomTraits::Triangle_2>(),
// std::declval<int>())) reference;
typedef decltype(
typename GeomTraits::Construct_vertex_2()(
*std::declval<key_type&>(), 0)) reference;
typedef boost::readable_property_map_tag category;
typedef Point_from_triangle_2_iterator_property_map<GeomTraits, Iterator> 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 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.
*
* \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<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
* \sa `AABB_segment_primitive_2<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_triangle_primitive_3<GeomTraits,Iterator,CacheDatum>`
*/
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<Iterator>,
internal::Point_from_triangle_2_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum >
#endif
{
typedef AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Point_from_triangle_2_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum > Base;
public:
///constructor from an iterator
AABB_triangle_primitive_2(Iterator it) : Base(it){}
};
} // end namespace CGAL
#include <CGAL/enable_warnings.h>
#endif // CGAL_AABB_TRIANGLE_PRIMITIVE_2_H_

View File

@ -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_3_H_
#define CGAL_AABB_TRIANGLE_PRIMITIVE_3_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#include <CGAL/AABB_primitive.h>
#include <iterator>
namespace CGAL {
namespace internal {
template <class GeomTraits, class Iterator>
struct Point_from_triangle_3_iterator_property_map{
//classical typedefs
typedef Iterator key_type;
typedef typename GeomTraits::Point_3 value_type;
// typedef decltype(
// std::declval<typename GeomTraits::Construct_vertex_3>()(
// std::declval<typename GeomTraits::Triangle_3>(),
// std::declval<int>())) reference;
typedef decltype(
typename GeomTraits::Construct_vertex_3()(
*std::declval<key_type&>(), 0)) reference;
typedef boost::readable_property_map_tag category;
typedef Point_from_triangle_3_iterator_property_map<GeomTraits, Iterator> Self;
inline friend reference
get(Self, key_type it)
{
return typename GeomTraits::Construct_vertex_3()( *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_3` and `Triangle_3`.
* It also provides the functor `Construct_vertex_3` that has an operator taking a `Triangle_3`
* and an integer as parameters and returning a triangle point as a type convertible to `Point_3`.
* \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Triangle_3`
* \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<Id,ObjectPropertyMap,PointPropertyMapPolyhedron,ExternalPropertyMaps,CacheDatum>`
* \sa `AABB_segment_primitive_3<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_triangle_primitive_2<GeomTraits,Iterator,CacheDatum>`
* \sa `AABB_face_graph_triangle_primitive<FaceGraph,VertexPointPMap,OneFaceGraphPerTree,CacheDatum>`
*/
template < class GeomTraits,
class Iterator,
class CacheDatum=Tag_false>
class AABB_triangle_primitive_3
#ifndef DOXYGEN_RUNNING
: public AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Point_from_triangle_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum >
#endif
{
typedef AABB_primitive< Iterator,
Input_iterator_property_map<Iterator>,
internal::Point_from_triangle_3_iterator_property_map<GeomTraits, Iterator>,
Tag_false,
CacheDatum > Base;
public:
///constructor from an iterator
AABB_triangle_primitive_3(Iterator it) : Base(it){}
};
} // end namespace CGAL
#include <CGAL/enable_warnings.h>
#endif // CGAL_AABB_TRIANGLE_PRIMITIVE_3_H_

View File

@ -36,7 +36,7 @@ namespace CGAL
std::declval<int>())) reference;
// typedef decltype(
// typename GeomTraits::Construct_vertex_3()(
// *std::declval<key_type&>(), 0)) reference; // fails polyhedron demo!
// *std::declval<key_type&>(), 0)) reference; // fails CGAL Lab!
typedef boost::readable_property_map_tag category;
typedef Point_from_cell_iterator_proprety_map<GeomTraits, Iterator> Self;

View File

@ -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.

View File

@ -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.

View File

@ -246,7 +246,7 @@ void test(const std::string filename,
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef Primitive_generator<Primitive,K,Polyhedron> Pr_generator;
typedef typename Pr_generator::Primitive Pr;
typedef CGAL::AABB_traits<K, Pr> Traits;
typedef CGAL::AABB_traits_3<K, Pr> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
Polyhedron polyhedron;
@ -316,13 +316,13 @@ class Naive_implementations
{
typedef Primitive_generator<Primitive,K,Polyhedron> Pr_generator;
typedef typename Pr_generator::Primitive Pr;
typedef CGAL::AABB_traits<K, Pr> Traits;
typedef CGAL::AABB_traits_3<K, Pr> 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;
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<Object_and_primitive_id> Intersection_result;

View File

@ -10,7 +10,7 @@
#include <CGAL/function_objects.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/Polyhedron_3.h>
@ -64,7 +64,7 @@ std::tuple<std::size_t, std::size_t, std::size_t, long> test(const char* name) {
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
std::ifstream ifs(name);

View File

@ -23,7 +23,7 @@
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
template <class K>
@ -43,7 +43,7 @@ int test()
// construct tree from facets
typedef typename CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
typedef typename CGAL::AABB_traits<K,Primitive> Traits;
typedef typename CGAL::AABB_traits_3<K,Primitive> Traits;
typedef typename CGAL::AABB_tree<Traits> Tree;
typedef typename Tree::Object_and_primitive_id Object_and_primitive_id;
Tree tree(faces(polyhedron).first, faces(polyhedron).second, polyhedron);

View File

@ -0,0 +1,56 @@
#include <CGAL/Installation/internal/disable_deprecation_warnings_and_errors.h>
#include <iostream>
#include <list>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_segment_primitive.h>
typedef CGAL::Simple_cartesian<double> 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<Segment>::iterator Iterator;
typedef CGAL::AABB_segment_primitive<K, Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> 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<Segment> 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;
}

View File

@ -0,0 +1,51 @@
#include <CGAL/Installation/internal/disable_deprecation_warnings_and_errors.h>
#include <iostream>
#include <list>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_triangle_primitive.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::FT FT;
typedef K::Ray_3 Ray;
typedef K::Point_3 Point;
typedef K::Triangle_3 Triangle;
typedef std::list<Triangle>::iterator Iterator;
typedef CGAL::AABB_triangle_primitive<K, Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> AABB_triangle_traits;
typedef CGAL::AABB_tree<AABB_triangle_traits> Tree;
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<Triangle> 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);
std::cout << closest_point << std::endl;
FT sqd = tree.squared_distance(point_query);
std::cout << sqd << std::endl;
return EXIT_SUCCESS;
}

View File

@ -21,7 +21,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Polyhedron_3.h>

View File

@ -22,7 +22,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/spatial_sort.h>

View File

@ -19,7 +19,7 @@
#include <CGAL/Timer.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Polyhedron_3.h>
#include "AABB_test_util.h"

View File

@ -26,7 +26,7 @@
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include "AABB_test_util.h"

View File

@ -27,7 +27,7 @@
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include "AABB_test_util.h"

View File

@ -27,7 +27,7 @@
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include "AABB_test_util.h"

View File

@ -26,7 +26,7 @@
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include "AABB_test_util.h"

View File

@ -5,7 +5,7 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/AABB_halfedge_graph_segment_primitive.h>
@ -24,8 +24,8 @@ CGAL::Tag_false> S_Primitive;
typedef CGAL::AABB_face_graph_triangle_primitive<Mesh,
CGAL::Default,
CGAL::Tag_false> T_Primitive;
typedef CGAL::AABB_traits<K, T_Primitive> T_Traits;
typedef CGAL::AABB_traits<K, S_Primitive> S_Traits;
typedef CGAL::AABB_traits_3<K, T_Primitive> T_Traits;
typedef CGAL::AABB_traits_3<K, S_Primitive> S_Traits;
typedef CGAL::AABB_tree<T_Traits> T_Tree;
typedef CGAL::AABB_tree<S_Traits> S_Tree;
typedef T_Tree::Primitive_id T_Primitive_id;

View File

@ -6,7 +6,7 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/Surface_mesh.h>
@ -15,22 +15,22 @@ typedef K::Point_3 Point;
typedef K::Triangle_3 Triangle;
typedef CGAL::Surface_mesh<Point> Mesh;
typedef CGAL::AABB_face_graph_triangle_primitive<Mesh> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef CGAL::AABB_face_graph_triangle_primitive<Mesh,
CGAL::Default, CGAL::Tag_true, CGAL::Tag_true> Primitive2;
typedef CGAL::AABB_traits<K, Primitive2> Traits2;
typedef CGAL::AABB_traits_3<K, Primitive2> Traits2;
typedef CGAL::AABB_tree<Traits2> Tree2;
typedef CGAL::AABB_face_graph_triangle_primitive<Mesh,
CGAL::Default, CGAL::Tag_false, CGAL::Tag_true> Primitive3;
typedef CGAL::AABB_traits<K, Primitive3> Traits3;
typedef CGAL::AABB_traits_3<K, Primitive3> Traits3;
typedef CGAL::AABB_tree<Traits3> Tree3;
typedef CGAL::AABB_face_graph_triangle_primitive<Mesh,
CGAL::Default, CGAL::Tag_false, CGAL::Tag_false> Primitive4;
typedef CGAL::AABB_traits<K, Primitive4> Traits4;
typedef CGAL::AABB_traits_3<K, Primitive4> Traits4;
typedef CGAL::AABB_tree<Traits4> Tree4;
int main(void)

View File

@ -3,8 +3,8 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_segment_primitive.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_segment_primitive_3.h>
#include <cassert>
typedef CGAL::Simple_cartesian<double> K;
@ -16,8 +16,8 @@ typedef K::Segment_3 Segment;
typedef K::Triangle_3 Triangle;
typedef std::vector<Segment>::iterator Iterator;
typedef CGAL::AABB_segment_primitive<K,Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_segment_primitive_3<K,Iterator> Primitive;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
int main()

View File

@ -0,0 +1,86 @@
#include <iostream>
#include <vector>
#include <array>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits_2.h>
#include <CGAL/AABB_indexed_triangle_primitive_2.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::Point_3 Point_3;
typedef K::Point_2 Point_2;
typedef K::Ray_2 Ray;
template <class GeomTraits>
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<GeomTraits> Self;
Projection_xy_point_map() {}
inline friend value_type get(Self, key_type p)
{
return value_type(p.x(), p.y());
}
};
typedef std::vector<std::array<uint8_t, 3> >::const_iterator IndexIterator;
typedef std::vector<Point_3> PointRange;
typedef CGAL::AABB_indexed_triangle_primitive_2<K, IndexIterator, PointRange, CGAL::Tag_false, Projection_xy_point_map<K>> Primitive;
typedef CGAL::AABB_traits_2<K, Primitive> AABB_triangle_traits;
typedef CGAL::AABB_tree<AABB_triangle_traits> Tree;
typedef Tree::Point_and_primitive_id Point_and_primitive_id;
typedef std::optional<Tree::Intersection_and_primitive_id<Ray>::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<Point_3> points = { a, b, c, d, e, f };
std::vector<std::array<uint8_t, 3> > 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.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(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.4));
Ray_intersection intersection = tree.first_intersection(ray);
assert(intersection.has_value());
assert(std::distance(triangles.cbegin(), intersection->second) == 3);
std::list<Ray_intersection> intersections;
tree.all_intersections(ray, std::back_inserter(intersections));
assert(intersections.size() == 4);
return EXIT_SUCCESS;
}

View File

@ -6,8 +6,8 @@
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/AABB_halfedge_graph_segment_primitive.h>
#include <CGAL/AABB_segment_primitive.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_segment_primitive_3.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
@ -32,8 +32,8 @@ class TestCase<0>
typedef K::Segment_3 Segment;
typedef K::Triangle_3 Triangle;
typedef std::vector<Segment>::iterator Iterator;
typedef CGAL::AABB_segment_primitive<K, Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_segment_primitive_3<K, Iterator> Primitive;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
public:
@ -106,8 +106,8 @@ class TestCase<1>
typedef CGAL::AABB_face_graph_triangle_primitive<Mesh, CGAL::Default,
CGAL::Tag_false>
T_Primitive;
typedef CGAL::AABB_traits<K, T_Primitive> T_Traits;
typedef CGAL::AABB_traits<K, S_Primitive> S_Traits;
typedef CGAL::AABB_traits_3<K, T_Primitive> T_Traits;
typedef CGAL::AABB_traits_3<K, S_Primitive> S_Traits;
typedef CGAL::AABB_tree<T_Traits> T_Tree;
typedef CGAL::AABB_tree<S_Traits> S_Tree;
typedef T_Tree::Primitive_id T_Primitive_id;

View File

@ -9,7 +9,7 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/AABB_halfedge_graph_segment_primitive.h>
@ -25,14 +25,14 @@ typedef CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epick> > Mesh;
typedef CGAL::AABB_face_graph_triangle_primitive<Mesh,
CGAL::Default,
CGAL::Tag_false> T_Primitive;
typedef CGAL::AABB_traits<K, T_Primitive> T_Traits;
typedef CGAL::AABB_traits_3<K, T_Primitive> T_Traits;
typedef CGAL::AABB_tree<T_Traits> T_Tree;
typedef T_Tree::Primitive_id T_Primitive_id;
typedef CGAL::AABB_halfedge_graph_segment_primitive<Mesh,
CGAL::Default,
CGAL::Tag_false> E_Primitive;
typedef CGAL::AABB_traits<K, E_Primitive> E_Traits;
typedef CGAL::AABB_traits_3<K, E_Primitive> E_Traits;
typedef CGAL::AABB_tree<E_Traits> E_Tree;
typedef E_Tree::Primitive_id E_Primitive_id;

View File

@ -0,0 +1,66 @@
#include <iostream>
#include <vector>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits_2.h>
#include <CGAL/AABB_polyline_segment_primitive_2.h>
#include <CGAL/AABB_segment_primitive_2.h>
#include <CGAL/Polygon_2.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::Segment_2 Segment;
typedef K::Point_2 Point;
typedef std::vector<Point> PointRange;
typedef PointRange::const_iterator Iterator_pr;
typedef CGAL::AABB_polyline_segment_primitive_2<K, Iterator_pr, PointRange> Primitive_pr;
typedef CGAL::AABB_traits_2<K, Primitive_pr> Traits_pr;
typedef CGAL::AABB_tree<Traits_pr> Tree_pr;
typedef Tree_pr::Point_and_primitive_id Point_and_primitive_id_pr;
typedef CGAL::Polygon_2<K> Polygon_2;
typedef Polygon_2::const_iterator Iterator_poly;
typedef CGAL::AABB_polyline_segment_primitive_2<K, Iterator_poly, Polygon_2> Primitive_poly;
typedef CGAL::AABB_traits_2<K, Primitive_poly> Traits_poly;
typedef CGAL::AABB_tree<Traits_poly> Tree_poly;
typedef Tree_poly::Point_and_primitive_id Point_and_primitive_id_poly;
template<class AABBTree, class PPId>
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<Point> polyline = { a, b, c, d, e };
Polygon_2 poly(polyline.begin(), polyline.end());
test<Tree_poly, Point_and_primitive_id_poly>(Tree_poly(poly.begin(), poly.end(), poly));
test<Tree_pr, Point_and_primitive_id_pr>(Tree_pr(polyline.begin(), std::prev(polyline.end()), polyline));
return EXIT_SUCCESS;
}

View File

@ -10,7 +10,7 @@
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/Timer.h>
@ -23,7 +23,7 @@ typedef K::Segment_3 Segment;
typedef K::Ray_3 Ray;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef Tree::Primitive_id Primitive_id;
typedef CGAL::Timer Timer;

View File

@ -0,0 +1,58 @@
#include <iostream>
#include <list>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits_2.h>
#include <CGAL/AABB_segment_primitive_2.h>
#include <CGAL/Polygon_2.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::FT FT;
typedef K::Segment_2 Segment;
typedef K::Point_2 Point;
typedef std::list<Segment> SegmentRange;
typedef SegmentRange::const_iterator Iterator;
typedef CGAL::AABB_segment_primitive_2<K, Iterator> Primitive;
typedef CGAL::AABB_traits_2<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> 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<Segment> 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;
}

View File

@ -3,8 +3,8 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_segment_primitive.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_segment_primitive_3.h>
#include <cassert>
typedef CGAL::Simple_cartesian<double> K;
@ -16,8 +16,8 @@ typedef K::Segment_3 Segment;
typedef K::Triangle_3 Triangle;
typedef std::vector<Segment>::iterator Iterator;
typedef CGAL::AABB_segment_primitive<K,Iterator> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_segment_primitive_3<K,Iterator> Primitive;
typedef CGAL::AABB_traits_3<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
int main()

View File

@ -0,0 +1,50 @@
// Author(s) : Camille Wormser, Pierre Alliez
#include <iostream>
#include <list>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits_2.h>
#include <CGAL/AABB_triangle_primitive_2.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::FT FT;
typedef K::Ray_2 Ray;
typedef K::Point_2 Point;
typedef K::Triangle_2 Triangle;
typedef std::list<Triangle>::const_iterator Iterator;
typedef CGAL::AABB_triangle_primitive_2<K, Iterator> Primitive;
typedef CGAL::AABB_traits_2<K, Primitive> AABB_triangle_traits;
typedef CGAL::AABB_tree<AABB_triangle_traits> 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<Triangle> 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;
}

View File

@ -0,0 +1,49 @@
// Author(s) : Camille Wormser, Pierre Alliez
#include <iostream>
#include <list>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_triangle_primitive_3.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::FT FT;
typedef K::Ray_3 Ray;
typedef K::Point_3 Point;
typedef K::Triangle_3 Triangle;
typedef std::list<Triangle>::const_iterator Iterator;
typedef CGAL::AABB_triangle_primitive_3<K, Iterator> Primitive;
typedef CGAL::AABB_traits_3<K, Primitive> AABB_triangle_traits;
typedef CGAL::AABB_tree<AABB_triangle_traits> 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<Triangle> 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;
}

View File

@ -5,7 +5,7 @@
#include <CGAL/AABB_tree/internal/triangle_datum_covering.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/point_generators_3.h>
#include <CGAL/Polygon_mesh_processing/bbox.h>
@ -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<Mesh, CGAL::Default, CGAL::Tag_true, CGAL::Tag_true>;
using Traits = CGAL::AABB_traits<GT, Primitive>;
using Traits = CGAL::AABB_traits_3<GT, Primitive>;
using Tree = CGAL::AABB_tree<Traits>;
// Build
@ -99,7 +99,7 @@ void test_cover(const Mesh& mesh,
using AABB_tree = CGAL::AABB_trees::internal::AABB_covered_triangle_tree<GT, Point>;
using FG_Primitive = CGAL::AABB_face_graph_triangle_primitive<Mesh, CGAL::Default, CGAL::Tag_true, CGAL::Tag_true>;
using FG_Traits = CGAL::AABB_traits<GT, FG_Primitive>;
using FG_Traits = CGAL::AABB_traits_3<GT, FG_Primitive>;
using FG_Tree = CGAL::AABB_tree<FG_Traits>;
CGAL::Bbox_3 bbox = CGAL::Polygon_mesh_processing::bbox(mesh);

View File

@ -23,7 +23,6 @@ Number_types
Polyhedron
Profiling_tools
Property_map
Random_numbers
STL_Extension
Spatial_sorting
Stream_support

View File

@ -68,9 +68,9 @@ private:
Polynomial poly_;
int number_of_real_roots_;
IT* numerator;
IT* denominator_exponent;
bool* is_exact;
std::vector<IT> numerator;
std::vector<IT> denominator_exponent;
std::vector<bool> is_exact;
IT LEFT,SCALE,DENOM;
bool is_strong_;
int k;
@ -91,9 +91,9 @@ public:
k(kk),
interval_given(false) {
numerator = new IT[CGAL::degree(P)];
denominator_exponent = new IT[CGAL::degree(P)];
is_exact = new bool[CGAL::degree(P)];
numerator.resize(CGAL::degree(P));
denominator_exponent.resize(CGAL::degree(P));
is_exact.resize(CGAL::degree(P));
number_of_real_roots_ = 0;
if(CGAL::degree(P) == 0)
{
@ -116,9 +116,9 @@ public:
k(kk),
interval_given(true) {
numerator = new IT[CGAL::degree(P)];
denominator_exponent = new IT[CGAL::degree(P)];
is_exact = new bool[CGAL::degree(P)];
numerator.resize(CGAL::degree(P));
denominator_exponent.resize(CGAL::degree(P));
is_exact.resize(CGAL::degree(P));
number_of_real_roots_ = 0;
if(CGAL::degree(P) == 0)
{
@ -153,9 +153,9 @@ public:
k(D.k),
interval_given(D.interval_given) {
numerator = new IT[CGAL::degree(poly_)];
denominator_exponent = new IT[CGAL::degree(poly_)];
is_exact = new bool[CGAL::degree(poly_)];
numerator.resize(CGAL::degree(poly_));
denominator_exponent.resize(CGAL::degree(poly_));
is_exact.resize(CGAL::degree(poly_));
for(int i=0; i<number_of_real_roots(); i++)
{
numerator[i] = D.numerator[i];
@ -166,9 +166,6 @@ public:
// destructor
~Descartes() {
delete[] numerator;
delete[] denominator_exponent;
delete[] is_exact;
}
public: // functions

View File

@ -15,7 +15,7 @@
#define CGAL_ALPHA_WRAP_3_BENCHMARK_ALPHA_WRAP_3_QUALITY_DISTANCE_H_
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/bounding_box.h>
#include <CGAL/Polygon_mesh_processing/bbox.h>
@ -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<TriangleMesh>;
using AABB_traits = CGAL::AABB_traits<GT, Primitive>;
using AABB_traits = CGAL::AABB_traits_3<GT, Primitive>;
using AABB_tree = CGAL::AABB_tree<AABB_traits>;
using CGAL::parameters::choose_parameter;

View File

@ -727,7 +727,7 @@ private:
std::cout << "> Extract possibly non-manifold wrap... ()" << std::endl;
#endif
clear(output_mesh);
remove_all_elements(output_mesh);
CGAL_assertion_code(for(auto cit=m_tr.finite_cells_begin(), cend=m_tr.finite_cells_end(); cit!=cend; ++cit))
CGAL_assertion(cit->tds_data().is_clear());
@ -814,7 +814,7 @@ private:
CGAL_assertion_code(for(Vertex_handle v : m_tr.finite_vertex_handles()))
CGAL_assertion(!is_non_manifold(v));
clear(output_mesh);
remove_all_elements(output_mesh);
std::vector<Point_3> points;
std::vector<std::array<std::size_t, 3> > faces;
@ -1153,15 +1153,17 @@ private:
if(!is_positive(alpha) || !is_positive(offset))
{
#ifdef CGAL_AW3_DEBUG
std::cerr << "Error: invalid input parameters: " << alpha << " and" << offset << std::endl;
std::cerr << "Error: invalid input parameters: " << alpha << " and " << offset << std::endl;
#endif
return false;
}
#ifdef CGAL_AW3_DEBUG
if(refining && alpha > m_alpha)
std::cerr << "Warning: refining with an alpha greater than the last iteration's!" << std::endl;
if(refining && offset != m_offset)
std::cerr << "Warning: refining with a different offset value!" << std::endl;
#endif
m_alpha = FT(alpha);
m_sq_alpha = square(m_alpha);

View File

@ -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 <typename Query>
static bool do_intersect(const Query& query,

View File

@ -18,7 +18,7 @@
#include <CGAL/Alpha_wrap_3/internal/Oracle_base.h>
#include <CGAL/AABB_primitive.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/Named_function_parameters.h>
@ -51,7 +51,7 @@ struct PS_oracle_traits
CGAL::Tag_false, // not external
CGAL::Tag_false>; // no caching
using AABB_traits = CGAL::AABB_traits<Geom_traits, Primitive>;
using AABB_traits = CGAL::AABB_traits_3<Geom_traits, Primitive>;
using AABB_tree = CGAL::AABB_tree<AABB_traits>;
};

View File

@ -17,9 +17,9 @@
#include <CGAL/Alpha_wrap_3/internal/Alpha_wrap_AABB_geom_traits.h>
#include <CGAL/Alpha_wrap_3/internal/Oracle_base.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_segment_primitive.h>
#include <CGAL/AABB_segment_primitive_3.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/Named_function_parameters.h>
#include <CGAL/property_map.h>
@ -52,7 +52,7 @@ struct SS_oracle_traits
CGAL::Tag_false, // not external
CGAL::Tag_false>; // no caching
using AABB_traits = CGAL::AABB_traits<Geom_traits, Primitive>;
using AABB_traits = CGAL::AABB_traits_3<Geom_traits, Primitive>;
using AABB_tree = CGAL::AABB_tree<AABB_traits>;
};

View File

@ -18,8 +18,8 @@
#include <CGAL/Alpha_wrap_3/internal/Oracle_base.h>
#include <CGAL/Alpha_wrap_3/internal/splitting_helper.h>
#include <CGAL/AABB_triangle_primitive.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_triangle_primitive_3.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/Named_function_parameters.h>

View File

@ -18,7 +18,7 @@
#include <CGAL/AABB_tree/internal/AABB_traversal_traits.h>
#include <CGAL/AABB_primitive.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/array.h>
#include <CGAL/Bbox_3.h>
@ -83,7 +83,7 @@ struct Splitter_traversal_traits
: public CGAL::internal::AABB_tree::Projection_traits<AABBTraits>
{
using Base = CGAL::internal::AABB_tree::Projection_traits<AABBTraits>;
using Point = typename AABBTraits::Point_3;
using Point = typename AABBTraits::Point;
using Primitive = typename AABBTraits::Primitive;
std::unordered_set<std::size_t> visited_data;
@ -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<GT, Primitive, BPM>;
using AABB_traits = CGAL::AABB_traits_3<GT, Primitive, BPM>;
using AABB_tree = CGAL::AABB_tree<AABB_traits>;
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,84 @@
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s): Engin Deniz Diktas <denizdiktas@gmail.com>
#ifndef AOS_H
#define AOS_H
#include <map>
#include <memory>
#include <vector>
#include <qvector3d.h>
#include "Kml_reader.h"
class Aos {
public:
using Approx_arc = std::vector<QVector3D>;
using Approx_arcs = std::vector<Approx_arc>;
//using Arr_handle = void*;
using Arr_handle = std::shared_ptr<void>;
static Approx_arc get_approx_identification_curve(double error);
// this constructs some sample arcs manually (used to check the visual output)
static Approx_arcs get_approx_arcs(double error);
// this is used to construct approximate arcs from KML-Placemark data
static Approx_arcs get_approx_arcs(const Kml::Placemark& placemark,
double error);
static void get_curves();
static void check(const Kml::Placemarks& placemarks);
// Extended check: here we use the extended version of the DCEL to understand
// what is going on with the additional vertices and faces.
// INPUT: GIS data
// OUTPUT: vertices created during arrangement construction
static std::vector<QVector3D> ext_check(const Kml::Placemarks& placemarks);
// Same as above function but works by identifying the duplicate nodes
static std::vector<QVector3D> ext_check_id_based(Kml::Placemarks& placemarks);
// This function is used to find the newly-created faces during arrangement
// construction. It uses the extended DCEL structure (see: above 2 functions).
// NOTE: The need for this function arises due to the following observation:
// when constructing the arrangement from our data-set I observed a newly
// created face which is not defined explicitly in the data-set. My intiution
// tells me that this is the Caspian sea, because it is the only land-locked
// polygon whose boundaries are not defined in the data-set and its boundaries
// are defined indirecly by its surrounding countries.
static Approx_arcs find_new_faces(Kml::Placemarks& placemarks);
// save the arrangement created with EPEC
static void save_arr(Kml::Placemarks& placemarks,
const std::string& file_name);
// loads the arrangement created by the save_arr function
// NOTE: This one loads the arrangement as "Country_arr" type
static Arr_handle load_arr(const std::string& file_name);
static Arr_handle construct(Kml::Placemarks& placemarks);
//static std::vector<QVector3D> get_triangles(Arr_handle arrh);
//using Country_triangles_map = std::map<std::string, std::vector<QVector3D>>;
//static Country_triangles_map get_triangles_by_country(Arr_handle arrh);
using Country_color_map = std::map<std::string, std::size_t>;
static Country_color_map get_color_mapping(Arr_handle arrh);
static std::string locate_country(Arr_handle arrh, const QVector3D& point);
// this will get the approximate arcs of face-edges from the arrangement
// NOTE: this is similar to "get_approx_arcs(KML::Placemarks&, double)" above!
static Approx_arcs get_approx_arcs_from_faces_edges(Arr_handle arrh,
double error);
};
#endif

View File

@ -0,0 +1,47 @@
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s): Engin Deniz Diktas <denizdiktas@gmail.com>
#ifndef AOS_DEFS_H
#define AOS_DEFS_H
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Arrangement_on_surface_2.h>
#include <CGAL/Arr_extended_dcel.h>
#include <CGAL/Arr_geodesic_arc_on_sphere_traits_2.h>
#include <CGAL/Arr_spherical_topology_traits_2.h>
#include <CGAL/Vector_3.h>
//#define USE_EPIC
#ifdef USE_EPIC
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
#else
using Kernel = CGAL::Exact_predicates_exact_constructions_kernel;
#endif
using Geom_traits = CGAL::Arr_geodesic_arc_on_sphere_traits_2<Kernel>;
using Point = Geom_traits::Point_2;
using Curve = Geom_traits::Curve_2;
using Topol_traits = CGAL::Arr_spherical_topology_traits_2<Geom_traits>;
using Arrangement = CGAL::Arrangement_on_surface_2<Geom_traits, Topol_traits>;
// the following is from "arr_inexact_construction_segments.h":
using Segment = Geom_traits::X_monotone_curve_2;
using Vertex_handle = Arrangement::Vertex_handle;
// COUNTRIES AOS for grouping the faces by the country name
using Countries_dcel = CGAL::Arr_face_extended_dcel<Geom_traits, std::string>;
using Countries_topol_traits =
CGAL::Arr_spherical_topology_traits_2<Geom_traits, Countries_dcel>;
using Countries_arr =
CGAL::Arrangement_on_surface_2<Geom_traits, Countries_topol_traits>;
#endif

Some files were not shown because too many files have changed in this diff Show More