106 out <<
"#ANN " << ANNversion <<
"\n";
109 out <<
"points " <<
dim <<
" " << n_pts <<
"\n";
110 for (
int i = 0; i < n_pts; i++) {
134 void ANNkd_split::dump(
137 out <<
"split " << cut_dim <<
" " << cut_val <<
" ";
138 out << cd_bnds[
ANN_LO] <<
" " << cd_bnds[
ANN_HI] <<
"\n";
144 void ANNkd_leaf::dump(
151 out <<
"leaf " << n_pts;
152 for (
int j = 0; j < n_pts; j++) {
153 out <<
" " << bkt[j];
159 void ANNbd_shrink::dump(
162 out <<
"shrink " << n_bnds <<
"\n";
163 for (
int j = 0; j < n_bnds; j++) {
164 out << bnds[j].cd <<
" " << bnds[j].cv <<
" " << bnds[j].sd <<
"\n";
203 the_dim, the_n_pts, the_bkt_size,
204 the_bnd_box_lo, the_bnd_box_hi);
207 SkeletonTree(the_n_pts, the_dim, the_bkt_size, the_pts, the_pidx);
209 bnd_box_lo = the_bnd_box_lo;
210 bnd_box_hi = the_bnd_box_hi;
232 the_dim, the_n_pts, the_bkt_size,
233 the_bnd_box_lo, the_bnd_box_hi);
236 SkeletonTree(the_n_pts, the_dim, the_bkt_size, the_pts, the_pidx);
273 if (strcmp(str,
"#ANN") != 0) {
284 if (strcmp(str,
"points") == 0) {
289 for (
int i = 0; i < the_n_pts; i++) {
292 if (idx < 0 || idx >= the_n_pts) {
295 for (j = 0; j < the_dim; j++) {
296 in >> the_pts[idx][j];
313 if (strcmp(str,
"tree") == 0) {
320 for (j = 0; j < the_dim; j++) {
321 in >> the_bnd_box_lo[j];
323 for (j = 0; j < the_dim; j++) {
324 in >> the_bnd_box_hi[j];
326 the_pidx =
new ANNidx[the_n_pts];
329 the_root =
annReadTree(in, tree_type, the_pidx, next_idx);
330 if (next_idx != the_n_pts) {
385 if (strcmp(tag,
"null") == 0) {
391 if (strcmp(tag,
"leaf") == 0) {
394 int old_idx = next_idx;
399 for (
int i = 0; i < n_pts; i++) {
400 in >> the_pidx[next_idx++];
403 return new ANNkd_leaf(n_pts, &the_pidx[old_idx]);
408 else if (strcmp(tag,
"split") == 0) {
410 in >> cd >> cv >> lb >> hb;
416 return new ANNkd_split(cd, cv, lb, hb, lc, hc);
421 else if (strcmp(tag,
"shrink") == 0) {
429 for (
int i = 0; i < n_bnds; i++) {
430 in >> cd >> cv >> sd;
438 return new ANNbd_shrink(n_bnds, bds, ic, oc);
void SkeletonTree(int n, int dd, int bs, ANNpointArray pa=NULL, ANNidxArray pi=NULL)
void annPrintPt(ANNpoint pt, int dim, std::ostream &out)
ANNbd_tree(int n, int dd, int bs=1)
static ANNkd_ptr annReadTree(istream &in, ANNtreeType tree_type, ANNidxArray the_pidx, int &next_idx)
static ANNkd_ptr annReadDump(istream &in, ANNtreeType tree_type, ANNpointArray &the_pts, ANNidxArray &the_pidx, int &the_dim, int &the_n_pts, int &the_bkt_size, ANNpoint &the_bnd_box_lo, ANNpoint &the_bnd_box_hi)
ANNkd_tree(int n=0, int dd=0, int bs=1)
DLL_API ANNpoint annAllocPt(int dim, ANNcoord c=0)
DLL_API ANNpointArray annAllocPts(int n, int dim)
void annError(const char *msg, ANNerr level)
virtual void Dump(ANNbool with_pts, std::ostream &out)