mirror of https://github.com/CGAL/cgal
KD-tree forbids copies -> a pointer now.
This commit is contained in:
parent
439292a46c
commit
55021bdb9f
|
|
@ -37,14 +37,11 @@ namespace CGAL
|
||||||
private:
|
private:
|
||||||
Tree m_tree;
|
Tree m_tree;
|
||||||
public:
|
public:
|
||||||
AABB_search_tree() {}
|
|
||||||
~AABB_search_tree() {}
|
|
||||||
|
|
||||||
template <class ConstPointIterator>
|
template <class ConstPointIterator>
|
||||||
void init(ConstPointIterator begin, ConstPointIterator beyond)
|
AABB_search_tree(ConstPointIterator begin, ConstPointIterator beyond):
|
||||||
{
|
m_tree(begin, beyond){}
|
||||||
// m_tree = Tree(begin, beyond);
|
|
||||||
}
|
~AABB_search_tree() {}
|
||||||
|
|
||||||
// TOFIX: make it const
|
// TOFIX: make it const
|
||||||
Point closest_point(const Point& query)
|
Point closest_point(const Point& query)
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,11 @@ namespace CGAL {
|
||||||
bool rebuild(ConstPrimitiveIterator first, ConstPrimitiveIterator beyond);
|
bool rebuild(ConstPrimitiveIterator first, ConstPrimitiveIterator beyond);
|
||||||
|
|
||||||
/// Non virtual destructor
|
/// Non virtual destructor
|
||||||
~AABB_tree() { clear(); }
|
~AABB_tree() {
|
||||||
|
clear();
|
||||||
|
if(m_search_tree_constructed)
|
||||||
|
delete(m_search_tree);
|
||||||
|
}
|
||||||
|
|
||||||
/// Clears the tree
|
/// Clears the tree
|
||||||
void clear(void)
|
void clear(void)
|
||||||
|
|
@ -349,7 +353,7 @@ namespace CGAL {
|
||||||
// single root node
|
// single root node
|
||||||
Node* m_p_root;
|
Node* m_p_root;
|
||||||
// search KD-tree
|
// search KD-tree
|
||||||
Search_tree m_search_tree;
|
Search_tree* m_search_tree;
|
||||||
bool m_search_tree_constructed;
|
bool m_search_tree_constructed;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -425,7 +429,7 @@ namespace CGAL {
|
||||||
AABB_tree<Tr>::construct_search_tree(ConstPointIterator first,
|
AABB_tree<Tr>::construct_search_tree(ConstPointIterator first,
|
||||||
ConstPointIterator beyond)
|
ConstPointIterator beyond)
|
||||||
{
|
{
|
||||||
m_search_tree.init(first, beyond);
|
m_search_tree = new Search_tree(first, beyond);
|
||||||
m_search_tree_constructed = true;
|
m_search_tree_constructed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -436,14 +440,13 @@ namespace CGAL {
|
||||||
CGAL_assertion(!m_data.empty());
|
CGAL_assertion(!m_data.empty());
|
||||||
|
|
||||||
// iterate over primitives to get points on them
|
// iterate over primitives to get points on them
|
||||||
std::list<Point> points;
|
std::vector<Point> points;
|
||||||
typename std::vector<Primitive>::const_iterator it;
|
typename std::vector<Primitive>::const_iterator it;
|
||||||
for(it = m_data.begin(); it != m_data.end(); ++it)
|
for(it = m_data.begin(); it != m_data.end(); ++it)
|
||||||
{
|
{
|
||||||
points.push_back(it->reference_point());
|
points.push_back(it->reference_point());
|
||||||
}
|
}
|
||||||
m_search_tree.init(points.begin(), points.end());
|
construct_search_tree(points.begin(), points.end());
|
||||||
m_search_tree_constructed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Tr>
|
template<typename Tr>
|
||||||
|
|
@ -547,7 +550,7 @@ namespace CGAL {
|
||||||
{
|
{
|
||||||
Point hint;
|
Point hint;
|
||||||
if(m_search_tree_constructed)
|
if(m_search_tree_constructed)
|
||||||
hint = m_search_tree.closest_point(query); // pick closest neighbor point as hint (fast)
|
hint = m_search_tree->closest_point(query); // pick closest neighbor point as hint (fast)
|
||||||
else
|
else
|
||||||
hint = m_data[0].reference_point(); // pick first primitive reference point as hint (slow)
|
hint = m_data[0].reference_point(); // pick first primitive reference point as hint (slow)
|
||||||
return closest_point(query,hint);
|
return closest_point(query,hint);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue