A simple Octree structure that can build up on the Point Clouds
This repo can only load .ply files at the moment (open for all improvements!) and you can use PointCloud class for that.
PointCloud* pcl = new PointCloud();
after creating it just call LoadPly function.
pcl->LoadPly("PointClouds/dragon.ply");
now you loaded your Point Cloud. To built an octree, first create one.
Octree<Point>* octree = new Octree<Point>();
here note that Point is a struct defined in PointCloud.h
struct Point {
float* coords;
int idx;
Point(int i, float* c) : idx(i), coords(c) {};
};
PS: I created Octree class as a template to easy further developments. Then call
BuiltOctreeFromPointCloud(PointCloud*, float minSize, vect<T*> objects)
function. minSize determines minimum node size of octree.
octree->BuiltOctreeFromPointCloud(pcl, 0.2f, pcl->points);
Now you have your octree for the point cloud.
You can call following functions:
float* GetClosestNodePosFromPoint(float* point);
float* GetClosestObject(float* point);
First one returns the closest Node's pos, whether it is empty or not, independent from size. Second one returns the position of the closest non empty node. This function can be improved by returning the properties of the objects in that particular node.
These examples rendered with Coin3D library which is not included in this project.