Skip to content

Commit

Permalink
[JuPedSim] Improved dynamic geometry switching performance further.
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoueraud87 authored and namdre committed Feb 29, 2024
1 parent 4126a2a commit c30560a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/microsim/MSBaseVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <microsim/devices/MSDevice_Routing.h>
#include <microsim/lcmodels/MSAbstractLaneChangeModel.h>
#include <microsim/transportables/MSPerson.h>
#include <microsim/transportables/MSStageDriving.h>
#include "MSGlobals.h"
#include "MSVehicleControl.h"
#include "MSVehicleType.h"
Expand Down Expand Up @@ -1989,6 +1990,21 @@ MSBaseVehicle::getPersonNumber() const {
return boarded + myParameter->personNumber;
}

int
MSBaseVehicle::getLeavingPersonNumber() const {
int leavingPersonNumber = 0;
const std::vector<MSTransportable*>& persons = getPersons();
for (std::vector<MSTransportable*>::const_iterator it_p = persons.begin(); it_p != persons.end(); ++it_p) {
MSStageDriving* const stage = dynamic_cast<MSStageDriving*>((*it_p)->getCurrentStage());
const MSStop* stop = &myStops.front();
const MSVehicle* joinVeh = dynamic_cast<MSVehicle*>(MSNet::getInstance()->getVehicleControl().getVehicle((*stop).pars.join));
if (stop && stage->canLeaveVehicle(*it_p, *this, *stop) && !MSDevice_Transportable::willTransferAtJoin(*it_p, joinVeh)) {
leavingPersonNumber++;
}
}
return leavingPersonNumber;
}

std::vector<std::string>
MSBaseVehicle::getPersonIDList() const {
std::vector<std::string> ret;
Expand Down
5 changes: 5 additions & 0 deletions src/microsim/MSBaseVehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ class MSBaseVehicle : public SUMOVehicle {
*/
int getPersonNumber() const;

/** @brief Returns the number of leaving persons
* @return The number of leaving passengers
*/
int getLeavingPersonNumber() const;

/** @brief Returns the list of persons
* @return The list of passengers on-board
*/
Expand Down
2 changes: 1 addition & 1 deletion src/microsim/transportables/MSPModel_JuPedSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ MSPModel_JuPedSim::execute(SUMOTime time) {
std::vector<GEOSGeometry*> carriagePolygons;
std::vector<GEOSGeometry*> rampPolygons;
for (const MSVehicle* train : allStoppedTrains) {
if (train->getPersonNumber() > 0) {
if (train->getLeavingPersonNumber() > 0) {
const MSTrainHelper trainHelper(train);
const std::vector<MSTrainHelper::Carriage*>& carriages = trainHelper.getCarriages();
for (const MSTrainHelper::Carriage* carriage : carriages) {
Expand Down

0 comments on commit c30560a

Please sign in to comment.