#include "Model.h"

Model::Model(){
	dim		= 0;
	queryPt	= NULL;
	dataPts	= NULL;
	kdTree	= NULL;
	nnIdx	= NULL;
	dists	= NULL;
}

Model::~Model(){
	releaseAnnTree();
}

bool	Model::buildAnnTree(){
	int	nSurfels = int(m_geometry.size());
	if(nSurfels < 1)
		return false;

	releaseAnnTree();
	return true;
	
	nnIdx	= new ANNidx[1];
	dists	= new ANNdist[1];
	queryPt	= annAllocPt(3);
	dataPts	= annAllocPts(nSurfels, 3);
	for (int id = 0; id < nSurfels; id++){
		Surfel	&surfel = m_geometry[id];
		for (int j = 0; j < 3; j++){
			dataPts[id][j]   = surfel.pos[j];
		}
	}
	kdTree	= new ANNkd_tree(dataPts, nSurfels, 3);
}

void	Model::releaseAnnTree(){

}

int		Model::nearestNeighborIndex(Vector3f &pos){
	return -1;
}

void	Model::rendering()
{

}