diff --git a/src/kd_tree.cc b/src/kd_tree.cc index fd3bc5d..ea5551d 100644 --- a/src/kd_tree.cc +++ b/src/kd_tree.cc @@ -25,15 +25,14 @@ ostream& operator<<(ostream &os, KdTree::Point const &point) { return os; } +KdTree::Node::Node(Point const &position, vtkIdType id): position{position}, id{id} {} + ///////////////////////////////////////////////////////////////////// void KdTree::fill(std::vector &points) { - nodes.resize(points.size()); - - for(std::size_t i = 0; i < points.size(); ++i) { - nodes[i].position = points[i].first; - nodes[i].index = points[i].second; - } + nodes.reserve(points.size()); + for(std::size_t i = 0; i < points.size(); ++i) + nodes.push_back({points[i].first, points[i].second}); root = fillRec(0, points.size(), 0); } diff --git a/src/kd_tree.h b/src/kd_tree.h index e8232b1..4d35e30 100644 --- a/src/kd_tree.h +++ b/src/kd_tree.h @@ -30,8 +30,10 @@ public: private: struct Node { + Node(Point const &position, vtkIdType id); + Point position; - vtkIdType index; + vtkIdType id; Node *leftChild; Node *rightChild;