Pathfinder
Octree.h
Go to the documentation of this file.
1 
10 #ifndef OCTREE_H
11 #define OCTREE_H
12 
13 #include "Using.h"
14 
15 namespace Pathfinder {
16 
20  const short threshold = 10;
21 
22 
32  struct Octree {
33 
37  Geometry::Vec3 min;
38 
39 
43  Geometry::Vec3 max;
44 
45 
49  std::vector<Octree*> child;
50 
51 
55  std::vector<Polygon*> polygons;
56 
57 
62  std::vector<std::pair<Vertex, Graph*>> graphVertices;
63 
64 
72  Octree(
73  const Geometry::Vec3& AABBmin,
74  const Geometry::Vec3& AABBmax
75  );
76 
77 
89  Octree(
90  const float& size,
91  const std::vector<Polygon*>& polygons,
92  const std::vector<std::pair<Vertex, Graph*>>& graphVertices
93  );
94 
95 
103  void
104  deleteOctree(
105  const bool& root
106  );
107 
108 
122  void
123  buildOctree(
124  const std::vector<Polygon*>& polygons,
125  const std::vector<std::pair<Vertex, Graph*>>& graphVertices,
126  const std::string& indent
127  );
128 
129 
139  bool
141  const Polygon* polygon,
142  const std::string& indent
143  );
144 
145 
154  bool
156  const Geometry::Vec3& p,
157  const std::string& indent
158  );
159 
160 
171  std::vector<std::pair<Vertex, Graph*>>
173  const Geometry::Vec3& p,
174  const std::string& indent
175  );
176 
177  };
178 
179 
188  Octree*
189  createOctree(
190  const std::vector<Graph*>& graphList
191  );
192 
193 
201  void
202  printOctree(
203  const Octree* octree,
204  const std::string& indent
205  );
206 
207 }
208 
209 #endif
std::vector< std::pair< Vertex, Graph * > > getNeighbours(const Geometry::Vec3 &p, const std::string &indent)
Given a point p in 3D space, return all vertices associated to the smallest existing octree that has ...
Definition: Octree.cpp:197
bool pointInOctree(const Geometry::Vec3 &p, const std::string &indent)
Check if a point lies inside an octree.
Definition: Octree.cpp:180
void buildOctree(const std::vector< Polygon *> &polygons, const std::vector< std::pair< Vertex, Graph *>> &graphVertices, const std::string &indent)
For two lists of Polygons and vertices, sort them into an empty octree.
Definition: Octree.cpp:76
Geometry::Vec3 max
The AABBmax of the current cube.
Definition: Octree.h:43
Definition: AABB.cpp:21
A struct that represents a single polygon.
Definition: Polygon.h:21
Octree(const Geometry::Vec3 &AABBmin, const Geometry::Vec3 &AABBmax)
A basic constructor that initializes all data members with dummy data.
Definition: Octree.cpp:25
std::vector< Polygon * > polygons
Store pointers to Polygons that lie in this octree.
Definition: Octree.h:55
bool polygonInOctree(const Polygon *polygon, const std::string &indent)
Check if a poylgon lies inside an octree.
Definition: Octree.cpp:163
const short threshold
If this threshold is reached, stop octree recursion.
Definition: Octree.h:20
Octree * createOctree(const std::vector< Graph *> &graphList)
Given the output of buildGraphList, create an octree containing all polygons and vertices.
Definition: Octree.cpp:231
void deleteOctree(const bool &root)
Free all memory allocated to this octree and polygons.
Definition: Octree.cpp:50
void printOctree(const Octree *octree, const std::string &indent)
Output a graphical representation of an octree to the console.
Definition: Octree.cpp:271
This struct implements the octree data structure.
Definition: Octree.h:32
This file provides using and enum declarations.
std::vector< std::pair< Vertex, Graph * > > graphVertices
Store graph vertices that lie in this octree together with a reference to their graph.
Definition: Octree.h:62
std::vector< Octree * > child
Store pointers to the eight children of the octree.
Definition: Octree.h:49
Geometry::Vec3 min
The AABBmin of the current cube.
Definition: Octree.h:37