This commit is contained in:
CookieKastanie 2022-02-28 23:58:43 +01:00
parent 2425729a72
commit b4927aba4c
2 changed files with 8 additions and 7 deletions

View File

@ -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<Tuple> &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);
}

View File

@ -30,8 +30,10 @@ public:
private:
struct Node {
Node(Point const &position, vtkIdType id);
Point position;
vtkIdType index;
vtkIdType id;
Node *leftChild;
Node *rightChild;