Commit f38f6093 authored by Arne Graf's avatar Arne Graf

cleaning

parent d65740a5
Pipeline #3878 passed with stages
in 5 minutes and 42 seconds
......@@ -91,9 +91,12 @@ UnivFFviaFM::UnivFFviaFM(Room* roomArg, Configuration* const confArg, double hx,
}
}
}
create(lines, tmpDoors, wantedDoors, FF_HOMO_SPEED, hx, wallAvoid, useWallDistances);
//create(lines, tmpDoors, wantedDoors, FF_WALL_AVOID, hx, wallAvoid, useWallDistances);
//this will interpret "useWallDistances" as best as possible. Users should clearify with "setSpeedMode" before calling "AddTarget"
if (useWallDistances) {
create(lines, tmpDoors, wantedDoors, FF_WALL_AVOID, hx, wallAvoid, useWallDistances);
} else {
create(lines, tmpDoors, wantedDoors, FF_HOMO_SPEED, hx, wallAvoid, useWallDistances);
}
}
UnivFFviaFM::UnivFFviaFM(SubRoom* sr, Configuration* const conf, double hx, double wallAvoid, bool useWallDistances)
......@@ -135,7 +138,12 @@ UnivFFviaFM::UnivFFviaFM(SubRoom* subRoomArg, Configuration* const confArg, doub
tmpDoors.emplace(std::make_pair(uidNotConst, (Line) *trans));
}
create(lines, tmpDoors, wantedDoors, FF_HOMO_SPEED, hx, wallAvoid, useWallDistances);
//this will interpret "useWallDistances" as best as possible. Users should clearify with "setSpeedMode" before calling "AddTarget"
if (useWallDistances) {
create(lines, tmpDoors, wantedDoors, FF_WALL_AVOID, hx, wallAvoid, useWallDistances);
} else {
create(lines, tmpDoors, wantedDoors, FF_HOMO_SPEED, hx, wallAvoid, useWallDistances);
}
}
void UnivFFviaFM::create(std::vector<Line>& walls, std::map<int, Line>& doors, std::vector<int> targetUIDs, int mode,
......@@ -995,7 +1003,7 @@ void UnivFFviaFM::addTarget(const int uid, double* costarrayDBL, Point* gradarra
if (_mode == CENTERPOINT) {
newArrayDBL[_grid->getKeyAtPoint(tempCenterPoint)] = magicnum(TARGET_REGION);
}
//the following condition is not clean: we have _speedmode and _useWallDistances which are redundant
if (_speedmode == FF_WALL_AVOID) {
calcFF(newArrayDBL, newArrayPt, _speedFieldSelector[REDU_WALL_SPEED]);
} else if (_speedmode == FF_HOMO_SPEED) {
......@@ -1074,6 +1082,10 @@ void UnivFFviaFM::setMode(int modeArg) {
_mode=modeArg;
}
void UnivFFviaFM::setSpeedMode(int speedModeArg) {
_speedmode = speedModeArg;
}
void UnivFFviaFM::writeFF(const std::string& filename, std::vector<int> targetID) {
Log->Write("INFO: \tWrite Floorfield to file");
......@@ -1290,14 +1302,18 @@ void UnivFFviaFM::getDirectionToUID(int destID, const long int key, Point& direc
double UnivFFviaFM::getDistance2WallAt(const Point &pos) {
if (_useWallDistances || (_speedmode == FF_WALL_AVOID)) {
return _costFieldWithKey[0][_grid->getKeyAtPoint(pos)];
if (_costFieldWithKey[0]) {
return _costFieldWithKey[0][_grid->getKeyAtPoint(pos)];
}
}
return DBL_MAX;
}
void UnivFFviaFM::getDir2WallAt(const Point &pos, Point &p) {
if (_useWallDistances || (_speedmode == FF_WALL_AVOID)) {
p = _directionFieldWithKey[0][_grid->getKeyAtPoint(pos)];
if (_directionFieldWithKey[0]) {
p = _directionFieldWithKey[0][_grid->getKeyAtPoint(pos)];
}
} else {
p = Point(0.0, 0.0);
}
......
......@@ -98,6 +98,7 @@ public:
std::vector<int> getKnownDoorUIDs();
void setUser(int userArg);
void setMode(int modeArg);
void setSpeedMode(int speedModeArg);
SubRoom** getSubRoomFF();
SubRoom* getSubRoom(const Point& pos);
......@@ -150,7 +151,7 @@ private:
SubRoom* * _subrooms = nullptr; // this is an array (first asterisk) of pointers (second asterisk)
double _wallAvoidDistance = 0.;
bool _useWallDistances = false;
bool _useWallDistances = false; //could be used in DirectionStrategy even if mode _speedmode is FF_HOMO_SPEED
//the following maps are responsible for dealloc the arrays
std::map<int, double*> _costFieldWithKey;
......
......@@ -189,6 +189,7 @@ bool FFRouter::Init(Building* building)
// }
locffptr->setUser(DISTANCE_AND_DIRECTIONS_USED);
locffptr->setMode(CENTERPOINT);
locffptr->setSpeedMode(FF_HOMO_SPEED);
locffptr->addAllTargetsParallel();
locffptr->writeFF("UnivFF"+std::to_string(pairRoomIt->first)+".vtk", locffptr->getKnownDoorUIDs());
Log->Write("INFO: \tAdding distances in Room %d to matrix", (*pairRoomIt).first);
......@@ -517,7 +518,7 @@ int FFRouter::FindExit(Pedestrian* p)
#pragma omp critical(finalDoors)
_finalDoors.emplace(std::make_pair(p->GetID(), bestFinalDoor));
if (_CroTrByUID.count(bestDoor)) {
p->SetExitIndex(bestDoor);
p->SetExitLine(_CroTrByUID.at(bestDoor));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment