Commit 4c012102 authored by Ulrich Kemloh's avatar Ulrich Kemloh

The code is still broken. But this commit is necessary.

parent c447f94e
......@@ -117,6 +117,12 @@ file(
)
#Target
add_executable(
rebuild.exe
${source_files}
)
#find the correct OpenMP flag
FIND_PACKAGE(OpenMP)
......@@ -127,17 +133,20 @@ if(OPENMP_FOUND)
endif()
#find and add the CGAL library
#fixme: complete this section
FIND_PACKAGE(CGAL)
if(CGAL_FOUND)
add_definitions(-D_CGAL=1)
#include (${CGAL_USE_FILE})
#INCLUDE_DIRECTORIES(${CGAL_CORE_INCLUDE_DIR})
#add_definitions(-D_CGAL=1)
#target_link_libraries (rebuild.exe ${CGAL_CORE_LIBRARY})
#message (SEND_ERROR "${CGAL_FOUND}")
#message (FATAL_ERROR "${CGAL_CORE_INCLUDE_DIR}")
#message (SEND_ERROR " Erreur: ${CGAL_FOUND}")
#message (SEND_ERROR " Erreur: ${CGAL_USE_FILE}")
endif()
add_executable(
rebuild.exe
${source_files}
)
if(WIN32)
target_link_libraries (rebuild.exe wsock32)
endif()
......@@ -146,4 +155,4 @@ endif()
# POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}
# COMMAND ${CMAKE_COMMAND} -E copy ${EXAMPLE_BIN_NAME} ${PROJECT_BINARY_DIR}/.
#)
\ No newline at end of file
#)
......@@ -27,6 +27,7 @@
#include "IODispatcher.h"
#include "../pedestrian/Pedestrian.h"
#include "../routing/NavMesh.h"
#include <cmath>
......@@ -90,8 +91,7 @@ void IODispatcher::Write(string str) {
}
;
void IODispatcher::WriteHeader(int nPeds, int fps, Building* building, int seed,
int szenarioID) {
void IODispatcher::WriteHeader(int nPeds, double fps, Building* building, int seed ) {
nPeds = building->GetNumberOfPedestrians();
string tmp;
......@@ -117,6 +117,7 @@ void IODispatcher::WriteGeometry(Building* building) {
bool plotHlines = true;
bool plotCrossings = true;
bool plotTransitions = true;
bool plotPlayingField=false;
vector<string> rooms_to_plot;
//Promenade
......@@ -212,6 +213,32 @@ void IODispatcher::WriteGeometry(Building* building) {
}
}
if(plotPlayingField){
//add the playing area
double width=3282;
double length=5668;
char tmp[100];
geometry.append("\t\t<wall>\n");
sprintf(tmp, "\t\t\t<point xPos=\"%.2f\" yPos=\"%.2f\"/>\n",-length,width);
geometry.append(tmp);
sprintf(tmp, "\t\t\t<point xPos=\"%.2f\" yPos=\"%.2f\"/>\n",-length,-width);
geometry.append(tmp);
sprintf(tmp, "\t\t\t<point xPos=\"%.2f\" yPos=\"%.2f\"/>\n",length,-width);
geometry.append(tmp);
sprintf(tmp, "\t\t\t<point xPos=\"%.2f\" yPos=\"%.2f\"/>\n",length,width);
geometry.append(tmp);
sprintf(tmp, "\t\t\t<point xPos=\"%.2f\" yPos=\"%.2f\"/>\n",-length,width);
geometry.append(tmp);
geometry.append("\t\t</wall>\n");
geometry.append("\t\t<wall>\n");
sprintf(tmp, "\t\t\t<point xPos=\"%.2f\" yPos=\"%.2f\"/>\n",0.0,width);
geometry.append(tmp);
sprintf(tmp, "\t\t\t<point xPos=\"%.2f\" yPos=\"%.2f\"/>\n",0.0,-width);
geometry.append(tmp);
geometry.append("\t\t</wall>\n");
}
geometry.append("\t</geometry>\n");
Write(geometry);
}
......@@ -533,12 +560,16 @@ void IODispatcher::WriteFooter() {
Write("</trajectoriesDataset>\n");
}
/**
* FLAT format implementation
*/
TrajectoriesFLAT::TrajectoriesFLAT() :
IODispatcher() {
}
void TrajectoriesFLAT::WriteHeader(int nPeds, int fps, Building* building) {
void TrajectoriesFLAT::WriteHeader(int nPeds, double fps, Building* building, int seed) {
}
......@@ -569,3 +600,69 @@ void TrajectoriesFLAT::WriteFooter() {
}
/**
* VTK Implementation of the geometry and trajectories
*/
TrajectoriesVTK::TrajectoriesVTK() {
}
void TrajectoriesVTK::WriteHeader(int nPeds, double fps, Building* building, int seed) {
Write("# vtk DataFile Version 4.0");
Write(building->GetCaption());
Write("ASCII");
Write("");
}
void TrajectoriesVTK::WriteGeometry(Building* building) {
stringstream tmp;
NavMesh* nv= new NavMesh(building);
nv->BuildNavMesh();
//nv->WriteToFile("../pedunc/examples/stadium/arena.nav");
Write("DATASET UNSTRUCTURED_GRID");
//writing the vertices
const vector<NavMesh::JVertex*>& vertices= nv->GetVertices() ;
tmp<<"POINTS "<<vertices.size()<<" FLOAT"<<endl;
for (unsigned int v=0;v<vertices.size();v++){
tmp<<vertices[v]->pPos.GetX()<<" " <<vertices[v]->pPos.GetY() <<" 0.0"<<endl;
}
Write(tmp.str());
tmp.str(std::string());
//writing the cells data
const vector<NavMesh::JNode*>& cells= nv->GetNodes();
int nComponents=cells.size();
stringstream tmp1;
for (unsigned int n=0;n<cells.size();n++){
int hSize=cells[n]->pHull.size();
tmp1<<hSize<<"";
for(unsigned int i=0;i<cells[n]->pHull.size();i++){
tmp1<<" "<<cells[n]->pHull[i].id;
}
tmp1<<endl;
nComponents+= hSize;
}
tmp<<"CELLS "<<cells.size()<<" "<<nComponents<<endl;
tmp<<tmp1.str();
Write(tmp.str());
tmp.str(std::string());
// writing the cell type
tmp<<"CELL_TYPES "<<cells.size()<<endl;
for (unsigned int n=0;n<cells.size();n++){
tmp<<"9"<<endl;
}
Write(tmp.str());
}
void TrajectoriesVTK::WriteFrame(int frameNr, Building* building) {
}
void TrajectoriesVTK::WriteFooter() {
}
......@@ -51,7 +51,7 @@ public:
void AddIO(OutputHandler* ioh);
const std::vector<OutputHandler*>& GetIOHandlers();
void Write(std::string str);
virtual void WriteHeader(int nPeds, int fps, Building* building, int seed=0, int szenarioID=0);
virtual void WriteHeader(int nPeds, double fps, Building* building, int seed);
virtual void WriteGeometry(Building* building);
virtual void WriteFrame(int frameNr, Building* building);
virtual void WriteFooter();
......@@ -79,12 +79,24 @@ public:
class TrajectoriesFLAT:public IODispatcher {
public:
TrajectoriesFLAT();
virtual ~TrajectoriesFLAT(){};
virtual void WriteHeader(int nPeds, int fps, Building* building);
virtual void WriteHeader(int nPeds, double fps, Building* building, int seed);
virtual void WriteGeometry(Building* building);
virtual void WriteFrame(int frameNr, Building* building);
virtual void WriteFooter();
};
class TrajectoriesVTK:public IODispatcher {
public:
TrajectoriesVTK();
virtual ~TrajectoriesVTK(){};
virtual void WriteHeader(int nPeds, double fps, Building* building, int seed);
virtual void WriteGeometry(Building* building);
virtual void WriteFrame(int frameNr, Building* building);
virtual void WriteFooter();
......
......@@ -10,12 +10,12 @@ $(DIRS):
release:
( cd build/release && cmake -DCMAKE_BUILD_TYPE=release ../.. && $(MAKE) --no-print-directory )
( cd build/release && cmake -DCMAKE_BUILD_TYPE=Release ../.. && $(MAKE) --no-print-directory )
# ctags -R --language-force=c++ *.*
# ctags -eR --language-force=c++ *.*
debug:
( cd build/debug && cmake -DCMAKE_BUILD_TYPE=debug ../.. && $(MAKE) --no-print-directory )
( cd build/debug && cmake -DCMAKE_BUILD_TYPE=Debug ../.. && $(MAKE) --no-print-directory )
# ctags -R --language-force=c++ *.*
# ctags -eR --language-force=c++ *.*
......
......@@ -33,6 +33,7 @@ using namespace std;
Simulation::Simulation() {
_nPeds = 0; // number of pedestrians, Default 10
_tmax = 0;
_seed=8091983;
_deltaT = 0;
_building = NULL;
_distribution = NULL;
......@@ -167,7 +168,12 @@ void Simulation::InitArgs(ArgumentParser* args) {
case FORMAT_VTK:
{
Log->Write("INFO: \tFormat vtk not yet supported\n");
exit(0);
OutputHandler* file = new FileHandler((args->GetTrajectoriesFile() +".vtk").c_str());
if(_iod) delete _iod;
_iod = new TrajectoriesVTK();
_iod->AddIO(file);
//exit(0);
break;
}
}
......@@ -351,6 +357,9 @@ void Simulation::InitArgs(ArgumentParser* args) {
}
//pBuilding->WriteToErrorLog();
//get the seed
_seed=args->GetSeed();
}
......@@ -364,7 +373,7 @@ int Simulation::RunSimulation() {
// writing the header
_iod->WriteHeader(_nPeds, _fps, _building);
_iod->WriteHeader(_nPeds, _fps, _building,_seed);
_iod->WriteGeometry(_building);
_iod->WriteFrame(0,_building);
......
......@@ -57,6 +57,8 @@ private:
double _deltaT;
/// frame rate for the trajectories
double _fps;
///seed using for the random number generator
unsigned int _seed;
/// building object
Building* _building;
///initial distribution of the pedestrians
......@@ -70,6 +72,7 @@ private:
/// writing the trajectories to file
IODispatcher* _iod;
public:
Simulation();
virtual ~Simulation();
......
......@@ -362,7 +362,7 @@ void ArgumentParser::ParseArgs(int argc, char **argv) {
}
break;
}
case 'R':
case 'R': // TODO: are these options still correct ?
{
int r = atoi(optarg);
switch(r){
......@@ -375,6 +375,12 @@ void ArgumentParser::ParseArgs(int argc, char **argv) {
case 3:
pRoutingStrategies.push_back(make_pair (3,ROUTING_QUICKEST));
break;
case 4:
pRoutingStrategies.push_back(make_pair (4,ROUTING_DYNAMIC));
break;
case 5:
pRoutingStrategies.push_back(make_pair (5,ROUTING_DUMMY));
break;
default:
Log->Write("ERROR: \tin ArgumentParser::ParseArgs() "
"wrong value for routing strategy!!!\n");
......@@ -538,7 +544,7 @@ void ArgumentParser::ParseIniFile(string inifile){
if(!xPara.getChildNode("exitCrossingStrategy").isEmpty()){
string exitStrategy=xPara.getChildNode("exitCrossingStrategy").getText();
pExitStrategy=xmltof(exitStrategy.c_str(),pExitStrategy);
Log->Write("INFO: \exitCrossingStrategy <"+string(exitStrategy)+">");
Log->Write("INFO: \texitCrossingStrategy <"+string(exitStrategy)+">");
}
//linked-cells
......
......@@ -980,7 +980,7 @@ void Building::LoadRoutingInfo(string filename) {
}
_routingEngine->AddTrip(vTrip);
}
Log->Write("INFO:\t done with loading extra routing information");
Log->Write("INFO:\tdone with loading extra routing information");
}
void Building::LoadTrafficInfo(string filename) {
......@@ -989,7 +989,7 @@ void Building::LoadTrafficInfo(string filename) {
if (filename == "") {
Log->Write("INFO:\t No file supplied !");
Log->Write("INFO:\t done with loading traffic info file");
Log->Write("INFO:\tdone with loading traffic info file");
return;
}
......
......@@ -12,13 +12,13 @@
<!-- traffic information: e.g closed doors -->
<traffic>inputfiles/traffic.xml</traffic>
<!-- trajectories file and format -->
<trajectories format="xml-plain" fps="8">
<trajectories format="xml" fps="8">
<file location="outputfiles/trajectories.xml"/>
<!--<socket hostname="127.0.0.1" port="8989"/> -->
</trajectories>
<!-- where to store the logs
<!-- where to store the logs -->
<logfile>outputfiles/log.txt</logfile>
-->
<!-- These parameters may be overwritten -->
<parameters>
......
......@@ -16,7 +16,7 @@
<routers>
<router id="1" method="local_shortest"/>
<router id="2" method="global_shortest"/>
<!--<router id="3" method="quickest"/>-->
<router id="3" method="quickest"/>
<router id="4" method="dummy"/>
</routers>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -18,14 +18,14 @@ DummyRouter::~DummyRouter() {
}
int DummyRouter::FindExit(Pedestrian* p) {
p->SetExitIndex(0);
p->SetExitIndex(1);
//p->SetExitLine(_building->getGetCrossing(0));
return 1;
}
void DummyRouter::Init(Building* b) {
_building=b;
Log->Write("ERROR: Do not use this router !!");
Log->Write("ERROR: \tdo not use this <<Dummy>> router !!");
//dump all navigation lines
......
......@@ -1696,8 +1696,8 @@ void NavMesh::WriteBehavior() {
}
file<< "\t\t</GoalSet>"<<endl;
}
//write the goal set promenade
//write the goal set promenade
file<< "\t\t<Behavior class=\"1\">"<<endl;
file<< "\t\t\t<Property name=\"prefSpeed\" type=\"float\" dist=\"c\" value=\"1.3\" />"<<endl;
......@@ -1812,7 +1812,7 @@ void NavMesh::WriteStartPositions() {
int room_id=room->GetID();
vector<Point > freePosRoom = availablePos[room_id];
int nAgentsPerRoom=50; // the number of agents to distribute
int nAgentsPerRoom=10; // the number of agents to distribute
for (int a=0;a<nAgentsPerRoom;a++){
int index = rand() % freePosRoom.size();
file<< "\t\t<Agent p_x=\""<<freePosRoom[index]._x<<" \"p_y=\""<<freePosRoom[index]._y<<"\"/>"<<endl;
......@@ -2305,3 +2305,19 @@ void NavMesh::Test(){
}
cout<<"Test passed !"<<endl;
}
const std::vector<NavMesh::JEdge*>& NavMesh::GetEdges() const {
return pEdges;
}
const std::vector<NavMesh::JNode*>& NavMesh::GetNodes() const {
return pNodes;
}
const std::vector<NavMesh::JObstacle*>& NavMesh::GetObst() const {
return pObst;
}
const std::vector<NavMesh::JVertex*>& NavMesh::GetVertices() const {
return pVertices;
}
......@@ -40,6 +40,7 @@ class NavMesh {
bool operator> (const JVertex& v) const{
return v.pPos._x>pPos._x;
}
};
class JNode {
......@@ -173,24 +174,6 @@ class NavMesh {
}
}
public:
NavMesh(Building* b);
virtual ~NavMesh();
void BuildNavMesh();
void WriteToFile(std::string fileName);
void WriteToFileTraVisTo(std::string fileName);
void WriteToFileTraVisTo(std::string fileName, const std::vector<Point>& points);
void WriteToFileTraVisTo(std::string fileName, JNode* node);
int AddVertex(JVertex* v);
int AddEdge(JEdge* e);
int AddObst(JObstacle* o);
int AddNode(JNode* n);
///return the JVertex with the corresponding point
JVertex* GetVertex(const Point& p);
void DumpNode(int id);
void DumpEdge(int id);
void DumpObstacle(int id);
private:
std::vector<JVertex*> pVertices;
......@@ -224,7 +207,27 @@ private:
/// Return the id of the JObstacle
int IsObstacle(Point& p1, Point& p2);
public:
NavMesh(Building* b);
virtual ~NavMesh();
void BuildNavMesh();
void WriteToFile(std::string fileName);
void WriteToFileTraVisTo(std::string fileName);
void WriteToFileTraVisTo(std::string fileName, const std::vector<Point>& points);
void WriteToFileTraVisTo(std::string fileName, JNode* node);
int AddVertex(JVertex* v);
int AddEdge(JEdge* e);
int AddObst(JObstacle* o);
int AddNode(JNode* n);
///return the JVertex with the corresponding point
JVertex* GetVertex(const Point& p);
void DumpNode(int id);
void DumpEdge(int id);
void DumpObstacle(int id);
/// Write the simulation scenario for the
/// pedunc simulator
void WriteScenario();
......@@ -238,6 +241,14 @@ public:
void Test();
const std::vector<NavMesh::JEdge*>& GetEdges() const;
const std::vector<NavMesh::JNode*>& GetNodes() const;
const std::vector<NavMesh::JObstacle*>& GetObst() const;
const std::vector<NavMesh::JVertex*>& GetVertices() const;
// need to access vertices and nodes
friend class TrajectoriesVTK;
};
#endif /* NAVMESH_H_ */
......@@ -624,13 +624,14 @@ void QuickestPathRouter::Init(Building* building){
Log->Write("INFO:\tInit Quickest Path Router Engine");
GlobalRouter::Init(building);
// pBuilding=building;
ReduceGraph();
//TODO: reduce graph is missbehaving
//ReduceGraph();
//ExpandGraph();
// DumpAccessPoints(981);
// exit(0);
vector<string> rooms;
//rooms.push_back("050");
rooms.push_back("010");
//rooms.push_back("010");
//rooms.push_back("020");
//rooms.push_back("030");
//rooms.push_back("040");
......@@ -647,7 +648,7 @@ void QuickestPathRouter::Init(Building* building){
//rooms.push_back("150");
//rooms.push_back("outside");
//WriteGraphGV("routing_graph.gv",FINAL_DEST_ROOM_040,rooms);
WriteGraphGV("routing_graph.gv",FINAL_DEST_OUT,rooms);
//WriteGraphGV("routing_graph.gv",FINAL_DEST_OUT,rooms);
//DumpAccessPoints(1185);
//DumpAccessPoints(1186);
//DumpAccessPoints(1188);
......
make
#./rebuild.exe -n ./Inputfiles/start.dat --geometry ./Inputfiles/Raum60.jul --exitstrategy 1 --dt 0.001 --linkedcells --routing 2
#./rebuild.exe --inifile --exitstrategy 3 --routing 3 --travisto 1 --linkedcells --log 2 --fps 8
./rebuild.exe --inifile=./samples/ini-arena.xml
#./rebuild.exe --inifile=./samples/ini-arena.xml
#./rebuild.exe --inifile=ini-unc.xml -e 3
#./rebuild.exe --inifile=ini-Headon.xml
#./rebuild.exe --inifile=ini.xml
./rebuild.exe --inifile=ini.xml
#./rebuild.exe --inifile=ini-Bottleneck.xml -e 3 --fps=16
#./rebuild.exe --inifile=ini-Perpen.xml
#./rebuild.exe --inifile=ini-GSP.xml
......
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