本文整理汇总了C++中Road类的典型用法代码示例。如果您正苦于以下问题:C++ Road类的具体用法?C++ Road怎么用?C++ Road使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Road类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
//全体再描画、ラベルを含む、エラーチェック
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();
}
示例2: ScanA
void ScanA(Car car, Road road)
{
if ((car.GetY()<road.GetCurrentY()-15)||(car.GetY()>road.GetCurrentY()+65))
AFlag=true;
else
AFlag=false;
}
示例3: Road
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();
}
示例4: dprintf
/* 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;
}
}
}
示例5: TwinRoad
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);
}
示例6: Road
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);
}
示例7: main
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;
}
示例8: while
//交差点削除、接続単路も削除、なしなら無視
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);
}
示例9: LOG
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]]);
}
}
}
}
示例10: while
//---- 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");
}
}
示例11: RemoveEvent
// 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);
}
示例12: location
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();
}
}
示例13:
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;
}
示例14: create
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;
}
示例15: showStatus
//ステータス表示、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());
}