Commit ccbaa466 authored by Erik Andresen's avatar Erik Andresen

first approaches to implement dynamic fireMesh

parent b0f80961
......@@ -220,6 +220,7 @@ set ( source_files
routing/cognitive_map/sensor/SmokeSensor.cpp
routing/cognitive_map/fire_mesh/FireMesh.cpp
routing/cognitive_map/fire_mesh/Knot.cpp
routing/cognitive_map/fire_mesh/FireMeshStorage.cpp
poly2tri/common/shapes.cpp
poly2tri/sweep/sweep_context.cpp
......@@ -259,6 +260,9 @@ set ( header_files
routing/cognitive_map/sensor/JamSensor.h
routing/cognitive_map/sensor/LastDestinationsSensor.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/PedDistributor.h
......
......@@ -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);
//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
return _crossing;
}
const FireMesh &GraphEdge::GetFireMesh() const
{
return _fireMesh;
}
//const FireMesh *GraphEdge::GetFireMesh() const
//{
// return _fireMesh;
//}
void GraphEdge::SetUpFireMesh()
{
//void GraphEdge::SetUpFireMesh()
//{
//TODO: read this prefix from the ini file
// std::string filename = "D:/workspace/JuPedSim/jpscore/inputfiles/cognitive_map";
std::string prefix = "D:/workspace/JPS/JPScore/inputfiles/cognitive_map";
// //TODO: read this prefix from the ini file
// // std::string filename = "D:/workspace/JuPedSim/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())
+ "_Y_" + std::to_string(_crossing->GetCentre().GetY()) + ".csv";
_fireMesh.SetKnotValuesFromFile(filename);
}
// std::string filename = prefix + "/Door_X_" + std::to_string(_crossing->GetCentre().GetX())
// + "_Y_" + std::to_string(_crossing->GetCentre().GetY()) + ".csv";
// _fireMesh.SetKnotValuesFromFile(filename);
//}
double GraphEdge::GetSmokeFactor(const Point &pointPed) const
{ //std::cout << pointPed.GetX() << " " << pointPed.GetY() << std::endl;
if (_fireMesh.statusMesh()==true)
return _fireMesh.GetKnotValue(pointPed.GetX(),pointPed.GetY());
else
return 1.0;
//double GraphEdge::GetSmokeFactor(const Point &pointPed) const
//{ //std::cout << pointPed.GetX() << " " << pointPed.GetY() << std::endl;
// if (_fireMesh.statusMesh()==true)
// return _fireMesh.GetKnotValue(pointPed.GetX(),pointPed.GetY());
// else
// return 1.0;
}
//}
bool GraphEdge::IsExit() const
{
......
......@@ -63,10 +63,10 @@ public:
const Crossing * GetCrossing() const;
///FireMesh
const FireMesh& GetFireMesh() const;
void SetUpFireMesh();
//const FireMesh * GetFireMesh() const;
//void SetUpFireMesh();
double GetSmokeFactor(const Point &pointPed) const;
//double GetSmokeFactor(const Point &pointPed) const;
double GetApproximateDistance() const;
double GetApproximateDistance(const Point &) const;
void SetFactor(double factor, std::string name);
......@@ -80,7 +80,7 @@ private:
const GraphVertex * const _src;
const GraphVertex * const _dest;
const Crossing * const _crossing;
FireMesh _fireMesh;
//FireMesh * _fireMesh;
/**
* Factor Bag
......
......@@ -12,8 +12,15 @@
#include "../../../pedestrian/Pedestrian.h"
#include "../../../geometry/SubRoom.h"
#include "../fire_mesh/FireMesh.h"
#include "../fire_mesh/FireMeshStorage.h"
#include <set>
SmokeSensor::SmokeSensor(const Building *b, const &filepath, const &updateintervall, const &finalTime) : AbstractSensor(b)
{
_FMStorage= new FireMeshStorage(b,filepath,updateintervall,finalTime);
}
SmokeSensor::~SmokeSensor()
{
}
......@@ -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 @@
#include "AbstractSensor.h"
class Point;
class FireMeshStorage;
class SmokeSensor : public AbstractSensor
{
public:
SmokeSensor(const Building * b) : AbstractSensor(b) { }
SmokeSensor(const Building * b, const&filepath, const&updateintervall, const&finalTime);
virtual ~SmokeSensor();
std::string GetName() const;
void execute(const Pedestrian *, CognitiveMap *) const;
void set_FMStorage(const &fmStorage);
const FireMeshStorage* get_FMStorage();
private:
std::shared_ptr<FireMeshStorage> _FMStorage;
};
#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