Commit d9a7b185 authored by Mohcine Chraibi's avatar Mohcine Chraibi

Formatting Code

The goal of this commit is always to make  diffs unambiguous by
2. Untabifying all files
1. Indent all files by using 4 spaces

Please adapt you editor so that it uses NO tabs  and only 4 spaces for indenting
parent 7c16ba28
......@@ -2,6 +2,7 @@
# -DCMAKE_CXX_COMPILER:STRING=clang++ -DCMAKE_C_COMPILER:STRING=clang .
# -DCMAKE_BUILD_TYPE:STRING=Debug (default Release)
# -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON (default OFF)
# -DBUILD_TESTING=ON (default OFF)
#--------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
......@@ -16,12 +17,11 @@ set(JPSCORE_VERSION
${JPSCORE_MAJOR_VERSION}.${JPSCORE_MINOR_VERSION}.${JPSCORE_PATCH_VERSION})
message( STATUS "JPSCORE_VERSION: " ${JPSCORE_VERSION} )
# # configure_file (
# # "${CMAKE_SOURCE_DIR}/Config.h.in"
# # "${CMAKE_BINARY_DIR}/Config.h"
# # )
# #include_directories ("${CMAKE_BINARY_DIR}")
if(NOT BUILD_TESTING)
set(BUILD_TESTING OFF)
endif(NOT BUILD_TESTING)
message( STATUS "BUILD_TESTING: " ${BUILD_TESTING} )
if(NOT DEFINED PROCESSOR_COUNT)
# Unknown:
set(PROCESSOR_COUNT 0)
......@@ -33,15 +33,6 @@ if(NOT DEFINED PROCESSOR_COUNT)
list(LENGTH procs PROCESSOR_COUNT)
endif(EXISTS "${cpuinfo_file}")
# Mac:
# if(APPLE)
# find_program(cmd_sys_pro "system_profiler")
# if(cmd_sys_pro)
# execute_process(COMMAND ${cmd_sys_pro} OUTPUT_VARIABLE info)
# string(REGEX REPLACE "^.*Total Number Of Cores: ([0-9]+).*$" "\\1"
# PROCESSOR_COUNT "${info}")
# endif(cmd_sys_pro)
# endif(APPLE)
# Windows:
if(WIN32)
......@@ -50,8 +41,6 @@ if(NOT DEFINED PROCESSOR_COUNT)
endif(NOT DEFINED PROCESSOR_COUNT)
if(PROCESSOR_COUNT)
# add 1 should be magic! http://www.kitware.com/blog/home/post/63
#math(EXPR PROCESSOR_COUNT "${PROCESSOR_COUNT} + 1")
message( STATUS "PROCESSOR_COUNT: " ${PROCESSOR_COUNT})
set(CTEST_BUILD_FLAGS "-j${PROCESSOR_COUNT}")
endif(PROCESSOR_COUNT)
......@@ -104,8 +93,7 @@ FIND_PACKAGE(CGAL QUIET)
if(CGAL_FOUND)
include (${CGAL_USE_FILE})
INCLUDE_DIRECTORIES(${CGAL_CORE_INCLUDE_DIR})
add_definitions(-D_CGAL=1)
target_link_libraries (jpscore ${CGAL_CORE_LIBRARY})
add_definitions(-D_CGAL=1)
message (SEND_ERROR "${CGAL_FOUND}")
message (FATAL_ERROR "${CGAL_CORE_INCLUDE_DIR}")
message (SEND_ERROR " Erreur: ${CGAL_FOUND}")
......@@ -115,7 +103,10 @@ else(CGAL_FOUND)
endif(CGAL_FOUND)
# test files: all cpp-files in Utest
file(GLOB test_files "${CMAKE_TEST_DIR}/*.cpp")
if(BUILD_TESTING)
file(GLOB test_files "${CMAKE_TEST_DIR}/*.cpp")
endif(BUILD_TESTING)
set ( source_files
main.cpp
Simulation.cpp
......@@ -269,7 +260,7 @@ set ( header_files
add_library ( core SHARED ${source_files} )
#add_library(core OBJECT ${source_files} ${header_files})
#Target
add_executable(
jpscore main.cpp
......@@ -303,33 +294,33 @@ else(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE MATCHES Debug)
endif(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE MATCHES Debug)
# ----------------------------- cTest ------------------------------------------
enable_testing() #adds another build target, which is test for Makefile generators
include(CTest) #adding Dart support
#test if code compiles and runs default setting. Takes about 30 seconds
add_test (jpscore_compile ${CMAKE_CTEST_COMMAND}
--build-and-test "${CMAKE_SOURCE_DIR}" "${EXECUTABLE_OUTPUT_PATH}" #"${CMAKE_BINARY_DIR}"
--build-generator ${CMAKE_GENERATOR}
--build-makeprogram ${CMAKE_MAKE_PROGRAM} -j${PROCESSOR_COUNT}
--build-two-config
--build-exe-dir ${EXECUTABLE_OUTPUT_PATH} # todo wo soll der exe hin?: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
--build-project JPScore
--test-command jpscore --ini=${CMAKE_SOURCE_DIR}/inputfiles/Default/ini.xml
)
if(BUILD_TESTING)
enable_testing() #adds another build target, which is test for Makefile generators
include(CTest) #adding Dart support
#test if code compiles and runs default setting. Takes about 30 seconds
add_test (jpscore_compile ${CMAKE_CTEST_COMMAND}
--build-and-test "${CMAKE_SOURCE_DIR}" "${EXECUTABLE_OUTPUT_PATH}" #"${CMAKE_BINARY_DIR}"
--build-generator ${CMAKE_GENERATOR}
--build-makeprogram ${CMAKE_MAKE_PROGRAM} -j${PROCESSOR_COUNT}
--build-two-config
--build-exe-dir ${EXECUTABLE_OUTPUT_PATH} # todo wo soll der exe hin?: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
--build-project JPScore
--test-command jpscore --ini=${CMAKE_SOURCE_DIR}/inputfiles/Default/ini.xml
)
foreach (test_src ${test_files})
GET_FILENAME_COMPONENT(test ${test_src} NAME_WE)
add_executable( ${test} ${test_src})
target_link_libraries (${test} core)
add_test(NAME ${test} COMMAND ${test})
endforeach(test_src ${test_files})
find_package(PythonInterp)
if(PYTHONINTERP_FOUND)
message(STATUS "Found Python: " ${PYTHON_EXECUTABLE})
message(STATUS "run: " ${CMAKE_SOURCE_DIR}/Utest/testflow.py)
set (test_parameters "${CMAKE_SOURCE_DIR}")
add_test(NAME flow COMMAND "${CMAKE_TEST_DIR}/testflow.py" "${test_parameters}")
#add_test(testtime "${CMAKE_SOURCE_DIR}/Utest/run.py")
endif(PYTHONINTERP_FOUND)
foreach (test_src ${test_files})
GET_FILENAME_COMPONENT(test ${test_src} NAME_WE)
add_executable( ${test} ${test_src})
target_link_libraries (${test} core)
add_test(NAME ${test} COMMAND ${test})
endforeach(test_src ${test_files})
find_package(PythonInterp)
if(PYTHONINTERP_FOUND)
message(STATUS "Found Python: " ${PYTHON_EXECUTABLE})
message(STATUS "run: " ${CMAKE_SOURCE_DIR}/Utest/testflow.py)
set (test_parameters "${CMAKE_SOURCE_DIR}")
add_test(NAME flow COMMAND "${CMAKE_TEST_DIR}/testflow.py" "${test_parameters}")
endif(PYTHONINTERP_FOUND)
endif(BUILD_TESTING)
This diff is collapsed.
......@@ -27,7 +27,7 @@
*/
#ifndef _IODISPATCHER_H
#define _IODISPATCHER_H
#define _IODISPATCHER_H
#include "OutputHandler.h"
#include "../geometry/Building.h"
......@@ -38,35 +38,35 @@
extern OutputHandler* Log;
class IODispatcher {
private:
std::vector<OutputHandler* > pHandlers;
std::string WritePed(Pedestrian* ped);
public:
IODispatcher();
IODispatcher(const IODispatcher& orig);
virtual ~IODispatcher();
void AddIO(OutputHandler* ioh);
const std::vector<OutputHandler*>& GetIOHandlers();
void Write(const std::string& str);
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();
int AreaLevel(std::string caption);
template<typename A>
bool IsElementInVector(const std::vector<A> &vec, A& el) {
typename std::vector<A>::const_iterator it;
it = std::find (vec.begin(), vec.end(), el);
if(it==vec.end()){
return false;
}else{
return true;
}
}
private:
std::vector<OutputHandler* > pHandlers;
std::string WritePed(Pedestrian* ped);
public:
IODispatcher();
IODispatcher(const IODispatcher& orig);
virtual ~IODispatcher();
void AddIO(OutputHandler* ioh);
const std::vector<OutputHandler*>& GetIOHandlers();
void Write(const std::string& str);
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();
int AreaLevel(std::string caption);
template<typename A>
bool IsElementInVector(const std::vector<A> &vec, A& el) {
typename std::vector<A>::const_iterator it;
it = std::find (vec.begin(), vec.end(), el);
if(it==vec.end()){
return false;
}else{
return true;
}
}
};
......@@ -74,54 +74,54 @@ public:
class TrajectoriesFLAT:public IODispatcher {
public:
TrajectoriesFLAT();
virtual ~TrajectoriesFLAT(){};
public:
TrajectoriesFLAT();
virtual ~TrajectoriesFLAT(){};
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();
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(){};
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();
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 TrajectoriesXML_MESH:public IODispatcher {
public:
TrajectoriesXML_MESH(){};
virtual ~TrajectoriesXML_MESH(){};
public:
TrajectoriesXML_MESH(){};
virtual ~TrajectoriesXML_MESH(){};
//virtual void WriteHeader(int nPeds, double fps, Building* building, int seed);
//virtual void WriteFrame(int frameNr, Building* building);
//virtual void WriteFooter();
virtual void WriteGeometry(Building* building);
//virtual void WriteHeader(int nPeds, double fps, Building* building, int seed);
//virtual void WriteFrame(int frameNr, Building* building);
//virtual void WriteFooter();
virtual void WriteGeometry(Building* building);
};
class TrajectoriesJPSV06: public IODispatcher {
public:
TrajectoriesJPSV06(){};
virtual ~TrajectoriesJPSV06(){};
public:
TrajectoriesJPSV06(){};
virtual ~TrajectoriesJPSV06(){};
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();
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();
};
#endif /* _IODISPATCHER_H */
#endif /* _IODISPATCHER_H */
......@@ -35,35 +35,35 @@ using namespace std;
void OutputHandler::Write(string str) {
if (this != NULL)
cout << str << endl;
if (this != NULL)
cout << str << endl;
}
void OutputHandler::Write(const char* message,...) {
char msg[CLENGTH];
va_list ap;
va_start (ap, message);
vsprintf (msg,message ,ap);
va_end (ap);
string str(msg);
if(str.find("ERROR")==string::npos) {
cout<<msg<<endl;
cout.flush();
}
else {
cerr<<msg<<endl;
cerr.flush();
}
//cout << "\033[1;30mbold red text\033[0m\n";
//cout << "\033[1;31"<<msg<<"\033[0m\n";
//cout << "\033[1;31 bla bla \033[0m\n";
char msg[CLENGTH];
va_list ap;
va_start (ap, message);
vsprintf (msg,message ,ap);
va_end (ap);
string str(msg);
if(str.find("ERROR")==string::npos) {
cout<<msg<<endl;
cout.flush();
}
else {
cerr<<msg<<endl;
cerr.flush();
}
//cout << "\033[1;30mbold red text\033[0m\n";
//cout << "\033[1;31"<<msg<<"\033[0m\n";
//cout << "\033[1;31 bla bla \033[0m\n";
}
void STDIOHandler::Write(string str) {
if (this != NULL)
cout << str << endl;
if (this != NULL)
cout << str << endl;
}
FileHandler::FileHandler(const char *fn) {
......@@ -88,13 +88,13 @@ void FileHandler::Write(string str) {
}
void FileHandler::Write(const char* string,...) {
char msg[CLENGTH];
va_list ap;
va_start (ap, string);
vsprintf (msg,string ,ap);
va_end (ap);
pfp<<msg<<endl;
pfp.flush();
char msg[CLENGTH];
va_list ap;
va_start (ap, string);
vsprintf (msg,string ,ap);
va_end (ap);
pfp<<msg<<endl;
pfp.flush();
}
TraVisToHandler::TraVisToHandler(string host, int port) {
......@@ -105,7 +105,7 @@ TraVisToHandler::TraVisToHandler(string host, int port) {
}
TraVisToHandler::~TraVisToHandler(){
delete client;
delete client;
}
void TraVisToHandler::Write(string str) {
......
......@@ -37,39 +37,39 @@
#include "../general/Macros.h"
class OutputHandler {
public:
virtual void Write(std::string str);
virtual void Write(const char *string, ...);
virtual ~OutputHandler(){};
public:
virtual void Write(std::string str);
virtual void Write(const char *string, ...);
virtual ~OutputHandler(){};
};
class STDIOHandler : public OutputHandler {
public:
void Write(std::string str);
public:
void Write(std::string str);
};
class FileHandler : public OutputHandler {
private:
std::ofstream pfp;
public:
FileHandler(const char *fn);
virtual ~FileHandler();
void Write(std::string str);
void Write(const char *string,...);
private:
std::ofstream pfp;
public:
FileHandler(const char *fn);
virtual ~FileHandler();
void Write(std::string str);
void Write(const char *string,...);
};
class TraVisToHandler : public OutputHandler {
private:
TraVisToClient* client;
private:
TraVisToClient* client;
public:
TraVisToHandler(std::string host, int port);
virtual ~TraVisToHandler();
void Write(std::string str);
public:
TraVisToHandler(std::string host, int port);
virtual ~TraVisToHandler();
void Write(std::string str);
//Some tags are broken
std::vector<std::string> brokentags;
//Some tags are broken
std::vector<std::string> brokentags;
};
......
......@@ -418,8 +418,8 @@ TraVisToClient::shutdownAndCloseSocket(socket_t sock) {
//FIXME:
//if (SOCKET_ERROR == closesocket(tcpSocket)) {
// derror("closesocket() failed");
// status = false;
// derror("closesocket() failed");
// status = false;
//}
dtrace("leaving shutdownAndCloseSocket()");
......
......@@ -91,58 +91,58 @@ typedef int socket_t;
#define HOST "localhost"
class TraVisToClient {
public:
public:
/// create a client with specific parameters
TraVisToClient(std::string hostname = HOST, unsigned short port = PORT);
/// create a client with specific parameters
TraVisToClient(std::string hostname = HOST, unsigned short port = PORT);
/// Destructor
virtual ~TraVisToClient();
/// Destructor
virtual ~TraVisToClient();
/// send datablock to the server
/// this functions is still blocking unfortunately, so it may
/// influence the execution time of your program
void sendData(const char* data);
/// send datablock to the server
/// this functions is still blocking unfortunately, so it may
/// influence the execution time of your program
void sendData(const char* data);
/// close the client (end the connection)
void close();
/// close the client (end the connection)
void close();
/// send a datagram using the unreliable
/// udp protokoll
void sendDatagram(char *datagram);
/// send a datagram using the unreliable
/// udp protokoll
void sendDatagram(char *datagram);
private:
void createConnection();
private:
void createConnection();
unsigned long lookupHostAddress(const char *hostName);
unsigned long lookupHostAddress(const char *hostName);
socket_t createClientSocket(const char *serverName, unsigned short portNumber);
socket_t createClientSocket(const char *serverName, unsigned short portNumber);
socket_t createServerSocket(unsigned short portNumber);
socket_t createServerSocket(unsigned short portNumber);
bool shutdownAndCloseSocket(socket_t sock);
bool shutdownAndCloseSocket(socket_t sock);
bool sendMessage(socket_t sock, const void *msg, int msgSize);
bool sendMessage(socket_t sock, const void *msg, int msgSize);
bool receiveMessage(socket_t sock, void *msg, int msgSize);
bool receiveMessage(socket_t sock, void *msg, int msgSize);
void _printErrorMessage(void);
void _printErrorMessage(void);
#ifdef _WIN32
bool _startWin32SocketSession(void);
void _stopWin32SocketSession(void);
bool _startWin32SocketSession(void);
void _stopWin32SocketSession(void);
#else
#define closesocket close
#define closesocket close
#endif
private:
bool _isConnected;
socket_t _tcpSocket;
std::string _hostname;
unsigned short _port;
std::vector<const char *> _msgQueue;
private:
bool _isConnected;
socket_t _tcpSocket;
std::string _hostname;
unsigned short _port;
std::vector<const char *> _msgQueue;
};
......
This diff is collapsed.
......@@ -51,81 +51,81 @@
extern OutputHandler* Log;
class Simulation {
private:
///Number of pedestrians in the simulation
int _nPeds;
///Maximum simulation time
double _tmax;
/// time step
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
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;
///new: EventManager
EventManager* _em;
/// argument parser
ArgumentParser* _argsParser;
public:
Simulation();
virtual ~Simulation();
/**
* 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
*/