27 sprintf(algName,
"HPA*(%d)",partialLimit);
51 if ((from==to) || (from ==0) || (to==0)){
52 if (
verbose) std::cout<<
"Returning an empty path\n";
64 if (m->getClusterIdFromNode(from)==m->getClusterIdFromNode(to))
70 if (
verbose)std::cout<<
"Nodes are inside the same cluster\n";
74 setUpSearch(from, to);
77 if (!m->Pathable(from,to)){
78 if (
verbose) std::cout<<
"Not Pathable\n";
84 if (
verbose) std::cout<<
"Pathable\n";
87 path* abPath = findAbstractPath(fromnum,tonum);
95 if (partialLimit > 0){
98 for (
int x = 0; x < partialLimit-1; x++){
110 m->GetMap()->GetPointFromCoordinate(s,px,py);
112 node* newTo = m->GetNodeFromMap(px,py);
113 mapPath = findMapPath(thisPart, from, newTo);
119 mapPath = findMapPath(abPath,from,to);
128 finalPath = smoothPath(mapPath);
150 if (
verbose) std::cout<<
"HPA*: setting up search\n";
160 fromnum = m->insertNode(from,expanded,touched);
161 nodesExpanded += expanded;
162 nodesTouched += touched;
163 tonum = m->insertNode(to,expanded,touched);
164 nodesExpanded += expanded;
165 nodesTouched += touched;
174 if (
verbose) std::cout<<
"HPA*: finding the abstract path\n";
176 assert(from == fromnum);
183 std::cout<<
"Abstract path: ";
188 std::cout<<std::endl;
200 Graph *g = m->GetAbstractGraph(1);
211 path* lowlevel = m->getCachedPath(e);
215 if ((lowlevel->
n == m->getLowLevelNode(n2)) &&
216 (lowlevel->
tail()->
n == m->getLowLevelNode(n)))
219 lowlevel = lowlevel->
reverse();
225 returnme =
new path(m->getLowLevelNode(n),
new path(m->getLowLevelNode(n2)));
246 lowlevel = m->getCachedPath(e);
252 if ((lowlevel->
n == m->getLowLevelNode(n2)) &&
253 (lowlevel->
tail()->
n == m->getLowLevelNode(n)))
255 lowlevel = lowlevel->
reverse();
259 if (tailend->
n == lowlevel->
n)
271 returnme->
tail()->
next =
new path(m->getLowLevelNode(n2));
283 if ((fromnum!=0) && (tonum != 0)){
286 m->removeNodes(fromnum,tonum);
301 if (
verbose) std::cout<<
"Smoothing the path\n";
304 int clusterSize = m->getClusterSize();
310 for (
path *tmp = p; tmp != 0; tmp = tmp->
next)
312 lookup.push_back(tmp->n);
323 while(lookup[n]==0 && n<lookup.size()-1)
326 if (n>=lookup.size()-1){
336 std::cout<<
"in here\n";
337 for (
unsigned int j=n; j<last && j<lookup.size(); j++)
346 int currY = lookup[n]->GetLabelL(
kFirstData+1);
347 minx = currX - clusterSize;
348 maxx = currX + clusterSize;
349 miny = currY - clusterSize;
350 maxy = currY + clusterSize;
353 for (dir = NORTH; dir <= NW; dir++)
356 path* pathToNode = nextPathNode(lookup[n],dir);
363 if (lastNode > curr && !nextInLookup(lastNode, curr,lookup))
366 unsigned int index = n;
367 path* pathCopy = pathToNode;
371 while(pathCopy->
next){
373 assert(index <= end);
375 lookup[index]=pathCopy->
n;
377 pathCopy = pathCopy->
next;
380 assert(index <= end);
382 lookup[index]=pathCopy->
n;
395 else if (smType==TWO_BACK)
396 n = backTwoNodes(end,lookup);
400 delete pathToNode; pathToNode = 0;
419 for (
unsigned int j=0; j<lookup.size(); j++){
422 smooth =
new path(lookup[j],0);
437 while(lookupVec[i]==NULL){
441 while(lookupVec[i]==NULL){
458 for (
int i=curr+1; i<=last; i++)
462 if (lookupVec[i]!=NULL)
475 Graph *g = m->GetAbstractGraph(0);
480 node* next = getNextNode(px,py,dir);
488 if (e && (nextKey >= 0) && (nextKey <
static_cast<int>(lookup.size())) && (lookup[nextKey]==next)){
494 path * p = nextPathNode(next,dir);
496 return new path(n,p);
516 if ((x < minx) || (x > maxx) || (y < miny) || (y>maxy))
522 return m->GetNodeFromMap(x,y+1);
525 return m->GetNodeFromMap(x+1,y);
528 return m->GetNodeFromMap(x, y-1);
531 return m->GetNodeFromMap(x-1, y);
534 return m->GetNodeFromMap(x+1, y+1);
537 return m->GetNodeFromMap(x+1, y-1);
540 return m->GetNodeFromMap(x-1, y-1);
543 return m->GetNodeFromMap(x-1, y+1);
564 if (x < minx) minx = x;
565 if (x > maxx) maxx = x;
567 if (y < miny) miny = y;
568 if (y > maxy) maxy = y;
576 if (x < minx) minx = x;
577 if (x > maxx) maxx = x;
579 if (y < miny) miny = y;
580 if (y > maxy) maxy = y;
582 assert((minx !=
MAX_INT)&&(miny !=
MAX_INT)&&(maxx != -1)&&(maxy != -1));