Memosa-FVM  0.2
KSearchTree.cpp
Go to the documentation of this file.
1 // This file os part of FVM
2 // Copyright (c) 2012 FVM Authors
3 // See LICENSE file for terms.
4 
5 #include "KSearchTree.h"
6 
7 
9 {
10  _tree = boost::shared_ptr<Tree>(new Tree());
11 
12  const int nPoints = points.getLength();
13  for(int n=0; n<nPoints; n++)
14  _tree->insert(MyPoint(points[n],n));
15 }
16 
18 {
19  _tree = boost::shared_ptr<Tree>(new Tree());
20 }
21 
22 void
23 KSearchTree::insert(const Vec3D& v, const int n)
24 {
25  _tree->insert(MyPoint(v,n));
26 }
27 
28 
29 void
30 KSearchTree::findNeighbors(const Vec3D& p, const int k, Array<int>& neighbors)
31 {
32  MyPoint query(p, -1);
33  if ( _tree->size() == 0 ){
34  return;
35  }
36  K_neighbor_search search(*_tree, query, k);
37 
38  int i=0;
39  for(K_neighbor_search::iterator it = search.begin();
40  it != search.end();
41  it++)
42  {
43  neighbors[i++] = it->first.index;
44  }
45 
46 }
CGAL::Orthogonal_k_neighbor_search< Traits > K_neighbor_search
Definition: KSearchTree.h:139
void findNeighbors(const Vec3D &p, const int k, Array< int > &neighbors)
Definition: KSearchTree.cpp:30
Definition: Array.h:14
boost::shared_ptr< Tree > _tree
Definition: KSearchTree.h:142
K_neighbor_search::Tree Tree
Definition: KSearchTree.h:140
void insert(const Vec3D &v, const int n)
Definition: KSearchTree.cpp:23
int getLength() const
Definition: Array.h:87