diff --git a/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h b/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h index 123bda80c47..2b46d8dea03 100644 --- a/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h +++ b/AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h @@ -75,25 +75,17 @@ using Intersection_and_primitive_id = unspecified_type; /// \name Splitting /// During the construction of the AABB tree, the primitives are -/// sorted according to some comparison functions related to the \f$x\f$, -/// \f$ y\f$ or \f$ z\f$ coordinate axis: +/// splitted according to some comparison functions related to the longest axis: /// @{ /*! -A functor object to split a range of primitives into two sub-ranges along the X-axis. Provides the operator: -`void operator()(InputIterator first, InputIterator beyond);` %Iterator type `InputIterator` must be a model of RandomAccessIterator and have `Primitive` as value type. The operator is used for determining the primitives assigned to the two children nodes of a given node, assuming that the goal is to split the X-dimension of the bounding box of the node. The primitives assigned to this node are passed as argument to the operator. It should modify the iterator range in such a way that its first half and its second half correspond to the two children nodes. +A functor object to split a range of primitives into two sub-ranges along the longest axis. Provides the operator: + `void operator()(InputIterator first, InputIterator beyond);` %Iterator type `InputIterator` must be a model of RandomAccessIterator + and have `Primitive` as value type. The operator is used for determining the primitives assigned to the two children nodes of a given node, + assuming that the goal is to split the chosen axis dimension of the bounding box of the node. The primitives assigned to this node are passed as argument + to the operator. It should modify the iterator range in such a way that its first half and its second half correspond to the two children nodes. */ -typedef unspecified_type Split_primitives_along_x_axis; - -/*! -A functor object to split a range of primitives into two sub-ranges along the Y-axis. See `Split_primitives_along_x_axis` for the detailed description. -*/ -typedef unspecified_type Split_primitives_along_y_axis; - -/*! -A functor object to split a range of primitives into two sub-ranges along the Z-axis. See `Split_primitives_along_x_axis` for the detailed description. -*/ -typedef unspecified_type Split_primitives_along_z_axis; +typedef unspecified_type Split_primitives; /*! A functor object to compute the bounding box of a set of primitives. Provides the operator: @@ -132,7 +124,7 @@ A functor object to compute the intersection of a query and a primitive. Provide \cgalHeading{Note on Backward Compatibility} Before the release 4.3 of \cgal, the return type of this function used to be `boost::optional`. */ -typedef unspecified_type Intersect; +typedef unspecified_type Intersection; /// \name Distance Queries /// The following predicates are required for each @@ -170,19 +162,9 @@ typedef unspecified_type Equal_3; /// @{ /*! -Returns the primitive splitting functor for the X axis. +Returns the primitive splitting functor. */ -Split_primitives_along_x_axis split_primitives_along_x_axis_object(); - -/*! -Returns the primitive splitting functor for the Y axis. -*/ -Split_primitives_along_y_axis split_primitives_along_y_axis_object(); - -/*! -Returns the primitive splitting functor for the Z axis. -*/ -Split_primitives_along_z_axis split_primitives_along_z_axis_object(); +Split_primitives split_primitives_object(); /*! Returns the bounding box constructor. @@ -197,7 +179,7 @@ Do_intersect do_intersect_object(); /*! Returns the intersection constructor. */ -Intersect intersect_object(); +Intersection intersection_object(); /*! Returns the distance comparison functor. diff --git a/AABB_tree/include/CGAL/AABB_traits.h b/AABB_tree/include/CGAL/AABB_traits.h index 632f2256d4b..42540c0a764 100644 --- a/AABB_tree/include/CGAL/AABB_traits.h +++ b/AABB_tree/include/CGAL/AABB_traits.h @@ -289,12 +289,12 @@ public: * Sorts the range defined by [first,beyond[. Sort is achieved on bbox longuest * axis, using the comparison function `_less_than` (dim in {x,y,z}) */ - class Sort_primitives + class Split_primitives { typedef AABB_traits Traits; const Traits& m_traits; public: - Sort_primitives(const AABB_traits& traits) + Split_primitives(const AABB_traits& traits) : m_traits(traits) {} template @@ -320,7 +320,7 @@ public: } }; - Sort_primitives sort_primitives_object() const {return Sort_primitives(*this);} + Split_primitives split_primitives_object() const {return Split_primitives(*this);} /* diff --git a/AABB_tree/include/CGAL/AABB_transformed_traits.h b/AABB_tree/include/CGAL/AABB_transformed_traits.h new file mode 100644 index 00000000000..b78aad44f54 --- /dev/null +++ b/AABB_tree/include/CGAL/AABB_transformed_traits.h @@ -0,0 +1,138 @@ + +// Copyright (c) 2018 GeometryFactory (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0+ +// +// +// Author(s) : Maxime Gimeno +// + +#ifndef CGAL_AABB_TRANSFORMED_TRAITS_H +#define CGAL_AABB_TRANSFORMED_TRAITS_H + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +/// \file AABB_transformed_traits.h + +namespace CGAL { + +/// \addtogroup PkgAABB_tree +/// @{ + +/// \tparam BaseTraits a model of `CGAL::AABBTraits` +/// +/// \sa `AABBTraits` +/// \sa `AABB_tree` +/// \sa `AABBPrimitive` +/// \sa `AABBPrimitiveWithSharedData` + + template +class AABB_transformed_traits: + public BaseTraits +{ + typedef typename CGAL::Object Object; +public: + typedef BaseTraits Geom_traits; + + // AABBTraits concept types + typedef typename BaseTraits::FT FT; + typedef typename BaseTraits::Point_3 Point_3; + typedef typename BaseTraits::Primitive Primitive; + typedef typename BaseTraits::Bounding_box Bounding_box; + typedef typename BaseTraits::Point_and_primitive_id Point_and_primitive_id; + typedef typename BaseTraits::Object_and_primitive_id Object_and_primitive_id; + template + struct Intersection_and_primitive_id { + typedef typename BaseTraits::template Intersection_and_primitive_id::Intersection_type Intersection_type; + + typedef typename BaseTraits::template Intersection_and_primitive_id::Type Type; + }; + + //SearchGeomTriats_3 concept types + typedef typename BaseTraits::Iso_cuboid_3 Iso_cuboid_3; + typedef typename BaseTraits::Sphere_3 Sphere_3; + typedef typename BaseTraits::Construct_iso_cuboid_3 Construct_iso_cuboid_3; + typedef typename BaseTraits::Construct_min_vertex_3 Construct_min_vertex_3; + typedef typename BaseTraits::Construct_max_vertex_3 Construct_max_vertex_3; + typedef typename BaseTraits::Construct_center_3 Construct_center_3; + typedef typename BaseTraits::Compute_squared_radius_3 Compute_squared_radius_3; + typedef typename BaseTraits::Cartesian_const_iterator_3 Cartesian_const_iterator_3; + typedef typename BaseTraits::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator_3; + + //Splitting + typedef typename BaseTraits::Split_primitives Split_primitives; + typedef typename BaseTraits::Compute_bbox Compute_bbox; + + //Intersections + typedef typename BaseTraits::Do_intersect Do_intersect; + //typedef typename BaseTraits::Intersect Intersect; + typedef typename BaseTraits::Intersection Intersection; + + //Distance Queries + typedef typename BaseTraits::Compare_distance Compare_distance; + typedef typename BaseTraits::Closest_point Closest_point ; + typedef typename BaseTraits::Squared_distance Squared_distance; + typedef typename BaseTraits::Equal_3 Equal_3 ; + + //Operations + Split_primitives split_primitives_object() const { + return BaseTraits::split_primitives_object(); + } + + Compute_bbox compute_bbox_object() const{ + return BaseTraits::compute_bbox_object(); + } + Do_intersect do_intersect_3_object() const{ + return BaseTraits::do_intersect_3_object(); + } + + Intersection intersection_object() const{ + return BaseTraits::intersection_object(); + } + + Compare_distance compare_distance_object() const{ + return BaseTraits::compare_distance_object(); + } + Closest_point closest_point_object() const{ + return BaseTraits::closest_point_object(); + } + Squared_distance squared_distance_object() const{ + return BaseTraits::squared_distance_object(); + } + Equal_3 equal_3_object() const{ + return BaseTraits::equal_3_object; + } +}; + + +} // end namespace CGAL + +#include + +#endif // CGAL_AABB_TRANSFORMED_TRAITS_H diff --git a/AABB_tree/include/CGAL/internal/AABB_tree/AABB_node.h b/AABB_tree/include/CGAL/internal/AABB_tree/AABB_node.h index e3504a615ab..5d0cf5ce4d2 100644 --- a/AABB_tree/include/CGAL/internal/AABB_tree/AABB_node.h +++ b/AABB_tree/include/CGAL/internal/AABB_tree/AABB_node.h @@ -138,7 +138,7 @@ AABB_node::expand(ConstPrimitiveIterator first, m_bbox = traits.compute_bbox_object()(first, beyond); // sort primitives along longest axis aabb - traits.sort_primitives_object()(first, beyond, m_bbox); + traits.split_primitives_object()(first, beyond, m_bbox); switch(range) { diff --git a/AABB_tree/test/AABB_tree/aabb_any_all_benchmark.cpp b/AABB_tree/test/AABB_tree/aabb_any_all_benchmark.cpp index 394bce109b5..5a14a58a893 100644 --- a/AABB_tree/test/AABB_tree/aabb_any_all_benchmark.cpp +++ b/AABB_tree/test/AABB_tree/aabb_any_all_benchmark.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -70,7 +71,8 @@ boost::tuple test(const char* name) typedef CGAL::Polyhedron_3 Polyhedron; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; - typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_traits Base_Traits; + typedef CGAL::AABB_transformed_traits Traits; typedef CGAL::AABB_tree Tree; std::ifstream ifs(name); diff --git a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_node_with_join.h b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_node_with_join.h index d2ae2d1303f..85e40e511ca 100644 --- a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_node_with_join.h +++ b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_node_with_join.h @@ -151,7 +151,7 @@ AABB_node_with_join::expand(ConstPrimitiveIterator first, m_bbox = traits.compute_bbox_object()(first, beyond); // sort primitives along longest axis aabb - traits.sort_primitives_object()(first, beyond, m_bbox); + traits.split_primitives_object()(first, beyond, m_bbox); switch(range) { diff --git a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_traits_2.h b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_traits_2.h index 1eb99e9e72a..b0f65bc63a3 100644 --- a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_traits_2.h +++ b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_traits_2.h @@ -90,7 +90,7 @@ public: // Put the n/2 smallest primitives in the front, the n/2 largest primitives // in the back. They are compared along the bbox' longest axis. - class Sort_primitives + class Split_primitives { public: template @@ -111,9 +111,9 @@ public: } }; - Sort_primitives sort_primitives_object() const + Split_primitives split_primitives_object() const { - return Sort_primitives(); + return Split_primitives(); } // Computes the bounding box of a set of primitives