/* a box defined below: _____max |__|__| |__|__| min */ typedef struct _quadbox_t { double _xmin, _ymin, _xmax, _ymax; }quadbox_t;
/* quad node */ typedef struct _quadnode_t { quadbox_t _box; /* node bound box */ list_t *_lst; /* node data list */ struct _quadnode_t *_sub[QUAD_SUBNODES]; /* pointer to subnodes of this node */ }quadnode_t;
/* quad tree */ typedef struct _quadtree_t { quadnode_t *_root; int _depth; /* max depth of tree: 0-based */ float _overlap; /* overlapped ratio of quanbox */ }quadtree_t;
/*============================================================================= Public Functions =============================================================================*/ /* creates a quadtree and returns a pointer to it */ extern quadtree_t* quadtree_create (quadbox_t box, int depth, /* 4~8 */ float overlap /* 0.02 ~ 0.4 */ );
/* destroys a quad tree and free all memory */ extern void quadtree_destroy (IN quadtree_t *qtree );
/* inserts a node identified by node_key into a quadtree, returns the node quadtree encoding */ extern quadnode_t * quadtree_insert (IN quadtree_t *qtree, IN long node_key, IN quadbox_t *node_box );
/* searches nodes inside search_box */ extern void quadtree_search (IN const quadtree_t *qtree, IN quadbox_t *search_box, OUT list_t *results_list );