libmove3d
3.13.0
|
00001 00002 #ifndef GP_KDTREE_H 00003 #define GP_KDTREE_H 00004 00005 00010 00014 class gpAABB 00015 { 00016 private: 00017 class gpKdTree *tree_; 00018 double xmin_, xmax_, ymin_, ymax_, zmin_, zmax_; 00019 bool root_; 00020 bool leaf_; 00021 unsigned int level_; 00022 class gpAABB *children_[2]; 00023 class gpAABB *brother_; 00024 std::list<unsigned int> inner_points_; 00025 public: 00026 gpAABB(gpKdTree *tree, std::list<unsigned int> &inner_points); 00027 gpAABB(gpAABB *previous, std::list<unsigned int> &inner_points); 00028 ~gpAABB(); 00029 int divide(); 00030 int draw(unsigned int level); 00031 int sphereIntersection(p3d_vector3 center, double radius, std::list<class gpContact> &points); 00032 }; 00033 00036 class gpKdTree 00037 { 00038 friend class gpAABB; 00039 private: 00040 class gpAABB *root_; 00041 std::vector<class gpContact> points; 00042 unsigned int depth_; 00043 public: 00044 gpKdTree(); 00045 gpKdTree(std::list<class gpContact> &contactList); 00046 ~gpKdTree(); 00047 int build(std::list<class gpContact> &contactList); 00048 int draw(unsigned int level); 00049 int sphereIntersection(p3d_vector3 center, double radius, std::list<class gpContact> &points); 00050 unsigned int depth() 00051 { return depth_; } 00052 }; 00053 00057 class gpAABBTris 00058 { 00059 private: 00060 class gpKdTreeTris *tree_; 00061 double xmin_, xmax_, ymin_, ymax_, zmin_, zmax_; 00062 bool root_; 00063 bool leaf_; 00064 bool inside_; 00065 unsigned int level_; 00066 class gpAABBTris *children_[2]; 00067 class gpAABBTris *brother_; 00068 std::list<unsigned int> inner_triangles_; 00069 public: 00071 gpAABBTris(gpKdTreeTris *tree, std::list<unsigned int> &inner_triangles); 00073 gpAABBTris(gpAABBTris *previous, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax); 00074 bool isTriangleOutside(p3d_vector3 p1, p3d_vector3 p2, p3d_vector3 p3); 00075 bool isInsidePolyhedre(); 00076 int divide(); 00077 int draw(unsigned int level); 00078 int sample(double step, std::list<gpVector3D> &points); 00079 }; 00080 00083 class gpKdTreeTris 00084 { 00085 friend class gpAABBTris; 00086 private: 00087 class gpAABBTris *root_; 00088 p3d_polyhedre *polyhedron_; 00089 std::list<unsigned int> inner_triangles_; 00090 unsigned int depth_; 00091 public: 00092 gpKdTreeTris(p3d_polyhedre *polyhedron); 00093 int draw(unsigned int level); 00094 unsigned int depth() 00095 { return depth_; } 00096 int pointCloud(double step, std::list<gpVector3D> &points); 00097 }; 00098 00099 #endif 00100