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:
Sébastien Loriot 2012-01-05 09:45:15 +00:00
parent a40fea01b4
commit 69b2f7079a
3 changed files with 25 additions and 28 deletions

View File

@ -138,6 +138,8 @@ CGAL 3.10 offers the following improvements and new functionality : </p>
</li>
<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>
<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>
<h3>STL extension</h3>

View File

@ -86,43 +86,38 @@ namespace CGAL {
typedef std::vector<Point_with_transformed_distance*> Point_with_distance_vector;
typedef std::vector<FT> Distance_vector;
iterator *start;
iterator *past_the_end;
//data members
const Tree& m_tree;
Query_item m_query;
Distance m_dist;
FT m_Eps;
bool m_search_nearest;
public:
// constructor
Incremental_neighbor_search(const Tree& tree, const Query_item& q,
FT Eps=FT(0.0), bool search_nearest=true,
const Distance& tr=Distance())
{
start = new iterator(tree,q,tr,Eps,search_nearest);
past_the_end = new iterator();
}
// destructor
~Incremental_neighbor_search()
{
delete start;
delete past_the_end;
}
const Distance& tr=Distance()):
m_tree(tree),m_query(q),m_dist(tr),m_Eps(Eps),m_search_nearest(search_nearest)
{}
iterator
begin() const
{
return *start;
return iterator(m_tree,m_query,m_dist,m_Eps,m_search_nearest);
}
iterator
end() const
{
return *past_the_end;
return iterator();
}
std::ostream&
statistics(std::ostream& s)
{
start->statistics(s);
begin()->statistics(s);
return s;
}

View File

@ -352,27 +352,26 @@ namespace CGAL {
// constructor
Orthogonal_incremental_neighbor_search(const Tree& tree,
const Query_item& q, FT Eps = FT(0.0),
bool search_nearest=true, const Distance& tr=Distance())
: start(tree,q,tr,Eps,search_nearest),
past_the_end()
bool search_nearest=true, const Distance& tr=Distance())
: m_tree(tree),m_query(q),m_dist(tr),m_Eps(Eps),m_search_nearest(search_nearest)
{}
iterator
begin()
{
return start;
return iterator(m_tree,m_query,m_dist,m_Eps,m_search_nearest);
}
iterator
end()
{
return past_the_end;
return iterator();
}
std::ostream&
statistics(std::ostream& s)
{
start.statistics(s);
begin()->statistics(s);
return s;
}
@ -504,11 +503,12 @@ namespace CGAL {
}; // class iterator
iterator start;
iterator past_the_end;
//data members
const Tree& m_tree;
Query_item m_query;
Distance m_dist;
FT m_Eps;
bool m_search_nearest;
}; // class
template <class Traits, class Query_item, class Distance>