#ifndef _OCTREE_H
#define _OCTREE_H



#ifdef OLD
typedef struct
{
	float    r, g, b;
	float    count;    // weight
} data_t;
#endif



typedef struct
{
    int x1, y1, z1;    // lower corner
    int x2, y2, z2;    // upper corner
} cube_t;


typedef struct octree_n
{
    int              leaf;        // leaf (really depth)
    cube_t           cube;        // space this node represents
    struct octree_n  *octant[8];  // children
    // data_t           *data;       // data at node

	// these fields are wasted at nodes, only used at leafs
	float            r, g, b;
	float            count;      
} octree_t;



octree_t *Octree_Init(void);
octree_t *Octree_FindColor(octree_t *p, float r, float g, float b);

// void Octree_AddNode(octree_t *p, data_t *data);
void Octree_AddColor(octree_t *p, float r, float g, float b, float weight);
void Octree_Print(octree_t *p);
void Octree_Free(octree_t *p);
// int  Octree_FindPal(octree_t *p, int x, int y, int z);



#endif
