mirror of https://github.com/CGAL/cgal
BUGFIX:
incremental neighbor search classes were storing a nested ref_counted iterator for begin() which implies that a call to operator++ on a copy of an iterator increment the internal copy of the class (cannot make several pass). There is still a problem in case of copy outside of the class but this is a first step (a deep_copy method should be provided for iterators which would need a small feature).
This commit is contained in:
parent
a40fea01b4
commit
69b2f7079a
|
|
@ -138,6 +138,8 @@ CGAL 3.10 offers the following improvements and new functionality : </p>
|
||||||
</li>
|
</li>
|
||||||
<li>The class <code>Kd_tree</code> is now guaranteed to be read-only thread-safe. As usual in CGAL,
|
<li>The class <code>Kd_tree</code> is now guaranteed to be read-only thread-safe. As usual in CGAL,
|
||||||
this small overhead introduced for thread-safety can be deactivated by defining <code>CGAL_HAS_NO_THREADS</code>.</li>
|
this small overhead introduced for thread-safety can be deactivated by defining <code>CGAL_HAS_NO_THREADS</code>.</li>
|
||||||
|
<li>Bug-fix in <code>Orthogonal_incremental_neighbor_search</code> and <code>Incremental_neighbor_search</code> classes. Several calls to <code>begin()</code>
|
||||||
|
now allow to make several nearest neighbor search queries independently.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3>STL extension</h3>
|
<h3>STL extension</h3>
|
||||||
|
|
|
||||||
|
|
@ -86,43 +86,38 @@ namespace CGAL {
|
||||||
typedef std::vector<Point_with_transformed_distance*> Point_with_distance_vector;
|
typedef std::vector<Point_with_transformed_distance*> Point_with_distance_vector;
|
||||||
typedef std::vector<FT> Distance_vector;
|
typedef std::vector<FT> Distance_vector;
|
||||||
|
|
||||||
iterator *start;
|
//data members
|
||||||
iterator *past_the_end;
|
const Tree& m_tree;
|
||||||
|
Query_item m_query;
|
||||||
|
Distance m_dist;
|
||||||
|
FT m_Eps;
|
||||||
|
bool m_search_nearest;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
Incremental_neighbor_search(const Tree& tree, const Query_item& q,
|
Incremental_neighbor_search(const Tree& tree, const Query_item& q,
|
||||||
FT Eps=FT(0.0), bool search_nearest=true,
|
FT Eps=FT(0.0), bool search_nearest=true,
|
||||||
const Distance& tr=Distance())
|
const Distance& tr=Distance()):
|
||||||
{
|
m_tree(tree),m_query(q),m_dist(tr),m_Eps(Eps),m_search_nearest(search_nearest)
|
||||||
start = new iterator(tree,q,tr,Eps,search_nearest);
|
{}
|
||||||
past_the_end = new iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
// destructor
|
|
||||||
~Incremental_neighbor_search()
|
|
||||||
{
|
|
||||||
delete start;
|
|
||||||
delete past_the_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
begin() const
|
begin() const
|
||||||
{
|
{
|
||||||
return *start;
|
return iterator(m_tree,m_query,m_dist,m_Eps,m_search_nearest);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
end() const
|
end() const
|
||||||
{
|
{
|
||||||
return *past_the_end;
|
return iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream&
|
std::ostream&
|
||||||
statistics(std::ostream& s)
|
statistics(std::ostream& s)
|
||||||
{
|
{
|
||||||
start->statistics(s);
|
begin()->statistics(s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -353,26 +353,25 @@ namespace CGAL {
|
||||||
Orthogonal_incremental_neighbor_search(const Tree& tree,
|
Orthogonal_incremental_neighbor_search(const Tree& tree,
|
||||||
const Query_item& q, FT Eps = FT(0.0),
|
const Query_item& q, FT Eps = FT(0.0),
|
||||||
bool search_nearest=true, const Distance& tr=Distance())
|
bool search_nearest=true, const Distance& tr=Distance())
|
||||||
: start(tree,q,tr,Eps,search_nearest),
|
: m_tree(tree),m_query(q),m_dist(tr),m_Eps(Eps),m_search_nearest(search_nearest)
|
||||||
past_the_end()
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
begin()
|
begin()
|
||||||
{
|
{
|
||||||
return start;
|
return iterator(m_tree,m_query,m_dist,m_Eps,m_search_nearest);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
end()
|
end()
|
||||||
{
|
{
|
||||||
return past_the_end;
|
return iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream&
|
std::ostream&
|
||||||
statistics(std::ostream& s)
|
statistics(std::ostream& s)
|
||||||
{
|
{
|
||||||
start.statistics(s);
|
begin()->statistics(s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -504,11 +503,12 @@ namespace CGAL {
|
||||||
|
|
||||||
}; // class iterator
|
}; // class iterator
|
||||||
|
|
||||||
|
//data members
|
||||||
iterator start;
|
const Tree& m_tree;
|
||||||
iterator past_the_end;
|
Query_item m_query;
|
||||||
|
Distance m_dist;
|
||||||
|
FT m_Eps;
|
||||||
|
bool m_search_nearest;
|
||||||
}; // class
|
}; // class
|
||||||
|
|
||||||
template <class Traits, class Query_item, class Distance>
|
template <class Traits, class Query_item, class Distance>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue