/*1* KdTree.h2* RVO2-3D Library3*4* Copyright 2008 University of North Carolina at Chapel Hill5*6* Licensed under the Apache License, Version 2.0 (the "License");7* you may not use this file except in compliance with the License.8* You may obtain a copy of the License at9*10* https://www.apache.org/licenses/LICENSE-2.011*12* Unless required by applicable law or agreed to in writing, software13* distributed under the License is distributed on an "AS IS" BASIS,14* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15* See the License for the specific language governing permissions and16* limitations under the License.17*18* Please send all bug reports to <[email protected]>.19*20* The authors may be contacted via:21*22* Jur van den Berg, Stephen J. Guy, Jamie Snape, Ming C. Lin, Dinesh Manocha23* Dept. of Computer Science24* 201 S. Columbia St.25* Frederick P. Brooks, Jr. Computer Science Bldg.26* Chapel Hill, N.C. 27599-317527* United States of America28*29* <https://gamma.cs.unc.edu/RVO2/>30*/31/**32* \file KdTree.h33* \brief Contains the KdTree class.34*/35#ifndef RVO3D_KD_TREE_H_36#define RVO3D_KD_TREE_H_3738#include <cstddef>39#include <vector>4041#include "Vector3.h"4243namespace RVO3D {44class Agent3D;45class RVOSimulator3D;4647/**48* \brief Defines <i>k</i>d-trees for agents in the simulation.49*/50class KdTree3D {51public:52/**53* \brief Defines an agent <i>k</i>d-tree node.54*/55class AgentTreeNode3D {56public:57/**58* \brief The beginning node number.59*/60size_t begin;6162/**63* \brief The ending node number.64*/65size_t end;6667/**68* \brief The left node number.69*/70size_t left;7172/**73* \brief The right node number.74*/75size_t right;7677/**78* \brief The maximum coordinates.79*/80Vector3 maxCoord;8182/**83* \brief The minimum coordinates.84*/85Vector3 minCoord;86};8788/**89* \brief Constructs a <i>k</i>d-tree instance.90* \param sim The simulator instance.91*/92explicit KdTree3D(RVOSimulator3D *sim);9394/**95* \brief Builds an agent <i>k</i>d-tree.96*/97void buildAgentTree(std::vector<Agent3D *> agents);9899void buildAgentTreeRecursive(size_t begin, size_t end, size_t node);100101/**102* \brief Computes the agent neighbors of the specified agent.103* \param agent A pointer to the agent for which agent neighbors are to be computed.104* \param rangeSq The squared range around the agent.105*/106void computeAgentNeighbors(Agent3D *agent, float rangeSq) const;107108void queryAgentTreeRecursive(Agent3D *agent, float &rangeSq, size_t node) const;109110std::vector<Agent3D *> agents_;111std::vector<AgentTreeNode3D> agentTree_;112RVOSimulator3D *sim_;113114friend class Agent3D;115friend class RVOSimulator3D;116};117}118119#endif /* RVO3D_KD_TREE_H_ */120121122