Lane Class Reference

A class representing a lane in a road. More...

#include <Lane.h>

Collaboration diagram for Lane:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void clear ()
 Clears the lane so it can be used in another simulation.
void CheckFeatures (const double curTime, double prevPosition, double curPosition, Vehicle *pVeh)
 Checks all features on the road.
void setRoadSegments (std::vector< RoadSegment * > segments)
 Sets the road segments for the direction.
void setOutputDetector (OutputDetector *out)
 Sets the output detector for the direction.
 Lane ()
 Default constructor.
 Lane (int iLane, int length, std::vector< Detector * > detectors, bool DirPos, bool AllowLaneChange)
 Main constructor.
virtual ~Lane ()
 Default destructor.
bool update (const double step, const double curTime)
 Updates the positions of all Vehicles in the Lane.
int getIndex ()
 Gets the index of the lane.
double getLastPos ()
 Gets the position of the last vehicle in the lane.
int getNoVeh ()
 Gets the number of vehicles in the lane.
double getLength ()
 Gets the length of the Lane.
void insert (int i, Vehicle *pVeh)
 Inserts a Vehicle into the Lane.
void setRightLane (Lane *right)
 Sets a pointer to the Lane to the right of the current Lane The Lane index is in global coords:
  • For DriveOnRight the lanes are numbered from bottom to top 0.

void setLeftLane (Lane *left)
 Sets a pointer to the Lane to the left of the current Lane The Lane index is in global coords:
  • For DriveOnRight the lanes are numbered from bottom to top 0.

std::vector< Vehicle * > getPos ()
 Gets all the Vehicles currently in the Lane.

Private Member Functions

VehicleFinadAdjacentVehicle (Lane *AdjacentLane, double location, bool front, int *iAdjacentLane=NULL)
 Finds a vehicle in the adjacent lane.
LaneChangeLanes (Vehicle *pVeh)
 Changes a Vehicle's Lane if advantageous and possible.
LaneImplementLaneChange (Vehicle *pVeh, int LaneChangeID, int iVehLeftLane, int iVehRightLane)
 Changes a vehicle to another lane.
void CheckDetectors (const double curTime, double prevPosition, double curPosition, Vehicle *pVeh)
 Adds a vehicle to the detectors list of vehicles for that step.
void CheckRoadSegments (double prevPosition, double curPosition, Vehicle *pVeh)
 Checks whether a vehicle has entered or exited any road segments.

Private Attributes

std::vector< Vehicle * > m_pVehicles
std::vector< Detector * > m_vDetectors
int m_Dir
int m_iLane
double m_Flow
double m_RoadLength
int m_NoVeh
double m_PrevVehiclePosition
bool m_AllowLaneChanging
bool m_DirPos
double m_CurTime
bool m_bTrackLaneChanges
std::vector< RoadSegment * > m_RoadSegments
Lanem_LeftLane
Lanem_RightLane
OutputDetectorm_pOutputDetector
LaneChangeDetectorm_pLaneChangeDetector
double MIN_SPACE_FOR_NEXT_VEHICLE


Detailed Description

A class representing a lane in a road.

Definition at line 24 of file Lane.h.


Constructor & Destructor Documentation

Lane::Lane (  ) 

Default constructor.

Definition at line 16 of file Lane.cpp.

References m_LeftLane, and m_RightLane.

00017 {
00018         m_LeftLane = NULL;
00019         m_RightLane = NULL;
00020 }

Lane::Lane ( int  iLane,
int  RoadLength,
std::vector< Detector * >  detectors,
bool  DirPos,
bool  AllowLaneChange 
)

Main constructor.

The main constructor used for creating a Lane object.

Parameters:
iLane The lane's index
RoadLength The length of the Road
detectors The detectors to be used in the lane
DirPos Whether the lane is in the positive direction or not
AllowLaneChange Whether lane changing is allowed

Definition at line 38 of file Lane.cpp.

References Detector::getDetectorType(), Detector::getDirPos(), CConfigData::IDM, m_AllowLaneChanging, m_bTrackLaneChanges, m_DirPos, m_iLane, m_LeftLane, m_NoVeh, m_pLaneChangeDetector, m_PrevVehiclePosition, m_RightLane, m_RoadLength, m_vDetectors, METRICS_TYPE_LANE_CHANGE, CConfigData::IDM_Config::MIN_SPACE_FOR_NEXT_VEHICLE, and MIN_SPACE_FOR_NEXT_VEHICLE.

00039 {
00040         
00041         MIN_SPACE_FOR_NEXT_VEHICLE = g_ConfigData.IDM.MIN_SPACE_FOR_NEXT_VEHICLE;
00042         m_PrevVehiclePosition = MIN_SPACE_FOR_NEXT_VEHICLE;
00043         
00044         m_NoVeh = 0;
00045         m_RoadLength = RoadLength;
00046         m_LeftLane = NULL;
00047         m_RightLane = NULL;
00048         m_bTrackLaneChanges = false;
00049 
00050         m_iLane = iLane;
00051         m_vDetectors = detectors;
00052         m_DirPos = DirPos;
00053         m_AllowLaneChanging = AllowLaneChange;
00054 
00055         for(int i = 0; i < m_vDetectors.size(); i++)
00056         {
00057                 Detector* pDet = m_vDetectors.at(i);
00058                 if( (pDet->getDetectorType() == METRICS_TYPE_LANE_CHANGE) && (pDet->getDirPos() == m_DirPos) )
00059                 {
00060                         m_bTrackLaneChanges = true;
00061                         m_pLaneChangeDetector = dynamic_cast<LaneChangeDetector*>(pDet);
00062                         break;
00063                 }
00064         }
00065 }

Here is the call graph for this function:

Lane::~Lane (  )  [virtual]

Default destructor.

Definition at line 23 of file Lane.cpp.

00024 {
00025 
00026 }


Member Function Documentation

void Lane::clear (  ) 

Clears the lane so it can be used in another simulation.

This function clears all of the lane's information so that it may be used in another simulation without re-instanciating.

Definition at line 529 of file Lane.cpp.

References m_pVehicles, m_RoadSegments, and m_vDetectors.

00530 {
00531         
00532         // If we exit in mid-sim, clear all vehicles currently on the road
00533         for(int i = 0; i < m_pVehicles.size(); i++)
00534                 delete m_pVehicles.at(i);
00535 
00536         // Free the vector for vehicles
00537         m_pVehicles.clear();
00538         
00539         // Free the vectors for detectors and segments (both deleted in direction)
00540         m_vDetectors.clear();
00541         m_RoadSegments.clear();
00542 }

void Lane::CheckFeatures ( const double  curTime,
double  prevPosition,
double  curPosition,
Vehicle pVeh 
)

Checks all features on the road.

Parameters:
curTime The current time
prevPosition The vehicle's position in the previous step
curPosition The vehicle's current position
pVeh The vehicle
See also:
CheckDetectors()

CheckRoadSegments()

This function checks all of the special features on the road

Definition at line 161 of file Lane.cpp.

References CheckDetectors(), and CheckRoadSegments().

Referenced by update().

00162 {
00163         CheckDetectors(curTime, prevPosition, curPosition, pVeh);
00164         CheckRoadSegments(prevPosition, curPosition, pVeh);
00165 }

Here is the call graph for this function:

void Lane::setRoadSegments ( std::vector< RoadSegment * >  segments  ) 

Sets the road segments for the direction.

Parameters:
segments The road segments

Definition at line 464 of file Lane.cpp.

References m_RoadSegments.

Referenced by Direction::createLanes().

00465 {
00466         m_RoadSegments = segments;
00467 }

void Lane::setOutputDetector ( OutputDetector out  ) 

Sets the output detector for the direction.

Parameters:
out The output detector

Definition at line 455 of file Lane.cpp.

References m_pOutputDetector.

Referenced by Direction::createLanes().

00456 {
00457         m_pOutputDetector = out;
00458 }

bool Lane::update ( const double  step,
const double  curTime 
)

Updates the positions of all Vehicles in the Lane.

This function is called for each iteration of the simulation, and handles the updating of the positions of Vehicles, and the removal of Vehicles which are no longer on the Road. If there are any Vehicles on the Road, the Vehicle at the head of the Lane is updated with respect to the clear Road ahead of it. Following this, all Vehicles following the Vehicle at the head of the Road are updated with respect to the preceding Vehicle. These Vehicles are also checked to see if it is time to determine if changing to another Lane would be advantageous. After all Vehicles have been updated, it is checked to see whether the Vehicle at the head of the Lane has yet passed the end of the Road. If it has, it is removed from the Lane and the simulation. Vehicles are also checked to see if they have passed a detector during the update

Parameters:
step The timestep
curTime The current simulation time
Returns:
Whether the lane is empty or not
See also:
ChangeLanes()

CheckFeatures()

Definition at line 90 of file Lane.cpp.

References ChangeLanes(), CheckFeatures(), m_AllowLaneChanging, m_CurTime, m_NoVeh, m_PrevVehiclePosition, m_pVehicles, m_RoadLength, and MIN_SPACE_FOR_NEXT_VEHICLE.

00091 {
00092         m_CurTime = curTime;
00093         bool laneEmpty = true;
00094 
00095         if(m_pVehicles.size() > 0)
00096         {
00097                 // Update the head of the lane to drive towards the end of the road
00098                 double previousPos = m_pVehicles.front()->getPos();
00099                 m_pVehicles.front()->update(step);
00100                 double currentPos = m_pVehicles.front()->getPos();
00101                 CheckFeatures(curTime, previousPos, currentPos, m_pVehicles.front());
00102 
00103                 // Update each vehicle based on the properties of the preceding vehicle
00104                 for(int i = 1; i < m_pVehicles.size(); i++)
00105                 {
00106                         previousPos = m_pVehicles[i]->getPos();
00107                         m_pVehicles[i]->update(step, m_pVehicles[i-1]);
00108                         currentPos = m_pVehicles[i]->getPos();
00109                         
00110                         bool bChangedLane = false;
00111                         if(m_AllowLaneChanging)                                                                                 // Check if overtaking is allowed
00112                         {
00113                                 bool bChangeStatus = m_pVehicles.at(i)->getChangeStatus();      // Ready to change lane?
00114                                 if(bChangeStatus)
00115                                 {
00116                                         Lane* pNewLane = ChangeLanes(m_pVehicles.at(i));                // return new lane if it's changed
00117                                         bChangedLane = pNewLane == NULL ? false : true;                 // Has it changed?
00118                                         if(bChangedLane)
00119                                         {
00120                                                 // get the new lane to check the vehicle for a detector/segment for this time step
00121                                                 pNewLane->CheckFeatures(curTime, previousPos, currentPos, m_pVehicles.at(i));
00122                                                 m_pVehicles.at(i)->setChangeStatus(false);                      // Reset status
00123                                                 m_pVehicles.erase(m_pVehicles.begin()+i);                       // Remove from this lane
00124                                         }                                                                                                                                                       
00125                                 }
00126                         }
00127                         if(!bChangedLane)
00128                                 CheckFeatures(curTime, previousPos, currentPos, m_pVehicles.at(i));
00129 
00130                 }
00131                 // update position of last vehicle in lane
00132                 // so more vehicles can get on the road
00133                 m_PrevVehiclePosition = m_pVehicles.back()->getPos();   
00134 
00135                 //Remove any vehicles that are no longer on the road
00136                 if(m_pVehicles.at(0)->getPos() > m_RoadLength + MIN_SPACE_FOR_NEXT_VEHICLE)
00137                 {
00138                         delete m_pVehicles.front();
00139                         m_pVehicles.erase(m_pVehicles.begin());
00140                         m_NoVeh--;
00141                 }
00142                 laneEmpty = false;;
00143         }
00144         return laneEmpty;
00145 }

Here is the call graph for this function:

int Lane::getIndex (  ) 

Gets the index of the lane.

Returns:
The index of the lane

Definition at line 268 of file Lane.cpp.

References m_iLane.

Referenced by ImplementLaneChange().

00269 {
00270         return m_iLane;
00271 }

double Lane::getLastPos (  ) 

Gets the position of the last vehicle in the lane.

Returns:
The position of the last vehicle in the lane

Definition at line 259 of file Lane.cpp.

References m_PrevVehiclePosition.

00260 {
00261         return m_PrevVehiclePosition;
00262 }

int Lane::getNoVeh (  ) 

Gets the number of vehicles in the lane.

Returns:
The number of vehicles in the lane

Definition at line 250 of file Lane.cpp.

References m_pVehicles.

00251 {
00252         return m_pVehicles.size();
00253 }

double Lane::getLength (  ) 

Gets the length of the Lane.

Returns:
The length of the Lane

Definition at line 205 of file Lane.cpp.

References m_RoadLength.

00206 {
00207         return m_RoadLength;
00208 }

void Lane::insert ( int  i,
Vehicle pVeh 
)

Inserts a Vehicle into the Lane.

This function inserts a given Vehicle into a particular position in a Lane

Parameters:
i The position to insert the Vehicle into
pVeh The Vehicle to insert

Definition at line 436 of file Lane.cpp.

References Vehicle::getPos(), m_NoVeh, m_PrevVehiclePosition, and m_pVehicles.

Referenced by ImplementLaneChange().

00437 {
00438         if(i == m_pVehicles.size())     // insert at end
00439         {
00440                 m_pVehicles.push_back(pVeh);
00441                 m_PrevVehiclePosition = pVeh->getPos();
00442         }
00443         else if(i <= 0)                         // insert at front
00444                 m_pVehicles.insert(m_pVehicles.begin(), pVeh);
00445         else                                            // insert between front & back, i.e. lane change
00446                 m_pVehicles.insert(m_pVehicles.begin()+i, pVeh);
00447 
00448         m_NoVeh++;
00449 }

Here is the call graph for this function:

void Lane::setRightLane ( Lane right  ) 

Sets a pointer to the Lane to the right of the current Lane The Lane index is in global coords:

  • For DriveOnRight the lanes are numbered from bottom to top 0.

..n

  • For left driving the lanes are numbered from top to bottom 0...n

Parameters:
right The Lane to point to

Definition at line 241 of file Lane.cpp.

References m_RightLane.

00242 {
00243         m_RightLane = right;
00244 }

void Lane::setLeftLane ( Lane left  ) 

Sets a pointer to the Lane to the left of the current Lane The Lane index is in global coords:

  • For DriveOnRight the lanes are numbered from bottom to top 0.

..n

  • For left driving the lanes are numbered from top to bottom 0...n

Parameters:
left The Lane to point to

Definition at line 229 of file Lane.cpp.

References m_LeftLane.

00230 {
00231         m_LeftLane = left;
00232 }

std::vector< Vehicle * > Lane::getPos (  ) 

Gets all the Vehicles currently in the Lane.

This function returns the vector which contains pointers to all Vehicles which are currently in the Lane

Returns:
All of the Vehicles in the Lane

Definition at line 217 of file Lane.cpp.

References m_pVehicles.

Referenced by FinadAdjacentVehicle().

00218 {
00219         return m_pVehicles;
00220 }

Vehicle * Lane::FinadAdjacentVehicle ( Lane AdjacentLane,
double  location,
bool  front,
int *  iAdjacentLane = NULL 
) [private]

Finds a vehicle in the adjacent lane.

Parameters:
AdjacentLane The lane at which we are looking
location The location of the vehicle wishing to change
front Whether or not we are looking for the vehicle in front of the current vehicle's position
iAdjacentLane The index to switch into in the adjacent lane
Returns:
The vehicle desired
This function finds the vehicle that in the adjacent lane, in front of (front == true) the given location, or behind (front == false) the given location. It returns the appropriate vehicle, and sets iAdjacentIndex to the index into which the current vehicle should change if it changes lane.

Definition at line 400 of file Lane.cpp.

References getPos().

Referenced by ChangeLanes().

00401 {
00402         std::vector<Vehicle*> AdjacentLaneVeh = AdjacentLane->getPos();
00403 
00404         if(AdjacentLaneVeh.size() == 0)
00405                 return NULL;
00406 
00407         // searches from back of nextLane up to the vehicle in front
00408         int i = AdjacentLaneVeh.size() - 1;
00409 
00410         while(i >= 0 && AdjacentLaneVeh.at(i)->getPos() < location)
00411                 i--;
00412 
00413         if(iAdjacentLane != NULL)       // i points to the vehicle in front of us in the other lane
00414                 *iAdjacentLane = i+1;   // place the position in iAdjacentLane
00415 
00416         //We need to check for bounds here, since we're returning a Vehicle, not an index
00417 
00418         if(front && i >= 0)
00419                 return AdjacentLaneVeh.at(i);
00420         else if(front && i < 0)
00421                 return NULL;
00422         else if(!front && i == AdjacentLaneVeh.size() - 1)
00423                 return NULL;
00424         else
00425                 return AdjacentLaneVeh.at(i+1);
00426 }

Here is the call graph for this function:

Lane * Lane::ChangeLanes ( Vehicle pVeh  )  [private]

Changes a Vehicle's Lane if advantageous and possible.

Parameters:
pVeh The vehicle changing lanes
Returns:
Whether or not the vehicle has changed lane
This function is called whenever it is time for a Vehicle to check whether or not it would be advantageous to move to another Lane. The vehicle finds its neighbours in the left and right lanes, and then decides whether to change lane, or which lane to change to, based on their properties.

Definition at line 285 of file Lane.cpp.

References Vehicle::DecideLaneChange(), FinadAdjacentVehicle(), Vehicle::getDirection(), Vehicle::getPos(), ImplementLaneChange(), m_LeftLane, and m_RightLane.

Referenced by update().

00286 {
00287         // since if it's a single lane you cannot change so let's not even bother
00288         if(m_RightLane == NULL && m_LeftLane == NULL)
00289                 return false;
00290 
00291         bool DirPos = pVeh->getDirection();
00292         Vehicle* LeftFrontVehicle = NULL;       Vehicle* LeftBackVehicle = NULL;
00293         Vehicle* RightFrontVehicle = NULL;  Vehicle* RightBackVehicle = NULL;
00294         int iLeftLane = 0;                                      int iRightLane = 0;
00295         bool LeftLaneExists = m_LeftLane != NULL ? true : false;
00296         bool RightLaneExists = m_RightLane != NULL ? true : false;
00297         
00298         if(LeftLaneExists)
00299         {
00300                 LeftFrontVehicle = FinadAdjacentVehicle(m_LeftLane, pVeh->getPos(), true, &iLeftLane);
00301                 LeftBackVehicle = FinadAdjacentVehicle(m_LeftLane, pVeh->getPos(), false);
00302         }
00303         
00304         if(RightLaneExists)
00305         {
00306                 RightFrontVehicle = FinadAdjacentVehicle(m_RightLane, pVeh->getPos(), true, &iRightLane);
00307                 RightBackVehicle = FinadAdjacentVehicle(m_RightLane, pVeh->getPos(), false);
00308         }
00309         int LaneChangeID = 0;
00310         if(DirPos)      // in DirPos
00311                 LaneChangeID = pVeh->DecideLaneChange(  LeftFrontVehicle,       LeftBackVehicle, 
00312                                                                                                 RightFrontVehicle,      RightBackVehicle,
00313                                                                                                 LeftLaneExists,         RightLaneExists);
00314         else    // in DirNeg so swap vehicles - see comment in Vehicle::DecideLaneChange()
00315                 LaneChangeID = pVeh->DecideLaneChange(  RightFrontVehicle,      RightBackVehicle,
00316                                                                                                 LeftFrontVehicle,       LeftBackVehicle,
00317                                                                                                 RightLaneExists,        LeftLaneExists);
00318 
00319         if(LaneChangeID == 0)
00320                 return NULL;
00321         else
00322         {
00323                 Lane* pNewLane = ImplementLaneChange(pVeh, LaneChangeID, iLeftLane, iRightLane);
00324                 return pNewLane;
00325         }
00326 }

Here is the call graph for this function:

Lane * Lane::ImplementLaneChange ( Vehicle pVeh,
int  LaneChangeID,
int  iVehLeftLane,
int  iVehRightLane 
) [private]

Changes a vehicle to another lane.

Parameters:
pVeh The vehicle changing lane
LaneChangeID The lane to change to
iVehLeftLane The index of the vehicle if moving to the left lane
iVehRightLane The index of the vehicle if moving to the right lane
This function inserts the vehicle that is changing lane into the appropriate lane. It also takes care of tracking lane changes if the user specifies that lane changes should be tracked.

Definition at line 339 of file Lane.cpp.

References LaneChangeDetector::addEvent(), Vehicle::getDirection(), Vehicle::getID(), getIndex(), Vehicle::getLane(), Vehicle::getPos(), insert(), m_bTrackLaneChanges, m_CurTime, m_LeftLane, m_pLaneChangeDetector, m_RightLane, m_RoadLength, and Vehicle::setLane().

Referenced by ChangeLanes().

00340 {
00341         Lane* VehiclesLeftLane;         Lane* VehiclesRightLane;        Lane* LaneToChange;
00342         
00343         int fromLane = pVeh->getLane();         // for lane change detector
00344         double position = pVeh->getPos();
00345         bool DirPos = pVeh->getDirection();
00346         bool changeLeft = true;
00347 
00348         if(DirPos)
00349         {
00350                 VehiclesLeftLane = m_LeftLane;          VehiclesRightLane = m_RightLane;
00351         }
00352         else
00353         {
00354                 VehiclesLeftLane = m_RightLane;         VehiclesRightLane = m_LeftLane;
00355 
00356                 int temp = iVehLeftLane;                        // Swapping vehicle index in new Lane
00357                 iVehLeftLane = iVehRightLane;
00358                 iVehRightLane = temp;
00359 
00360                 position = m_RoadLength - position;
00361         }
00362         if(LaneChangeID == 1)
00363         {
00364                 // change to the vehicle's left lane
00365                 pVeh->setLane(VehiclesLeftLane->getIndex()+1);  // vehicle lane numbers are 1-based
00366                 VehiclesLeftLane->insert(iVehLeftLane, pVeh);
00367                 LaneToChange = VehiclesLeftLane;
00368         }
00369         else
00370         {
00371                 changeLeft = false;
00372                 // change to vehicle's right lane
00373                 pVeh->setLane(VehiclesRightLane->getIndex()+1); // vehicle lane numbers are 1-based
00374                 VehiclesRightLane->insert(iVehRightLane, pVeh);
00375                 LaneToChange = VehiclesRightLane;
00376         }
00377 
00378         if(m_bTrackLaneChanges) // If we are tracking changes, add this event
00379         {
00380                 int toLane = (LaneToChange->getIndex() + 1);
00381                 LaneChangeEvent* lce = new LaneChangeEvent(position, fromLane, toLane, pVeh->getID(), changeLeft, DirPos, m_CurTime);
00382                 m_pLaneChangeDetector->addEvent(lce);
00383         }
00384 
00385         return LaneToChange;
00386 }

Here is the call graph for this function:

void Lane::CheckDetectors ( const double  curTime,
double  prevPosition,
double  curPosition,
Vehicle pVeh 
) [private]

Adds a vehicle to the detectors list of vehicles for that step.

Parameters:
curTime The current simulation time
prevPosition The vehicle's previous position
curPosition The vehicle's current position
pVeh The vehicle
This function takes account of all detectors that are currently on the road and checks to see if a given vehicle has passed any detectors in the last simulation step. If a vehicle has passed a detector, it is added to that detector

Definition at line 179 of file Lane.cpp.

References OutputDetector::addVehicle(), Detector::getLocation(), m_pOutputDetector, and m_vDetectors.

Referenced by CheckFeatures().

00180 {
00181         // if the vehicle has moved past it in the last time step
00182         // add the vehicle to the detector
00183         
00185         int DetectorLocation = m_pOutputDetector->getLocation();
00186         if(prevPosition <= DetectorLocation && curPosition >= DetectorLocation)
00187                 m_pOutputDetector->addVehicle(pVeh, curTime);
00188 
00190         
00191         for(int i = 0; i < m_vDetectors.size(); i++)
00192         {
00193                 DetectorLocation = m_vDetectors.at(i)->getLocation();
00194                 if(prevPosition <= DetectorLocation && curPosition >= DetectorLocation)
00195                         m_vDetectors.at(i)->addVehicle(pVeh, curTime);
00196         }
00197 }

Here is the call graph for this function:

void Lane::CheckRoadSegments ( double  prevPosition,
double  curPosition,
Vehicle pVeh 
) [private]

Checks whether a vehicle has entered or exited any road segments.

Parameters:
prevPosition The position of the vehicle before the update
curPosition The position of the vehicle after the update
pVeh The vehicle involved
This function takes account of all segments in the road - speedlimits, gradients, etc - and checks each update to see if a vehicle has entered or exited any of the segments on the road. Overlapping segments are accounted for, as if a vehicle exits a segment and has not entered a subsequent segment, it is checked to see whether the vehicle is still in the bounds of a previous segment

Definition at line 482 of file Lane.cpp.

References DriverModel::ClearRestriction(), Vehicle::getDriver(), and m_RoadSegments.

Referenced by CheckFeatures().

00483 {
00484         bool entered = false;
00485         bool exited = false;
00486         int nSegments = m_RoadSegments.size();
00487 
00488         for(int i = 0; i < nSegments; i++)                                              // for each road segment
00489         {
00490                 int start = m_RoadSegments.at(i)->getBeginning();       // its start and end
00491                 int end = m_RoadSegments.at(i)->getEnd();
00492 
00493                 if(prevPosition <= start && curPosition >= start)       // if we have entered the segment
00494                 {
00495                         m_RoadSegments.at(i)->addVehicle(pVeh);
00496                         entered = true;
00497                 }
00498                 else if(prevPosition < end && curPosition >= end)       // else if we have exited the segment
00499                 {
00500                         m_RoadSegments.at(i)->removeVehicle(pVeh);
00501                         exited = true;
00502                 }
00503         }
00504 
00505         if(exited && !entered) // if we have exited a segment, but not entered a subsequent one
00506         {
00507                 for(int j = 0; j < nSegments; j++)
00508                 {
00509                         int start = m_RoadSegments.at(j)->getBeginning();
00510                         int end = m_RoadSegments.at(j)->getEnd();
00511 
00512                         if(curPosition >= start && curPosition < end)
00513                         {
00514                                 m_RoadSegments.at(j)->addVehicle(pVeh);
00515                                 entered = true;
00516                                 break;
00517                         }
00518                 }
00519                 if(!entered) 
00520                         pVeh->getDriver()->ClearRestriction();
00521         }
00522 }

Here is the call graph for this function:


Member Data Documentation

std::vector<Vehicle*> Lane::m_pVehicles [private]

Definition at line 58 of file Lane.h.

Referenced by clear(), getNoVeh(), getPos(), insert(), and update().

std::vector<Detector*> Lane::m_vDetectors [private]

Definition at line 59 of file Lane.h.

Referenced by CheckDetectors(), clear(), and Lane().

int Lane::m_Dir [private]

Definition at line 61 of file Lane.h.

int Lane::m_iLane [private]

Definition at line 62 of file Lane.h.

Referenced by getIndex(), and Lane().

double Lane::m_Flow [private]

Definition at line 63 of file Lane.h.

double Lane::m_RoadLength [private]

Definition at line 64 of file Lane.h.

Referenced by getLength(), ImplementLaneChange(), Lane(), and update().

int Lane::m_NoVeh [private]

Definition at line 65 of file Lane.h.

Referenced by insert(), Lane(), and update().

double Lane::m_PrevVehiclePosition [private]

Definition at line 66 of file Lane.h.

Referenced by getLastPos(), insert(), Lane(), and update().

bool Lane::m_AllowLaneChanging [private]

Definition at line 67 of file Lane.h.

Referenced by Lane(), and update().

bool Lane::m_DirPos [private]

Definition at line 68 of file Lane.h.

Referenced by Lane().

double Lane::m_CurTime [private]

Definition at line 69 of file Lane.h.

Referenced by ImplementLaneChange(), and update().

bool Lane::m_bTrackLaneChanges [private]

Definition at line 70 of file Lane.h.

Referenced by ImplementLaneChange(), and Lane().

std::vector<RoadSegment*> Lane::m_RoadSegments [private]

Definition at line 72 of file Lane.h.

Referenced by CheckRoadSegments(), clear(), and setRoadSegments().

Lane* Lane::m_LeftLane [private]

Definition at line 74 of file Lane.h.

Referenced by ChangeLanes(), ImplementLaneChange(), Lane(), and setLeftLane().

Lane* Lane::m_RightLane [private]

Definition at line 75 of file Lane.h.

Referenced by ChangeLanes(), ImplementLaneChange(), Lane(), and setRightLane().

Definition at line 76 of file Lane.h.

Referenced by CheckDetectors(), and setOutputDetector().

Definition at line 77 of file Lane.h.

Referenced by ImplementLaneChange(), and Lane().

Definition at line 79 of file Lane.h.

Referenced by Lane(), and update().


The documentation for this class was generated from the following files:

Generated on Wed Aug 20 00:48:47 2008 for EvolveTraffic by  doxygen 1.5.6