This commit is contained in:
Sébastien Loriot 2024-02-19 18:42:35 +01:00
parent b503b42636
commit 14089f54f9
5 changed files with 18 additions and 13 deletions

View File

@ -2,7 +2,7 @@
\ingroup PkgOrthtreeConcepts \ingroup PkgOrthtreeConcepts
\cgalConcept \cgalConcept
Refinement of the OrthtreeTraitsWithData concept, adding requirements for the Refinement of the `OrthtreeTraitsWithData` concept, adding requirements for the
traits class of a `CGAL::Orthtree` in order to supports nearest-neighbor searching. traits class of a `CGAL::Orthtree` in order to supports nearest-neighbor searching.
Nearest neighbor searches expect a tree where `Node_data` is a model of `ForwardRange`. Nearest neighbor searches expect a tree where `Node_data` is a model of `ForwardRange`.
@ -36,7 +36,7 @@ public:
using Node_data_element = unspecified_type; using Node_data_element = unspecified_type;
/*! /*!
* \brief Functor with an operator calculate the squared distance of `Node_data_element` from a point. * \brief Functor with an operator that calculates the squared distance of a `Node_data_element` from a point.
* *
* Provides the operator: * Provides the operator:
* `FT operator()(const Node_data_element&, const Point_d&)` * `FT operator()(const Node_data_element&, const Point_d&)`

View File

@ -25,11 +25,10 @@ public:
using Node_data = unspecified_type; using Node_data = unspecified_type;
/*! /*!
* \brief Functor which initializes the contained elements for the root node. * \brief Functor which initializes elements contained by the root node.
* *
* Each node of a tree has an associated `Node_data` value. * Each node of a tree has an associated `Node_data` value.
* For most nodes, this is set by `Distribute_node_contents`, but that is not possible for the root node. * This functor initializes the `Node_data` of the root node.
* Instead, this functor initializes the `Node_data` of the root node.
* It takes no arguments, and returns an instance of `Node_data`. * It takes no arguments, and returns an instance of `Node_data`.
* *
* Provides the operator: * Provides the operator:

View File

@ -1,4 +1,3 @@
/*! /*!
\ingroup PkgOrthtreeConcepts \ingroup PkgOrthtreeConcepts
\cgalConcept \cgalConcept
@ -24,7 +23,7 @@ public:
Node_index first_index() const; Node_index first_index() const;
/*! /*!
\brief returns the next node to iterate to, given the previous node. \brief returns the next node to be traversed given the previous node `n`.
*/ */
Node_index next(Node_index n) const; Node_index next(Node_index n) const;
}; };

View File

@ -110,12 +110,10 @@ struct Node_data_wrapper<GT, false>
\sa `CGAL::Quadtree` \sa `CGAL::Quadtree`
\sa `CGAL::Octree` \sa `CGAL::Octree`
\tparam GeomTraits must be a model of `OrthtreeTraits` \tparam GeomTraits must be a model of `OrthtreeTraits` or `OrthtreeTraitswithData`.
*/ */
template <typename GeomTraits> template <typename GeomTraits>
class Orthtree { class Orthtree {
static inline constexpr bool has_data = Orthtree_impl::has_Node_data<GeomTraits>::value;
public: public:
/// \name Template Types /// \name Template Types
/// @{ /// @{
@ -124,6 +122,11 @@ public:
/// \name Traits Types /// \name Traits Types
/// @{ /// @{
#ifndef DOXYGEN_RUNNING
static inline constexpr bool has_data = Orthtree_impl::has_Node_data<GeomTraits>::value;
#else
static inline constexpr bool has_data = bool_value; ///< `true` if `GeomTraits` is a model of `OrthtreeTraitswithData` and `false` otherwise.
#endif
static constexpr int dimension = Traits::dimension; ///< Dimension of the tree static constexpr int dimension = Traits::dimension; ///< Dimension of the tree
using Kernel = typename Traits::Kernel; ///< Kernel type. using Kernel = typename Traits::Kernel; ///< Kernel type.
using FT = typename Traits::FT; ///< Number type. using FT = typename Traits::FT; ///< Number type.
@ -133,7 +136,11 @@ public:
using Adjacency = typename Traits::Adjacency; ///< Adjacency type. using Adjacency = typename Traits::Adjacency; ///< Adjacency type.
using Node_index = typename Traits::Node_index; ///< Index of a given node in the tree; the root always has index 0. using Node_index = typename Traits::Node_index; ///< Index of a given node in the tree; the root always has index 0.
#ifndef DOXYGEN_RUNNING
using Node_data = typename Orthtree_impl::Node_data_wrapper<Traits, has_data>::Node_data; using Node_data = typename Orthtree_impl::Node_data_wrapper<Traits, has_data>::Node_data;
#else
using Node_data = std::conditional_t<has_data,typename GeomTraits::Node_data,void*>;
#endif
/// @} /// @}

View File

@ -26,7 +26,7 @@ namespace CGAL {
/*! /*!
\ingroup PkgOrthtreeTraits \ingroup PkgOrthtreeTraits
Traits class for the `Orthtree` class to be used to contruct a 3D octree around Traits class for the `Orthtree` class to be used to construct a 3D octree around
a triangulated surface mesh. Each node of the octree will store all the faces of the a triangulated surface mesh. Each node of the octree will store all the faces of the
mesh intersected by its bounding box. The subdivision of the octree is controlled mesh intersected by its bounding box. The subdivision of the octree is controlled
by the nested class `Orthtree_traits_face_graph::Split_predicate_node_min_extent` by the nested class `Orthtree_traits_face_graph::Split_predicate_node_min_extent`
@ -93,13 +93,13 @@ struct Orthtree_traits_face_graph : public Orthtree_traits_base<
}; };
} }
auto construct_root_node_contents_object() { auto construct_root_node_contents_object() const {
return [&]() -> Node_data { return [&]() -> Node_data {
return {faces(m_pm).begin(), faces(m_pm).end()}; return {faces(m_pm).begin(), faces(m_pm).end()};
}; };
} }
auto distribute_node_contents_object() { auto distribute_node_contents_object() const {
return [&](Node_index n, Tree& tree, const Point_d& /* center */) -> void { return [&](Node_index n, Tree& tree, const Point_d& /* center */) -> void {
Node_data& ndata = tree.data(n); Node_data& ndata = tree.data(n);
for (int i = 0; i < 8; ++i) { for (int i = 0; i < 8; ++i) {