本文整理汇总了C++中Intersection::getID方法的典型用法代码示例。如果您正苦于以下问题:C++ Intersection::getID方法的具体用法?C++ Intersection::getID怎么用?C++ Intersection::getID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Intersection
的用法示例。
在下文中一共展示了Intersection::getID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool Intersection::operator !=(const Intersection &p2) const{
if(this->id != p2.getID())
return true;
return false;
}
示例2: loadMap
void loadMap() {
gv = new GraphViewer(WIDTH, HEIGHT, false);
gv->setBackground("res/background2.png");
gv->createWindow(WIDTH, HEIGHT);
gv->setVertexSize(0.1, 0.1);
//gv->defineVertexColor(DEFAULT_COLOR);
//gv->defineEdgeColor(DEFAULT_COLOR);
float x, y;
int ids, idd;
for(unsigned i=0; i<map->getNumVertex(); i++){
Intersection source = map->getVertexSet()[i]->getIntersection();
ids = source.getID();
x = convertGeoCordToPixel(source.getCoord().x, source.getCoord().y)[0];
y = convertGeoCordToPixel(source.getCoord().x, source.getCoord().y)[1];
gv->addNode(ids, x, y);
ostringstream convert;
convert << ids;
gv->setVertexLabel(ids, convert.str());
if(source.getIP()){ //interest points a azul
gv->setVertexColor(ids, "blue");
}
else // outros a vermelho
gv->setVertexColor(ids, "red");
for(unsigned j=0; j<map->getVertexSet()[i]->getAdj().size(); j++){
Intersection dest = map->getVertexSet()[i]->getAdj()[j].getDest()->getIntersection();
idd = dest.getID();
x = convertGeoCordToPixel(dest.getCoord().x, dest.getCoord().y)[0];
y = convertGeoCordToPixel(dest.getCoord().x, dest.getCoord().y)[1];
gv->addNode(idd, x, y);
ostringstream convert2;
convert2 << idd;
gv->setVertexLabel(idd, convert2.str());
gv->setVertexColor(idd, "green");
gv->addEdge(map->getVertexSet()[i]->getAdj()[j].getID(), ids, idd, EdgeType::DIRECTED);
gv->setEdgeLabel(map->getVertexSet()[i]->getAdj()[j].getID(), map->getVertexSet()[i]->getAdj()[j].getName());
}
}
gv->rearrange();
return;
}
示例3: addMapPieceToMap
void MapGenerator::addMapPieceToMap(char* string, Map* map){
if (string[0] == 'e'){
//endpoint
int ID;
double x, y;
char direction;
Direction d;
sscanf(string, "e,%d,%lf,%lf,%c\n", &ID, &x, &y, &direction);
printf("Added endpoint to map. ID=%d, x=%lf, y=%lf, direction=%c\n", ID, x, y, direction);
switch(direction){
case 'n':
d = NORTH;
break;
case 's':
d = SOUTH;
break;
case 'e':
d = EAST;
break;
case 'w':
d = WEST;
break;
default:
d = NORTH;
}
EndPoint* endPoint = new EndPoint(ID, x, y, d);
map->endPoints[map->numEndPoints] = endPoint;
map->numEndPoints++;
}
else if (string[0] == 'i'){
//intersection
int ID;
double x, y;
sscanf(string, "i,%d,%lf,%lf\n", &ID, &x, &y);
printf("Added intersection to map. ID=%d, x=%lf, y=%lf\n", ID, x, y);
Intersection* intersection = new Intersection(ID, x, y);
map->intersections[map->numIntersections] = intersection;
map->numIntersections++;
}
else if (string[0] == 'r'){
//road
printf("road\n");
char atype, btype;
int aID, bID;
int atbLanes, btaLanes;
sscanf(string, "r,%c%d,%c%d,%d,%d", &atype, &aID, &btype, &bID, &atbLanes, &btaLanes);
printf("Added road to map PointAType=%c, PointAID=%d, PointBType=%c, PointBID=%d, #lanes from A to B=%d, #lanes from B to A=%d\n", atype, aID, btype, bID, atbLanes, btaLanes);
MapPiece *pointA = NULL, *pointB = NULL;
//find the points
EndPoint* currentEndPoint;
Intersection* currentIntersection;
for (int i = 0; i < map->numEndPoints; i++){
currentEndPoint = map->endPoints[i];
if (currentEndPoint->getID() == aID){
pointA = currentEndPoint;
}
if (currentEndPoint->getID() == bID){
pointB = currentEndPoint;
}
}
printf("trying intersection\n");
for (int i = 0; i < map->numIntersections; i++){
currentIntersection = map->intersections[i];
if (currentIntersection->getID() == aID){
pointA = currentIntersection;
}
if (currentIntersection->getID() == bID){
pointB = currentIntersection;
}
}
//create the road
Road* road = new Road(pointA, pointB, atbLanes, btaLanes);
map->roads[map->numRoads] = road;
map->numRoads++;
if (atype == 'e'){
((EndPoint*)pointA)->setRoad(road);
}
else if (atype == 'i'){
if (road->getPointA() == pointA){
((Intersection*)pointA)->setRoad(road, road->getDirection());
}
else{
((Intersection*)pointA)->setRoad(road, -road->getDirection());
//.........这里部分代码省略.........