//全体再描画、ラベルを含む、エラーチェック void MapFrame::repaintAll(bool checkError, bool clearSelect) { Map* pMap = app.getMap(); MAP_INTSECMAP_IT imi; Intsec* pIntsec; MAP_ROADMAP_IT rmi; Road* pRoad; // qDebug("MapFrame::repaintAll"); if (clearSelect) _intsecIdSelect =_intsecIdDest =_roadIdSelect = MAP_NOID; pIntsec = pMap->nextIntsec(&imi, true); while (pIntsec != NULL) { if (checkError) pIntsec->checkError(); showIntsec(pIntsec); pIntsec = pMap->nextIntsec(&imi); } if (checkError) { pRoad = pMap->nextRoad(&rmi, true); while (pRoad != NULL) { pRoad->checkError(); pRoad = pMap->nextRoad(&rmi); } } repaint(); }
void ScanA(Car car, Road road) { if ((car.GetY()<road.GetCurrentY()-15)||(car.GetY()>road.GetCurrentY()+65)) AFlag=true; else AFlag=false; }
void MyGraphicsView::FinishRoadCreation(std::string const & name, int speed) { std::deque<QGraphicsEllipseItem *>::iterator it1; std::deque<QGraphicsLineItem *>::iterator it2; Node *lastPoint; Node *currentPoint; Road *road; road = new Road(name, speed); for (it1 = this->points.begin(); it1 != this->points.end(); ++it1) { if (it1 == this->points.begin()) lastPoint = new Node((*it1)->pos().x(), (*it1)->pos().y()); else { currentPoint = new Node((*it1)->pos().x(), (*it1)->pos().y()); road->addLink(*lastPoint, *currentPoint, 1); } (*it1)->setOpacity(0.3); lastPoint = currentPoint; } for (it2 = this->lines.begin(); it2 != this->lines.end(); ++it2) { (*it2)->setOpacity(0.3); } this->points.clear(); this->lines.clear(); }
/* static */ void RoadManager::readRoads(const std::string& dirName, RoadManager::roadMap_t& roadMap, bool global, bool doRead) { ConfigDirectory::fileList_t fileList; dprintf(MY_DEBUG_NOTE, "Read roads directory:\n"); bool ret = ConfigDirectory::load(dirName.c_str(), fileList); if (!ret) { dprintf(MY_DEBUG_WARNING, "unable to read roads directory\n"); return; } for (ConfigDirectory::fileList_t::const_iterator it = fileList.begin(); it != fileList.end(); it++) { std::string roadFilename = it->c_str(); bool ret = false; Road* road = new Road(dirName+"/"+roadFilename, ret, global, doRead); if (ret) { roadMap[road->getName()] = road; } else { dprintf(MY_DEBUG_ERROR, "road file is invalid: %s\n", roadFilename.c_str()); delete road; } } }
void TrafficNetwork::addRoad(const long startNodeId, const long endNodeId, const string roadName, const double length,const double speedLimit, const int nbBands){ Node* startNode = nodes[startNodeId]; Node* endNode = nodes[endNodeId]; Road* r; if(nbBands == 0){ r = new TwinRoad(roadName,length,speedLimit,nbBands,startNode,endNode); //if twin has already been added ; link them together if(endNode->hasNeighbor(startNodeId)){ TwinRoad* twin = (TwinRoad*) endNode->roadTo(startNodeId); twin->setTwin((TwinRoad*)r); ((TwinRoad*)r)->setTwin(twin); } }else{ r = new Road(roadName,length,speedLimit,nbBands,startNode,endNode); } if(monitered){ RoadMonitor* monitor = new RoadMonitor(startNodeId,endNodeId); r->addMonitor(monitor); } startNode->addRoad(endNodeId,r); }
void MapFactory::addEdge_(int v1_, int v2_) { Road* r = new Road(verticesElements[v1_], verticesElements[v2_]); mapElements.push_back(PMapElement(r)); Weight w = (r->getLength() + 2 * CROSS_SIZE); boost::add_edge(vertices[v1_], vertices[v2_], w, *g); }
int main(int argc, char *argv[]) { //SDK读入=90ms char *topo[MAX_EDGE_NUM]; int edge_num; char *demand[MAX_DEMAND_NUM]; int demand_num; char *topo_file = argv[1]; edge_num = read_file(topo, MAX_EDGE_NUM, topo_file); if (edge_num == 0) { Print("Please input valid topo file.\n"); return -1; } char *demand_file = argv[2]; demand_num = read_file(demand, MAX_DEMAND_NUM, demand_file); if (demand_num != MAX_DEMAND_NUM) { Print("Please input valid demand file.\n"); return -1; } //生成检查result.csv文件合法性和路径信息的程序 //程序如果带5个参数(第一个是文件名)就输出具体的信息,否则只输出重复边个数和权值 G.initial(topo,edge_num); Road0.initial(demand[0],&G); Road1.initial(demand[1],&G); exam_result(argv[1],argv[3],(argc==5)); return 0; }
//交差点削除、接続単路も削除、なしなら無視 void Map::deleteIntsec(int intsecId) { MAP_INTSECMAP_IT imi; Intsec* pIntsec; INTSEC_ROADMAP_IT irmi; Road* pRoad; vector<int> deleteRoadId; int i; // qDebug("Map::deleteIntsec %d", intsecId); imi = _intsecMap.find(intsecId); if (imi == _intsecMap.end()) return; pIntsec = imi->second; //単路削除時に接続情報を消すので後でまとめて実行 pRoad = pIntsec->nextRoad(&irmi, true); while (pRoad != NULL) { deleteRoadId.push_back(pRoad->getRoadId()); pRoad = pIntsec->nextRoad(&irmi); } for (i=0; i < (int)deleteRoadId.size(); i++) deleteRoad(deleteRoadId[i]); delete pIntsec; _intsecMap.erase(imi); }
void WorldModel::updateBlockades() { for (set<Blockade *>::iterator blockade = blockades.begin(); blockade != blockades.end(); blockade++) { if ((*blockade)->getLastClearTime() == m_time - 1 && (*blockade)->getLastCycleUpdated() != m_time) { LOG(Main, 1) << "I cleared blockade: " << (*blockade)->getId() << endl; Road *r = (Road*) objects[(*blockade)->getPosition()]; for (vector<Blockade*>::iterator i = r->getBlockades().begin(); i != r->getBlockades().end(); i++) { if ((*i)->getId() == (*blockade)->getId()) { r->getBlockades().erase(i); break; } } objects[(*blockade)->getId()] = NULL; blockades.erase(blockade); } } for (int i = 0; i < roads.size(); i++) { if (roads[i]->getLastCycleUpdatedBySense() == m_time) { roads[i]->clearBlockades(); for (int j = 0; j < (int) roads[i]->getBlockadeIds().size(); j++) { roads[i]->addBlockade((Blockade*) objects[roads[i]->getBlockadeIds()[j]]); } } } }
//特定位置の道路取得、なしなら NULL Road* MapFrame::getRoadAt(int viewX, int viewY) { Map* pMap = app.getMap(); Road* pRoad; Road* pRoadSelect; MAP_ROADMAP_IT rmi; double distance, distancePrev; pRoad = pMap->nextRoad(&rmi, true); pRoadSelect = NULL; distancePrev = (double)ROADSELECT_MIN; while (pRoad != NULL) { if (app.measureLinePoint(getViewX(pRoad->getIntsec(ROAD_IT_SMALL)->getMapPosX()), getViewY(pRoad->getIntsec(ROAD_IT_SMALL)->getMapPosY()), getViewX(pRoad->getIntsec(ROAD_IT_LARGE)->getMapPosX()), getViewY(pRoad->getIntsec(ROAD_IT_LARGE)->getMapPosY()), viewX, viewY, ROADSELECT_MIN, &distance)) { if (distance < distancePrev) { // qDebug("MapFrame::mouseReleaseEvent road %f-%f", distance, distancePrev); pRoadSelect = pRoad; distancePrev = distance; } } pRoad = pMap->nextRoad(&rmi); } return pRoadSelect; }
//---- Road methods void Scene::setupRoad() { Ogre::Terrain* baseTerrain = mTerrainGroup->getTerrain(0, 0); //TODO Different road XML files for different scenes Ogre::String roadsFile = "../data/scene/roads.xml"; tinyxml2::XMLDocument doc; tinyxml2::XMLError e = doc.LoadFile(roadsFile.c_str()); if (e != tinyxml2::XML_SUCCESS) { return; } tinyxml2::XMLElement* root = doc.RootElement(); if (!root) { return; } tinyxml2::XMLElement* roadXML = root->FirstChildElement("Road"); while (roadXML) { Road* road = new Road(mSim); road->setup(baseTerrain, mSceneMgr); if (!road->loadFromXML(roadXML)) { std::cout << "Road failed to load" << std::endl; continue; } // PSSM materials not included... road->rebuildRoadGeometry(); mRoads.push_back(road); roadXML = roadXML->NextSiblingElement("Road"); } }
// Remove an event. // Pass in a position and a bool that says whether // the event is an accident void Event::RemoveEvent(Position *position, bool accident) { if(position->end != 0) { Road * road = position->beginning->FindRoad(position->end); road->SetBlocked(false); } else position->beginning->SetBlocked(false); }
void CityUpdater::getAdjacencyList() { adjacencyList.clear(); Location location(0,0); Road* road; for (unsigned int i=0; i<roadMap.size(); i++) { vector<neighbor> tmpVector; if (roadMap[i]->isOpen(Road::NORTH) && ((roadMap[i]->getLocation().getRow())-1 >= 0)) { // location.setRow(roadMap[i]->getLocation().getRow()-1); location.setCol(roadMap[i]->getLocation().getCol()); road = dynamic_cast<Road*>(cityMap->getCase(location)); if (!(road->isBlocked())){ int index = std::find(roadMap.begin(), roadMap.end(), road) - roadMap.begin(); tmpVector.push_back(neighbor(index, 1)); } // } if (roadMap[i]->isOpen(Road::WEST) && ((roadMap[i]->getLocation().getCol())-1 >= 0)) { // location.setRow(roadMap[i]->getLocation().getRow()); location.setCol(roadMap[i]->getLocation().getCol()-1); road = dynamic_cast<Road*>(cityMap->getCase(location)); if (!(road->isBlocked())){ int index = std::find(roadMap.begin(), roadMap.end(), road) - roadMap.begin(); tmpVector.push_back(neighbor(index, 1)); } // } if (roadMap[i]->isOpen(Road::SOUTH) && ((roadMap[i]->getLocation().getRow())+1 < cityMap->getNumberOfRows())) { // location.setRow(roadMap[i]->getLocation().getRow()+1); location.setCol(roadMap[i]->getLocation().getCol()); road = dynamic_cast<Road*>(cityMap->getCase(location)); if (!(road->isBlocked())){ int index = std::find(roadMap.begin(), roadMap.end(), road) - roadMap.begin(); tmpVector.push_back(neighbor(index, 1)); } // } if (roadMap[i]->isOpen(Road::EAST) && ((roadMap[i]->getLocation().getCol())+1 < cityMap->getNumberOfCols())) { // location.setRow(roadMap[i]->getLocation().getRow()); location.setCol(roadMap[i]->getLocation().getCol()+1); road = dynamic_cast<Road*>(cityMap->getCase(location)); if (!(road->isBlocked())){ int index = std::find(roadMap.begin(), roadMap.end(), road) - roadMap.begin(); tmpVector.push_back(neighbor(index, 1)); } // } adjacencyList.push_back(tmpVector); tmpVector.clear(); } }
std::vector<double> TrafficNetwork::getMinTTVec(){ std::vector<double>minTTs(Road::roadCounter); std::vector<long> nIds; for(NodeVec::iterator it= nodes.begin() ; it!=nodes.end(); ++it){ nIds = (*it)->getNeighborsId(); for(std::vector<long>::iterator jt = nIds.begin(); jt != nIds.end(); ++jt){ Road* r = (*it)->roadTo(*jt); minTTs[r->getId()]= r->getMinTravelTime(); } } return minTTs; }
static Target create( const Option& o ) { Road* road = new Road( &o ); TargetValue* THIS = new TargetValue( road ); road->setTHIS(THIS); Target target = THIS; road->build(o); //l.addFeature( target ); return target; }
//ステータス表示、ID ありなら表示 void MapFrame::showStatus(int viewX, int viewY, int intsecId) { stringstream ss; ss << "(" << (int)getMapX(viewX) << "," << (int)getMapY(viewY) << ")"; //広域は選択しないと交差点IDが取れないので常に外す if (intsecId != MAP_NOID && app.getMainWindow()->getEditMode() != MainWindow::large) ss << " ID " << intsecId; if (_intsecIdSelect != MAP_NOID) { Road *road = NULL; if (_intsecIdDest != MAP_NOID) road = app.getMap()->getRoad(_intsecIdSelect, _intsecIdDest); if (road == NULL) ss << " Select ID " << _intsecIdSelect; else { int itSelect = road->getIntsecType(_intsecIdSelect); int itDest = road->getIntsecType(_intsecIdDest); ss << " Select ID (Lane) " << _intsecIdSelect << " (" << road->getLane(itSelect, ROAD_LT_IN) << ") -> " << _intsecIdDest << " (" << road->getLane(itDest, ROAD_LT_OUT) << ") / " << _intsecIdDest << " (" << road->getLane(itDest, ROAD_LT_IN) << ") -> " << _intsecIdSelect << " (" << road->getLane(itSelect, ROAD_LT_OUT) << ") Distance " << (int)road->getDistance(); } } app.getMainWindow()->statusBar()->showMessage(ss.str().c_str()); }
/** *@param point Point du plan *@return Route du plan la plus proche de point */ const Map::Road* Map::getRoute(const Utils::Point &point) const { Road *route = NULL; foreach(Road* r, m_Routes) { if (route == NULL) { route = r; } else { Utils::Point p1 = (r->deuxieme() + r->premier()) / 2.0, p2 = (route->deuxieme() + route->premier()) / 2.0; if ((p1 - point).norme() < (p2 - point).norme()) route = r; } } return route; }
//単路付け換え、付け換え後単路返却、構造的変換なので注意、既存単路不可 Road* Map::replaceRoad(Intsec* pIntsec, Intsec* pIntsecNew, Intsec* pIntsecCon) { bool already; Road* pRoad; Road* pRoadNew; pRoad = pIntsec->getRoad(pIntsecCon->getIntsecId()); Q_ASSERT(pRoad!=NULL); pRoadNew = createRoad(pIntsecCon, pIntsecNew, &already); Q_ASSERT(!already); pRoadNew->copyLane(pRoad); if (pIntsecCon->getFirstIntsecIdCon() == pIntsec->getIntsecId()) pIntsecCon->setFirstIntsecIdCon(pIntsecNew->getIntsecId()); deleteRoad(pRoad->getRoadId()); return pRoadNew; }
// Create an event. // Pass in a position and a bool that says whether // the event is an accident void Event::CreateEvent(Position *position, bool accident) { if(position->end != 0) { Road * road = position->beginning->FindRoad(position->end); road->SetBlocked(true); if(accident) road->IncrementAccidents(); } else { position->beginning->SetBlocked(true); position->beginning->IncrementAccidents(); } }
void Scene::addRoads(QPen solidLinePen, QPen dashedLinePen, QBrush brush) { std::vector<Intersection *> intersections = world->getIntersections(); for (const auto &intersection : intersections) { int roadsNumber = intersection->getRoadsNumber(); for (int i = 0; i < roadsNumber; i++) { Road *road = intersection->getRoad(i); addRect(road->getQRect(), solidLinePen, brush); int lanesNumber = road->getLanesNumber(); for (int j = 1; j < lanesNumber; j++) { addLine(QLine(road->getSourceSide().getPoint(j * 1. / lanesNumber).toQPoint(), road->getTargetSide().getPoint((lanesNumber - j) * 1. / lanesNumber).toQPoint()), dashedLinePen); } } } }
void CityUpdater::getRoadMap() { roadMap.clear(); checkPointsList.clear(); Location location(0,0); Road* road; for (int row=0; row<(cityMap->getNumberOfRows()); row++) { for (int col=0; col<(cityMap->getNumberOfCols()); col++) { location.setRow(row); location.setCol(col); if((road = dynamic_cast<Road*>(cityMap->getCase(location)))) { roadMap.push_back(road); if ((road->print() == "═□ ") || (road->print() == " □ ") || (road->print() == " □═")) { checkPointsList.push_back(road); } } } } }
//デバッグトレース void Map::debugTrace() { MAP_INTSECMAP_IT imi; Intsec* pIntsec; MAP_ROADMAP_IT rmi; Road* pRoad; for (imi = _intsecMap.begin(); imi != _intsecMap.end(); imi++) { pIntsec = imi->second; pIntsec->debugTrace(); } for (rmi = _roadMap.begin(); rmi != _roadMap.end(); rmi++) { pRoad = rmi->second; pRoad->debugTrace(); } }
Map::Map(const QString &nomFichier) { QDomDocument doc("Plan"); QFile fichier(nomFichier); if (!fichier.open(QIODevice::ReadOnly)) { return; } if (!doc.setContent(&fichier)) { fichier.close(); return; } fichier.close(); QDomNodeList intersections = doc.elementsByTagName("Intersection"); for (int n = 0; n < intersections.size(); ++n) { QDomElement intersection = intersections.at(n).toElement(); qreal x = intersection.attribute("x").toFloat(), y = intersection.attribute("y").toFloat(); QString nom = intersection.attribute("nom"); Intersection *i = new Intersection(nom, Utils::Point(x, y)); if (m_Intersections.contains(nom)) { delete m_Intersections[nom]; } m_Intersections[nom] = i; } QDomNodeList routes = doc.elementsByTagName("Route"); for (int n = 0; n < routes.count(); ++n) { QDomElement route = routes.at(n).toElement(); Road *r = new Road(route.attribute("nom"), m_Intersections[route.attribute("depart")], m_Intersections[route.attribute("fin")]); for (int j = 0; j < route.attribute("pvd").toUInt(); ++j) { Road::Voie v; v.m_Direction = Road::Voie::PREM_VERS_DEUX; r->ajouterVoie(v); } for (int j = 0; j < route.attribute("dvp").toUInt(); ++j) { Road::Voie v; v.m_Direction = Road::Voie::DEUX_VERS_PREM; r->ajouterVoie(v); } m_Routes.push_back(r); } creerTrousIntersection(); }
void RoadMap::readSubRoadsFile(const std::string& fsubroads){ std::ifstream subroads; int i = 0; subroads.open(fsubroads.c_str()); if(!subroads.is_open()){ std::cout << "subroads file does not exist\n"; return; } while(!subroads.eof()){ string str; stringstream ss; uint id_road, id_node1, id_node2; char lixo; ss.clear(); getline(subroads, str, '\n'); ss << str; ss >> id_road >> lixo >> id_node1 >> lixo >> id_node2; //TODO Falta conferir se os id est�o em crossroads/roads. Crossroad* c1 = &crossRoads.find(id_node1)->second; Crossroad* c2 = &crossRoads.find(id_node2)->second; Road* r = &roads.find(id_road)->second; r->addCrossroad(c1); r->addCrossroad(c2); uint dist = c1->getDist(*c2); if(!this->addEdge(*c1, *c2, dist)) cerr << "Edge ups..." << id_node1 << " " << id_node2 << endl; if(r->isTwoWay()){ if(!this->addEdge(*c2, *c1, dist)) cerr << "Edge ups..." << id_node2 << " " << id_node1 << endl; i++; } i++; } subroads.close(); cout << i; }
/** * @brief Network::synthesize_traffic Creates new traffic in the model, attempting to meet density requirements. */ void Network::synthesize_traffic() { vector<vector<Cell*> > cells; for(vector<Road*>::size_type i = 0; i < this->input_roads.size(); i++) { Road *r = this->input_roads.at(i); vector<Cell*> v; for(vector<Cell*>::size_type x = 0; x < r->get_length() && x < r->get_speed_limit(); x++) { Cell *c = r->get_cell(x); if(!c->has_vehicle()) v.push_back(c); else break; } if(!v.empty()) cells.push_back(v); } while((this->get_actual_input_density() < this->get_desired_input_density()) && !cells.empty()) { unsigned int index = (rand() % cells.size() + 0); if(!cells.at(index).empty()) { Cell *cell = cells.at(index).back(); Vehicle *v = new Vehicle(cell->get_speed_limit()); v->set_generation(this->generation); cell->set_vehicle(v); cells.at(index).pop_back(); } else cells.erase(cells.begin() + index); } }
void RoadTileSet::draw() { //cairo_set_source_rgba(g, 0, 0, 0, 1); //cairo_rectangle(g, 0, 0, pixel_width, pixel_height); //cairo_fill(g); cairo_set_source_rgba(g, 0, 0, 0, 1); //cairo_set_antialias(g, CAIRO_ANTIALIAS_GOOD); int k = 0; for (size_t level = 0; level < line_width.size(); ++level) { cairo_set_line_width(g, line_width[level]); for (int i = 0; i < 9; ++i) { for (int j = i + 1; j < 9; ++j) { Road r; int row = k / cols; int col = k % cols; r.w = r.h = 32; r.set_directions(i, j); cairo_save(g); //cairo_translate(g // , 0.5 + margin + col * tile_width + ((col == 0) ? 0 : (col - 1) * space) + tile_width / 2.0 // , 0.5 + margin + row * tile_height + ((row == 0) ? 0 : (row - 1) * space) + tile_height / 2.0); cairo_translate(g , 0.5 + margin + col * (tile_width + space) + tile_width / 2.0 , 0.5 + margin + row * (tile_height + space) + tile_height / 2.0); r.drawto(g, surf); cairo_restore(g); ++k; } } } }
/** * Reads the edges from a file and loads them into the graph */ void readEdges(Graph<Node, Road> & g, GraphViewer *gv) { ifstream inFile; //Ler o ficheiro subroads.txt inFile.open("database/subroadsDemo.txt"); if (!inFile) { cerr << "Unable to open file subroadsDemo.txt"; exit(1); // call system to stop } std::string line; unsigned long roadID; unsigned long node1ID, node2ID; while (std::getline(inFile, line)) { std::stringstream linestream(line); std::string data; linestream >> roadID; std::getline(linestream, data, ';'); // read up-to the first ; (discard ;). linestream >> node1ID; std::getline(linestream, data, ';'); // read up-to the first ; (discard ;). linestream >> node2ID; float weight = calcWeight(findNode(g, node1ID), findNode(g, node2ID)); gv->addEdge(roadID, node1ID, node2ID, EdgeType::UNDIRECTED); Road r = readRoads(roadID, gv); if (r.is_two_way()) g.addEdge1(findNode(g, node2ID), findNode(g, node1ID), weight, r); g.addEdge1(findNode(g, node1ID), findNode(g, node2ID), weight, r); } inFile.close(); }
void CityUpdater::updateRoadBlocks(){ if (blockedRoads.size() > 0){ if (blockedRoads[0]->getTurnsLeft() <= 0){ do { SocketMessage update; update.setTopic("roadblock"); update.set("location", blockedRoads[0]->getLocation().toString()); update.set("state", "0"); sendUpdateToPlayers(update); Road* toFree = blockedRoads.front(); blockedRoads.pop_front(); toFree->setUpBarricade(false); } while (blockedRoads.size() > 0 && blockedRoads[0]->getTurnsLeft() <= 0); freeRoad(); } if (blockedRoads.size() > 0){ for (unsigned int i=0; i<blockedRoads.size(); i++){ blockedRoads[i]->decreaseTurnsLeft(); } } } }
//単路削除、なしなら無視 void Map::deleteRoad(int roadId) { MAP_ROADMAP_IT rmi; Road* pRoad; Intsec* pIntsec1; Intsec* pIntsec2; rmi = _roadMap.find(roadId); if (rmi != _roadMap.end()) { pRoad = rmi->second; pIntsec1 = pRoad->getIntsec(ROAD_IT_SMALL); pIntsec2 = pRoad->getIntsec(ROAD_IT_LARGE); // qDebug("Map::deleteRoad %d %d-%d 0x%x", // roadId, pIntsec1->getIntsecId(), pIntsec2->getIntsecId(), pRoad); pIntsec1->deleteRoad(pIntsec2->getIntsecId()); pIntsec2->deleteRoad(pIntsec1->getIntsecId()); delete pRoad; _roadMap.erase(rmi); } // qDebug("Map::deleteRoad end %d", roadId); }
void Road::build(const TilePos& pos ) { Tilemap& tilemap = Scenario::instance().getCity().getTilemap(); LandOverlay* saveOverlay = tilemap.at( pos ).get_terrain().getOverlay(); Construction::build( pos ); setPicture(computePicture()); if( Aqueduct* aqua = safety_cast< Aqueduct* >( saveOverlay ) ) { aqua->build( pos ); return; } // update adjacent roads for (std::list<Tile*>::iterator itTile = _accessRoads.begin(); itTile != _accessRoads.end(); ++itTile) { Road* road = safety_cast< Road* >( (*itTile)->get_terrain().getOverlay() ); // let's think: may here different type screw up whole program? if( road ) { road->computeAccessRoads(); road->setPicture(road->computePicture()); } } // NOTE: also we need to update accessRoads for adjacent building // how to detect them if MaxDistance2Road can be any // so let's recompute accessRoads for every _building_ std::list<LandOverlay*> list = Scenario::instance().getCity().getOverlayList(); // it looks terrible!!!! for (std::list<LandOverlay*>::iterator itOverlay = list.begin(); itOverlay!=list.end(); ++itOverlay) { LandOverlay *overlay = *itOverlay; Building *construction = dynamic_cast<Building*>(overlay); if (construction != NULL) // if NULL then it ISN'T building { construction->computeAccessRoads(); } } }