Commit b2c5ba31 authored by Ulrich Kemloh's avatar Ulrich Kemloh

Cleaning, documenting, refactoring

Comments are now using the doxygen format.
german-->english
parent 07f7d253
......@@ -734,7 +734,7 @@ EXCLUDE_SYMLINKS = NO
# against the file with absolute path, so to exclude all test directories
# for example use the pattern */test/*
EXCLUDE_PATTERNS =
EXCLUDE_PATTERNS = */testings/* */scripts/* */samples/* */inputfiles/* */outputfiles/* */Debug/* */Release/* */build/* */MCD/*
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
......
......@@ -531,20 +531,20 @@ void IODispatcher::WriteFooter() {
Write("</trajectoriesDataset>\n");
}
Trajectories::Trajectories() :
TrajectoriesFLAT::TrajectoriesFLAT() :
IODispatcher() {
}
void Trajectories::WriteHeader(int nPeds, int fps, Building* building) {
void TrajectoriesFLAT::WriteHeader(int nPeds, int fps, Building* building) {
}
void Trajectories::WriteGeometry(Building* building) {
void TrajectoriesFLAT::WriteGeometry(Building* building) {
}
void Trajectories::WriteFrame(int frameNr, Building* building) {
void TrajectoriesFLAT::WriteFrame(int frameNr, Building* building) {
char tmp[CLENGTH] = "";
for (int roomindex = 0; roomindex < building->GetAnzRooms(); roomindex++) {
......@@ -563,7 +563,7 @@ void Trajectories::WriteFrame(int frameNr, Building* building) {
}
}
void Trajectories::WriteFooter() {
void TrajectoriesFLAT::WriteFooter() {
}
......@@ -75,12 +75,12 @@ public:
};
class Trajectories:public IODispatcher {
class TrajectoriesFLAT:public IODispatcher {
public:
Trajectories();
virtual ~Trajectories(){};
TrajectoriesFLAT();
virtual ~TrajectoriesFLAT(){};
virtual void WriteHeader(int nPeds, int fps, Building* building);
virtual void WriteGeometry(Building* building);
......
This diff is collapsed.
/*Simulation.h:
The Simulation class represents a simulation of pedestrians
based on a certain model in a specific scenario. A simulation is defined by
various parameters and functions.
Copyright (C) <2009-2010> <Jonas Mehlich and Mohcine Chraibi>
This file is part of OpenPedSim.
OpenPedSim is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
OpenPedSim is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
/**
* @file Simulation.h
* @date Created on: Dec 15, 2010
* Copyright (C) <2009-2011>
*
* @section LICENSE
* This file is part of JuPedSim.
*
* JuPedSim is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* JuPedSim is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
*
* \section description
* The Simulation class represents a simulation of pedestrians
* based on a certain model in a specific scenario. A simulation is defined by
* various parameters and functions.
*
*/
#ifndef SIMULATION_H_
......@@ -43,36 +49,67 @@ extern OutputHandler* Log;
class Simulation {
private:
int pActionPt; // on or off
int pNPeds; // number of pedestrians
double pTmax; // Maximale Simulationszeit
double pDt; // Zeitschritt
double fps; // framerate
Building* pBuilding; // Geometrie mit Rooms, SubRooms und Wänden
PedDistributor* pDistribution; // verteilt die Fußgänger zu Beginn der Simulation
DirectionStrategy* pDirection; // gibt die Richtungswahl zum Ziel an
ForceModel* pModel; // das verwendete Kraftmodell (im Moment nur GCFM)
ODESolver* pSolver; // Löser für die ODE
IODispatcher* iod;
Trajectories* pTrajectories;
///Number of pedestrians in the simulation
int _nPeds;
///Maximum simulation time
double _tmax;
/// time step
double _deltaT;
/// frame rate for the trajectories
double _fps;
/// building object
Building* _building;
///initial distribution of the pedestrians
PedDistributor* _distribution;
/// door crossing strategy for the pedestrians
DirectionStrategy* _direction;
/// Force model to use
ForceModel* _model;
/// differential equation solver
ODESolver* _solver;
/// writing the trajectories to file
IODispatcher* _iod;
public:
// Konstruktor
Simulation();
virtual ~Simulation();
// Setter-Funktionen
int SetNPeds(int i);
// Getter-Funktionen
int GetNPeds() const;
/**
* Initialize the number of agents in the simulation
*/
void SetPedsNumber(int i);
/**
* Initialize the number of agents in the simulation
*/
int GetPedsNumber() const;
/**
* Returns the number of agents when running on a distributed system (MPI)
* NOT IMPLEMENTED
*/
int GetNPedsGlobal() const;
/**
* @return the building object containing all geometry elements
*/
Building* GetBuilding() const;
// Sonstige-Funktionen
/**
* Read parameters from the argument parser class.
*/
void InitArgs(ArgumentParser *args);
int InitSimulation();
/**
*
* @return the total simulated/evacuation time
*/
int RunSimulation();
void Update(); // update the complete system
void DistributeDestinations(); //assign the pedestrians their final destinations
void InitRoutineClearing(); // set some parameters specific to routine clearing
/**
* Update the pedestrians states: positions, velocity, route
*/
void Update();
};
......
......@@ -145,10 +145,14 @@ public:
const FileFormat& GetFileFormat() const;
/**
* Parse the commands passed to the command line
* specially looks for the initialization file
*/
void ParseArgs(int argc, char **argv);
/**
* parse the initialization file
* Parse the initialization file
* @param inifile
*/
void ParseIniFile(string inifile);
......
......@@ -37,7 +37,7 @@
// zur Versionskontrolle beim Geometrieformat
#define VERSION 0.40
#define JPS_VERSION "1.1"
#define JPS_VERSION "0.4"
// Länge von char vectoren zur Ausgabe
#define CLENGTH 1000
......
......@@ -77,7 +77,7 @@ int main(int argc, char **argv) {
//some output
double execTime = difftime(endtime, starttime);
char tmp[CLENGTH];
sprintf(tmp, "\nPedestrians [%d] threads [%d]", sim.GetNPeds(),
sprintf(tmp, "\nPedestrians [%d] threads [%d]", sim.GetPedsNumber(),
args->GetMaxOpenMPThreads());
Log->Write(tmp);
sprintf(tmp, "\nExec Time [s] : %.2f", execTime);
......
This diff is collapsed.
......@@ -6,20 +6,20 @@
* Copyright (C) <2009-2010>
*
* @section LICENSE
* This file is part of OpenPedSim.
* This file is part of JuPedSim.
*
* OpenPedSim is free software: you can redistribute it and/or modify
* JuPedSim is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* OpenPedSim is distributed in the hope that it will be useful,
* JuPedSim is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>.
* along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
*
* @section DESCRIPTION
*
......@@ -34,20 +34,20 @@ using namespace std;
AccessPoint::AccessPoint(int id, double center[2],double radius) {
pID=id;
pCenter[0]=center[0];
pCenter[1]=center[1];
pRadius=radius;
pFinalDestination=false;
pRoom1ID=-1;
pRoom2ID=-1;
pConnectingAPs.clear();
pMapDestToDist.clear();
_id=id;
_center[0]=center[0];
_center[1]=center[1];
_radius=radius;
_finalDestination=false;
_room1ID=-1;
_room2ID=-1;
_connectingAPs.clear();
_mapDestToDist.clear();
pCentre=Point(center[0],center[1]);
pTransitPedestrians = vector<Pedestrian*>();
pConnectingAPs = vector<AccessPoint*>();
pIsClosed=0;
pNavLine=NULL;
_transitPedestrians = vector<Pedestrian*>();
_connectingAPs = vector<AccessPoint*>();
_isClosed=0;
_navLine=NULL;
}
AccessPoint::~AccessPoint() {
......@@ -56,24 +56,24 @@ AccessPoint::~AccessPoint() {
int AccessPoint::GetID()
{
return pID;
return _id;
}
int AccessPoint::IsClosed(){
return pIsClosed;
return _isClosed;
}
void AccessPoint::SetClosed(int isClosed){
pIsClosed=isClosed;
_isClosed=isClosed;
}
void AccessPoint::setFinalDestination(bool isFinal)
{
pFinalDestination=isFinal;
_finalDestination=isFinal;
}
bool AccessPoint::isFinalDestination()
{
return pFinalDestination;
return _finalDestination;
}
const Point& AccessPoint::GetCentre() const{
......@@ -82,23 +82,23 @@ const Point& AccessPoint::GetCentre() const{
void AccessPoint::AddIntermediateDest(int final, int inter){
pMapDestToAp[final]=inter;
_mapDestToAp[final]=inter;
}
void AccessPoint::AddFinalDestination(int UID, double distance){
pMapDestToDist[UID]=distance;
_mapDestToDist[UID]=distance;
}
double AccessPoint::GetDistanceTo(int UID){
//this is probably a final destination
if(pMapDestToDist.count(UID)==0){
if(_mapDestToDist.count(UID)==0){
cout<<"No route to host ["<< UID<<" ]"<<endl;
Dump();
//TODO:FIXME: this should not happened
exit(EXIT_FAILURE);
//return -1;
}
return pMapDestToDist[UID];
return _mapDestToDist[UID];
}
double AccessPoint::GetDistanceTo(AccessPoint* ap){
......@@ -107,25 +107,24 @@ double AccessPoint::GetDistanceTo(AccessPoint* ap){
void AccessPoint::AddConnectingAP(AccessPoint* ap){
//only add of not already inside
for(unsigned int p=0;p<pConnectingAPs.size();p++){
if(pConnectingAPs[p]->GetID()==ap->GetID()) return;
for(unsigned int p=0;p<_connectingAPs.size();p++){
if(_connectingAPs[p]->GetID()==ap->GetID()) return;
}
pConnectingAPs.push_back(ap);
_connectingAPs.push_back(ap);
}
int AccessPoint::GetNextApTo(int UID){
//this is probably a final destination
if(pMapDestToAp.count(UID)==0){
if(_mapDestToAp.count(UID)==0){
cout<<"No route to host ["<< UID<<" ]"<<endl;
Dump();
return -1;
}
return pMapDestToAp[UID];
return _mapDestToAp[UID];
}
int AccessPoint::GetNearestTransitAPTO(int UID){
const vector <AccessPoint*>& possibleDest= pNavigationGraphTo[UID];
const vector <AccessPoint*>& possibleDest= _navigationGraphTo[UID];
if(possibleDest.size()==0){
return -1;
......@@ -147,18 +146,18 @@ int AccessPoint::GetNearestTransitAPTO(int UID){
}
void AccessPoint::setConnectingRooms(int r1, int r2){
pRoom1ID=r1;
pRoom2ID=r2;
_room1ID=r1;
_room2ID=r2;
}
double AccessPoint::distanceTo(double x, double y){
return sqrt((x-pCenter[0])*(x-pCenter[0]) + (y-pCenter[1])*(y-pCenter[1]));
return sqrt((x-_center[0])*(x-_center[0]) + (y-_center[1])*(y-_center[1]));
}
bool AccessPoint::isInRange(int roomID){
if((roomID!=pRoom1ID) && (roomID!=pRoom2ID)){
if((roomID!=_room1ID) && (roomID!=_room2ID)){
return false;
}
return true;
......@@ -166,11 +165,11 @@ bool AccessPoint::isInRange(int roomID){
bool AccessPoint::isInRange(double xPed, double yPed, int roomID){
if((roomID!=pRoom1ID)&& (roomID!=pRoom2ID)){
if((roomID!=_room1ID)&& (roomID!=_room2ID)){
return false;
}
if (((xPed - pCenter[0]) * (xPed - pCenter[0]) + (yPed - pCenter[1]) * (yPed
- pCenter[1])) <= pRadius * pRadius)
if (((xPed - _center[0]) * (xPed - _center[0]) + (yPed - _center[1]) * (yPed
- _center[1])) <= _radius * _radius)
return true;
return false;
......@@ -178,91 +177,91 @@ bool AccessPoint::isInRange(double xPed, double yPed, int roomID){
void AccessPoint::DeleteTransitPed(Pedestrian* ped){
vector<Pedestrian*>::iterator it;
it = find (pTransitPedestrians.begin(), pTransitPedestrians.end(), ped);
if(it==pTransitPedestrians.end()){
it = find (_transitPedestrians.begin(), _transitPedestrians.end(), ped);
if(it==_transitPedestrians.end()){
cout<<" Ped not found"<<endl;
}else{
pTransitPedestrians.erase(it);
_transitPedestrians.erase(it);
}
}
void AccessPoint::AddTransitPed(Pedestrian* ped){
pTransitPedestrians.push_back(ped);
_transitPedestrians.push_back(ped);
}
void AccessPoint::SetNavLine(NavLine* line) {
pNavLine=line;
_navLine=line;
}
NavLine* AccessPoint::GetNavLine() const {
return pNavLine;
return _navLine;
}
const vector<Pedestrian*>& AccessPoint::GetAllTransitPed() const{
return pTransitPedestrians;
return _transitPedestrians;
}
const vector <AccessPoint*>& AccessPoint::GetConnectingAPs(){
return pConnectingAPs;
return _connectingAPs;
}
void AccessPoint::RemoveConnectingAP(AccessPoint* ap){
vector<AccessPoint*>::iterator it;
it = find (pConnectingAPs.begin(), pConnectingAPs.end(), ap);
if(it==pConnectingAPs.end()){
it = find (_connectingAPs.begin(), _connectingAPs.end(), ap);
if(it==_connectingAPs.end()){
cout<<" there is no connection to AP: "<< ap->GetID()<<endl;
}else{
pConnectingAPs.erase(it);
_connectingAPs.erase(it);
}
}
const vector <AccessPoint*>& AccessPoint::GetTransitAPsTo(int UID){
return pNavigationGraphTo[UID];
return _navigationGraphTo[UID];
}
void AccessPoint::AddTransitAPsTo(int UID,AccessPoint* ap){
pNavigationGraphTo[UID].push_back(ap);
_navigationGraphTo[UID].push_back(ap);
}
void AccessPoint::Reset(int UID){
pNavigationGraphTo[UID].clear();
_navigationGraphTo[UID].clear();
}
void AccessPoint::Dump(){
cout<<" -----------------------"<<endl;
cout<<" ID: " <<pID<<" centre = [ "<< pCenter[0] <<", " <<pCenter[1] <<" ]"<<endl;
cout<<" ID: " <<_id<<" centre = [ "<< _center[0] <<", " <<_center[1] <<" ]"<<endl;
cout <<" Is Final destination :"<<isFinalDestination()<<endl;
cout <<" Distance to final destination"<<endl;
for(std::map<int, double>::iterator p = pMapDestToDist.begin(); p != pMapDestToDist.end(); ++p) {
for(std::map<int, double>::iterator p = _mapDestToDist.begin(); p != _mapDestToDist.end(); ++p) {
cout<<" [ "<<p->first<<", " << p->second<<" m ]";
}
cout<<endl<<endl;
cout<<" transit to final destination:"<<endl;
for(std::map<int, int>::iterator p = pMapDestToAp.begin(); p != pMapDestToAp.end(); p++) {
for(std::map<int, int>::iterator p = _mapDestToAp.begin(); p != _mapDestToAp.end(); p++) {
cout<<" ---> [ "<<p->first<<" via " << p->second<<" ]";
}
cout<<endl<<endl;
cout<<" connected to aps : " ;
for(unsigned int p=0;p<pConnectingAPs.size();p++){
cout<<" [ "<<pConnectingAPs[p]->GetID()<<" , "<<pConnectingAPs[p]->GetDistanceTo(this)<<" m ]";
for(unsigned int p=0;p<_connectingAPs.size();p++){
cout<<" [ "<<_connectingAPs[p]->GetID()<<" , "<<_connectingAPs[p]->GetDistanceTo(this)<<" m ]";
}
cout<<endl<<endl;
cout <<" queue [ ";
for(unsigned int p=0;p<pTransitPedestrians.size();p++){
cout<<" "<<pTransitPedestrians[p]->GetPedIndex();
for(unsigned int p=0;p<_transitPedestrians.size();p++){
cout<<" "<<_transitPedestrians[p]->GetPedIndex();
}
cout<<" ]"<<endl;
cout<<endl<<" connected to rooms: "<<pRoom1ID<<" and "<<pRoom2ID<<endl;
cout<<endl<<" connected to rooms: "<<_room1ID<<" and "<<_room2ID<<endl;
cout<<endl;
}
......@@ -6,20 +6,20 @@
* Copyright (C) <2009-2010>
*
* @section LICENSE
* This file is part of OpenPedSim.
* This file is part of JuPedSim.
*
* OpenPedSim is free software: you can redistribute it and/or modify
* JuPedSim is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* OpenPedSim is distributed in the hope that it will be useful,
* JuPedSim is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenPedSim. If not, see <http://www.gnu.org/licenses/>.
* along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
*
* @section DESCRIPTION
*
......@@ -141,35 +141,33 @@ public:
private:
int pID;
double pCenter[2];
double pRadius;
bool pFinalDestination;
int pRoom1ID;
int pRoom2ID;
int _id;
double _center[2];
double _radius;
bool _finalDestination;
int _room1ID;
int _room2ID;
Point pCentre;
NavLine* pNavLine;
vector<Pedestrian*> pTransitPedestrians;
int pIsClosed;
NavLine* _navLine;
vector<Pedestrian*> _transitPedestrians;
int _isClosed;
// store the final destinations
//std::vector <int> pFinalDestination;
// stores the connecting APs
vector<AccessPoint*>pConnectingAPs;
vector<AccessPoint*>_connectingAPs;
// store part of a graph
// map a final destination to the next ap to reach it
// store the nearest AP to reach the destination
map<int, int> pMapDestToAp;
map<int, int> _mapDestToAp;
// store part of the weight matrix
// store the total distance to the destination int
map <int,double> pMapDestToDist;
map <int,double> _mapDestToDist;
//store the navigation graph
map<int,vector<AccessPoint*> > pNavigationGraphTo;
map<int,vector<AccessPoint*> > _navigationGraphTo;
};
......
......@@ -7,6 +7,8 @@
#include "DTriangulation.h"
using namespace std;
DTriangulation::DTriangulation() {
_cdt=NULL;
}
......
/*
* DTriangulation.h
/**
* @file DTriangulation
* @author Ulrich Kemloh <kemlohulrich@gmail.com>
* \date Created on: DNov 30, 2012
*
* @section LICENSE
* This file is part of JuPedSim.
*
* JuPedSim is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* JuPedSim is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
*
* @section DESCRIPTION
* Perform the Delauney triangulation of a polygon with holes.
*
*
* Created on: Nov 30, 2012
* Author: Ulrich Kemloh
*/
#ifndef DTRIANGULATION_H_
......@@ -20,26 +40,39 @@
#include "../geometry/Point.h"
#include "../poly2tri/poly2tri.h"
using std::vector;
using std::endl;
using std::cout;
class DTriangulation {
public:
DTriangulation();
virtual ~DTriangulation();
/**
* Triangulate the specified domain
* \see SetOuterPolygone
* \see AddHole
*/
void Triangulate();
/**
* @return the triangles resulting from the triangulation
*/
std::vector<p2t::Triangle*> GetTriangles(){
return _cdt->GetTriangles();
}
/**
* Set the boundaries of the domain
* @param outerConstraints
*/
void SetOuterPolygone(std::vector<Point> outerConstraints);
/**
* Add a new hole
* A domain can contains holes.
* They should fully be inside the domain.
*/
void AddHole(std::vector<Point> hole);
//templates for freing and clearing a vector of pointers
......
......@@ -22,7 +22,6 @@
* @section DESCRIPTION
*
*
*
*/
#ifndef _DIRECTIONSTRATEGY_H
......@@ -31,17 +30,16 @@
#include "../geometry/Room.h"
/************************************************************
DirectionStrategy (abstrakte Klasse)
************************************************************/
/**
*
*/
class DirectionStrategy {
public:
DirectionStrategy();
DirectionStrategy(const DirectionStrategy& orig);
virtual ~DirectionStrategy();
// virtuelle Funktionen werden in den abgeleiteten Klassen implementiert
virtual Point GetTarget(Room* room, Pedestrian* ped) const = 0;