60 int depth = std::numeric_limits<int>::max());
73 return m_nodes[nodeID]->GetNpoints();
77 return m_nodes[nodeID]->GetLoc();
81 return m_nodes[nodeID]->GetDepth();
85 return m_nodes[nodeID]->GetDelta();
89 void GetStats(
int &maxPts,
int &nPts,
int &nNodes,
int &nLeaves,
93 class Octant :
public std::enable_shared_from_this<Octant>
154 void GetLeaves(std::vector<OctantSharedPtr> &leaves);
155 void SetIndices(
const std::vector<int> &indices);
156 void AddNeighbours(
const std::vector<OctantSharedPtr> &neighbours);
158 const std::vector<int> &indices);
161 std::vector<OctantSharedPtr> &nodes);
std::vector< OctantWeakPtr > & GetNeighbours()
Array< OneD, NekDouble > & GetCentre()
Array< OneD, NekDouble > m_centre
Coordinates of the centre of the octant.
void AddPoints(const Array< OneD, Array< OneD, NekDouble > > &pts, const std::vector< int > &indices)
Adds to 'm_pointInd' the IDs of the points in 'pts' that fall inside the octant.
Array< OneD, OctantSharedPtr > & GetChildren()
int m_depth
Depth in octree (root is 1)
double m_delta
Length of the octant side.
void AddNeighbours(const std::vector< OctantSharedPtr > &neighbours)
Adds to 'm_neighbours' the octants that are not already in the list.
int m_loc
Position in the father octant (1-8)
void GetLeaves(std::vector< OctantSharedPtr > &leaves)
Updates 'leaves' so that it contains all the leaf nodes belonging to the octant.
void SetIndices(const std::vector< int > &indices)
Sets the values of 'm_pointInd' to those in 'indices'.
std::vector< int > m_pointInd
Indices of the points comprised by the octant.
std::vector< OctantWeakPtr > m_neighbours
Vector of pointers to the neighbouring octants.
int m_nPts
Number of points in the octant.
void Subdivide(int maxPts, const Array< OneD, Array< OneD, NekDouble > > &pts, std::vector< OctantSharedPtr > &nodes)
Recursively divides the octant into 8 children and fills the leaf nodes with their corresponding poin...
Array< OneD, NekDouble > m_bounds
Min/max coordinates of the octant (x, y, z)
bool m_isLeaf
True for a leaf octant, false otherwise.
std::vector< int > & GetIndices()
int GetLocInNode(const Array< OneD, NekDouble > &coords)
Returns the position inside an octant in the range (1-8). The name convention is as follows: let be ...
Array< OneD, NekDouble > & GetBounds()
int m_id
ID of the octant (index in 'm_nodes' vector)
Array< OneD, OctantSharedPtr > m_children
Vector of pointers to the children octants.
Octant()
Construct a new Octree::Octant object.
void SetNeighbours(int nodeID)
Once the nodes of the octree are created, sets their neighbours as explained in 'Octree::QueryNeighbo...
int QueryDepth(int nodeID)
OctantSharedPtr m_root
First node of the tree, linked to the rest.
std::vector< int > QueryNeighbours(int nodeID)
Returns the IDs of the octants that surround the queried node. First, it finds the neighbouring nodes...
std::vector< int > QueryPoints(int nodeID)
Returns the indices of the points of the mesh contained in the tree.
int m_nNodes
Number of octants in the tree.
void GetStats(int &maxPts, int &nPts, int &nNodes, int &nLeaves, int &depth)
Returns some characteristic values of the tree.
int m_nLeaves
Number of leaf nodes in the tree.
std::shared_ptr< Octant > OctantSharedPtr
int QueryClosest(const Array< OneD, Array< OneD, NekDouble > > &pts, const Array< OneD, NekDouble > &coords, double &distance, int pointInd=-1)
Finds the ID of the closest point in 'pts' to the one specified by 'coords'. It also returns the dist...
std::weak_ptr< Octant > OctantWeakPtr
int m_maxPts
Max points allowed in each octant.
int m_maxDepth
Maximum depth of the tree.
int QueryDelta(int nodeID)
int QueryLocation(int nodeID)
void AdvanceToStats(int nodeID)
Goes through all the nodes of the octree counting the number of octants and the maximum depth reached...
int QueryNpoints(int nodeID)
Octree()
Construct a new octree object.
int m_nMshPts
Number of points in the mesh.
std::vector< OctantSharedPtr > m_nodes
Vector of pointers to every octant in the tree.
int QueryNode(const Array< OneD, NekDouble > &coords, int depth=std::numeric_limits< int >::max())
Given the coordinates 'coords' of a point, returns the leaf octant that contains it....