38 std::vector<node *> fromChain;
39 std::vector<node *> toChain;
47 if (fromChain.size() == 0)
78 lastPath =
doRefinement(aMap, thisPart, fromChain,toChain);
112 toChain.push_back(n);
116 toChain.push_back(n);
121 std::vector<node *> &fromChain,
node *from,
122 std::vector<node *> &toChain,
node *to)
127 if ((from == 0) || (to == 0) || (!aMap->
Pathable(from, to)) || (from == to))
131 printf(
"craStar: from == 0\n");
133 printf(
"craStar: to == 0\n");
135 printf(
"craStar: from == to\n");
136 if (from && to && (!aMap->
Pathable(from, to)))
137 printf(
"craStar: no path from %p to %p\n", (
void*)from, (
void*)to);
144 printf(
"At nodes #%d and %d\n", from->
GetNum(), to->
GetNum());
148 unsigned int previousSize = fromChain.size();
154 while((
int)fromChain.size()-1 >
absLevel)
158 fromChain.pop_back();
162 while ((fromChain.size() > 2) && ((fromChain.size() > (previousSize)/2) ||
166 fromChain.pop_back();
175 std::vector<node *> &fromChain,
176 std::vector<node *> &toChain,
186 from = fromChain.back();
188 result = astar->
GetPath(aMap, from, to, rp);
207 && (fromChain.back() == absPath->
n));
209 path* lastPath = absPath;
211 while(fromChain.size() > 1)
215 fromChain.pop_back();
216 node* from = fromChain.back();
221 node* to = toChain.back();
223 if (
verbose) std::cout<<
"From: "<<*from<<
"\nto: "<<*to<<std::endl;
225 path* apath = lastPath;
232 std::cout<<
"abstract path\n";
236 std::cout<<*(apath->
n)<<std::endl;
239 std::cout<<*(apath->
n)<<std::endl;
242 node* currentLow = from;
244 assert(aMap->
GetNthParent(currentLow,abstractLevel) == apath->
n);
247 path* returnPath =
new path(currentLow);
267 currentLow =
getNextNode(aMap, currentLow, returnPath, apath, g, abstractLevel);
272 currentLow =
getNextNode(aMap, currentLow, returnPath, apath, g, abstractLevel);
276 node* lastnode = currentLow;
278 if (returnPath->
tail()->
n != to)
302 lastPath = returnPath;
315 std::vector<node*> neighbors(currentLow->
GetNumEdges());
317 double minHeur = DBL_MAX;
324 while(neighborNode != -1)
339 neighbors[numInArray] = neigh;
340 double hdist = aMap->
h(neigh,apath->
n);
345 minIndex = numInArray;
354 if (neighborNode == -1)
358 node* neigh = neighbors[minIndex];
386 neighbors[minIndex] = neighbors[numInArray-1];
388 for (
int i=0; i<numInArray-1; i++)
392 neigh = neighbors[i];
422 std::vector<node *> &fromChain,
423 std::vector<node *> &toChain,
426 node *to, *from, *hTarget = 0;
429 from = fromChain.back();
430 fromChain.pop_back();
436 printf(
"Building path from %d to %d (%ld/%ld)\n",
439 std::vector<node *> eligibleNodeParents;
446 path *trav = lastPath;
457 hTarget = trav->
next->
n;
462 if (
verbose) printf(
"Setting target parent to %d\n", to->
GetNum());
468 for (
path *trav = lastPath; trav; trav = trav->
next)
473 for (
edge *e = trav->n->edgeIterNext(ei); e; e = trav->n->edgeIterNext(ei)) {
474 if (e->getFrom() == trav->n->GetNum())
475 eligibleNodeParents.push_back(g->
GetNode(e->getTo()));
477 eligibleNodeParents.push_back(g->
GetNode(e->getFrom()));
480 eligibleNodeParents.push_back(trav->n);
504 path *change = 0, *last = 0;
505 for (
path *trav = lastPath; trav; trav = trav->
next)
507 if (trav->n == origDest)
509 if (trav->n->GetLabelL(
kParent) != parent)
536 if (
verbose) std::cout<<
"Smoothing the path\n";
544 for (
path *tmp = p; tmp != 0; tmp = tmp->
next)
572 for (
unsigned int i=n; i<last && i<
lookup.size(); i++)
582 for (dir =
NORTH; dir <=
NW; dir++)
598 unsigned int index = n;
599 path* pathCopy = pathToNode;
603 while(pathCopy->
next)
607 assert(index <= end);
611 pathCopy = pathCopy->
next;
614 assert(index <= end);
638 delete pathToNode; pathToNode = 0;
662 for (
unsigned int i=0; i<
lookup.size(); i++)
683 while(lookupVal[i]==NULL)
689 while(lookupVal[i]==NULL)
708 for (
int i=curr+1; i<=last; i++)
712 if (lookupVal[i]!=NULL)
739 if (e && (nextKey >= 0) && (nextKey <
static_cast<int>(
lookup.size())) && (
lookup[nextKey]==next))
753 return new path(n,p);
779 return m->GetNodeFromMap(x,y+1);
782 return m->GetNodeFromMap(x+1,y);
785 return m->GetNodeFromMap(x, y-1);
788 return m->GetNodeFromMap(x-1, y);
791 return m->GetNodeFromMap(x+1, y+1);
794 return m->GetNodeFromMap(x+1, y-1);
797 return m->GetNodeFromMap(x-1, y-1);
800 return m->GetNodeFromMap(x-1, y+1);