Commit b74b3931 authored by Oliver Schmidts's avatar Oliver Schmidts

Merge branch 'v0.7' of https://cst.version.fz-juelich.de/jupedsim/jpscore into v0.7

parents 99af59e0 46626dbc
...@@ -227,6 +227,7 @@ set ( source_files ...@@ -227,6 +227,7 @@ set ( source_files
routing/cognitive_map/sensor/SmokeSensor.cpp routing/cognitive_map/sensor/SmokeSensor.cpp
routing/cognitive_map/fire_mesh/FireMesh.cpp routing/cognitive_map/fire_mesh/FireMesh.cpp
routing/cognitive_map/fire_mesh/Knot.cpp routing/cognitive_map/fire_mesh/Knot.cpp
routing/cognitive_map/fire_mesh/FireMeshStorage.cpp
poly2tri/common/shapes.cpp poly2tri/common/shapes.cpp
poly2tri/sweep/sweep_context.cpp poly2tri/sweep/sweep_context.cpp
...@@ -266,6 +267,9 @@ set ( header_files ...@@ -266,6 +267,9 @@ set ( header_files
routing/cognitive_map/sensor/JamSensor.h routing/cognitive_map/sensor/JamSensor.h
routing/cognitive_map/sensor/LastDestinationsSensor.h routing/cognitive_map/sensor/LastDestinationsSensor.h
routing/cognitive_map/sensor/SmokeSensor.h routing/cognitive_map/sensor/SmokeSensor.h
routing/cognitive_map/fire_mesh/FireMesh.h
routing/cognitive_map/fire_mesh/Knot.h
routing/cognitive_map/fire_mesh/FireMeshStorage.h
pedestrian/Pedestrian.h pedestrian/Pedestrian.h
pedestrian/PedDistributor.h pedestrian/PedDistributor.h
......
...@@ -86,7 +86,7 @@ int CognitiveMapRouter::FindExit(Pedestrian * p) ...@@ -86,7 +86,7 @@ int CognitiveMapRouter::FindExit(Pedestrian * p)
} }
if (std::fmod(p->GetGlobalTime(),1)==0) if (std::fmod(p->GetGlobalTime(),10)==0)
{ {
sensor_manager->execute(p, SensorManager::PERIODIC); sensor_manager->execute(p, SensorManager::PERIODIC);
//std::cout << p->GetGlobalTime() << std::endl; //std::cout << p->GetGlobalTime() << std::endl;
......
#include "FireMeshStorage.h"
FireMeshStorage::FireMeshStorage(const Building * const b, const std::string &filepath, const double &updateintervall, const double &finalTime)
{
_building=b;
_filepath=filepath;
CreateTimeList(updateintervall,finalTime);
IdentifyDoors();
CreateFireMeshes();
}
FireMeshStorage::~FireMeshStorage()
{
}
void FireMeshStorage::CreateTimeList(const double &updateIntervall, const double &finalTime, const double &startTime)
{
//fulfill list with times when new Mesh should be used
double i=0;
while (i<=finalTime)
{
_timelist.push_back(i);
i+=updateIntervall;
}
}
void FireMeshStorage::IdentifyDoors()
{
const std::map<int,std::unique_ptr<Door>> doors = _building->GetAllRooms();
for (auto it=doors.begin(); it!= doors.end(); ++it)
{
_doors.push_back(it.second);
}
}
void FireMeshStorage::CreateFireMeshes()
{
for (auto &door:_doors)
{
for (auto &i:_timelist)
{
std::string filename = _filepath + "/Door_X_" + std::to_string(door->GetCentre().GetX())
+ "_Y_" + std::to_string(door->GetCentre().GetY()) + "/t_"+std::to_string(i)+".csv";
FireMesh mesh(filename);
_fMContainer.emplace(std::make_pair(door->GetCentre(),i),mesh);
}
}
}
const FireMesh &FireMeshStorage::get_FireMesh(const Point &doorCentre, const double &simTime)
{
return _fMContainer.at(std::make_pair(doorCentre,simTime));
}
#ifndef FIREMESHSTORAGE_H
#define FIREMESHSTORAGE_H
#include <unordered_map>
#include "FireMesh.h"
#include "../../../geometry/Building.h"
// Container to store all fireMeshs. Sorted first by coordinates of the corresponding door, secondly by simulation's global time
using fireMeshContainer = std::unordered_map<std::pair<Point,double>,FireMesh>;
class FireMeshStorage
{
public:
FireMeshStorage(const Building * const b, const std::string &filepath, const double &updateintervall, const double &finalTime);
~FireMeshStorage();
void CreateTimeList(const double &updateIntervall, const double &finalTime, const double &startTime=0);
void IdentifyDoors();
void CreateFireMeshes();
const FireMesh& get_FireMesh(const Point &doorCentre, const double &simTime);
private:
Building *_building;
fireMeshContainer _fMContainer;
std::string _filepath;
std::vector<double> _timelist;
std::vector<Door> _doors;
};
#endif // FIREMESHSTORAGE_H
...@@ -153,32 +153,32 @@ const Crossing * GraphEdge::GetCrossing() const ...@@ -153,32 +153,32 @@ const Crossing * GraphEdge::GetCrossing() const
return _crossing; return _crossing;
} }
const FireMesh &GraphEdge::GetFireMesh() const //const FireMesh *GraphEdge::GetFireMesh() const
{ //{
return _fireMesh; // return _fireMesh;
} //}
void GraphEdge::SetUpFireMesh() //void GraphEdge::SetUpFireMesh()
{ //{
//TODO: read this prefix from the ini file // //TODO: read this prefix from the ini file
// std::string filename = "D:/workspace/JuPedSim/jpscore/inputfiles/cognitive_map"; // // std::string filename = "D:/workspace/JuPedSim/jpscore/inputfiles/cognitive_map";
std::string prefix = "D:/workspace/JPS/JPScore/inputfiles/cognitive_map"; // std::string prefix = "D:/workspace/JPS/JPScore/inputfiles/cognitive_map";
std::string filename = prefix + "/Door_X_" + std::to_string(_crossing->GetCentre().GetX()) // std::string filename = prefix + "/Door_X_" + std::to_string(_crossing->GetCentre().GetX())
+ "_Y_" + std::to_string(_crossing->GetCentre().GetY()) + ".csv"; // + "_Y_" + std::to_string(_crossing->GetCentre().GetY()) + ".csv";
_fireMesh.SetKnotValuesFromFile(filename); // _fireMesh.SetKnotValuesFromFile(filename);
} //}
double GraphEdge::GetSmokeFactor(const Point &pointPed) const //double GraphEdge::GetSmokeFactor(const Point &pointPed) const
{ //std::cout << pointPed.GetX() << " " << pointPed.GetY() << std::endl; //{ //std::cout << pointPed.GetX() << " " << pointPed.GetY() << std::endl;
if (_fireMesh.statusMesh()==true) // if (_fireMesh.statusMesh()==true)
return _fireMesh.GetKnotValue(pointPed.GetX(),pointPed.GetY()); // return _fireMesh.GetKnotValue(pointPed.GetX(),pointPed.GetY());
else // else
return 1.0; // return 1.0;
} //}
bool GraphEdge::IsExit() const bool GraphEdge::IsExit() const
{ {
......
...@@ -63,10 +63,10 @@ public: ...@@ -63,10 +63,10 @@ public:
const Crossing * GetCrossing() const; const Crossing * GetCrossing() const;
///FireMesh ///FireMesh
const FireMesh& GetFireMesh() const; //const FireMesh * GetFireMesh() const;
void SetUpFireMesh(); //void SetUpFireMesh();
double GetSmokeFactor(const Point &pointPed) const; //double GetSmokeFactor(const Point &pointPed) const;
double GetApproximateDistance() const; double GetApproximateDistance() const;
double GetApproximateDistance(const Point &) const; double GetApproximateDistance(const Point &) const;
void SetFactor(double factor, std::string name); void SetFactor(double factor, std::string name);
...@@ -80,7 +80,7 @@ private: ...@@ -80,7 +80,7 @@ private:
const GraphVertex * const _src; const GraphVertex * const _src;
const GraphVertex * const _dest; const GraphVertex * const _dest;
const Crossing * const _crossing; const Crossing * const _crossing;
FireMesh _fireMesh; //FireMesh * _fireMesh;
/** /**
* Factor Bag * Factor Bag
......
...@@ -12,8 +12,15 @@ ...@@ -12,8 +12,15 @@
#include "../../../pedestrian/Pedestrian.h" #include "../../../pedestrian/Pedestrian.h"
#include "../../../geometry/SubRoom.h" #include "../../../geometry/SubRoom.h"
#include "../fire_mesh/FireMesh.h" #include "../fire_mesh/FireMesh.h"
#include "../fire_mesh/FireMeshStorage.h"
#include <set> #include <set>
SmokeSensor::SmokeSensor(const Building *b, const &filepath, const &updateintervall, const &finalTime) : AbstractSensor(b)
{
_FMStorage= new FireMeshStorage(b,filepath,updateintervall,finalTime);
}
SmokeSensor::~SmokeSensor() SmokeSensor::~SmokeSensor()
{ {
} }
...@@ -68,4 +75,16 @@ void SmokeSensor::execute(const Pedestrian * pedestrian, CognitiveMap * cognitiv ...@@ -68,4 +75,16 @@ void SmokeSensor::execute(const Pedestrian * pedestrian, CognitiveMap * cognitiv
} }
void SmokeSensor::set_FMStorage(const&fmStorage)
{
_FMStorage=fmStorage;
}
const FireMeshStorage *SmokeSensor::get_FMStorage()
{
return _FMStorage;
}
...@@ -12,21 +12,26 @@ ...@@ -12,21 +12,26 @@
#include "AbstractSensor.h" #include "AbstractSensor.h"
class Point; class Point;
class FireMeshStorage;
class SmokeSensor : public AbstractSensor class SmokeSensor : public AbstractSensor
{ {
public: public:
SmokeSensor(const Building * b) : AbstractSensor(b) { } SmokeSensor(const Building * b, const&filepath, const&updateintervall, const&finalTime);
virtual ~SmokeSensor(); virtual ~SmokeSensor();
std::string GetName() const; std::string GetName() const;
void execute(const Pedestrian *, CognitiveMap *) const; void execute(const Pedestrian *, CognitiveMap *) const;
void set_FMStorage(const &fmStorage);
const FireMeshStorage* get_FMStorage();
private: private:
std::shared_ptr<FireMeshStorage> _FMStorage;
}; };
#endif // SMOKESENSOR_H #endif // SMOKESENSOR_H
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