From 41ae2c31bb201ead472724fe478733dc3ef1bfd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 26 Mar 2020 19:28:26 +0100 Subject: [PATCH] extra run of the script to remove tabs and trailing whitespaces --- AABB_tree/include/CGAL/AABB_tree.h | 878 ++++++++++++++--------------- 1 file changed, 439 insertions(+), 439 deletions(-) diff --git a/AABB_tree/include/CGAL/AABB_tree.h b/AABB_tree/include/CGAL/AABB_tree.h index 6ac023ecbb6..094a1c124aa 100644 --- a/AABB_tree/include/CGAL/AABB_tree.h +++ b/AABB_tree/include/CGAL/AABB_tree.h @@ -40,7 +40,7 @@ namespace CGAL { /// \addtogroup PkgAABBTreeRef /// @{ - /** + /** * Class AABB_tree is a static data structure for efficient * intersection and distance computations in 3D. It builds a * hierarchy of axis-aligned bounding boxes (an AABB tree) from a set @@ -53,43 +53,43 @@ namespace CGAL { * \sa `AABBPrimitive` * */ - template - class AABB_tree - { - private: - // internal KD-tree used to accelerate the distance queries - typedef AABB_search_tree Search_tree; + template + class AABB_tree + { + private: + // internal KD-tree used to accelerate the distance queries + typedef AABB_search_tree Search_tree; - // type of the primitives container - typedef std::vector Primitives; + // type of the primitives container + typedef std::vector Primitives; - typedef AABB_tree Self; + typedef AABB_tree Self; - public: + public: typedef AABBTraits AABB_traits; - + /// \name Types ///@{ /// Number type returned by the distance queries. - typedef typename AABBTraits::FT FT; + typedef typename AABBTraits::FT FT; /// Type of 3D point. - typedef typename AABBTraits::Point_3 Point; + typedef typename AABBTraits::Point_3 Point; /// Type of input primitive. - typedef typename AABBTraits::Primitive Primitive; - /// Identifier for a primitive in the tree. - typedef typename Primitive::Id Primitive_id; - /// Unsigned integral size type. - typedef typename Primitives::size_type size_type; + typedef typename AABBTraits::Primitive Primitive; + /// Identifier for a primitive in the tree. + typedef typename Primitive::Id Primitive_id; + /// Unsigned integral size type. + typedef typename Primitives::size_type size_type; /// Type of bounding box. - typedef typename AABBTraits::Bounding_box Bounding_box; + typedef typename AABBTraits::Bounding_box Bounding_box; /// 3D 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; + typedef typename AABBTraits::Point_and_primitive_id Point_and_primitive_id; + /// \deprecated + typedef typename AABBTraits::Object_and_primitive_id Object_and_primitive_id; /*! An alias to `AABBTraits::Intersection_and_primitive_id` @@ -104,10 +104,10 @@ namespace CGAL { }; #endif - + ///@} - public: + public: /// \name Creation ///@{ @@ -131,8 +131,8 @@ namespace CGAL { * It is equivalent to constructing an empty tree and calling `insert(first,last,t...)`. * The tree stays empty if the memory allocation is not successful. */ - template - AABB_tree(InputIterator first, InputIterator beyond,T&& ...); + template + AABB_tree(InputIterator first, InputIterator beyond,T&& ...); /// After one or more calls to `insert()` the internal data /// structure of the tree must be reconstructed. This procedure @@ -151,12 +151,12 @@ namespace CGAL { #endif ///@} - /// \name Operations - ///@{ + /// \name Operations + ///@{ /// Equivalent to calling `clear()` and then `insert(first,last,t...)`. - template - void rebuild(ConstPrimitiveIterator first, ConstPrimitiveIterator beyond,T&& ...); + template + void rebuild(ConstPrimitiveIterator first, ConstPrimitiveIterator beyond,T&& ...); /// Add a sequence of primitives to the set of primitives of the AABB tree. @@ -165,51 +165,51 @@ namespace CGAL { /// `Primitive(%InputIterator, T...)`. If `Primitive` is a model of the concept /// `AABBPrimitiveWithSharedData`, a call to `AABBTraits::set_shared_data(t...)` /// is made using the internally stored traits. - template - void insert(InputIterator first, InputIterator beyond,T&& ...); + template + void insert(InputIterator first, InputIterator beyond,T&& ...); /// Adds a primitive to the set of primitives of the tree. inline void insert(const Primitive& p); - /// Clears and destroys the tree. - ~AABB_tree() - { - clear(); - } + /// Clears and destroys the tree. + ~AABB_tree() + { + clear(); + } /// Returns a const reference to the internally stored traits class. const AABBTraits& traits() const{ - return m_traits; + return m_traits; } - - /// Clears the tree. - void clear() - { - // clear AABB tree + + /// Clears the tree. + void clear() + { + // clear AABB tree clear_nodes(); - m_primitives.clear(); - clear_search_tree(); - m_default_search_tree_constructed = true; - } + m_primitives.clear(); + clear_search_tree(); + m_default_search_tree_constructed = true; + } + + /// Returns the axis-aligned bounding box of the whole tree. + /// \pre `!empty()` + const Bounding_box bbox() const { + CGAL_precondition(!empty()); + if(size() > 1) + return root_node()->bbox(); + else + return traits().compute_bbox_object()(m_primitives.begin(), + m_primitives.end()); + } - /// Returns the axis-aligned bounding box of the whole tree. - /// \pre `!empty()` - const Bounding_box bbox() const { - CGAL_precondition(!empty()); - if(size() > 1) - return root_node()->bbox(); - else - return traits().compute_bbox_object()(m_primitives.begin(), - m_primitives.end()); - } - /// Returns the number of primitives in the tree. - size_type size() const { return m_primitives.size(); } - - /// Returns \c true, iff the tree contains no primitive. - bool empty() const { return m_primitives.empty(); } - ///@} + size_type size() const { return m_primitives.size(); } - private: + /// Returns \c true, iff the tree contains no primitive. + bool empty() const { return m_primitives.empty(); } + ///@} + + private: template void set_primitive_data_impl(CGAL::Boolean_tag,T ... ){} template @@ -221,27 +221,27 @@ namespace CGAL { set_primitive_data_impl(CGAL::Boolean_tag::value>(),std::forward(t)...); } - bool build_kd_tree() const; - template - bool build_kd_tree(ConstPointIterator first, ConstPointIterator beyond) const; + bool build_kd_tree() const; + template + bool build_kd_tree(ConstPointIterator first, ConstPointIterator beyond) const; public: /// \name Intersection Tests ///@{ - /// Returns `true`, iff the query intersects at least one of - /// the input primitives. \tparam Query must be a type for - /// which `do_intersect` predicates are - /// defined in the traits class `AABBTraits`. - template - bool do_intersect(const Query& query) const; + /// Returns `true`, iff the query intersects at least one of + /// the input primitives. \tparam Query must be a type for + /// which `do_intersect` predicates are + /// defined in the traits class `AABBTraits`. + template + bool do_intersect(const Query& query) const; /// Returns the number of primitives intersected by the /// query. \tparam Query must be a type for which /// `do_intersect` predicates are defined /// in the traits class `AABBTraits`. - template - size_type number_of_intersected_primitives(const Query& query) const; + template + size_type number_of_intersected_primitives(const Query& query) const; /// Outputs to the iterator the list of all intersected primitives /// ids. This function does not compute the intersection points @@ -249,12 +249,12 @@ public: /// function below. \tparam Query must be a type for which /// `do_intersect` predicates are defined /// in the traits class `AABBTraits`. - template - OutputIterator all_intersected_primitives(const Query& query, OutputIterator out) const; + template + OutputIterator all_intersected_primitives(const Query& query, OutputIterator out) const; - /// Returns the intersected primitive id that is encountered first - /// in the tree traversal, iff + /// Returns the intersected primitive id that is encountered first + /// in the tree traversal, iff /// the query intersects at least one of the input primitives. No /// particular order is guaranteed over the tree traversal, such /// that, e.g, the primitive returned is not necessarily the @@ -262,8 +262,8 @@ public: /// must be a type for which /// `do_intersect` predicates are defined /// in the traits class `AABBTraits`. - template - boost::optional any_intersected_primitive(const Query& query) const; + template + boost::optional any_intersected_primitive(const Query& query) const; ///@} /// \name Intersections @@ -275,18 +275,18 @@ public: /// the iterator. `do_intersect()` /// predicates and intersections must be defined for `Query` /// in the `AABBTraits` class. - template - OutputIterator all_intersections(const Query& query, OutputIterator out) const; + template + OutputIterator all_intersections(const Query& query, OutputIterator out) const; - /// Returns the intersection that is encountered first - /// in the tree traversal. No particular + /// Returns the intersection that is encountered first + /// in the tree traversal. No particular /// order is guaranteed over the tree traversal, e.g, the /// primitive returned is not necessarily the closest from the /// source point of a ray query. Type `Query` must be a type /// for which `do_intersect` predicates /// and intersections are defined in the traits class AABBTraits. - template + template boost::optional< typename Intersection_and_primitive_id::Type > any_intersection(const Query& query) const; @@ -357,8 +357,8 @@ public: /// `accelerate_distance_queries()` should be called before the /// first distance query, so that an internal secondary search /// structure is build, for improving performance. - /// \pre `!empty()` - FT squared_distance(const Point& query) const; + /// \pre `!empty()` + FT squared_distance(const Point& query) const; /// Returns the point in the union of all input primitives which /// is closest to the query. In case there are several closest @@ -367,24 +367,24 @@ public: /// called before the first distance query, so that an internal /// secondary search structure is build, for improving /// performance. - /// \pre `!empty()` - Point closest_point(const Point& query) const; + /// \pre `!empty()` + Point closest_point(const Point& query) const; + - /// Returns a `Point_and_primitive_id` which realizes the /// smallest distance between the query point and all input /// primitives. Method `accelerate_distance_queries()` should be /// called before the first distance query, so that an internal /// secondary search structure is build, for improving /// performance. - /// \pre `!empty()` - Point_and_primitive_id closest_point_and_primitive(const Point& query) const; + /// \pre `!empty()` + Point_and_primitive_id closest_point_and_primitive(const Point& query) const; ///@} /// \name Accelerating the Distance Queries - /// + /// /// In the following paragraphs, we discuss details of the /// implementation of the distance queries. We explain the /// internal use of hints, how the user can pass his own hints to @@ -399,7 +399,7 @@ public: /// exact specification of these internal algorithms is that they /// minimize the distance to the object composed of the union of /// the primitives and the hint. - /// It follows that + /// It follows that /// - in order to return the exact distance to the set of /// primitives, the algorithms need the hint to be exactly on the /// primitives; @@ -438,51 +438,51 @@ public: /// relevant in some cases. ///@{ - /// Constructs internal search tree from - /// a point set taken on the internal primitives - /// returns `true` iff successful memory allocation - bool accelerate_distance_queries() const; - ///Turns off the lazy construction of the internal search tree. - void do_not_accelerate_distance_queries() const; + /// Constructs internal search tree from + /// a point set taken on the internal primitives + /// returns `true` iff successful memory allocation + bool accelerate_distance_queries() const; + ///Turns off the lazy construction of the internal search tree. + void do_not_accelerate_distance_queries() const; /// Constructs an internal KD-tree containing the specified point /// set, to be used as the set of potential hints for accelerating /// the distance queries. /// \tparam ConstPointIterator is an iterator with /// value type `Point_and_primitive_id`. - template - bool accelerate_distance_queries(ConstPointIterator first, ConstPointIterator beyond) const - { - #ifdef CGAL_HAS_THREADS - //this ensures that this is done once at a time - CGAL_SCOPED_LOCK(kd_tree_mutex); - #endif - clear_search_tree(); - m_default_search_tree_constructed = false; // not a default kd-tree - return build_kd_tree(first,beyond); - } - + template + bool accelerate_distance_queries(ConstPointIterator first, ConstPointIterator beyond) const + { + #ifdef CGAL_HAS_THREADS + //this ensures that this is done once at a time + CGAL_SCOPED_LOCK(kd_tree_mutex); + #endif + clear_search_tree(); + m_default_search_tree_constructed = false; // not a default kd-tree + return build_kd_tree(first,beyond); + } + /// Returns the minimum squared distance between the query point /// and all input primitives. The internal KD-tree is not used. - /// \pre `!empty()` - FT squared_distance(const Point& query, const Point& hint) const; + /// \pre `!empty()` + FT squared_distance(const Point& query, const Point& hint) const; /// Returns the point in the union of all input primitives which /// is closest to the query. In case there are several closest /// points, one arbitrarily chosen closest point is returned. The /// internal KD-tree is not used. - /// \pre `!empty()` - Point closest_point(const Point& query, const Point& hint) const; - + /// \pre `!empty()` + Point closest_point(const Point& query, const Point& hint) const; + /// Returns a `Point_and_primitive_id` which realizes the /// smallest distance between the query point and all input /// primitives. The internal KD-tree is not used. - /// \pre `!empty()` - Point_and_primitive_id closest_point_and_primitive(const Point& query, const Point_and_primitive_id& hint) const; + /// \pre `!empty()` + Point_and_primitive_id closest_point_and_primitive(const Point& query, const Point_and_primitive_id& hint) const; ///@} - private: + private: template friend class AABB_ray_intersection; @@ -492,37 +492,37 @@ public: m_p_nodes.clear(); } - // clears internal KD tree - void clear_search_tree() const - { - if ( m_search_tree_constructed ) - { - CGAL_assertion( m_p_search_tree!=nullptr ); - m_p_search_tree.reset(); - m_search_tree_constructed = false; + // clears internal KD tree + void clear_search_tree() const + { + if ( m_search_tree_constructed ) + { + CGAL_assertion( m_p_search_tree!=nullptr ); + m_p_search_tree.reset(); + m_search_tree_constructed = false; } - } + } - public: + public: /// \internal - template - void traversal(const Query& query, Traversal_traits& traits) const - { - switch(size()) - { - case 0: - break; - case 1: - traits.intersection(query, singleton_data()); - break; - default: // if(size() >= 2) - root_node()->template traversal(query, traits, m_primitives.size()); - } - } + template + void traversal(const Query& query, Traversal_traits& traits) const + { + switch(size()) + { + case 0: + break; + case 1: + traits.intersection(query, singleton_data()); + break; + default: // if(size() >= 2) + root_node()->template traversal(query, traits, m_primitives.size()); + } + } - private: - typedef AABB_node Node; + private: + typedef AABB_node Node; /** * @brief Builds the tree by recursive expansion. @@ -539,60 +539,60 @@ public: const std::size_t range, const AABBTraits&); - public: - // returns a point which must be on one primitive - Point_and_primitive_id any_reference_point_and_id() const - { - CGAL_assertion(!empty()); - return Point_and_primitive_id( + public: + // returns a point which must be on one primitive + Point_and_primitive_id any_reference_point_and_id() const + { + CGAL_assertion(!empty()); + return Point_and_primitive_id( internal::Primitive_helper::get_reference_point(m_primitives[0],m_traits), m_primitives[0].id() ); - } + } - public: - Point_and_primitive_id best_hint(const Point& query) const - { - if(m_search_tree_constructed) + public: + Point_and_primitive_id best_hint(const Point& query) const + { + if(m_search_tree_constructed) { - return m_p_search_tree->closest_point(query); + return m_p_search_tree->closest_point(query); } - else - return this->any_reference_point_and_id(); - } - - //! Returns the datum (geometric object) represented `p`. -#ifndef DOXYGEN_RUNNING - typename internal::Primitive_helper::Datum_type -#else - typename AABBTraits::Primitive::Datum_reference -#endif - datum(Primitive& p)const - { - return internal::Primitive_helper:: - get_datum(p, this->traits()); - } + else + return this->any_reference_point_and_id(); + } - private: + //! Returns the datum (geometric object) represented `p`. +#ifndef DOXYGEN_RUNNING + typename internal::Primitive_helper::Datum_type +#else + typename AABBTraits::Primitive::Datum_reference +#endif + datum(Primitive& p)const + { + return internal::Primitive_helper:: + get_datum(p, this->traits()); + } + + private: //Traits class AABBTraits m_traits; - // set of input primitives - Primitives m_primitives; - // tree nodes. first node is the root node - std::vector m_p_nodes; + // set of input primitives + Primitives m_primitives; + // tree nodes. first node is the root node + std::vector m_p_nodes; #ifdef CGAL_HAS_THREADS mutable CGAL_MUTEX internal_tree_mutex;//mutex used to protect const calls inducing build() mutable CGAL_MUTEX kd_tree_mutex;//mutex used to protect calls to accelerate_distance_queries #endif - + const Node* root_node() const { - CGAL_assertion(size() > 1); + CGAL_assertion(size() > 1); if(m_need_build){ #ifdef CGAL_HAS_THREADS //this ensures that build() will be called once CGAL_SCOPED_LOCK(internal_tree_mutex); if(m_need_build) #endif - const_cast< AABB_tree* >(this)->build(); + const_cast< AABB_tree* >(this)->build(); } return std::addressof(m_p_nodes[0]); } @@ -603,18 +603,18 @@ public: return m_p_nodes.back(); } - const Primitive& singleton_data() const { - CGAL_assertion(size() == 1); - return *m_primitives.begin(); - } + const Primitive& singleton_data() const { + CGAL_assertion(size() == 1); + return *m_primitives.begin(); + } - // search KD-tree - mutable std::unique_ptr m_p_search_tree; - mutable bool m_search_tree_constructed; + // search KD-tree + mutable std::unique_ptr m_p_search_tree; + mutable bool m_search_tree_constructed; mutable bool m_default_search_tree_constructed; // indicates whether the internal kd-tree should be built bool m_need_build; - }; // end class AABB_tree + }; // end class AABB_tree /// @} @@ -629,73 +629,73 @@ public: , m_need_build(false) {} - template - typename AABB_tree::Self& AABB_tree::operator=(Self&& tree) noexcept - { - m_traits = std::move(tree.m_traits); - m_primitives = std::move(tree.m_primitives); - m_p_nodes = std::move(tree.m_p_nodes); - m_p_search_tree = std::move(tree.m_p_search_tree); - m_search_tree_constructed = std::exchange(tree.m_search_tree_constructed, false); - m_default_search_tree_constructed = std::exchange(tree.m_default_search_tree_constructed, true); - m_need_build = std::exchange(tree.m_need_build, false); - return *this; - } + template + typename AABB_tree::Self& AABB_tree::operator=(Self&& tree) noexcept + { + m_traits = std::move(tree.m_traits); + m_primitives = std::move(tree.m_primitives); + m_p_nodes = std::move(tree.m_p_nodes); + m_p_search_tree = std::move(tree.m_p_search_tree); + m_search_tree_constructed = std::exchange(tree.m_search_tree_constructed, false); + m_default_search_tree_constructed = std::exchange(tree.m_default_search_tree_constructed, true); + m_need_build = std::exchange(tree.m_need_build, false); + return *this; + } - template - AABB_tree::AABB_tree(Self&& tree) noexcept - { - *this = std::move(tree); - } + template + AABB_tree::AABB_tree(Self&& tree) noexcept + { + *this = std::move(tree); + } - template - template - AABB_tree::AABB_tree(ConstPrimitiveIterator first, + template + template + AABB_tree::AABB_tree(ConstPrimitiveIterator first, ConstPrimitiveIterator beyond, T&& ... t) - : m_traits() + : m_traits() , m_primitives() - , m_p_nodes() - , m_p_search_tree(nullptr) - , m_search_tree_constructed(false) + , m_p_nodes() + , m_p_search_tree(nullptr) + , m_search_tree_constructed(false) , m_default_search_tree_constructed(true) , m_need_build(false) - { - // Insert each primitive into tree + { + // Insert each primitive into tree insert(first, beyond,std::forward(t)...); - } - - template - template - void AABB_tree::insert(ConstPrimitiveIterator first, + } + + template + template + void AABB_tree::insert(ConstPrimitiveIterator first, ConstPrimitiveIterator beyond, T&& ... t) - { - set_shared_data(std::forward(t)...); - while(first != beyond) - { - m_primitives.push_back(Primitive(first,std::forward(t)...)); - ++first; - } + { + set_shared_data(std::forward(t)...); + while(first != beyond) + { + m_primitives.push_back(Primitive(first,std::forward(t)...)); + ++first; + } m_need_build = true; } - + // Clears tree and insert a set of primitives - template - template - void AABB_tree::rebuild(ConstPrimitiveIterator first, + template + template + void AABB_tree::rebuild(ConstPrimitiveIterator first, ConstPrimitiveIterator beyond, T&& ... t) - { - // cleanup current tree and internal KD tree - clear(); + { + // cleanup current tree and internal KD tree + clear(); - // inserts primitives + // inserts primitives insert(first, beyond,std::forward(t)...); build(); - } - + } + template template void AABB_tree::build(T&& ... t) @@ -704,9 +704,9 @@ public: build(); } - template - void AABB_tree::insert(const Primitive& p) - { + template + void AABB_tree::insert(const Primitive& p) + { m_primitives.push_back(p); m_need_build = true; } @@ -743,119 +743,119 @@ public: } - // Build the data structure, after calls to insert(..) - template - void AABB_tree::build() - { + // Build the data structure, after calls to insert(..) + template + void AABB_tree::build() + { clear_nodes(); if(m_primitives.size() > 1) { - // allocates tree nodes - m_p_nodes.reserve(m_primitives.size()-1); + // allocates tree nodes + m_p_nodes.reserve(m_primitives.size()-1); - // constructs the tree - expand(new_node(), m_primitives.begin(), m_primitives.end(), - m_primitives.size(), m_traits); - } + // constructs the tree + expand(new_node(), m_primitives.begin(), m_primitives.end(), + m_primitives.size(), m_traits); + } - // In case the users has switched on the accelerated distance query - // data structure with the default arguments, then it has to be - // /built/rebuilt. - if(m_default_search_tree_constructed && !empty()){ - build_kd_tree(); - } - m_need_build = false; - } - // constructs the search KD tree from given points - // to accelerate the distance queries - template - bool AABB_tree::build_kd_tree() const - { - // iterate over primitives to get reference points on them - std::vector points; - points.reserve(m_primitives.size()); - typename Primitives::const_iterator it; - for(it = m_primitives.begin(); it != m_primitives.end(); ++it) - points.push_back( Point_and_primitive_id( - internal::Primitive_helper::get_reference_point( - *it,m_traits), it->id() ) ); + // In case the users has switched on the accelerated distance query + // data structure with the default arguments, then it has to be + // /built/rebuilt. + if(m_default_search_tree_constructed && !empty()){ + build_kd_tree(); + } + m_need_build = false; + } + // constructs the search KD tree from given points + // to accelerate the distance queries + template + bool AABB_tree::build_kd_tree() const + { + // iterate over primitives to get reference points on them + std::vector points; + points.reserve(m_primitives.size()); + typename Primitives::const_iterator it; + for(it = m_primitives.begin(); it != m_primitives.end(); ++it) + points.push_back( Point_and_primitive_id( + internal::Primitive_helper::get_reference_point( + *it,m_traits), it->id() ) ); - // clears current KD tree - clear_search_tree(); - bool res = build_kd_tree(points.begin(), points.end()); - m_default_search_tree_constructed = true; - return res; - } + // clears current KD tree + clear_search_tree(); + bool res = build_kd_tree(points.begin(), points.end()); + m_default_search_tree_constructed = true; + return res; + } - // constructs the search KD tree from given points - // to accelerate the distance queries - template - template - bool AABB_tree::build_kd_tree(ConstPointIterator first, - ConstPointIterator beyond) const - { - m_p_search_tree = std::make_unique(first, beyond); + // constructs the search KD tree from given points + // to accelerate the distance queries + template + template + bool AABB_tree::build_kd_tree(ConstPointIterator first, + ConstPointIterator beyond) const + { + m_p_search_tree = std::make_unique(first, beyond); m_default_search_tree_constructed = true; - m_search_tree_constructed = true; - return true; - } + m_search_tree_constructed = true; + return true; + } - template - void AABB_tree::do_not_accelerate_distance_queries()const - { - clear_search_tree(); - m_default_search_tree_constructed = false; - } + template + void AABB_tree::do_not_accelerate_distance_queries()const + { + clear_search_tree(); + m_default_search_tree_constructed = false; + } - // constructs the search KD tree from internal primitives - template - bool AABB_tree::accelerate_distance_queries() const - { - if(m_primitives.empty()) return true; - if (m_default_search_tree_constructed) - { - if (!m_need_build) return m_search_tree_constructed; - return true; // default return type, no tree built - } + // constructs the search KD tree from internal primitives + template + bool AABB_tree::accelerate_distance_queries() const + { + if(m_primitives.empty()) return true; + if (m_default_search_tree_constructed) + { + if (!m_need_build) return m_search_tree_constructed; + return true; // default return type, no tree built + } - if(!m_need_build) // the tree was already built, build the kd-tree - { - #ifdef CGAL_HAS_THREADS - //this ensures that this function will be done once - CGAL_SCOPED_LOCK(kd_tree_mutex); - #endif - if (!m_need_build) - { - // clears current KD tree - clear_search_tree(); - bool res = build_kd_tree(); - m_default_search_tree_constructed = true; - return res; - }; - } - m_default_search_tree_constructed = true; - return m_search_tree_constructed; - } + if(!m_need_build) // the tree was already built, build the kd-tree + { + #ifdef CGAL_HAS_THREADS + //this ensures that this function will be done once + CGAL_SCOPED_LOCK(kd_tree_mutex); + #endif + if (!m_need_build) + { + // clears current KD tree + clear_search_tree(); + bool res = build_kd_tree(); + m_default_search_tree_constructed = true; + return res; + }; + } + m_default_search_tree_constructed = true; + return m_search_tree_constructed; + } - template - template - bool - AABB_tree::do_intersect(const Query& query) const - { + template + template + bool + AABB_tree::do_intersect(const Query& query) const + { using namespace CGAL::internal::AABB_tree; typedef typename AABB_tree::AABB_traits AABBTraits; - Do_intersect_traits traversal_traits(m_traits); - this->traversal(query, traversal_traits); - return traversal_traits.is_intersection_found(); - } + Do_intersect_traits traversal_traits(m_traits); + this->traversal(query, traversal_traits); + return traversal_traits.is_intersection_found(); + } #ifndef DOXYGEN_RUNNING //To avoid doxygen to consider definition and declaration as 2 different functions (size_type causes problems) - template - template - typename AABB_tree::size_type - AABB_tree::number_of_intersected_primitives(const Query& query) const - { + template + template + typename AABB_tree::size_type + AABB_tree::number_of_intersected_primitives(const Query& query) const + { using namespace CGAL::internal::AABB_tree; using CGAL::internal::AABB_tree::Counting_output_iterator; typedef typename AABB_tree::AABB_traits AABBTraits; @@ -864,134 +864,134 @@ public: size_type counter = 0; Counting_iterator out(&counter); - Listing_primitive_traits traversal_traits(out,m_traits); - this->traversal(query, traversal_traits); - return counter; - } + this->traversal(query, traversal_traits); + return counter; + } #endif - template - template - OutputIterator - AABB_tree::all_intersected_primitives(const Query& query, - OutputIterator out) const - { + template + template + OutputIterator + AABB_tree::all_intersected_primitives(const Query& query, + OutputIterator out) const + { using namespace CGAL::internal::AABB_tree; typedef typename AABB_tree::AABB_traits AABBTraits; - Listing_primitive_traits traversal_traits(out,m_traits); - this->traversal(query, traversal_traits); - return out; - } + this->traversal(query, traversal_traits); + return out; + } - template - template - OutputIterator - AABB_tree::all_intersections(const Query& query, - OutputIterator out) const - { + template + template + OutputIterator + AABB_tree::all_intersections(const Query& query, + OutputIterator out) const + { using namespace CGAL::internal::AABB_tree; typedef typename AABB_tree::AABB_traits AABBTraits; - Listing_intersection_traits traversal_traits(out,m_traits); - this->traversal(query, traversal_traits); - return out; - } + this->traversal(query, traversal_traits); + return out; + } - template - template + template + template boost::optional< typename AABB_tree::template Intersection_and_primitive_id::Type > - AABB_tree::any_intersection(const Query& query) const - { + AABB_tree::any_intersection(const Query& query) const + { using namespace CGAL::internal::AABB_tree; typedef typename AABB_tree::AABB_traits AABBTraits; - First_intersection_traits traversal_traits(m_traits); - this->traversal(query, traversal_traits); - return traversal_traits.result(); - } + First_intersection_traits traversal_traits(m_traits); + this->traversal(query, traversal_traits); + return traversal_traits.result(); + } - template - template - boost::optional::Primitive_id> - AABB_tree::any_intersected_primitive(const Query& query) const - { + template + template + boost::optional::Primitive_id> + AABB_tree::any_intersected_primitive(const Query& query) const + { using namespace CGAL::internal::AABB_tree; typedef typename AABB_tree::AABB_traits AABBTraits; - First_primitive_traits traversal_traits(m_traits); - this->traversal(query, traversal_traits); - return traversal_traits.result(); - } + First_primitive_traits traversal_traits(m_traits); + this->traversal(query, traversal_traits); + return traversal_traits.result(); + } - // closest point with user-specified hint - template - typename AABB_tree::Point - AABB_tree::closest_point(const Point& query, - const Point& hint) const - { - CGAL_precondition(!empty()); - typename Primitive::Id hint_primitive = m_primitives[0].id(); + // closest point with user-specified hint + template + typename AABB_tree::Point + AABB_tree::closest_point(const Point& query, + const Point& hint) const + { + CGAL_precondition(!empty()); + typename Primitive::Id hint_primitive = m_primitives[0].id(); using namespace CGAL::internal::AABB_tree; typedef typename AABB_tree::AABB_traits AABBTraits; - Projection_traits projection_traits(hint,hint_primitive,m_traits); - this->traversal(query, projection_traits); - return projection_traits.closest_point(); - } + Projection_traits projection_traits(hint,hint_primitive,m_traits); + this->traversal(query, projection_traits); + return projection_traits.closest_point(); + } - // closest point without hint, the search KD-tree is queried for the - // first closest neighbor point to get a hint - template - typename AABB_tree::Point - AABB_tree::closest_point(const Point& query) const - { - CGAL_precondition(!empty()); - const Point_and_primitive_id hint = best_hint(query); - return closest_point(query,hint.first); - } + // closest point without hint, the search KD-tree is queried for the + // first closest neighbor point to get a hint + template + typename AABB_tree::Point + AABB_tree::closest_point(const Point& query) const + { + CGAL_precondition(!empty()); + const Point_and_primitive_id hint = best_hint(query); + return closest_point(query,hint.first); + } - // squared distance with user-specified hint - template - typename AABB_tree::FT - AABB_tree::squared_distance(const Point& query, - const Point& hint) const - { - CGAL_precondition(!empty()); - const Point closest = this->closest_point(query, hint); - return Tr().squared_distance_object()(query, closest); - } + // squared distance with user-specified hint + template + typename AABB_tree::FT + AABB_tree::squared_distance(const Point& query, + const Point& hint) const + { + CGAL_precondition(!empty()); + const Point closest = this->closest_point(query, hint); + return Tr().squared_distance_object()(query, closest); + } - // squared distance without user-specified hint - template - typename AABB_tree::FT - AABB_tree::squared_distance(const Point& query) const - { - CGAL_precondition(!empty()); - const Point closest = this->closest_point(query); - return Tr().squared_distance_object()(query, closest); - } + // squared distance without user-specified hint + template + typename AABB_tree::FT + AABB_tree::squared_distance(const Point& query) const + { + CGAL_precondition(!empty()); + const Point closest = this->closest_point(query); + return Tr().squared_distance_object()(query, closest); + } - // closest point with user-specified hint - template - typename AABB_tree::Point_and_primitive_id - AABB_tree::closest_point_and_primitive(const Point& query) const - { - CGAL_precondition(!empty()); - return closest_point_and_primitive(query,best_hint(query)); - } + // closest point with user-specified hint + template + typename AABB_tree::Point_and_primitive_id + AABB_tree::closest_point_and_primitive(const Point& query) const + { + CGAL_precondition(!empty()); + return closest_point_and_primitive(query,best_hint(query)); + } - // closest point with user-specified hint - template - typename AABB_tree::Point_and_primitive_id - AABB_tree::closest_point_and_primitive(const Point& query, - const Point_and_primitive_id& hint) const - { - CGAL_precondition(!empty()); + // closest point with user-specified hint + template + typename AABB_tree::Point_and_primitive_id + AABB_tree::closest_point_and_primitive(const Point& query, + const Point_and_primitive_id& hint) const + { + CGAL_precondition(!empty()); using namespace CGAL::internal::AABB_tree; typedef typename AABB_tree::AABB_traits AABBTraits; - Projection_traits projection_traits(hint.first,hint.second,m_traits); - this->traversal(query, projection_traits); - return projection_traits.closest_point_and_primitive(); - } + Projection_traits projection_traits(hint.first,hint.second,m_traits); + this->traversal(query, projection_traits); + return projection_traits.closest_point_and_primitive(); + } } // end namespace CGAL