Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef VERTEXOCTREE_H
00020 #define VERTEXOCTREE_H
00021
00022
00023 #include <Geometry3D.h>
00024 #include <mesh.h>
00025 #include <vector>
00026
00027
00028 namespace puma {
00029
00030
00031 class VertexOctree
00032 {
00033 public:
00034 VertexOctree(
00035 const TriMesh* mesh,
00036 unsigned int maximum_depth,
00037 unsigned int min_entries
00038 );
00039
00040 VertexOctree(
00041 const TriMesh* mesh,
00042 Vec3f center,
00043 float radius,
00044 unsigned int maximum_depth,
00045 unsigned int min_entries);
00046
00047 VertexOctree(
00048 const TriMesh* mesh,
00049 Vec3f center,
00050 float radius,
00051 unsigned int current_depth,
00052 std::vector<VertexHandle>& vertices,
00053 unsigned int maximum_depth,
00054 unsigned int min_entries,
00055 int parentIndex = 0,
00056 VertexOctree* parentTree = NULL);
00057
00058 ~VertexOctree(void) {};
00059
00060 bool searchNearest(const Vec3f &p, VertexHandle& vertex, float& distance);
00061 void refineTree();
00062 void getCubes(std::vector<Vec3f> &points, std::vector<int> &edges);
00063 void getCubeCenters(std::vector<Vec3f> ¢ers);
00064 void getPoints(std::vector<Vec3f> &points);
00065 void getVertices(std::vector<VertexHandle>& vertices);
00066 void getLeaves(std::vector<VertexOctree*>& leafes);
00067
00068 Vec3f center() { return m_center; }
00069 float radius() { return m_radius; }
00070 bool isLeaf() { return m_isLeaf; }
00071
00072
00073 private:
00074 void initialize(std::vector<VertexHandle>& faces);
00075 bool closerToVertex(const Vec3f &p, const VertexHandle& vertex_handle, float& distance);
00076
00077 private:
00078 const TriMesh* m_mesh;
00079 Vec3f m_center;
00080 float m_radius;
00081 int m_parentIndex;
00082 VertexOctree* m_parentTree;
00083 VertexOctree* m_child[8];
00084 unsigned int m_current_depth;
00085
00086
00087 unsigned int m_maximum_depth;
00088 unsigned int m_min_entries;
00089
00090 bool m_isLeaf;
00091 std::vector<VertexHandle> m_vertices;
00092 };
00093
00094
00095 }
00096
00097 #endif // VERTEXOCTREE_H defined
00098