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
a9e7a987
Commit
a9e7a987
authored
Mar 18, 2019
by
Mohcine Chraibi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generate TXT trajectories with limited size
- Max Size is 10 MB - Works only for txt files (format=plain)
parent
2f87f9b4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
30 deletions
+60
-30
IO/IODispatcher.cpp
IO/IODispatcher.cpp
+14
-12
IO/IODispatcher.h
IO/IODispatcher.h
+7
-7
IO/PedDistributionParser.cpp
IO/PedDistributionParser.cpp
+4
-4
Simulation.cpp
Simulation.cpp
+33
-6
Simulation.h
Simulation.h
+2
-1
No files found.
IO/IODispatcher.cpp
View file @
a9e7a987
...
...
@@ -61,11 +61,11 @@ const vector<Trajectories*>& IODispatcher::GetIOHandlers()
return
_outputHandlers
;
}
void
IODispatcher
::
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
)
void
IODispatcher
::
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
,
int
count
)
{
for
(
auto
const
&
it
:
_outputHandlers
)
{
it
->
WriteHeader
(
nPeds
,
fps
,
building
,
seed
);
it
->
WriteHeader
(
nPeds
,
fps
,
building
,
seed
,
count
);
}
}
void
IODispatcher
::
WriteGeometry
(
Building
*
building
)
...
...
@@ -118,7 +118,7 @@ string TrajectoriesJPSV04::WritePed(Pedestrian* ped)
return
string
(
tmp
);
}
void
TrajectoriesJPSV04
::
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
)
void
TrajectoriesJPSV04
::
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
,
int
count
)
{
building
->
GetCaption
();
string
tmp
;
...
...
@@ -329,11 +329,14 @@ TrajectoriesFLAT::TrajectoriesFLAT() : Trajectories()
{
}
void
TrajectoriesFLAT
::
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
)
void
TrajectoriesFLAT
::
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
,
int
count
)
{
(
void
)
seed
;
(
void
)
nPeds
;
char
tmp
[
CLENGTH
]
=
""
;
Write
(
"#description: my super simulation"
);
char
tmp
[
100
]
=
""
;
sprintf
(
tmp
,
"#description: jpscore (%s)"
,
JPSCORE_VERSION
);
Write
(
tmp
);
sprintf
(
tmp
,
"#count: %d"
,
count
);
Write
(
tmp
);
sprintf
(
tmp
,
"#framerate: %0.2f"
,
fps
);
Write
(
tmp
);
sprintf
(
tmp
,
"#geometry: %s"
,
building
->
GetGeometryFilename
().
c_str
());
...
...
@@ -353,7 +356,6 @@ void TrajectoriesFLAT::WriteGeometry(Building* building)
void
TrajectoriesFLAT
::
WriteFrame
(
int
frameNr
,
Building
*
building
)
{
char
tmp
[
CLENGTH
]
=
""
;
const
vector
<
Pedestrian
*
>&
allPeds
=
building
->
GetAllPedestrians
();
for
(
unsigned
int
p
=
0
;
p
<
allPeds
.
size
();
p
++
){
Pedestrian
*
ped
=
allPeds
[
p
];
...
...
@@ -363,7 +365,6 @@ void TrajectoriesFLAT::WriteFrame(int frameNr, Building* building)
sprintf
(
tmp
,
"%d
\t
%d
\t
%0.2f
\t
%0.2f
\t
%0.2f"
,
ped
->
GetID
(),
frameNr
,
x
,
y
,
z
);
Write
(
tmp
);
}
}
void
TrajectoriesFLAT
::
WriteFooter
()
...
...
@@ -396,10 +397,11 @@ TrajectoriesVTK::TrajectoriesVTK()
{
}
void
TrajectoriesVTK
::
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
)
void
TrajectoriesVTK
::
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
,
int
count
)
{
//suppress unused warnings
(
void
)
nPeds
;
(
void
)
fps
;
(
void
)
seed
;
(
void
)
nPeds
;
(
void
)
fps
;
(
void
)
seed
;
(
void
)
count
;
Write
(
"# vtk DataFile Version 4.0"
);
Write
(
building
->
GetCaption
());
Write
(
"ASCII"
);
...
...
@@ -465,7 +467,7 @@ void TrajectoriesVTK::WriteFooter()
}
void
TrajectoriesJPSV06
::
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
)
void
TrajectoriesJPSV06
::
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
,
int
count
)
{
building
->
GetCaption
();
string
tmp
;
...
...
@@ -621,7 +623,7 @@ void TrajectoriesXML_MESH::WriteGeometry(Building* building)
}
void
TrajectoriesJPSV05
::
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
)
void
TrajectoriesJPSV05
::
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
,
int
count
)
{
building
->
GetCaption
();
string
tmp
;
...
...
IO/IODispatcher.h
View file @
a9e7a987
...
...
@@ -51,7 +51,7 @@ public:
void
AddIO
(
Trajectories
*
ioh
);
const
std
::
vector
<
Trajectories
*>&
GetIOHandlers
();
void
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
);
void
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
,
int
count
);
void
WriteGeometry
(
Building
*
building
);
void
WriteFrame
(
int
frameNr
,
Building
*
building
);
void
WriteFooter
();
...
...
@@ -67,7 +67,7 @@ public:
_outputHandler
=
nullptr
;
};
virtual
~
Trajectories
(){
delete
_outputHandler
;};
virtual
void
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
)
=
0
;
virtual
void
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
,
int
count
)
=
0
;
virtual
void
WriteGeometry
(
Building
*
building
)
=
0
;
virtual
void
WriteFrame
(
int
frameNr
,
Building
*
building
)
=
0
;
virtual
void
WriteFooter
()
=
0
;
...
...
@@ -108,7 +108,7 @@ public:
TrajectoriesJPSV04
(){};
virtual
~
TrajectoriesJPSV04
(){};
virtual
void
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
);
virtual
void
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
,
int
count
);
virtual
void
WriteGeometry
(
Building
*
building
);
virtual
void
WriteFrame
(
int
frameNr
,
Building
*
building
);
virtual
void
WriteFooter
();
...
...
@@ -121,7 +121,7 @@ public:
TrajectoriesJPSV05
(){};
virtual
~
TrajectoriesJPSV05
(){};
virtual
void
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
);
virtual
void
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
,
int
count
);
virtual
void
WriteGeometry
(
Building
*
building
);
virtual
void
WriteFrame
(
int
frameNr
,
Building
*
building
);
virtual
void
WriteFooter
();
...
...
@@ -139,7 +139,7 @@ public:
}
;
virtual
void
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
);
virtual
void
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
,
int
count
);
virtual
void
WriteGeometry
(
Building
*
building
);
virtual
void
WriteFrame
(
int
frameNr
,
Building
*
building
);
virtual
void
WriteFooter
();
...
...
@@ -157,7 +157,7 @@ public:
}
;
virtual
void
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
);
virtual
void
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
,
int
count
);
virtual
void
WriteGeometry
(
Building
*
building
);
virtual
void
WriteFrame
(
int
frameNr
,
Building
*
building
);
virtual
void
WriteFooter
();
...
...
@@ -192,7 +192,7 @@ public:
TrajectoriesJPSV06
(){};
virtual
~
TrajectoriesJPSV06
(){
};
virtual
void
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
);
virtual
void
WriteHeader
(
long
nPeds
,
double
fps
,
Building
*
building
,
int
seed
,
int
count
);
virtual
void
WriteGeometry
(
Building
*
building
);
virtual
void
WriteFrame
(
int
frameNr
,
Building
*
building
);
virtual
void
WriteFooter
();
...
...
IO/PedDistributionParser.cpp
View file @
a9e7a987
...
...
@@ -180,22 +180,22 @@ bool PedDistributionParser::LoadPedDistribution(vector<std::shared_ptr<StartDist
if
(
!
docSource
.
LoadFile
())
{
Log
->
Write
(
"ERROR:
\t
%s"
,
docSource
.
ErrorDesc
());
Log
->
Write
(
"ERROR:
\t
could not parse the sources file."
);
//
return false;
return
false
;
}
TiXmlElement
*
xRootNodeSource
=
docSource
.
RootElement
();
if
(
!
xRootNodeSource
)
{
Log
->
Write
(
"ERROR:
\t
Root element does not exist in source file."
);
//
return false;
return
false
;
}
if
(
xRootNodeSource
->
ValueStr
()
!=
"JPScore"
)
{
Log
->
Write
(
"ERROR:
\t
Root element value in source file is not 'JPScore'."
);
//
return false;
return
false
;
}
TiXmlNode
*
xSourceF
=
xRootNodeSource
->
FirstChild
(
"agents_sources"
);
if
(
!
xSourceF
)
{
Log
->
Write
(
"ERROR:
\t
No agents_sources tag in file not found."
);
//
return false;
return
false
;
}
Log
->
Write
(
"INFO:
\t
Loading sources from file"
);
TiXmlNode
*
xSourceNodeF
=
xSourceF
->
FirstChild
(
"source"
);
...
...
Simulation.cpp
View file @
a9e7a987
...
...
@@ -37,6 +37,8 @@
#include "pedestrian/AgentsQueue.h"
#include "pedestrian/AgentsSourcesManager.h"
#include "geometry/WaitingArea.h"
#include <filesystem>
namespace
fs
=
std
::
filesystem
;
#ifdef _OPENMP
...
...
@@ -48,10 +50,13 @@
using
namespace
std
;
OutputHandler
*
Log
;
Trajectories
*
outputTXT
;
Simulation
::
Simulation
(
Configuration
*
args
)
:
_config
(
args
)
{
_countTraj
=
0
;
_maxFileSize
=
10
;
// MB
_nPeds
=
0
;
_seed
=
8091983
;
_deltaT
=
0
;
...
...
@@ -156,9 +161,9 @@ bool Simulation::InitArgs()
case
FORMAT_PLAIN
:
{
OutputHandler
*
file
=
new
FileHandler
(
_config
->
GetTrajectoriesFile
().
c_str
());
Trajectories
*
output
=
new
TrajectoriesFLAT
();
output
->
SetOutputHandler
(
file
);
_iod
->
AddIO
(
output
);
outputTXT
=
new
TrajectoriesFLAT
();
output
TXT
->
SetOutputHandler
(
file
);
_iod
->
AddIO
(
output
TXT
);
break
;
}
case
FORMAT_VTK
:
{
...
...
@@ -457,7 +462,8 @@ void Simulation::RunHeader(long nPed)
{
// writing the header
if
(
nPed
==-
1
)
nPed
=
_nPeds
;
_iod
->
WriteHeader
(
nPed
,
_fps
,
_building
.
get
(),
_seed
);
_iod
->
WriteHeader
(
nPed
,
_fps
,
_building
.
get
(),
_seed
,
0
);
// first trajectory
// count = 0
_iod
->
WriteGeometry
(
_building
.
get
());
if
(
_gotSources
)
_iod
->
WriteSources
(
GetAgentSrcManager
().
GetSources
());
...
...
@@ -467,7 +473,6 @@ void Simulation::RunHeader(long nPed)
int
firstframe
=
(
Pedestrian
::
GetGlobalTime
()
/
_deltaT
)
/
writeInterval
;
_iod
->
WriteFrame
(
firstframe
,
_building
.
get
());
//first initialisation needed by the linked-cells
UpdateRoutesAndLocations
();
ProcessAgentsQueue
();
...
...
@@ -482,7 +487,10 @@ double Simulation::RunBody(double maxSimTime)
//take the current time from the pedestrian
double
t
=
Pedestrian
::
GetGlobalTime
();
fs
::
path
TrajectoryName
(
_config
->
GetTrajectoriesFile
());
// in case we
// may need to
// generate
// several small files
//frame number. This function can be called many times,
static
int
frameNr
=
(
int
)
(
1
+
t
/
_deltaT
);
// Frame Number
...
...
@@ -509,6 +517,7 @@ double Simulation::RunBody(double maxSimTime)
bar
->
SetStyle
(
"\u2588"
,
"-"
);
//for linux
#endif
int
initialnPeds
=
_nPeds
;
// main program loop
while
((
_nPeds
||
(
!
_agentSrcManager
.
IsCompleted
()
&&
_gotSources
)
)
&&
t
<
maxSimTime
)
{
t
=
0
+
(
frameNr
-
1
)
*
_deltaT
;
...
...
@@ -550,6 +559,24 @@ double Simulation::RunBody(double maxSimTime)
// write the trajectories
if
(
0
==
frameNr
%
writeInterval
)
{
_iod
->
WriteFrame
(
frameNr
/
writeInterval
,
_building
.
get
());
fs
::
path
p
=
_config
->
GetTrajectoriesFile
();
int
sf
=
fs
::
file_size
(
p
);
if
(
sf
>
_maxFileSize
*
1024
*
1024
)
{
std
::
string
extention
=
p
.
extension
().
string
();
_countTraj
++
;
char
tmp_traj_name
[
100
];
sprintf
(
tmp_traj_name
,
"%s_%.4d_%s"
,
TrajectoryName
.
stem
().
string
().
c_str
(),
_countTraj
,
extention
.
c_str
());
_config
->
SetTrajectoriesFile
(
tmp_traj_name
);
Log
->
Write
(
"INFO:
\t
New trajectory file <%s>"
,
tmp_traj_name
);
OutputHandler
*
file
=
new
FileHandler
(
_config
->
GetTrajectoriesFile
().
c_str
());
outputTXT
->
SetOutputHandler
(
file
);
//_config->GetProjectRootDir()+"_1_"+_config->GetTrajectoriesFile());
// _config->SetTrajectoriesFile(name);
_iod
->
WriteHeader
(
_nPeds
,
_fps
,
_building
.
get
(),
_seed
,
_countTraj
);
// _iod->WriteGeometry(_building.get());
}
}
if
(
!
_gotSources
&&
!
_periodic
&&
_config
->
print_prog_bar
())
...
...
Simulation.h
View file @
a9e7a987
...
...
@@ -187,7 +187,8 @@ public:
void
UpdateDoorticks
()
const
;
int
GetMaxSimTime
()
const
;
int
_countTraj
=
0
;
// count number of TXT trajectories to produce
double
_maxFileSize
;
// in MB
};
#endif
/*SIMULATION_H_*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment