Test.cpp File Reference

#include <stdio.h>
#include "RTree.h"

Go to the source code of this file.

Data Structures

struct  Rect

Functions

void main ()
bool MySearchCallback (int id, void *arg)

Variables

int nrects = sizeof(rects) / sizeof(rects[0])
struct Rect rects []
Rect search_rect (6, 4, 10, 6)


Function Documentation

void main (  ) 

Definition at line 48 of file Test.cpp.

References RTree< DATATYPE, DATATYPENP, ELEMTYPE, NUMDIMS, CONTEXT, ELEMTYPEREAL, TMAXNODES, TMINNODES >::Insert(), Rect::max, max, Rect::min, min, MySearchCallback(), nrects, RTree< DATATYPE, DATATYPENP, ELEMTYPE, NUMDIMS, CONTEXT, ELEMTYPEREAL, TMAXNODES, TMINNODES >::Search(), and search_rect.

00049 {
00050   RTree<int, int, 2, float> tree;
00051 
00052   int i, nhits;
00053   printf("nrects = %d\n", nrects);
00054 
00055   for(i=0; i<nrects; i++)
00056   {
00057     tree.Insert(rects[i].min, rects[i].max, i); // Note, all values including zero are fine in this version
00058   }
00059 
00060   nhits = tree.Search(search_rect.min, search_rect.max, MySearchCallback, NULL);
00061 
00062   printf("Search resulted in %d hits\n", nhits);
00063 
00064   getchar(); // Wait for keypress on exit so we can read console output
00065 
00066   // Output:
00067   //
00068   // nrects = 4
00069   // Hit data rect 1
00070   // Hit data rect 2
00071   // Search resulted in 2 hits
00072 }

bool MySearchCallback ( int  id,
void *  arg 
)

Definition at line 41 of file Test.cpp.

Referenced by main().

00042 {
00043   printf("Hit data rect %d\n", id);
00044   return true; // keep going
00045 }


Variable Documentation

int nrects = sizeof(rects) / sizeof(rects[0])

Definition at line 36 of file Test.cpp.

Referenced by main().

struct Rect rects[]

Initial value:

 
{
  Rect(0, 0, 2, 2), 
  Rect(5, 5, 7, 7),
  Rect(8, 5, 9, 6),
  Rect(7, 1, 9, 2),
}

Definition at line 28 of file Test.cpp.

Rect search_rect(6, 4, 10, 6)

Referenced by main().


Generated on Wed May 5 00:06:39 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6