Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
JPScore
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
92
Issues
92
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
JuPedSim
JPScore
Commits
50537e39
Commit
50537e39
authored
Nov 10, 2014
by
Ulrich Kemloh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changing functions signature from void to bool.
Geometry functions now return false on failure.
parent
a5161e99
Changes
39
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
460 additions
and
401 deletions
+460
-401
IO/IODispatcher.cpp
IO/IODispatcher.cpp
+71
-67
Simulation.cpp
Simulation.cpp
+171
-141
Simulation.h
Simulation.h
+1
-1
events/EventManager.cpp
events/EventManager.cpp
+16
-13
general/Macros.h
general/Macros.h
+3
-0
geometry/Building.cpp
geometry/Building.cpp
+37
-25
geometry/Building.h
geometry/Building.h
+5
-5
geometry/Goal.cpp
geometry/Goal.cpp
+3
-4
geometry/Goal.h
geometry/Goal.h
+1
-1
geometry/Obstacle.cpp
geometry/Obstacle.cpp
+7
-5
geometry/Obstacle.h
geometry/Obstacle.h
+1
-1
geometry/SubRoom.cpp
geometry/SubRoom.cpp
+10
-8
geometry/SubRoom.h
geometry/SubRoom.h
+4
-4
main.cpp
main.cpp
+28
-26
math/GCFMModel.cpp
math/GCFMModel.cpp
+3
-13
math/GCFMModel.h
math/GCFMModel.h
+8
-11
math/GompertzModel.cpp
math/GompertzModel.cpp
+5
-7
math/GompertzModel.h
math/GompertzModel.h
+5
-9
math/OperationalModel.h
math/OperationalModel.h
+2
-1
pedestrian/Pedestrian.cpp
pedestrian/Pedestrian.cpp
+1
-1
routing/CognitiveMapRouter.cpp
routing/CognitiveMapRouter.cpp
+2
-1
routing/CognitiveMapRouter.h
routing/CognitiveMapRouter.h
+1
-1
routing/DirectionStrategy.cpp
routing/DirectionStrategy.cpp
+34
-30
routing/DummyRouter.cpp
routing/DummyRouter.cpp
+2
-1
routing/DummyRouter.h
routing/DummyRouter.h
+1
-1
routing/GlobalRouter.cpp
routing/GlobalRouter.cpp
+3
-1
routing/GlobalRouter.h
routing/GlobalRouter.h
+2
-2
routing/GraphRouter.cpp
routing/GraphRouter.cpp
+4
-2
routing/GraphRouter.h
routing/GraphRouter.h
+1
-1
routing/MeshRouter.cpp
routing/MeshRouter.cpp
+2
-1
routing/MeshRouter.h
routing/MeshRouter.h
+1
-1
routing/QuickestPathRouter.cpp
routing/QuickestPathRouter.cpp
+4
-2
routing/QuickestPathRouter.h
routing/QuickestPathRouter.h
+1
-1
routing/Router.h
routing/Router.h
+1
-1
routing/RoutingEngine.cpp
routing/RoutingEngine.cpp
+5
-2
routing/RoutingEngine.h
routing/RoutingEngine.h
+2
-1
routing/SafestPathRouter.cpp
routing/SafestPathRouter.cpp
+7
-3
routing/SafestPathRouter.h
routing/SafestPathRouter.h
+1
-2
routing/graph/RoutingGraph.cpp
routing/graph/RoutingGraph.cpp
+4
-4
No files found.
IO/IODispatcher.cpp
View file @
50537e39
...
@@ -315,9 +315,9 @@ void TrajectoriesJPSV04::WriteFrame(int frameNr, Building* building)
...
@@ -315,9 +315,9 @@ void TrajectoriesJPSV04::WriteFrame(int frameNr, Building* building)
string
caption
=
r
->
GetCaption
();
string
caption
=
r
->
GetCaption
();
if
((
rooms_to_plot
.
empty
()
==
false
)
if
((
rooms_to_plot
.
empty
()
==
false
)
&&
(
IsElementInVector
(
rooms_to_plot
,
caption
)
==
false
))
{
&&
(
IsElementInVector
(
rooms_to_plot
,
caption
)
==
false
))
{
continue
;
continue
;
}
}
data
.
append
(
WritePed
(
ped
));
data
.
append
(
WritePed
(
ped
));
}
}
...
@@ -341,6 +341,7 @@ TrajectoriesFLAT::TrajectoriesFLAT() : Trajectories()
...
@@ -341,6 +341,7 @@ TrajectoriesFLAT::TrajectoriesFLAT() : Trajectories()
void
TrajectoriesFLAT
::
WriteHeader
(
int
nPeds
,
double
fps
,
Building
*
building
,
int
seed
)
void
TrajectoriesFLAT
::
WriteHeader
(
int
nPeds
,
double
fps
,
Building
*
building
,
int
seed
)
{
{
(
void
)
seed
;
(
void
)
nPeds
;
char
tmp
[
CLENGTH
]
=
""
;
char
tmp
[
CLENGTH
]
=
""
;
Write
(
"#description: my super simulation"
);
Write
(
"#description: my super simulation"
);
sprintf
(
tmp
,
"#framerate: %0.2f"
,
fps
);
sprintf
(
tmp
,
"#framerate: %0.2f"
,
fps
);
...
@@ -356,7 +357,7 @@ void TrajectoriesFLAT::WriteHeader(int nPeds, double fps, Building* building, in
...
@@ -356,7 +357,7 @@ void TrajectoriesFLAT::WriteHeader(int nPeds, double fps, Building* building, in
void
TrajectoriesFLAT
::
WriteGeometry
(
Building
*
building
)
void
TrajectoriesFLAT
::
WriteGeometry
(
Building
*
building
)
{
{
(
void
)
building
;
}
}
void
TrajectoriesFLAT
::
WriteFrame
(
int
frameNr
,
Building
*
building
)
void
TrajectoriesFLAT
::
WriteFrame
(
int
frameNr
,
Building
*
building
)
...
@@ -392,6 +393,8 @@ TrajectoriesVTK::TrajectoriesVTK()
...
@@ -392,6 +393,8 @@ TrajectoriesVTK::TrajectoriesVTK()
void
TrajectoriesVTK
::
WriteHeader
(
int
nPeds
,
double
fps
,
Building
*
building
,
int
seed
)
void
TrajectoriesVTK
::
WriteHeader
(
int
nPeds
,
double
fps
,
Building
*
building
,
int
seed
)
{
{
//suppress unused warnings
(
void
)
nPeds
;
(
void
)
fps
;
(
void
)
seed
;
Write
(
"# vtk DataFile Version 4.0"
);
Write
(
"# vtk DataFile Version 4.0"
);
Write
(
building
->
GetCaption
());
Write
(
building
->
GetCaption
());
Write
(
"ASCII"
);
Write
(
"ASCII"
);
...
@@ -447,6 +450,7 @@ void TrajectoriesVTK::WriteGeometry(Building* building)
...
@@ -447,6 +450,7 @@ void TrajectoriesVTK::WriteGeometry(Building* building)
void
TrajectoriesVTK
::
WriteFrame
(
int
frameNr
,
Building
*
building
)
void
TrajectoriesVTK
::
WriteFrame
(
int
frameNr
,
Building
*
building
)
{
{
(
void
)
frameNr
;
(
void
)
building
;
}
}
void
TrajectoriesVTK
::
WriteFooter
()
void
TrajectoriesVTK
::
WriteFooter
()
...
@@ -481,24 +485,24 @@ void TrajectoriesJPSV06::WriteHeader(int nPeds, double fps, Building* building,
...
@@ -481,24 +485,24 @@ void TrajectoriesJPSV06::WriteHeader(int nPeds, double fps, Building* building,
void
TrajectoriesJPSV06
::
WriteGeometry
(
Building
*
building
)
void
TrajectoriesJPSV06
::
WriteGeometry
(
Building
*
building
)
{
{
// just put a link to the geometry file
// just put a link to the geometry file
// string embed_geometry;
// string embed_geometry;
// embed_geometry.append("\t<geometry>\n");
// embed_geometry.append("\t<geometry>\n");
// char file_location[CLENGTH] = "";
// char file_location[CLENGTH] = "";
// sprintf(file_location, "\t<file location= \"%s\"/>\n", building->GetGeometryFilename().c_str());
// sprintf(file_location, "\t<file location= \"%s\"/>\n", building->GetGeometryFilename().c_str());
// embed_geometry.append(file_location);
// embed_geometry.append(file_location);
// //embed_geometry.append("\t</geometry>\n");
// //embed_geometry.append("\t</geometry>\n");
//
//
// const map<int, Hline*>& hlines=building->GetAllHlines();
// const map<int, Hline*>& hlines=building->GetAllHlines();
// if(hlines.size()>0){
// if(hlines.size()>0){
// //embed_geometry.append("\t<geometry>\n");
// //embed_geometry.append("\t<geometry>\n");
// for (std::map<int, Hline*>::const_iterator it=hlines.begin(); it!=hlines.end(); ++it)
// for (std::map<int, Hline*>::const_iterator it=hlines.begin(); it!=hlines.end(); ++it)
// {
// {
// embed_geometry.append(it->second->WriteElement());
// embed_geometry.append(it->second->WriteElement());
// }
// }
// //embed_geometry.append("\t</geometry>\n");
// //embed_geometry.append("\t</geometry>\n");
// }
// }
// embed_geometry.append("\t</geometry>\n");
// embed_geometry.append("\t</geometry>\n");
// Write(embed_geometry);
// Write(embed_geometry);
//set the content of the file
//set the content of the file
string
fileName
=
building
->
GetProjectRootDir
()
+
"/"
+
building
->
GetGeometryFilename
().
c_str
();
string
fileName
=
building
->
GetProjectRootDir
()
+
"/"
+
building
->
GetGeometryFilename
().
c_str
();
...
@@ -510,51 +514,51 @@ void TrajectoriesJPSV06::WriteGeometry(Building* building)
...
@@ -510,51 +514,51 @@ void TrajectoriesJPSV06::WriteGeometry(Building* building)
buffer
<<
t
.
rdbuf
();
buffer
<<
t
.
rdbuf
();
embed_geometry
=
buffer
.
str
();
embed_geometry
=
buffer
.
str
();
Write
(
embed_geometry
);
Write
(
embed_geometry
);
//
//
//
//
// //collecting the hlines
// //collecting the hlines
// std::stringstream hlines_buffer;
// std::stringstream hlines_buffer;
// // add the header
// // add the header
// hlines_buffer<<" <routing version=\"0.5\" "
// hlines_buffer<<" <routing version=\"0.5\" "
// <<"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
// <<"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
// <<"xsi:noNamespaceSchemaLocation=\"http://134.94.2.137/jps_routing.xsd\" >"<<endl
// <<"xsi:noNamespaceSchemaLocation=\"http://134.94.2.137/jps_routing.xsd\" >"<<endl
// <<"<Hlines> "<<endl;
// <<"<Hlines> "<<endl;
//
//
// const map<int, Hline*>& hlines=building->GetAllHlines();
// const map<int, Hline*>& hlines=building->GetAllHlines();
// for (std::map<int, Hline*>::const_iterator it=hlines.begin(); it!=hlines.end(); ++it)
// for (std::map<int, Hline*>::const_iterator it=hlines.begin(); it!=hlines.end(); ++it)
// {
// {
// Hline* hl=it->second;
// Hline* hl=it->second;
// hlines_buffer <<"\t<Hline id=\""<< hl->GetID()<<"\" room_id=\""<<hl->GetRoom1()->GetID()
// hlines_buffer <<"\t<Hline id=\""<< hl->GetID()<<"\" room_id=\""<<hl->GetRoom1()->GetID()
// <<"\" subroom_id=\""<< hl->GetSubRoom1()->GetSubRoomID()<<"\">"<<endl;
// <<"\" subroom_id=\""<< hl->GetSubRoom1()->GetSubRoomID()<<"\">"<<endl;
// hlines_buffer <<"\t\t<vertex px=\""<< hl->GetPoint1()._x<<"\" py=\""<< hl->GetPoint1()._y<<"\" />"<<endl;
// hlines_buffer <<"\t\t<vertex px=\""<< hl->GetPoint1()._x<<"\" py=\""<< hl->GetPoint1()._y<<"\" />"<<endl;
// hlines_buffer <<"\t\t<vertex px=\""<< hl->GetPoint2()._x<<"\" py=\""<< hl->GetPoint2()._y<<"\" />"<<endl;
// hlines_buffer <<"\t\t<vertex px=\""<< hl->GetPoint2()._x<<"\" py=\""<< hl->GetPoint2()._y<<"\" />"<<endl;
// hlines_buffer <<"\t</Hline>"<<endl;
// hlines_buffer <<"\t</Hline>"<<endl;
// }
// }
// hlines_buffer<<"</Hlines> "<<endl;
// hlines_buffer<<"</Hlines> "<<endl;
// hlines_buffer<<"</routing> "<<endl;
// hlines_buffer<<"</routing> "<<endl;
//
//
// string hline_string=hlines_buffer.str();
// string hline_string=hlines_buffer.str();
// string to_replace="</geometry>";
// string to_replace="</geometry>";
// hline_string.append(to_replace);
// hline_string.append(to_replace);
//
//
// size_t start_pos = embed_geometry.find(to_replace);
// size_t start_pos = embed_geometry.find(to_replace);
// if(start_pos == std::string::npos)
// if(start_pos == std::string::npos)
// {
// {
// Log->Write("WARNING:\t missing %s tag while writing the geometry in the trajectory file.",to_replace.c_str());
// Log->Write("WARNING:\t missing %s tag while writing the geometry in the trajectory file.",to_replace.c_str());
// }
// }
//
//
// embed_geometry.replace(start_pos, to_replace.length(), hline_string);
// embed_geometry.replace(start_pos, to_replace.length(), hline_string);
// Write(embed_geometry);
// Write(embed_geometry);
// Write("\t<AttributeDescription>");
// Write("\t<AttributeDescription>");
// Write("\t\t<property tag=\"x\" description=\"xPosition\"/>");
// Write("\t\t<property tag=\"x\" description=\"xPosition\"/>");
// Write("\t\t<property tag=\"y\" description=\"yPosition\"/>");
// Write("\t\t<property tag=\"y\" description=\"yPosition\"/>");
// Write("\t\t<property tag=\"z\" description=\"zPosition\"/>");
// Write("\t\t<property tag=\"z\" description=\"zPosition\"/>");
// Write("\t\t<property tag=\"rA\" description=\"radiusA\"/>");
// Write("\t\t<property tag=\"rA\" description=\"radiusA\"/>");
// Write("\t\t<property tag=\"rB\" description=\"radiusB\"/>");
// Write("\t\t<property tag=\"rB\" description=\"radiusB\"/>");
// Write("\t\t<property tag=\"eC\" description=\"ellipseColor\"/>");
// Write("\t\t<property tag=\"eC\" description=\"ellipseColor\"/>");
// Write("\t\t<property tag=\"eO\" description=\"ellipseOrientation\"/>");
// Write("\t\t<property tag=\"eO\" description=\"ellipseOrientation\"/>");
// Write("\t</AttributeDescription>\n");
// Write("\t</AttributeDescription>\n");
}
}
void
TrajectoriesJPSV06
::
WriteFrame
(
int
frameNr
,
Building
*
building
)
void
TrajectoriesJPSV06
::
WriteFrame
(
int
frameNr
,
Building
*
building
)
...
...
Simulation.cpp
View file @
50537e39
This diff is collapsed.
Click to expand it.
Simulation.h
View file @
50537e39
...
@@ -100,7 +100,7 @@ public:
...
@@ -100,7 +100,7 @@ public:
/**
/**
* Read parameters from the argument parser class.
* Read parameters from the argument parser class.
*/
*/
void
InitArgs
(
ArgumentParser
*
args
);
bool
InitArgs
(
ArgumentParser
*
args
);
/**
/**
* @return the total simulated/evacuation time
* @return the total simulated/evacuation time
...
...
events/EventManager.cpp
View file @
50537e39
...
@@ -22,10 +22,10 @@ EventManager::EventManager(Building *_b){
...
@@ -22,10 +22,10 @@ EventManager::EventManager(Building *_b){
_lastUpdateTime
=
0
;
_lastUpdateTime
=
0
;
_deltaT
=
0
;
_deltaT
=
0
;
if
(
!
_file
){
if
(
!
_file
){
Log
->
Write
(
"INFO:
\t
Datei events.txt nicht gefunden. Dynamisches Eventhandling nicht moeglich
."
);
Log
->
Write
(
"INFO:
\t
Files 'events.txt' missing. Realtime interaction with the simulation not possible
."
);
}
}
else
{
else
{
Log
->
Write
(
"INFO:
\t
Datei events.txt gefunden. Dynamisches Eventhandling moeglich
."
);
Log
->
Write
(
"INFO:
\t
File 'events.txt' will be monitored for new events
."
);
_dynamic
=
true
;
_dynamic
=
true
;
}
}
}
}
...
@@ -42,7 +42,7 @@ void EventManager::SetProjectRootDir(const std::string &filename){
...
@@ -42,7 +42,7 @@ void EventManager::SetProjectRootDir(const std::string &filename){
}
}
void
EventManager
::
readEventsXml
(){
void
EventManager
::
readEventsXml
(){
Log
->
Write
(
"INFO:
\t
Looking for
event
s"
);
Log
->
Write
(
"INFO:
\t
Looking for
pre-defined events in other file
s"
);
//get the geometry filename from the project file
//get the geometry filename from the project file
TiXmlDocument
doc
(
_projectFilename
);
TiXmlDocument
doc
(
_projectFilename
);
if
(
!
doc
.
LoadFile
()){
if
(
!
doc
.
LoadFile
()){
...
@@ -97,16 +97,19 @@ void EventManager::readEventsXml(){
...
@@ -97,16 +97,19 @@ void EventManager::readEventsXml(){
Log
->
Write
(
"INFO:
\t
Events were read
\n
"
);
Log
->
Write
(
"INFO:
\t
Events were read
\n
"
);
}
}
void
EventManager
::
listEvents
(){
void
EventManager
::
listEvents
()
if
(
_event_times
.
size
()
==
0
){
{
Log
->
Write
(
"INFO:
\t
No events in the events.xml"
);
if
(
_event_times
.
size
()
==
0
)
{
}
//this notification was already printed ealier
else
{
//Log->Write("INFO: \tNo events in the events.xml");
char
buf
[
10
],
buf2
[
10
];
}
else
{
for
(
unsigned
int
i
=
0
;
i
<
_event_times
.
size
();
i
++
){
char
buf
[
10
],
buf2
[
10
];
sprintf
(
buf
,
"%f"
,
_event_times
[
i
]);
for
(
unsigned
int
i
=
0
;
i
<
_event_times
.
size
();
i
++
)
{
sprintf
(
buf2
,
"%d"
,
_event_ids
[
i
]);
sprintf
(
buf
,
"%f"
,
_event_times
[
i
]);
Log
->
Write
(
"INFO:
\t
After "
+
string
(
buf
)
+
" sec: "
+
_event_types
[
i
]
+
" "
+
string
(
buf2
)
+
" "
+
_event_states
[
i
]);
sprintf
(
buf2
,
"%d"
,
_event_ids
[
i
]);
Log
->
Write
(
"INFO:
\t
After "
+
string
(
buf
)
+
" sec: "
+
_event_types
[
i
]
+
" "
+
string
(
buf2
)
+
" "
+
_event_states
[
i
]);
}
}
}
}
...
...
general/Macros.h
View file @
50537e39
...
@@ -162,4 +162,7 @@ template<typename A>
...
@@ -162,4 +162,7 @@ template<typename A>
return
true
;
return
true
;
}
}
}
}
//another useful macro
//#define UNUSED(expr) (void)(expr)
#endif
/* _MACROS_H */
#endif
/* _MACROS_H */
geometry/Building.cpp
View file @
50537e39
...
@@ -259,7 +259,7 @@ void Building::AddSurroundingRoom()
...
@@ -259,7 +259,7 @@ void Building::AddSurroundingRoom()
}
}
void
Building
::
InitGeometry
()
bool
Building
::
InitGeometry
()
{
{
Log
->
Write
(
"INFO:
\t
Init Geometry"
);
Log
->
Write
(
"INFO:
\t
Init Geometry"
);
for
(
int
i
=
0
;
i
<
GetNumberOfRooms
();
i
++
)
{
for
(
int
i
=
0
;
i
<
GetNumberOfRooms
();
i
++
)
{
...
@@ -284,7 +284,8 @@ void Building::InitGeometry()
...
@@ -284,7 +284,8 @@ void Building::InitGeometry()
}
}
// initialize the poly
// initialize the poly
s
->
ConvertLineToPoly
(
goals
);
if
(
!
s
->
ConvertLineToPoly
(
goals
))
return
false
;
s
->
CalculateArea
();
s
->
CalculateArea
();
goals
.
clear
();
goals
.
clear
();
...
@@ -292,11 +293,14 @@ void Building::InitGeometry()
...
@@ -292,11 +293,14 @@ void Building::InitGeometry()
const
vector
<
Obstacle
*>&
obstacles
=
s
->
GetAllObstacles
();
const
vector
<
Obstacle
*>&
obstacles
=
s
->
GetAllObstacles
();
for
(
unsigned
int
obs
=
0
;
obs
<
obstacles
.
size
();
++
obs
)
{
for
(
unsigned
int
obs
=
0
;
obs
<
obstacles
.
size
();
++
obs
)
{
if
(
obstacles
[
obs
]
->
GetClosed
()
==
1
)
if
(
obstacles
[
obs
]
->
GetClosed
()
==
1
)
obstacles
[
obs
]
->
ConvertLineToPoly
();
if
(
!
obstacles
[
obs
]
->
ConvertLineToPoly
())
return
false
;
}
}
}
}
}
}
Log
->
Write
(
"INFO:
\t
Init Geometry successful!!!
\n
"
);
Log
->
Write
(
"INFO:
\t
Init Geometry successful!!!
\n
"
);
return
true
;
}
}
...
@@ -324,7 +328,7 @@ const std::string& Building::GetGeometryFilename() const
...
@@ -324,7 +328,7 @@ const std::string& Building::GetGeometryFilename() const
return
_geometryFilename
;
return
_geometryFilename
;
}
}
void
Building
::
LoadGeometry
(
const
std
::
string
&
geometryfile
)
bool
Building
::
LoadGeometry
(
const
std
::
string
&
geometryfile
)
{
{
//get the geometry filename from the project file
//get the geometry filename from the project file
string
geoFilenameWithPath
=
_projectRootDir
+
geometryfile
;
string
geoFilenameWithPath
=
_projectRootDir
+
geometryfile
;
...
@@ -335,7 +339,7 @@ void Building::LoadGeometry(const std::string &geometryfile)
...
@@ -335,7 +339,7 @@ void Building::LoadGeometry(const std::string &geometryfile)
if
(
!
doc
.
LoadFile
())
{
if
(
!
doc
.
LoadFile
())
{
Log
->
Write
(
"ERROR:
\t
%s"
,
doc
.
ErrorDesc
());
Log
->
Write
(
"ERROR:
\t
%s"
,
doc
.
ErrorDesc
());
Log
->
Write
(
"
\t
could not parse the project file"
);
Log
->
Write
(
"
\t
could not parse the project file"
);
exit
(
EXIT_FAILURE
)
;
return
false
;
}
}
Log
->
Write
(
"INFO:
\t
Parsing the geometry file"
);
Log
->
Write
(
"INFO:
\t
Parsing the geometry file"
);
...
@@ -352,23 +356,23 @@ void Building::LoadGeometry(const std::string &geometryfile)
...
@@ -352,23 +356,23 @@ void Building::LoadGeometry(const std::string &geometryfile)
if
(
!
docGeo
.
LoadFile
())
{
if
(
!
docGeo
.
LoadFile
())
{
Log
->
Write
(
"ERROR:
\t
%s"
,
docGeo
.
ErrorDesc
());
Log
->
Write
(
"ERROR:
\t
%s"
,
docGeo
.
ErrorDesc
());
Log
->
Write
(
"
\t
could not parse the geometry file"
);
Log
->
Write
(
"
\t
could not parse the geometry file"
);
exit
(
EXIT_FAILURE
)
;
return
false
;
}
}
TiXmlElement
*
xRootNode
=
docGeo
.
RootElement
();
TiXmlElement
*
xRootNode
=
docGeo
.
RootElement
();
if
(
!
xRootNode
)
{
if
(
!
xRootNode
)
{
Log
->
Write
(
"ERROR:
\t
Root element does not exist"
);
Log
->
Write
(
"ERROR:
\t
Root element does not exist"
);
exit
(
EXIT_FAILURE
)
;
return
false
;
}
}
if
(
xRootNode
->
ValueStr
()
!=
"geometry"
)
{
if
(
xRootNode
->
ValueStr
()
!=
"geometry"
)
{
Log
->
Write
(
"ERROR:
\t
Root element value is not 'geometry'."
);
Log
->
Write
(
"ERROR:
\t
Root element value is not 'geometry'."
);
exit
(
EXIT_FAILURE
)
;
return
false
;
}
}
if
(
xRootNode
->
Attribute
(
"unit"
))
if
(
xRootNode
->
Attribute
(
"unit"
))
if
(
string
(
xRootNode
->
Attribute
(
"unit"
))
!=
"m"
)
{
if
(
string
(
xRootNode
->
Attribute
(
"unit"
))
!=
"m"
)
{
Log
->
Write
(
"ERROR:
\t
Only the unit m (meters) is supported.
\n\t
You supplied [%s]"
,
xRootNode
->
Attribute
(
"unit"
));
Log
->
Write
(
"ERROR:
\t
Only the unit m (meters) is supported.
\n\t
You supplied [%s]"
,
xRootNode
->
Attribute
(
"unit"
));
exit
(
EXIT_FAILURE
)
;
return
false
;
}
}
double
version
=
xmltof
(
xRootNode
->
Attribute
(
"version"
),
-
1
);
double
version
=
xmltof
(
xRootNode
->
Attribute
(
"version"
),
-
1
);
...
@@ -377,7 +381,7 @@ void Building::LoadGeometry(const std::string &geometryfile)
...
@@ -377,7 +381,7 @@ void Building::LoadGeometry(const std::string &geometryfile)
Log
->
Write
(
"
\t
Wrong geometry version!"
);
Log
->
Write
(
"
\t
Wrong geometry version!"
);
Log
->
Write
(
"
\t
Only version >= %s supported"
,
JPS_VERSION
);
Log
->
Write
(
"
\t
Only version >= %s supported"
,
JPS_VERSION
);
Log
->
Write
(
"
\t
Please update the version of your geometry file to %s"
,
JPS_VERSION
);
Log
->
Write
(
"
\t
Please update the version of your geometry file to %s"
,
JPS_VERSION
);
exit
(
EXIT_FAILURE
)
;
return
false
;
}
}
_caption
=
xmltoa
(
xRootNode
->
Attribute
(
"caption"
),
"virtual building"
);
_caption
=
xmltoa
(
xRootNode
->
Attribute
(
"caption"
),
"virtual building"
);
...
@@ -388,7 +392,7 @@ void Building::LoadGeometry(const std::string &geometryfile)
...
@@ -388,7 +392,7 @@ void Building::LoadGeometry(const std::string &geometryfile)
TiXmlNode
*
xRoomsNode
=
xRootNode
->
FirstChild
(
"rooms"
);
TiXmlNode
*
xRoomsNode
=
xRootNode
->
FirstChild
(
"rooms"
);
if
(
!
xRoomsNode
)
{
if
(
!
xRoomsNode
)
{
Log
->
Write
(
"ERROR:
\t
The geometry should have at least one room and one subroom"
);
Log
->
Write
(
"ERROR:
\t
The geometry should have at least one room and one subroom"
);
exit
(
EXIT_FAILURE
)
;
return
false
;
}
}
for
(
TiXmlElement
*
xRoom
=
xRoomsNode
->
FirstChildElement
(
"room"
);
xRoom
;
for
(
TiXmlElement
*
xRoom
=
xRoomsNode
->
FirstChildElement
(
"room"
);
xRoom
;
...
@@ -431,7 +435,7 @@ void Building::LoadGeometry(const std::string &geometryfile)
...
@@ -431,7 +435,7 @@ void Building::LoadGeometry(const std::string &geometryfile)
if
(
xSubRoom
->
FirstChildElement
(
"up"
)
==
NULL
)
{
if
(
xSubRoom
->
FirstChildElement
(
"up"
)
==
NULL
)
{
Log
->
Write
(
"ERROR:
\t
the attribute <up> and <down> are missing for the stair"
);
Log
->
Write
(
"ERROR:
\t
the attribute <up> and <down> are missing for the stair"
);
Log
->
Write
(
"ERROR:
\t
check your geometry file"
);
Log
->
Write
(
"ERROR:
\t
check your geometry file"
);
exit
(
EXIT_FAILURE
)
;
return
false
;
}
}
double
up_x
=
xmltof
(
xSubRoom
->
FirstChildElement
(
"up"
)
->
Attribute
(
"px"
),
0.0
);
double
up_x
=
xmltof
(
xSubRoom
->
FirstChildElement
(
"up"
)
->
Attribute
(
"px"
),
0.0
);
double
up_y
=
xmltof
(
xSubRoom
->
FirstChildElement
(
"up"
)
->
Attribute
(
"py"
),
0.0
);
double
up_y
=
xmltof
(
xSubRoom
->
FirstChildElement
(
"up"
)
->
Attribute
(
"py"
),
0.0
);
...
@@ -601,8 +605,10 @@ void Building::LoadGeometry(const std::string &geometryfile)
...
@@ -601,8 +605,10 @@ void Building::LoadGeometry(const std::string &geometryfile)
AddTransition
(
t
);
AddTransition
(
t
);
}
}
Log
->
Write
(
"INFO:
\t
Loading building file successful!!!
\n
"
);
Log
->
Write
(
"INFO:
\t
Loading building file successful!!!
\n
"
);
//everything went fine
return
true
;
}
}
...
@@ -851,18 +857,21 @@ bool Building::IsVisible(const Point& p1, const Point& p2, bool considerHlines)
...
@@ -851,18 +857,21 @@ bool Building::IsVisible(const Point& p1, const Point& p2, bool considerHlines)
return
true
;
return
true
;
}
}
void
Building
::
SanityCheck
()
bool
Building
::
SanityCheck
()
{
{
Log
->
Write
(
"INFO:
\t
Checking the geometry for artifacts"
);
Log
->
Write
(
"INFO:
\t
Checking the geometry for artifacts"
);
bool
status
=
true
;
for
(
unsigned
int
i
=
0
;
i
<
_rooms
.
size
();
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
_rooms
.
size
();
i
++
)
{
Room
*
room
=
_rooms
[
i
];
Room
*
room
=
_rooms
[
i
];
for
(
int
j
=
0
;
j
<
room
->
GetNumberOfSubRooms
();
j
++
)
{
for
(
int
j
=
0
;
j
<
room
->
GetNumberOfSubRooms
();
j
++
)
{
SubRoom
*
sub
=
room
->
GetSubRoom
(
j
);
SubRoom
*
sub
=
room
->
GetSubRoom
(
j
);
sub
->
SanityCheck
();
if
(
!
sub
->
SanityCheck
())
status
=
false
;
}
}
}
}
Log
->
Write
(
"INFO:
\t
...Done!!!
\n
"
);
Log
->
Write
(
"INFO:
\t
...Done!!!
\n
"
);
return
status
;
}
}
...
@@ -938,25 +947,25 @@ void Building::InitGrid(double cellSize)
...
@@ -938,25 +947,25 @@ void Building::InitGrid(double cellSize)
Log
->
Write
(
"INFO:
\t
Done with Initializing the grid "
);
Log
->
Write
(
"INFO:
\t
Done with Initializing the grid "
);
}
}
void
Building
::
LoadRoutingInfo
(
const
string
&
filename
)
bool
Building
::
LoadRoutingInfo
(
const
string
&
filename
)
{
{
Log
->
Write
(
"INFO:
\t
Loading extra routing information"
);
Log
->
Write
(
"INFO:
\t
Loading extra routing information"
);
if
(
filename
==
""
)
{
if
(
filename
==
""
)
{
Log
->
Write
(
"INFO:
\t
No file supplied !"
);
Log
->
Write
(
"INFO:
\t
No file supplied !"
);
Log
->
Write
(
"INFO:
\t
done with loading extra routing information"
);
Log
->
Write
(
"INFO:
\t
done with loading extra routing information"
);
return
;
return
true
;
}
}
TiXmlDocument
docRouting
(
filename
);
TiXmlDocument
docRouting
(
filename
);
if
(
!
docRouting
.
LoadFile
())
{
if
(
!
docRouting
.
LoadFile
())
{
Log
->
Write
(
"ERROR:
\t
%s"
,
docRouting
.
ErrorDesc
());
Log
->
Write
(
"ERROR:
\t
%s"
,
docRouting
.
ErrorDesc
());
Log
->
Write
(
"ERROR:
\t
could not parse the routing file"
);
Log
->
Write
(
"ERROR:
\t
could not parse the routing file"
);
exit
(
EXIT_FAILURE
)
;
return
false
;
}
}
TiXmlElement
*
xRootNode
=
docRouting
.
RootElement
();
TiXmlElement
*
xRootNode
=
docRouting
.
RootElement
();
if
(
!
xRootNode
)
{
if
(
!
xRootNode
)
{
Log
->
Write
(
"ERROR:
\t
Root element does not exist"
);
Log
->
Write
(
"ERROR:
\t
Root element does not exist"
);
exit
(
EXIT_FAILURE
)
;
return
false
;
}
}
//load goals and routes
//load goals and routes
...
@@ -993,7 +1002,9 @@ void Building::LoadRoutingInfo(const string &filename)
...
@@ -993,7 +1002,9 @@ void Building::LoadRoutingInfo(const string &filename)
}
}
}
}
goal
->
ConvertLineToPoly
();
if
(
!
goal
->
ConvertLineToPoly
())
return
false
;
AddGoal
(
goal
);
AddGoal
(
goal
);
_routingEngine
->
AddFinalDestinationID
(
goal
->
GetId
());
_routingEngine
->
AddFinalDestinationID
(
goal
->
GetId
());
}
}
...
@@ -1008,7 +1019,7 @@ void Building::LoadRoutingInfo(const string &filename)
...
@@ -1008,7 +1019,7 @@ void Building::LoadRoutingInfo(const string &filename)
double
id
=
xmltof
(
trip
->
Attribute
(
"id"
),
-
1
);
double
id
=
xmltof
(
trip
->
Attribute
(
"id"
),
-
1
);
if
(
id
==
-
1
)
{
if
(
id
==
-
1
)
{
Log
->
Write
(
"ERROR:
\t
id missing for trip"
);
Log
->
Write
(
"ERROR:
\t
id missing for trip"
);
exit
(
EXIT_FAILURE
)
;
return
false
;
}
}
string
sTrip
=
trip
->
FirstChild
()
->
ValueStr
();
string
sTrip
=
trip
->
FirstChild
()
->
ValueStr
();
vector
<
string
>
vTrip
;
vector
<
string
>
vTrip
;
...
@@ -1023,9 +1034,10 @@ void Building::LoadRoutingInfo(const string &filename)
...
@@ -1023,9 +1034,10 @@ void Building::LoadRoutingInfo(const string &filename)
_routingEngine
->
AddTrip
(
vTrip
);
_routingEngine
->
AddTrip
(
vTrip
);
}
}
Log
->
Write
(
"INFO:
\t
done with loading extra routing information"
);
Log
->
Write
(
"INFO:
\t
done with loading extra routing information"
);
return
true
;
}
}
void
Building
::
LoadTrafficInfo
()
bool
Building
::
LoadTrafficInfo
()
{
{
Log
->
Write
(
"INFO:
\t
Loading the traffic info file"
);
Log
->
Write
(
"INFO:
\t
Loading the traffic info file"
);
...
@@ -1035,14 +1047,13 @@ void Building::LoadTrafficInfo()
...
@@ -1035,14 +1047,13 @@ void Building::LoadTrafficInfo()
if
(
!
doc
.
LoadFile
())
{
if
(
!
doc
.
LoadFile
())
{
Log
->
Write
(
"ERROR:
\t
%s"
,
doc
.
ErrorDesc
());
Log
->
Write
(
"ERROR:
\t
%s"
,
doc
.
ErrorDesc
());
Log
->
Write
(
"ERROR:
\t
could not parse the project file"
);
Log
->
Write
(
"ERROR:
\t
could not parse the project file"
);
exit
(
EXIT_FAILURE
)
;
return
false
;
}
}
TiXmlNode
*
xRootNode
=
doc
.
RootElement
()
->
FirstChild
(
"traffic_constraints"
);
TiXmlNode
*
xRootNode
=
doc
.
RootElement
()
->
FirstChild
(
"traffic_constraints"
);
if
(
!
xRootNode
)
{
if
(
!
xRootNode
)
{
Log
->
Write
(
"WARNING:
\t
could not find any traffic information"
);
Log
->
Write
(
"WARNING:
\t
could not find any traffic information"
);
return
;
return
true
;
//exit(EXIT_FAILURE);
}
}
//processing the rooms node