24 :aMap(_aMap), level(_level) {}
26 void getNeighbors(uint32_t nodeID, std::vector<uint32_t> &neighbors)
28 node *n = aMap->GetAbstractGraph(level)->GetNode(nodeID);
33 neighbors.push_back(tmp);
39 return aMap->h(aMap->GetAbstractGraph(level)->GetNode(node1),
40 aMap->GetAbstractGraph(level)->GetNode(node2));
43 double gcost(uint32_t node1, uint32_t node2)
45 return heuristic(node1, node2);
53 corridorLevel = aMap->GetAbstractionLevel(corr[0]);
54 for (
unsigned int x = 0; x < corridor.size(); x++)
61 if (corridor.size() == 0)
63 node *n = aMap->GetAbstractGraph(level)->GetNode(nodeID);
64 node *parent = aMap->GetNthParent(n, corridorLevel);
68 if ((
loc < corridor.size()) && (corridor[
loc] == parent))
96 :MapAbstraction(map),clusterSize(_clusterSize)
106 Graph* g = abstractions[1];
127 Map* map = MapAbstraction::GetMap();
128 int row=0, col=0, clusterId=0;
129 int horizSize,vertSize;
131 if (
verbose) std::cout<<
"Creating clusters and entrances\n";
140 Cluster cluster(clusterId++,row,col,i,j,horizSize,vertSize);
143 if (j > 0 && j < map->GetMapHeight())
148 if (i > 0 && i < map->GetMapWidth())
162 <<
"rows of clusters: "<<
rows<<
"\ncolumns of clusters: "<<
columns<<std::endl;
182 abstractions.push_back(
new Graph());
183 Graph *g = abstractions[1];
195 if (
verbose) std::cout<<
"abstract Graph has "<<abstractions[1]->GetNumNodes()<<
" nodes\n";
196 if (
verbose) std::cout<<
"abstract graphs has "<<abstractions[1]->GetNumEdges()<<
" edges\n";
223 Map* map = MapAbstraction::GetMap();
224 Graph* g = abstractions[0];
226 for (
int i=start; i<=end; i++)
230 while((i<=end) && (!GetNodeFromMap(i,latitude) || !GetNodeFromMap(i,latitude+1)
231 ||!(g->
FindEdge(GetNodeFromMap(i,latitude)->GetNum(), GetNodeFromMap(i,latitude+1)->GetNum()))))
243 while((i<=end)&&(GetNodeFromMap(i,latitude)) && (GetNodeFromMap(i,latitude+1))
244 && (g->
FindEdge(GetNodeFromMap(i,latitude)->GetNum(), GetNodeFromMap(i,latitude+1)->GetNum()))
245 && ((i==start) || ((g->
FindEdge(GetNodeFromMap(i-1,latitude)->GetNum(), GetNodeFromMap(i,latitude)->GetNum()))
246 && (g->
FindEdge(GetNodeFromMap(i-1,latitude+1)->GetNum(), GetNodeFromMap(i,latitude+1)->GetNum())))))
255 Entrance entrance1(latitude, begin,-1,-1,
260 Entrance entrance2(latitude, (i - 1),-1,-1,
269 Entrance entrance(latitude, ((i - 1) + begin)/2,-1,-1,
270 map->
GetNodeNum(((i - 1) + begin)/2,latitude),
271 map->
GetNodeNum(((i - 1) + begin)/2,latitude+1),
286 Map* map = MapAbstraction::GetMap();
288 Graph* g = abstractions[0];
289 for (
int i=start; i<=end; i++)
293 while((i<=end)&& (!GetNodeFromMap(meridian,i) || !GetNodeFromMap(meridian+1,i)
294 || (!(g->
FindEdge(GetNodeFromMap(meridian,i)->GetNum(), GetNodeFromMap(meridian+1,i)->GetNum())))))
308 while((i<=end) && (GetNodeFromMap(meridian,i)) && (GetNodeFromMap(meridian+1,i))
309 && (g->
FindEdge(GetNodeFromMap(meridian,i)->GetNum(), GetNodeFromMap(meridian+1,i)->GetNum()))
310 && ((i==start) || ((g->
FindEdge(GetNodeFromMap(meridian,i-1)->GetNum(), GetNodeFromMap(meridian,i)->GetNum()))
311 && (g->
FindEdge(GetNodeFromMap(meridian+1,i-1)->GetNum(), GetNodeFromMap(meridian+1,i)->GetNum())))))
320 Entrance entrance1(begin, meridian,-1,-1,
325 Entrance entrance2((i - 1), meridian,-1,-1,
334 Entrance entrance(((i - 1) + begin)/2, meridian,-1,-1,
335 map->
GetNodeNum(meridian,((i - 1) + begin)/2),
336 map->
GetNodeNum(meridian+1,((i - 1) + begin)/2),
353 if (
verbose) std::cout<<
"linking entrances and clusters\n";
357 for (
unsigned int i = 0; i <
entrances.size(); i++)
394 Map* map = MapAbstraction::GetMap();
395 if (
verbose) std::cout<<
"adding abstract nodes\n";
403 for (
unsigned int i=0; i<
entrances.size(); i++)
530 Map* map = MapAbstraction::GetMap();
531 if (
verbose) std::cout<<
"computing cluster paths\n";
532 for (
unsigned int i=0; i<
clusters.size(); i++)
536 std::vector<node*> corridor;
541 for (
unsigned int j=0; j < c.
parents.size(); j++)
542 corridor.push_back(c.
parents[j]);
563 point3d s(startx,starty,startz);
571 node* start = GetNodeFromMap(px,py);
575 node* goal = GetNodeFromMap(px,py);
588 std::vector<uint32_t> resultPath;
592 for (
unsigned int x = 0; x < resultPath.size(); x++)
593 p =
new path(GetAbstractGraph(start)->GetNode(resultPath[x]), p);
598 double dist = distance(p);
601 edge* newedge =
new edge(startnum, goalnum, dist);
637 assert (0 <=
id &&
id < (
int)
clusters.size());
674 Map* map = MapAbstraction::GetMap();
699 if (
verbose) std::cout<<
"Setting up parents\n";
700 Map* map = MapAbstraction::GetMap();
702 std::vector<node*> dummies;
706 for (
unsigned int i=0; i<
clusters.size(); i++)
720 dummies.push_back(dummyParent);
730 node* n = GetNodeFromMap(x,y);
739 for (
unsigned int i=0; i<
clusters.size(); i++)
744 std::vector<node*> corridor;
745 corridor.push_back(dummies[i]);
767 node* mnode = GetNodeFromMap(x,y);
770 double minDist = DBL_MAX;
794 std::vector<uint32_t> resultPath;
798 for (
unsigned int t = 0; t < resultPath.size(); t++)
799 p =
new path(GetAbstractGraph(low)->GetNode(resultPath[t]), p);
817 double dist = distance(p);
866 for (
node *next = abstractions[0]->nodeIterNext(ni); next;
867 next = abstractions[0]->nodeIterNext(ni))
870 if ((next->GetLabelL(
kParent) == -1) || ((next->GetLabelL(
kParent) >= numOrigNodes) && next->GetLabelL(
kParent) < numNodesAfter))
882 for (
unsigned int i=dummies.size()-1;i>0; --i)
886 int num = dummies[i]->GetNum();
897 for (
int j=0; j<numnodes; j++)
925 abstractionBFS(abstractions[0]->GetNode(tmp), parent, cluster,numOrigNodes,numNodesAfter);
939 abstractions.push_back(g);
942 for (
node *next = abstractions[1]->nodeIterNext(ni); next;
943 next = abstractions[1]->nodeIterNext(ni))
949 if (next->GetLabelL(
kParent) == -1)
1021 if (
verbose)std::cout<<
"in insert node\n";
1022 Map* map = MapAbstraction::GetMap();
1023 Graph* g = abstractions[1];
1053 int nodenum = g->
AddNode(newnode);
1079 point3d gl(goalx,goaly,goalz);
1082 node* goal = GetNodeFromMap(px,py);
1091 std::vector<node*> corridor;
1092 for (
unsigned int i=0; i<c.
parents.size(); i++)
1093 corridor.push_back(c.
parents[i]);
1104 std::vector<uint32_t> resultPath;
1108 for (
unsigned int x = 0; x < resultPath.size(); x++)
1109 p =
new path(GetAbstractGraph(n)->GetNode(resultPath[x]), p);
1118 double dist = distance(p);
1120 edge* newedge =
new edge(nodenum,num,dist);
1142 abstractions[2]->AddNode(par);
1171 if (
verbose) std::cout<<
"in remove node\n";
1173 Map* map = MapAbstraction::GetMap();
1183 Graph* g = abstractions[1];
1205 int snum = start->
GetNum();
1237 int gnum = goal->
GetNum();
1252 for (
unsigned int i=0; i<
newPaths.size(); i++)
1265 if (
temp[e])
return temp[e]->Clone();
1276 Map* map = MapAbstraction::GetMap();
1283 return MapAbstraction::GetNodeFromMap(px,py);
1289 Map* map = MapAbstraction::GetMap();
1290 Graph* g = abstractions[1];
1303 std::cout<<
"("<<px<<
","<<py<<
")";
1325 MapAbstraction::OpenGLDraw();
1326 GLdouble xx, yy, zz, rr;
1327 glColor3f(0.25, 0.0, 0.75);
1328 Map *map = GetMap();
1333 for (
int y = 0; y <= numYSectors; y++)
1335 glVertex3f(xx-rr, yy-rr+2*y*rr*
clusterSize, zz-5*rr);
1338 for (
int x = 0; x <= numXSectors; x++)
1340 glVertex3f(xx-rr+2*x*rr*
clusterSize, yy-rr, zz-5*rr);