mirror of https://github.com/CGAL/cgal
Fix constness issues in AABB_tree
*remove mutable data members *accelerate_distance_queries is not const *clear_search_tree is not const *root_node() const returns a const Node* *add root_note() non-const version *update documentation of AABB_tree class. function constness was not documented *update changes.html
This commit is contained in:
parent
ef043927fd
commit
eed2074f7f
|
|
@ -77,29 +77,29 @@ Class \ccRefName\ is a static data structure for efficient intersection and dist
|
|||
|
||||
|
||||
\ccGlue
|
||||
\ccMethod{Bounding_box bbox();}{Returns the axis-aligned bounding box of the whole tree. }
|
||||
\ccMethod{Bounding_box bbox() const;}{Returns the axis-aligned bounding box of the whole tree. }
|
||||
\ccGlue
|
||||
\ccMethod{size_type size();}{Returns the number of primitives in the tree. }
|
||||
\ccMethod{size_type size() const;}{Returns the number of primitives in the tree. }
|
||||
\ccGlue
|
||||
\ccMethod{bool empty();}{Returns \ccc{true}, iff tree contains no primitive. }
|
||||
\ccMethod{bool empty() const;}{Returns \ccc{true}, iff tree contains no primitive. }
|
||||
|
||||
% INTERSECTION TESTS
|
||||
\ccHeading{Intersection Tests}
|
||||
|
||||
\ccMethod{template <class Query>
|
||||
bool do_intersect(const Query& query);}{Returns \ccc{true}, iff the query intersects at least one of the input primitives. Type \ccc{Query} must be a type for which \ccHtmlNoLinksFrom{\ccc{do_intersect}} predicates are defined in the \ccc{AT} class.}
|
||||
bool do_intersect(const Query& query) const;}{Returns \ccc{true}, iff the query intersects at least one of the input primitives. Type \ccc{Query} must be a type for which \ccHtmlNoLinksFrom{\ccc{do_intersect}} predicates are defined in the \ccc{AT} class.}
|
||||
\ccGlue
|
||||
\ccMethod{template <class Query>
|
||||
size_type number_of_intersected_primitives(const Query& query);}{Returns the number of primitives intersected by the query. Type \ccc{Query} must be a type for which \ccHtmlNoLinksFrom{\ccc{do_intersect}} predicates are defined in the \ccc{AT} class.}
|
||||
size_type number_of_intersected_primitives(const Query& query) const;}{Returns the number of primitives intersected by the query. Type \ccc{Query} must be a type for which \ccHtmlNoLinksFrom{\ccc{do_intersect}} predicates are defined in the \ccc{AT} class.}
|
||||
\ccGlue
|
||||
\ccMethod{template <class Query, class OutputIterator>
|
||||
OutputIterator
|
||||
all_intersected_primitives(const Query& query,
|
||||
OutputIterator out);}{Outputs to the iterator the list of all intersected primitives ids. This function does not compute the intersection points and is hence faster than the function \ccc{all_intersections} function below. Type \ccc{Query} must be a type for which \ccHtmlNoLinksFrom{\ccc{do_intersect}} predicates are defined in the \ccc{AT} class.}
|
||||
OutputIterator out) const;}{Outputs to the iterator the list of all intersected primitives ids. This function does not compute the intersection points and is hence faster than the function \ccc{all_intersections} function below. Type \ccc{Query} must be a type for which \ccHtmlNoLinksFrom{\ccc{do_intersect}} predicates are defined in the \ccc{AT} class.}
|
||||
\ccGlue
|
||||
\ccMethod{template <class Query>
|
||||
boost::optional<Primitive::Id>
|
||||
any_intersected_primitive(const Query& query);}{Returns the first encountered intersected primitive id, 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 closest from the source point of a ray query. Type \ccc{Query} must be a type for which \ccHtmlNoLinksFrom{\ccc{do_intersect}} predicates are defined in the \ccc{AT} class.}
|
||||
any_intersected_primitive(const Query& query) const;}{Returns the first encountered intersected primitive id, 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 closest from the source point of a ray query. Type \ccc{Query} must be a type for which \ccHtmlNoLinksFrom{\ccc{do_intersect}} predicates are defined in the \ccc{AT} class.}
|
||||
|
||||
|
||||
% INTERSECTIONS
|
||||
|
|
@ -108,11 +108,11 @@ Class \ccRefName\ is a static data structure for efficient intersection and dist
|
|||
\ccMethod{template <class Query, class OutputIterator>
|
||||
OutputIterator
|
||||
all_intersections(const Query& query,
|
||||
OutputIterator out);}{Outputs to the iterator the list of all intersections between the query and input data, as objects of type \ccc{Object_and_primitive_id}. Type \ccc{Query} must be a type for which \ccHtmlNoLinksFrom{\ccc{do_intersect}} predicates and intersections are defined in the \ccc{AT} class.}
|
||||
OutputIterator out) const;}{Outputs to the iterator the list of all intersections between the query and input data, as objects of type \ccc{Object_and_primitive_id}. Type \ccc{Query} must be a type for which \ccHtmlNoLinksFrom{\ccc{do_intersect}} predicates and intersections are defined in the \ccc{AT} class.}
|
||||
\ccGlue
|
||||
\ccMethod{template <class Query>
|
||||
boost::optional<Object_and_primitive_id>
|
||||
any_intersection(const Query& query);}{Returns the first encountered intersection, 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 closest from the source point of a ray query. Type \ccc{Query} must be a type for which \ccHtmlNoLinksFrom{\ccc{do_intersect}} predicates and intersections are defined in the \ccc{AT} class.}
|
||||
any_intersection(const Query& query) const;}{Returns the first encountered intersection, 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 closest from the source point of a ray query. Type \ccc{Query} must be a type for which \ccHtmlNoLinksFrom{\ccc{do_intersect}} predicates and intersections are defined in the \ccc{AT} class.}
|
||||
|
||||
|
||||
|
||||
|
|
@ -120,13 +120,13 @@ Class \ccRefName\ is a static data structure for efficient intersection and dist
|
|||
\ccHeading{Distance Queries}
|
||||
|
||||
\ccMethod{FT
|
||||
squared_distance(const Point& query);}{Returns the minimum squared distance between the query point and all input primitives. Method \ccc{accelerate_distance_queries} should be called before the first distance query, so that an internal secondary search structure is build, for improving performance.}
|
||||
squared_distance(const Point& query) const;}{Returns the minimum squared distance between the query point and all input primitives. Method \ccc{accelerate_distance_queries} should be called before the first distance query, so that an internal secondary search structure is build, for improving performance.}
|
||||
\ccGlue
|
||||
\ccMethod{Point
|
||||
closest_point(const Point& query);}{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. Method \ccc{accelerate_distance_queries} should be called before the first distance query, so that an internal secondary search structure is build, for improving performance.}
|
||||
closest_point(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 points, one arbitrarily chosen closest point is returned. Method \ccc{accelerate_distance_queries} should be called before the first distance query, so that an internal secondary search structure is build, for improving performance.}
|
||||
\ccGlue
|
||||
\ccMethod{Point_and_primitive_id
|
||||
closest_point_and_primitive(const Point& query);}{Returns a \ccc{Point_and_primitive_id} which realizes the smallest distance between the query point and all input primitives. Method \ccc{accelerate_distance_queries} should be called before the first distance query, so that an internal secondary search structure is build, for improving performance.}
|
||||
closest_point_and_primitive(const Point& query) const;}{Returns a \ccc{Point_and_primitive_id} which realizes the smallest distance between the query point and all input primitives. Method \ccc{accelerate_distance_queries} should be called before the first distance query, so that an internal secondary search structure is build, for improving performance.}
|
||||
|
||||
% ACCELERATING THE DISTANCE QUERIES
|
||||
|
||||
|
|
@ -162,13 +162,13 @@ Note that, in some cases, the user is not able to provide ids of the primitives
|
|||
As an alternative to using the KD-tree, the user can also provide the hints directly, by using the following methods:
|
||||
|
||||
\ccMethod{FT
|
||||
squared_distance(const Point& query, const Point& hint);}{Returns the minimum squared distance between the query point and all input primitives. The internal KD-tree is not used.}
|
||||
squared_distance(const Point& query, const Point& hint) const;}{Returns the minimum squared distance between the query point and all input primitives. The internal KD-tree is not used.}
|
||||
|
||||
\ccMethod{Point
|
||||
closest_point(const Point& query, const Point& hint);}{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.}
|
||||
closest_point(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.}
|
||||
|
||||
\ccMethod{Point_and_primitive_id
|
||||
closest_point_and_primitive(const Point& query, const Point_and_primitive_id& hint);}{Returns a \ccc{Point_and_primitive_id} which realizes the smallest distance between the query point and all input primitives. The internal KD-tree is not used.}
|
||||
closest_point_and_primitive(const Point& query, const Point_and_primitive_id& hint) const;}{Returns a \ccc{Point_and_primitive_id} which realizes the smallest distance between the query point and all input primitives. The internal KD-tree is not used.}
|
||||
|
||||
\end{ccAdvanced}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2008 INRIA Sophia-Antipolis (France), ETH Zurich (Switzerland).
|
||||
// Copyright (c) 2008,2011 INRIA Sophia-Antipolis (France), ETH Zurich (Switzerland).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org); you may redistribute it under
|
||||
|
|
@ -121,12 +121,12 @@ namespace CGAL {
|
|||
// returns true iff successful memory allocation
|
||||
template<typename ConstPointIterator>
|
||||
bool accelerate_distance_queries(ConstPointIterator first,
|
||||
ConstPointIterator beyond) const;
|
||||
ConstPointIterator beyond);
|
||||
|
||||
/// Construct internal search tree from
|
||||
/// a point set taken on the internal primitives
|
||||
// returns true iff successful memory allocation
|
||||
bool accelerate_distance_queries() const;
|
||||
bool accelerate_distance_queries();
|
||||
|
||||
// intersection tests
|
||||
template<typename Query>
|
||||
|
|
@ -165,7 +165,7 @@ namespace CGAL {
|
|||
}
|
||||
|
||||
// clears internal KD tree
|
||||
void clear_search_tree() const
|
||||
void clear_search_tree()
|
||||
{
|
||||
delete m_p_search_tree;
|
||||
m_p_search_tree = NULL;
|
||||
|
|
@ -213,16 +213,22 @@ namespace CGAL {
|
|||
// single root node
|
||||
Node* m_p_root_node;
|
||||
|
||||
Node* root_node() const {
|
||||
const Node* root_node() const {
|
||||
if(m_need_build)
|
||||
const_cast< AABB_tree<AABBTraits>* >(this)->build();
|
||||
const_cast< AABB_tree<AABBTraits>* >(this)->build(); //THIS IS NOT THREADSAFE
|
||||
return m_p_root_node;
|
||||
}
|
||||
|
||||
Node* root_node() {
|
||||
if(m_need_build)
|
||||
build();
|
||||
return m_p_root_node;
|
||||
}
|
||||
|
||||
// search KD-tree
|
||||
mutable Search_tree* m_p_search_tree;
|
||||
mutable bool m_search_tree_constructed;
|
||||
mutable bool m_default_search_tree_constructed;
|
||||
const Search_tree* m_p_search_tree;
|
||||
bool m_search_tree_constructed;
|
||||
bool m_default_search_tree_constructed;
|
||||
bool m_need_build;
|
||||
|
||||
private:
|
||||
|
|
@ -329,7 +335,7 @@ namespace CGAL {
|
|||
template<typename Tr>
|
||||
template<typename ConstPointIterator>
|
||||
bool AABB_tree<Tr>::accelerate_distance_queries(ConstPointIterator first,
|
||||
ConstPointIterator beyond) const
|
||||
ConstPointIterator beyond)
|
||||
{
|
||||
// clears current KD tree
|
||||
clear_search_tree();
|
||||
|
|
@ -349,7 +355,7 @@ namespace CGAL {
|
|||
|
||||
// constructs the search KD tree from internal primitives
|
||||
template<typename Tr>
|
||||
bool AABB_tree<Tr>::accelerate_distance_queries() const
|
||||
bool AABB_tree<Tr>::accelerate_distance_queries()
|
||||
{
|
||||
CGAL_assertion(!m_primitives.empty());
|
||||
|
||||
|
|
|
|||
|
|
@ -121,8 +121,8 @@ namespace CGAL
|
|||
delete m_p_tree;
|
||||
}
|
||||
|
||||
// TOFIX: make it const
|
||||
Point_and_primitive_id closest_point(const Point& query)
|
||||
|
||||
Point_and_primitive_id closest_point(const Point& query) const
|
||||
{
|
||||
typedef typename Add_decorated_point<Traits, typename Traits::Primitive::Id>::Point_3 Decorated_point;
|
||||
Neighbor_search search(*m_p_tree, query, 1);
|
||||
|
|
|
|||
|
|
@ -98,6 +98,18 @@ Number of lines of code of CGAL<br>
|
|||
|
||||
<HR>
|
||||
|
||||
<h2 id="release3.10">Release 3.10 </h2>
|
||||
<DIV>
|
||||
<p> Release date: XXX 2011</p>
|
||||
|
||||
<p>
|
||||
CGAL 3.10 offers the following improvements and new functionality : </p>
|
||||
|
||||
<h3>AABB tree</h3>
|
||||
<ul>
|
||||
<li>Fix constness issues in the AABB_tree class.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="release3.9">Release 3.9 </h2>
|
||||
<DIV>
|
||||
<p> Release date: XXX 2011</p>
|
||||
|
|
|
|||
Loading…
Reference in New Issue