Go to the documentation of this file.
40 glBegin(GL_LINE_LOOP);
41 glVertex3f(x1, y1, z1);
42 glVertex3f(x2, y1, z1);
43 glVertex3f(x2, y2, z1);
44 glVertex3f(x1, y2, z1);
46 glBegin(GL_LINE_LOOP);
47 glVertex3f(x2, y2, z2);
48 glVertex3f(x1, y2, z2);
49 glVertex3f(x1, y1, z2);
50 glVertex3f(x2, y1, z2);
53 glVertex3f(x1, y1, z1);
54 glVertex3f(x1, y1, z2);
55 glVertex3f(x2, y1, z1);
56 glVertex3f(x2, y1, z2);
57 glVertex3f(x1, y2, z1);
58 glVertex3f(x1, y2, z2);
59 glVertex3f(x2, y2, z1);
60 glVertex3f(x2, y2, z2);
87 FILE *f = fopen(boxFile,
"r");
95 fscanf(f,
"%d %lf %lf %lf %lf %lf %lf\n",
102 printf(
"Unable to open box file %s\n", boxFile);
112 return sqrt(d1*d1+d2*d2+d3*d3);
117 bool drawThis = ((
levelDraw>>which)&0x1);
126 glDisable(GL_LIGHTING);
134 for (
unsigned int x = 0; x <
boxes.size(); x++)
137 boxes[x].OpenGLDraw();
140 glEnable(GL_LIGHTING);
157 if (e->GetLabelL(
kEdgeCapacity) == 0) glColor4f(.5, .5, .5, 1);
158 else if (e->GetLabelL(
kEdgeCapacity) <= 0) glColor4f(.2, .2, .2, 1);
159 else if (e->getMarked()) glColor4f(1, 1, 1, 1);
161 glColor4f(1-((GLfloat)(abLevel%15)/15.0), ((GLfloat)(abLevel%15)/15.0), 0, 1);
162 else glColor4f(((GLfloat)(abLevel%15)/15.0), 1-((GLfloat)(abLevel%15)/15.0), 0, 1);
164 glVertex3f(rv.
x, rv.
y, rv.
z);
169 glVertex3f(rv.
x, rv.
y, rv.
z);
187 glColor4f(.6, .6, .6, .6);
191 glVertex3f(v.
x, v.
y, v.
z);
192 glVertex3f(v1.
x, v1.
y, v1.
z);
211 ans.
x = ans.
y = ans.
z = 0;
218 ans.
x += weight*tmp.
x;
219 ans.
y += weight*tmp.
y;
220 ans.
z += weight*tmp.
z;
235 FILE *f = fopen(fname,
"r");
238 printf(
"Error opening %s for loading\n", fname);
242 std::vector<unsigned int> IDS;
245 fgets(nextLine, 255, f);
248 sscanf(nextLine,
"VERSION %lf", &version);
251 printf(
"Got %lf; code can only handle version 1.0\n", version);
255 while ((!feof(f)) && fgets(nextLine, 255, f))
257 if (nextLine[0] ==
'#')
259 if (strncmp(
"edges", nextLine, 5) == 0)
269 sscanf(nextLine,
"%d %lf %lf %lf", &ID, &x, &y, &z);
271 if (IDS.size() <= (
unsigned int)ID)
285 sscanf(nextLine,
"%d %d", &ID1, &ID2);
295 cout <<
"VERIFY START" << endl;
305 if (n->GetLabelL(
kParent) != -1)
313 { found =
true;
break; }
317 cout <<
"VERIFY: Graph doesn't verify; child:" << endl << *n << endl;
318 cout <<
"VERIFY: Graph doesn't verify; parent:" << endl << *parent << endl;
329 cout <<
"VERIFY: Graph doesn't verify; CHILD is null, parent:" << endl << *n << endl;
333 cout <<
"VERIFY: Graph doesn't verify; parent:" << endl << *n << endl;
334 cout <<
"VERIFY: Graph doesn't verify; child:" << endl << *child << endl;
354 if ((p1 == 0) || (p2 == 0))
356 cout <<
"VERIFY: One edge parent is null, and the other isn't " << *e << endl << *p1 << endl << *p2 << endl;
361 cout <<
"Didn't find parent edge of " << *e <<
" at abslevel " << x << endl;
362 cout << *p1 << endl << *p2 << endl;
366 cout <<
"VERIFY: Edge capacity is 0?!? " << e << endl;
386 cout <<
"VERIFY: Edge capactiy of " << *e <<
" is "
387 << e->GetLabelL(
kEdgeCapacity) <<
" but we only found " << count
388 <<
" edges below that abstract into it." << endl;
393 cout <<
"VERIFY END" << endl;
424 printf(
"Base Graph (0) has %d nodes\n", g->
GetNumNodes());
427 for (
int x = 1; ; x++)
438 printf(
"Abstract Graph #%2d has %d nodes\n", x, g->
GetNumNodes());
459 if (n->GetLabelL(
kParent) != -1)
continue;
482 if ((from != to) && (!(f = aGraph->
FindEdge(to, from))))
485 f =
new edge(from, to, weight);
500 for (
unsigned int x = 0; x <
boxes.size(); x++)
561 if ((!from) || (!to) ||
570 if ((from == 0) || (to == 0))
A generic class for basic operations on Graph abstractions.
void SetLabelL(unsigned int index, long val) const
void loadBoxes(char *boxFile)
void SetLabelF(unsigned int index, double val) const
edge * FindEdge(unsigned int from, unsigned int to)
Finds an edge between nodes with ids from and to, no matter which direction.
A generic vector (essentially the same as a point, but offers normalization)
unsigned int neighbor_iterator
void addNeighborsInBox(Graph *g, node *n, int which, node *parent)
node * nodeIterNext(node_iterator &) const
virtual void VerifyHierarchy()
verify that the hierarchy is consistent
std::vector< edge * >::const_iterator edge_iterator
virtual ~LoadedBBAbstraction()
node * GetNode(unsigned long num)
edge * edgeIterNext(edge_iterator &) const
node * createNewParent(Graph *, node *n)
std::vector< node * >::const_iterator node_iterator
long GetLabelL(unsigned int index) const
Graph * loadGraph(char *fname)
void addNodeToParent(node *n, node *parent)
edge_iterator getEdgeIter() const
void DrawLevelConnections(node *n) const
bool fless(double a, double b)
std::vector< BoundingBox > boxes
void DrawGraph(Graph *g) const
void SetLabelL(unsigned int index, long val)
bool pointInBox(double x, double y, double z)
node * findNodeParent(node *n)
const double unknownPosition
LoadedBBAbstraction(char *, char *)
Construct a new Graph hierarchy.
node_iterator getNodeIter() const
int nodeNeighborNext(neighbor_iterator &) const
void ToggleDrawAbstraction(int which)
std::vector< Graph * > abstractions
double GetLabelF(unsigned int index) const
unsigned int GetNum() const
recVec GetNodeLoc(node *n) const
long GetLabelL(unsigned int index) const
neighbor_iterator getNeighborIter() const
Graph * abstractGraph(Graph *g)
int findBoundingBox(node *n)
virtual void AddNode(node *n)
add node to abstraction
bool Pathable(node *from, node *to)
is there a legal path between these 2 nodes?
double h(node *a, node *b)
heuristic cost between any two nodes
virtual void AddEdge(edge *e, unsigned int absLevel)
add edge to abstraction
void buildAbstractions(Graph *g)
static const float VERSION
Nodes to be stored within a Graph.
Edge class for connections between node in a Graph.