Skip to content

Commit

Permalink
running astyle #563
Browse files Browse the repository at this point in the history
  • Loading branch information
behrisch committed May 6, 2024
1 parent 44e1d32 commit fb9899a
Show file tree
Hide file tree
Showing 40 changed files with 185 additions and 169 deletions.
2 changes: 1 addition & 1 deletion src/libsumo/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ Vehicle::changeTarget(const std::string& vehID, const std::string& edgeID) {
// change the final edge of the route and reroute
try {
const bool success = veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:changeTarget",
veh->getRouterTT(), onInit, false, false, destEdge);
veh->getRouterTT(), onInit, false, false, destEdge);
if (!success) {
throw TraCIException("ChangeTarget failed for vehicle '" + veh->getID() + "', destination edge '" + edgeID + "' unreachable.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/mesosim/MEInductLoop.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class MEInductLoop : public MSDetectorFileOutput {
//@}

const MSMeanData_Net::MSLaneMeanDataValues& getMeanData() const {
return myMeanData;
return myMeanData;
}

const MSEdge& getEdge() const;
Expand Down
3 changes: 1 addition & 2 deletions src/mesosim/METriggeredCalibrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ METriggeredCalibrator::METriggeredCalibrator(const std::string& id,
const double invalidJamThreshold,
const std::string& vTypes) :
MSCalibrator(id, edge, (MSLane*)nullptr, pos, aXMLFilename, outputFilename, freq, length, probe, invalidJamThreshold, vTypes, false),
mySegment(MSGlobals::gMesoNet->getSegmentForEdge(*edge, pos))
{
mySegment(MSGlobals::gMesoNet->getSegmentForEdge(*edge, pos)) {
myEdgeMeanData.setDescription("meandata_calibrator_" + getID());
mySegment->addDetector(&myEdgeMeanData);
}
Expand Down
2 changes: 1 addition & 1 deletion src/mesosim/MEVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ MEVehicle::getSpeed() const {

double
MEVehicle::getAverageSpeed() const {
if (mySegment == nullptr || myQueIndex == MESegment::PARKING_QUEUE ) {
if (mySegment == nullptr || myQueIndex == MESegment::PARKING_QUEUE) {
return 0;
} else {
return MIN2(mySegment->getLength() / STEPS2TIME(myEventTime - myLastEntryTime),
Expand Down
4 changes: 2 additions & 2 deletions src/microsim/MSEdge.h
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,8 @@ class MSEdge : public Named, public Parameterised {
}
const SUMOVehicleClass svc = vehicle->getVClass();
return (vehicle->ignoreTransientPermissions()
? (myOriginalCombinedPermissions & svc) != svc
: (myCombinedPermissions & svc) != svc);
? (myOriginalCombinedPermissions & svc) != svc
: (myCombinedPermissions & svc) != svc);
}

bool hasTransientPermissions() const;
Expand Down
4 changes: 2 additions & 2 deletions src/microsim/MSLane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2324,7 +2324,7 @@ MSLane::updateLengthSum() {
// avoid numerical instability
myBruttoVehicleLengthSum = 0;
myNettoVehicleLengthSum = 0;
} else if (myRecalculateBruttoSum){
} else if (myRecalculateBruttoSum) {
myBruttoVehicleLengthSum = 0;
for (VehCont::const_iterator i = myVehicles.begin(); i != myVehicles.end(); ++i) {
myBruttoVehicleLengthSum += (*i)->getVehicleType().getLengthWithGap();
Expand Down Expand Up @@ -2941,7 +2941,7 @@ MSLane::getLeaderOnConsecutive(double dist, double seen, double speed, const MSV
shortestGap = gap;
if (ll.vehAndGap.second < 0 && !MSGlobals::gComputeLC) {
// can always continue up to the stop line or crossing point
// @todo: figure out whether this should also impact lane changing
// @todo: figure out whether this should also impact lane changing
ll.vehAndGap.second = MAX2(seen - nextLane->getLength(), ll.distToCrossing);
}
result = ll.vehAndGap;
Expand Down
9 changes: 4 additions & 5 deletions src/microsim/MSRouteHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ MSRouteHandler::MSRouteHandler(const std::string& file, bool addVehiclesDirectly
myAmLoadingState(false),
myScaleSuffix(OptionsCont::getOptions().getString("scale-suffix")),
myReplayRerouting(OptionsCont::getOptions().getBool("replay-rerouting")),
myStartTriggeredInFlow(false)
{
myStartTriggeredInFlow(false) {
myActiveRoute.reserve(100);
}

Expand Down Expand Up @@ -440,7 +439,7 @@ MSRouteHandler::closeRoute(const bool mayBeDisconnected) {
if (myActiveRoute.size() > 0 && !myActiveRoute.back()->isConnectedTo(*myActiveRoute.front(), vClass)) {
if (tmpStops.size() == 0 || tmpStops.back().jump < 0) {
throw ProcessError(TLF("Disconnected route '%' when repeating. Last edge '%' is not connected to first edge '%'%",
myActiveRouteID, myActiveRoute.back()->getID(), myActiveRoute.front()->getID(), errSuffix));
myActiveRouteID, myActiveRoute.back()->getID(), myActiveRoute.front()->getID(), errSuffix));
}
}
}
Expand Down Expand Up @@ -878,7 +877,7 @@ MSRouteHandler::closeTransportableFlow() {
myVehicleParameter->incrementFlow(1, &myParsingRNG);
}
for (; i < myVehicleParameter->repetitionNumber && (myVehicleParameter->repetitionNumber != std::numeric_limits<int>::max()
|| depart + myVehicleParameter->repetitionTotalOffset <= myVehicleParameter->repetitionEnd); i++) {
|| depart + myVehicleParameter->repetitionTotalOffset <= myVehicleParameter->repetitionEnd); i++) {
// type existence has been checked on opening
MSVehicleType* const type = MSNet::getInstance()->getVehicleControl().getVType(myVehicleParameter->vtypeid, &myParsingRNG);
addFlowTransportable(depart + myVehicleParameter->repetitionTotalOffset, type, baseID, i);
Expand Down Expand Up @@ -1297,7 +1296,7 @@ MSRouteHandler::addStop(const SUMOSAXAttributes& attrs) {
throw ProcessError(TLF("The lane '%' for a stop is not known%.", stop.lane, errorSuffix));
}
} else if (ok && ((attrs.hasAttribute(SUMO_ATTR_X) && attrs.hasAttribute(SUMO_ATTR_Y))
|| (attrs.hasAttribute(SUMO_ATTR_LON) && attrs.hasAttribute(SUMO_ATTR_LAT)))) {
|| (attrs.hasAttribute(SUMO_ATTR_LON) && attrs.hasAttribute(SUMO_ATTR_LAT)))) {
Position pos;
bool geo = false;
if (attrs.hasAttribute(SUMO_ATTR_X) && attrs.hasAttribute(SUMO_ATTR_Y)) {
Expand Down
24 changes: 12 additions & 12 deletions src/microsim/MSTrainHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const double MSTrainHelper::PEDESTRIAN_RADIUS_EXTRA_TOLERANCE = 0.01;
// ===========================================================================
// method definitions
// ===========================================================================
void
void
MSTrainHelper::computeTrainDimensions(double exaggeration, int vehicleQuality) {
const MSVehicleType& vtype = myTrain->getVehicleType();
const double totalLength = vtype.getLength();
Expand Down Expand Up @@ -64,9 +64,9 @@ MSTrainHelper::computeTrainDimensions(double exaggeration, int vehicleQuality) {
}
myCarriageDoors = vtype.getParameter().carriageDoors;
}


void

void
MSTrainHelper::computeCarriages(bool reversed, bool secondaryShape) {
myCarriages.clear();

Expand Down Expand Up @@ -96,7 +96,7 @@ MSTrainHelper::computeCarriages(bool reversed, bool secondaryShape) {
}

myFirstPassengerCarriage = myDefaultLength == myLocomotiveLength || myNumCarriages == 1
|| (myTrain->getVClass() & (SVC_RAIL_ELECTRIC | SVC_RAIL_FAST | SVC_RAIL)) == 0 ? 0 : 1;
|| (myTrain->getVClass() & (SVC_RAIL_ELECTRIC | SVC_RAIL_FAST | SVC_RAIL)) == 0 ? 0 : 1;

const double lateralOffset = (myTrain->isParking() && myTrain->getNextStopParameter()->posLat == INVALID_DOUBLE
? (myTrain->getLane()->getWidth() * (MSGlobals::gLefthand ? -1 : 1))
Expand Down Expand Up @@ -134,7 +134,7 @@ MSTrainHelper::computeCarriages(bool reversed, bool secondaryShape) {
}
backLane = prev;
}

carriage->front = lane->getShape(secondaryShape).positionAtOffset(carriageOffset * lane->getLengthGeometryFactor(secondaryShape), lateralOffset);
carriage->back = backLane->getShape(secondaryShape).positionAtOffset(carriageBackOffset * lane->getLengthGeometryFactor(secondaryShape), lateralOffset);
myCarriages.push_back(carriage);
Expand All @@ -145,7 +145,7 @@ MSTrainHelper::computeCarriages(bool reversed, bool secondaryShape) {
}


void
void
MSTrainHelper::computeDoorPositions() {
for (Carriage* carriage : myCarriages) {
Position dir = carriage->front - carriage->back;
Expand All @@ -154,14 +154,14 @@ MSTrainHelper::computeDoorPositions() {
dir.norm2D();
for (int j = 1; j <= myCarriageDoors; j++) {
const double doorOffset = j * carriageLength / (myCarriageDoors + 1);
carriage->doorPositions.push_back(carriage->front - dir*doorOffset);
carriage->doorPositions.push_back(carriage->front - dir * doorOffset);
}
}
}
}


void
void
MSTrainHelper::computeUnboardingPositions(double passengerRadius, std::vector<Position>& unboardingPositions) {
passengerRadius += PEDESTRIAN_RADIUS_EXTRA_TOLERANCE;
for (Carriage* carriage : myCarriages) {
Expand All @@ -171,13 +171,13 @@ MSTrainHelper::computeUnboardingPositions(double passengerRadius, std::vector<Po
dir.norm2D();
const Position perp = Position(-dir.y(), dir.x());
double nbrLongitudinalCells, longitudinalOffset;
longitudinalOffset = std::modf((carriageLength - 2.0*passengerRadius) / (2.0*passengerRadius), &nbrLongitudinalCells);
longitudinalOffset = std::modf((carriageLength - 2.0 * passengerRadius) / (2.0 * passengerRadius), &nbrLongitudinalCells);
double nbrLateralCells, lateralOffset;
lateralOffset = std::modf((myHalfWidth*2.0 - 2.0*passengerRadius) / (2.0*passengerRadius), &nbrLateralCells);
const Position gridOrigin = carriage->back + dir*(passengerRadius + 0.5*longitudinalOffset) - perp*(myHalfWidth - passengerRadius - 0.5*lateralOffset);
lateralOffset = std::modf((myHalfWidth * 2.0 - 2.0 * passengerRadius) / (2.0 * passengerRadius), &nbrLateralCells);
const Position gridOrigin = carriage->back + dir * (passengerRadius + 0.5 * longitudinalOffset) - perp * (myHalfWidth - passengerRadius - 0.5 * lateralOffset);
for (unsigned int i = 0; i <= (unsigned int)nbrLongitudinalCells; i++) {
for (unsigned int j = 0; j <= (unsigned int)nbrLateralCells; j++) {
carriage->unboardingPositions.push_back(gridOrigin + dir * i * 2.0*passengerRadius + perp * j * 2.0*passengerRadius);
carriage->unboardingPositions.push_back(gridOrigin + dir * i * 2.0 * passengerRadius + perp * j * 2.0 * passengerRadius);
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/microsim/MSTrainHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MSVehicle;
// ===========================================================================
/**
* @class MSTrainHelper
* @brief A class that helps computing positions of a train's carriages
* @brief A class that helps computing positions of a train's carriages
* and additional structures.
*
*/
Expand All @@ -48,14 +48,14 @@ class MSTrainHelper {
std::vector<Position> unboardingPositions;
};

MSTrainHelper(const MSVehicle* vehicle, bool reversed = false, bool secondaryShape = false, double exaggeration = 1.0, int vehicleQuality = 3)
: myTrain(vehicle) {
MSTrainHelper(const MSVehicle* vehicle, bool reversed = false, bool secondaryShape = false, double exaggeration = 1.0, int vehicleQuality = 3)
: myTrain(vehicle) {
computeTrainDimensions(exaggeration, vehicleQuality);
computeCarriages(reversed, secondaryShape);
}

~MSTrainHelper() {
for (const Carriage* carriage: myCarriages) {
for (const Carriage* carriage : myCarriages) {
delete carriage;
}
}
Expand Down Expand Up @@ -91,30 +91,30 @@ class MSTrainHelper {
inline int getFirstPassengerCarriage() const {
return myFirstPassengerCarriage;
}

inline bool isReversed() const {
return myIsReversed;
}

inline const std::vector<Carriage*>& getCarriages() const {
return myCarriages;
}

/// @brief compute door positions on demand and fills the carriage structures
/// @remark need to be called before retrieving carriages if door positions needed
void computeDoorPositions();

/// @brief compute unboarding positions on demand and fills the carriage structures
/// @remark need to be called before retrieving carriages if unboarding positions needed
void computeUnboardingPositions(double passengerRadius, std::vector<Position>& unboardingPositions);

/// @brief return length exaggeration factor (special for long vehicles)
static double getUpscaleLength(double upscale, double length, int vehicleQuality);

/// @brief average door width used to compute doors positions
static const double CARRIAGE_DOOR_WIDTH;

/// @brief small extra tolerance used to avoid constraint violations
/// @brief small extra tolerance used to avoid constraint violations
static const double PEDESTRIAN_RADIUS_EXTRA_TOLERANCE;

private:
Expand Down
53 changes: 28 additions & 25 deletions src/microsim/cfmodels/MSCFModel_CC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,25 @@ MSCFModel_CC::setLeader(MSVehicle* veh, MSVehicle* const leader, std::string lea
auto* vars = (CC_VehicleVariables*) veh->getCarFollowVariables();
vars->leaderVehicle = leader;
vars->leaderVehicleId = leaderId;
if (leader != nullptr)
if (leader != nullptr) {
vars->isLeader = false;
else
} else
// if we are removing our leader, then this vehicle must become a leader of itself until being member of another platoon
{
vars->isLeader = true;
}
}

int
MSCFModel_CC::isPlatoonLaneChangeSafe(const MSVehicle* veh, bool left) const {
CC_VehicleVariables* vars = (CC_VehicleVariables*) veh->getCarFollowVariables();
if (!vars->isLeader) {
// before asking the leader, be sure it is still in the simulation
if (findVehicle(vars->leaderVehicleId))
if (findVehicle(vars->leaderVehicleId)) {
return isPlatoonLaneChangeSafe(vars->leaderVehicle, left);
else
} else {
return LCA_BLOCKED;
}
}
int result = 0;
std::pair<int, int> state = libsumo::Vehicle::getLaneChangeState(veh->getID(), left ? +1 : -1);
Expand All @@ -148,26 +151,27 @@ MSCFModel_CC::isPlatoonLaneChangeSafe(const MSVehicle* veh, bool left) const {
if (mState.second & LCA_BLOCKED || !noNeighbors) {
if (mState.second & LCA_BLOCKED) {
result = mState.second;
}
else {
if (!followers.empty())
} else {
if (!followers.empty()) {
result |= left ? LCA_BLOCKED_BY_LEFT_FOLLOWER : LCA_BLOCKED_BY_RIGHT_FOLLOWER;
if (!leaders.empty())
}
if (!leaders.empty()) {
result |= left ? LCA_BLOCKED_BY_LEFT_LEADER : LCA_BLOCKED_BY_RIGHT_LEADER;
}
}
break;
}
}
}
else {
} else {
if (state.second & LCA_BLOCKED) {
result = state.second;
}
else {
if (!followers.empty())
} else {
if (!followers.empty()) {
result |= left ? LCA_BLOCKED_BY_LEFT_FOLLOWER : LCA_BLOCKED_BY_RIGHT_FOLLOWER;
if (!leaders.empty())
}
if (!leaders.empty()) {
result |= left ? LCA_BLOCKED_BY_LEFT_LEADER : LCA_BLOCKED_BY_RIGHT_LEADER;
}
}
}
return result;
Expand Down Expand Up @@ -220,8 +224,7 @@ MSCFModel_CC::performPlatoonLaneChange(MSVehicle* const veh) const {
}

double
MSCFModel_CC::getSecureGap(const MSVehicle* const veh, const MSVehicle* const pred, const double speed, const double leaderSpeed, const double leaderMaxDecel) const
{
MSCFModel_CC::getSecureGap(const MSVehicle* const veh, const MSVehicle* const pred, const double speed, const double leaderSpeed, const double leaderMaxDecel) const {
CC_VehicleVariables* vars = (CC_VehicleVariables*)veh->getCarFollowVariables();

const double tolerance = 0.8;
Expand Down Expand Up @@ -250,26 +253,26 @@ MSCFModel_CC::commitToLaneChange(const MSVehicle* veh, bool left) const {
if (isLeader(veh)) {
SUMOTime timestep = MSNet::getInstance()->getCurrentTimeStep();
if (vars->laneChangeCommitTime == timestep) {
if (vars->commitToLaneChange)
if (vars->commitToLaneChange) {
return 0;
else
} else {
return vars->noCommitReason;
}
else {
}
} else {
int blocked = isPlatoonLaneChangeSafe(veh, left);
if (blocked == 0) {
vars->commitToLaneChange = true;
vars->laneChangeCommitTime = timestep;
}
return blocked;
}
}
else {
} else {
// before asking the leader, be sure it is still in the simulation
if (findVehicle(vars->leaderVehicleId))
if (findVehicle(vars->leaderVehicleId)) {
return commitToLaneChange(vars->leaderVehicle, left);
else
} else {
return LCA_BLOCKED;
}
}
}

Expand Down Expand Up @@ -1205,7 +1208,7 @@ MSCFModel_CC::duplicate(const MSVehicleType* vtype) const {
}

bool
MSCFModel_CC::isLeader(const MSVehicle *veh) const {
MSCFModel_CC::isLeader(const MSVehicle* veh) const {
auto vars = (CC_VehicleVariables*)veh->getCarFollowVariables();
return vars->isLeader;
}
8 changes: 4 additions & 4 deletions src/microsim/cfmodels/MSCFModel_Rail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ MSCFModel_Rail::MSCFModel_Rail(const MSVehicleType* vtype) :
WRITE_WARNING(TLF("Ignoring tractionTable because maxPower and maxTraction are set for vType '%'.", vtype->getID()));
}
const bool hasSomeResCoef = (myTrainParams.resCoef_constant != INVALID_DOUBLE
|| myTrainParams.resCoef_linear != INVALID_DOUBLE
|| myTrainParams.resCoef_quadratic != INVALID_DOUBLE);
|| myTrainParams.resCoef_linear != INVALID_DOUBLE
|| myTrainParams.resCoef_quadratic != INVALID_DOUBLE);
const bool hasAllResCoef = (myTrainParams.resCoef_constant != INVALID_DOUBLE
&& myTrainParams.resCoef_linear != INVALID_DOUBLE
&& myTrainParams.resCoef_quadratic != INVALID_DOUBLE);
&& myTrainParams.resCoef_linear != INVALID_DOUBLE
&& myTrainParams.resCoef_quadratic != INVALID_DOUBLE);
if (hasSomeResCoef && !hasAllResCoef) {
throw ProcessError(TLF("Some undefined resistance coefficients for vType '%' (requires resCoef_constant, resCoef_linear and resCoef_quadratic)", vtype->getID()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/microsim/cfmodels/MSCFModel_Rail.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class MSCFModel_Rail : public MSCFModel {

private:

static void convertMap(LookUpMap& map, double keyFactor = 1/3.6, double valueFactor = 1);
static void convertMap(LookUpMap& map, double keyFactor = 1 / 3.6, double valueFactor = 1);


TrainParams myTrainParams;
Expand Down

0 comments on commit fb9899a

Please sign in to comment.