| 120 | } |
| 121 | |
| 122 | IntVectorDataPtr nearestNNeighbours(const typename T::Point &p, unsigned int numNeighbours) |
| 123 | { |
| 124 | assert(m_tree); |
| 125 | |
| 126 | typedef std::vector<typename T::Neighbour> NeighbourArray; |
| 127 | |
| 128 | NeighbourArray points; |
| 129 | |
| 130 | unsigned int num = m_tree->nearestNNeighbours(p, numNeighbours, points); |
| 131 | |
| 132 | IntVectorDataPtr indices = new IntVectorData(); |
| 133 | |
| 134 | indices->writable().reserve( num ); |
| 135 | |
| 136 | for (typename NeighbourArray::const_iterator it = points.begin(); it != points.end(); ++it) |
| 137 | { |
| 138 | indices->writable().push_back( std::distance( m_points->readable().begin(), it->point ) ); |
| 139 | } |
| 140 | |
| 141 | return indices; |
| 142 | |
| 143 | } |
| 144 | |
| 145 | IntVectorDataPtr enclosedPoints( const Box &bound ) |
| 146 | { |