Point Cloud Viewer  1.00
A Viewer to display point clouds with phong shading by converting them to splats.
entityoctree.h
1 #ifndef ENTITYOCTREE_H
2 #define ENTITYOCTREE_H
3 
4 #include <list>
5 #include "entity.h"
6 
10 class EntityOctree {
11 public:
20  EntityOctree(Entity &entity, float x, float y, float z);
28  EntityOctree(EntityOctree &subtree, float x, float y, float z);
29  ~EntityOctree();
37  bool insert(Entity &entity, float &x);
49  void knnSearch(Entity **found, float *distances, unsigned char k, Entity &to, float &xP);
50 
51 private:
52  EntityOctree *data[8];
53  Entity *entity;
54  float x, y, z;
55  static const float threshold;
56 
62  bool subInsert(Entity &entity, float &x);
63  float computeDist(float x, float y, float z, float w);
64 
65 public:
69  class Iterator {
70  public:
76  Iterator(EntityOctree *root);
77 
84  bool next();
85 
91  bool finished();
92 
97  void replace(Entity &newEntity);
98 
105  Iterator &operator++(); //prefix increment
106 
113  Iterator operator++(int); //postfix increment
114 
121  Entity *operator->();
122 
129  Entity &operator*();
130  private:
131  std::list<EntityOctree*> stack;
132  std::list<unsigned char> stackIndex;
133  bool fin;
134 
135  void climbDown();
136  };
137 };
138 
139 #endif // ENTITYOCTREE_H
bool insert(Entity &entity, float &x)
Insert an entity into this octree.
Definition: entityoctree.cpp:40
bool finished()
Checks if the iterator is finished and removes the finished-flag.
Definition: entityoctree.cpp:150
Entity & operator*()
Returns the Entity at the current position.
Definition: entityoctree.cpp:205
Iterator(EntityOctree *root)
Creates an iterator for the subtree with the given root.
Definition: entityoctree.cpp:210
An element with a location in 3-dimensional space.
Definition: entity.h:9
Iterator & operator++()
Jumps to the next Entity in the tree.
Definition: entityoctree.cpp:164
An octree storing entities.
Definition: entityoctree.h:10
Entity * operator->()
Returns the Entity at the current position.
Definition: entityoctree.cpp:200
bool next()
Jumps to the next Entity in the tree.
Definition: entityoctree.cpp:145
void replace(Entity &newEntity)
Replaces the Entity at the current position.
Definition: entityoctree.cpp:158
An iterator to iterate over an octree.
Definition: entityoctree.h:69
void knnSearch(Entity **found, float *distances, unsigned char k, Entity &to, float &xP)
This method inserts all entities in the tree into the given list of neighbours.
Definition: entityoctree.cpp:50
EntityOctree(Entity &entity, float x, float y, float z)
Constructor; for more functionality use EntityOctreeContainer.
Definition: entityoctree.cpp:7