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
8326d0f1
Verified
Commit
8326d0f1
authored
May 29, 2019
by
Mohcine Chraibi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Debugging: SegFault after adding Trans
parent
b0548ec2
Pipeline
#20964
passed with stages
in 9 minutes and 19 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
131 additions
and
33 deletions
+131
-33
Simulation.cpp
Simulation.cpp
+74
-13
geometry/Building.cpp
geometry/Building.cpp
+47
-16
geometry/Building.h
geometry/Building.h
+2
-2
geometry/Crossing.cpp
geometry/Crossing.cpp
+7
-2
geometry/SubRoom.cpp
geometry/SubRoom.cpp
+1
-0
No files found.
Simulation.cpp
View file @
8326d0f1
...
...
@@ -658,6 +658,7 @@ double Simulation::RunBody(double maxSimTime)
std
::
string
trainType
=
""
;
Point
trackStart
,
trackEnd
;
auto
now
=
Pedestrian
::
GetGlobalTime
();
static
int
once
=
1
;
for
(
auto
&&
tab
:
TrainTimeTables
)
{
if
(
(
now
>=
tab
.
second
->
tin
)
&&
(
now
<=
tab
.
second
->
tout
)
)
...
...
@@ -669,14 +670,24 @@ double Simulation::RunBody(double maxSimTime)
continue
;
}
}
if
(
trainHere
)
correctGeometry
(
_building
,
trainType
,
trackStart
,
trackEnd
);
// todo: correctgeometry on arrival of a train. Reset it on departure of train.
if
(
trainHere
&&
once
)
{
correctGeometry
(
_building
,
trainType
,
trackStart
,
trackEnd
);
_routingEngine
->
UpdateRouter
();
once
=
0
;
}
std
::
cout
<<
KRED
<<
"Check: Building Has "
<<
_building
->
GetAllTransitions
().
size
()
<<
" Transitions
\n
"
<<
RESET
;
for
(
auto
&
itr
:
_building
->
GetAllTransitions
())
{
Transition
*
Trans
=
itr
.
second
;
std
::
cout
<<
"HH TRAN "
<<
Trans
->
GetID
()
<<
" room "
<<
Trans
->
GetID
()
<<
"
\n
"
;
std
::
cout
<<
"KNALL TRANS "
<<
Trans
->
IsOpen
()
<<
"
\n
"
;
std
::
cout
<<
"KNALL TRANS "
<<
Trans
->
IsClose
()
<<
"
\n
"
;
std
::
cout
<<
"KNALL TRANS "
<<
Trans
->
IsTempClose
()
<<
"
\n
"
;
if
(
Trans
->
IsTempClose
())
{
std
::
cout
<<
"enter IF
\n
"
;
if
((
Trans
->
GetMaxDoorUsage
()
!=
(
std
::
numeric_limits
<
int
>::
max
)())
||
(
Trans
->
GetOutflowRate
()
!=
(
std
::
numeric_limits
<
double
>::
max
)())
){
// || (Trans->GetOutflowRate() != std::numeric_limits<double>::max)){
...
...
@@ -743,13 +754,19 @@ double Simulation::RunBody(double maxSimTime)
bool
Simulation
::
correctGeometry
(
std
::
shared_ptr
<
Building
>
building
,
std
::
string
trainType
,
Point
TrackStart
,
Point
TrackEnd
)
{
std
::
cout
<<
"enter with train "
<<
trainType
.
c_str
()
<<
"
\n
"
;
std
::
cout
<<
KBLU
<<
"Enter correctGeometry: Building Has "
<<
building
->
GetAllTransitions
().
size
()
<<
" Transitions
\n
"
<<
RESET
;
//auto platforms = building->GetPlatforms();
SubRoom
*
subroom
;
auto
mytrack
=
building
->
GetTrackWalls
(
TrackStart
,
TrackEnd
,
subroom
);
int
room_id
,
subroom_id
;
auto
mytrack
=
building
->
GetTrackWalls
(
TrackStart
,
TrackEnd
,
room_id
,
subroom_id
);
std
::
cout
<<
"room: "
<<
room_id
<<
" subroom_id "
<<
subroom_id
<<
"
\n
"
;
Room
*
room
=
building
->
GetRoom
(
room_id
);
subroom
=
room
->
GetSubRoom
(
subroom_id
);
//todo safety check
int
transition_id
=
10000
;
if
(
mytrack
.
empty
()
||
subroom
==
nullptr
)
return
false
;
//auto subroom = building->GetSubRoomByID(subroomId);
auto
train
=
building
->
GetTrainTypes
().
at
(
trainType
);
auto
doors
=
train
->
doors
;
...
...
@@ -758,6 +775,8 @@ bool Simulation::correctGeometry(std::shared_ptr<Building> building, std::string
if
(
pws
.
empty
())
std
::
cout
<<
"simulation::correctGeometry: pws are empty
\n
"
;
subroom
->
GetUID
();
auto
walls
=
subroom
->
GetAllWalls
();
// debugging
std
::
cout
<<
"------
\n
"
;
for
(
auto
pw
:
pws
)
...
...
@@ -773,20 +792,62 @@ bool Simulation::correctGeometry(std::shared_ptr<Building> building, std::string
std
::
cout
<<
"------
\n
"
;
// case 1
Point
P
;
if
(
w1
.
ShareCommonPointWith
(
w2
,
P
))
if
(
w1
==
w2
)
{
std
::
cout
<<
"EQUAL
\n
"
;
Transition
*
e
=
new
Transition
();
e
->
SetID
(
transition_id
++
);
e
->
SetCaption
(
"tempDoor"
);
e
->
SetPoint1
(
p1
);
e
->
SetPoint2
(
p2
);
e
->
SetType
(
"train_door"
);
room
->
AddTransitionID
(
e
->
GetUniqueID
());
// danger area
e
->
SetRoom1
(
room
);
e
->
SetSubRoom1
(
subroom
);
subroom
->
AddTransition
(
e
);
// danger area
building
->
AddTransition
(
e
);
// danger area
std
::
cout
<<
"added transition
\n
"
;
std
::
cout
<<
"open: "
<<
e
->
IsOpen
()
<<
"
\n
"
;
std
::
cout
<<
"Close: "
<<
e
->
IsClose
()
<<
"
\n
"
;
std
::
cout
<<
"TempClose: "
<<
e
->
IsTempClose
()
<<
"
\n
"
;
std
::
cout
<<
KGRN
<<
"Transition added. Building Has "
<<
building
->
GetAllTransitions
().
size
()
<<
" Transitions
\n
"
<<
RESET
;
double
dist_pt1
=
(
w1
.
GetPoint1
()
-
e
->
GetPoint1
()).
NormSquare
();
double
dist_pt2
=
(
w1
.
GetPoint1
()
-
e
->
GetPoint2
()).
NormSquare
();
Point
A
,
B
;
if
(
dist_pt1
<
dist_pt2
)
{
A
=
e
->
GetPoint1
();
B
=
e
->
GetPoint2
();
}
else
{
A
=
e
->
GetPoint2
();
B
=
e
->
GetPoint1
();
}
Wall
NewWall
(
w1
.
GetPoint1
(),
A
);
Wall
NewWall1
(
w1
.
GetPoint2
(),
B
);
// add new lines to be controled against overlap with exits
building
->
TempAddedWalls
.
push_back
(
NewWall
);
building
->
TempAddedWalls
.
push_back
(
NewWall1
);
building
->
TempAddedDoors
.
push_back
(
*
e
);
building
->
TempRemovedWalls
.
push_back
(
w1
);
subroom
->
AddWall
(
NewWall
);
subroom
->
AddWall
(
NewWall1
);
subroom
->
RemoveWall
(
w1
);
//room->AddTransitionID(e->GetUniqueID());
}
else
if
(
w1
.
ShareCommonPointWith
(
w2
,
P
))
{
std
::
cout
<<
"ONE POINT COMON
\n
"
;
// add AP and BP: walls
// remove walls w1 and w2
// p1 p2 door
}
else
if
(
w1
==
w2
)
{
subroom
->
RemoveWall
(
w1
);
//building->TempRemoveWalls()
// use function we have in correct geometry
}
else
// disjoint
{
std
::
cout
<<
"DISJOINT
\n
"
;
// find points on w1 and w2 between p1 and p2
// (A, B)
// remove all walls connected to A
...
...
@@ -796,7 +857,7 @@ bool Simulation::correctGeometry(std::shared_ptr<Building> building, std::string
}
}
std
::
cout
<<
"------
\n
"
;
getc
(
stdin
);
/* getc(stdin); */
return
true
;
...
...
geometry/Building.cpp
View file @
8326d0f1
...
...
@@ -396,7 +396,7 @@ bool Building::InitGeometry()
return
true
;
}
const
std
::
vector
<
Wall
>
Building
::
GetTrackWalls
(
Point
TrackStart
,
Point
TrackEnd
,
SubRoom
*
subroom
)
const
const
std
::
vector
<
Wall
>
Building
::
GetTrackWalls
(
Point
TrackStart
,
Point
TrackEnd
,
int
&
room_id
,
int
&
subroom_id
)
const
{
bool
trackFound
=
false
;
int
track_id
=
-
1
;
...
...
@@ -436,10 +436,12 @@ const std::vector<Wall> Building::GetTrackWalls(Point TrackStart, Point TrackEnd
}
// plattforms
if
(
trackFound
)
{
subroom
=
_platforms
.
at
(
platform_id
)
->
sub
;
room_id
=
_platforms
.
at
(
platform_id
)
->
rid
;
subroom_id
=
_platforms
.
at
(
platform_id
)
->
sid
;
mytrack
=
_platforms
.
at
(
platform_id
)
->
tracks
[
track_id
];
std
::
cout
<<
"track has walls: "
<<
mytrack
.
size
()
<<
"
\n
"
;
std
::
cout
<<
"platform "
<<
platform_id
<<
" track "
<<
track_id
<<
"
\n
"
;
std
::
cout
<<
"room "
<<
room_id
<<
" subroom "
<<
subroom_id
<<
"
\n
"
;
}
else
{
...
...
@@ -497,12 +499,23 @@ const std::vector<std::pair<PointWall, PointWall > > Building::GetIntersectionPo
}
bool
Building
::
resetTempVectors
()
{
int
room_id
,
subroom_id
;
SubRoom
*
subroom
;
// remove temp added walls
for
(
auto
wall
:
TempAddedWalls
)
{
for
(
auto
platform
:
_platforms
)
{
auto
tracks
=
platform
.
second
->
tracks
;
room_id
=
platform
.
second
->
rid
;
subroom_id
=
platform
.
second
->
sid
;
for
(
auto
r
:
GetAllRooms
())
{
if
(
r
.
first
!=
room_id
)
continue
;
subroom
=
r
.
second
->
GetSubRoom
(
subroom_id
);
}
for
(
auto
track
:
tracks
)
{
auto
walls
=
track
.
second
;
...
...
@@ -510,8 +523,8 @@ bool Building::resetTempVectors()
{
if
(
trackWall
==
wall
)
{
auto
sub
=
platform
.
second
->
sub
;
sub
->
RemoveWall
(
wall
);
std
::
cout
<<
"todo
\n
"
;
sub
room
->
RemoveWall
(
wall
);
}
}
}
...
...
@@ -523,17 +536,25 @@ bool Building::resetTempVectors()
for
(
auto
platform
:
_platforms
)
{
auto
tracks
=
platform
.
second
->
tracks
;
room_id
=
platform
.
second
->
rid
;
subroom_id
=
platform
.
second
->
sid
;
for
(
auto
r
:
GetAllRooms
())
{
if
(
r
.
first
!=
room_id
)
continue
;
subroom
=
r
.
second
->
GetSubRoom
(
subroom_id
);
}
for
(
auto
track
:
tracks
)
{
auto
walls
=
track
.
second
;
for
(
auto
trackWall
:
walls
)
{
if
(
trackWall
==
wall
)
{
auto
sub
=
platform
.
second
->
sub
;
sub
->
AddWall
(
wall
)
;
}
}
auto
walls
=
track
.
second
;
for
(
auto
trackWall
:
walls
)
{
if
(
trackWall
==
wall
)
{
subroom
->
AddWall
(
wall
)
;
std
::
cout
<<
"todo
\n
"
;
}
}
}
}
}
...
...
@@ -544,6 +565,14 @@ bool Building::resetTempVectors()
for
(
auto
platform
:
_platforms
)
{
auto
tracks
=
platform
.
second
->
tracks
;
room_id
=
platform
.
second
->
rid
;
subroom_id
=
platform
.
second
->
sid
;
for
(
auto
r
:
GetAllRooms
())
{
if
(
r
.
first
!=
room_id
)
continue
;
subroom
=
r
.
second
->
GetSubRoom
(
subroom_id
);
}
for
(
auto
track
:
tracks
)
{
auto
walls
=
track
.
second
;
...
...
@@ -551,8 +580,8 @@ bool Building::resetTempVectors()
{
if
(
trackWall
==
door
)
{
auto
sub
=
platform
.
second
->
sub
;
s
ub
->
RemoveTransition
(
&
door
)
;
subroom
->
RemoveTransition
(
&
door
)
;
s
td
::
cout
<<
"todo
\n
"
;
}
}
}
...
...
@@ -595,7 +624,7 @@ bool Building::InitPlatforms()
Platform
{
num_platform
,
room
->
GetID
(),
sub
Room
,
sub
room_id
,
tracks
,
});
AddPlatform
(
p
);
...
...
@@ -1094,6 +1123,7 @@ bool Building::AddCrossing(Crossing* line)
bool
Building
::
AddTransition
(
Transition
*
line
)
{
std
::
cout
<<
"building addtransition "
<<
line
->
GetID
()
<<
"
\n
"
;
if
(
_transitions
.
count
(
line
->
GetID
())
!=
0
)
{
char
tmp
[
CLENGTH
];
sprintf
(
tmp
,
...
...
@@ -1170,6 +1200,7 @@ const map<int, Crossing*>& Building::GetAllCrossings() const
const
map
<
int
,
Transition
*>&
Building
::
GetAllTransitions
()
const
{
// std::cout << "BUILDING " << _transitions.
return
_transitions
;
}
...
...
geometry/Building.h
View file @
8326d0f1
...
...
@@ -53,7 +53,7 @@ struct Platform
{
int
id
;
int
rid
;
SubRoom
*
sub
;
int
sid
;
std
::
map
<
int
,
std
::
vector
<
Wall
>
>
tracks
;
};
...
...
@@ -256,7 +256,7 @@ public:
const
std
::
map
<
int
,
std
::
shared_ptr
<
Platform
>
>&
GetPlatforms
()
const
;
const
std
::
vector
<
Wall
>
GetTrackWalls
(
Point
TrackStart
,
Point
TrackEnd
,
SubRoom
*
subroom
)
const
;
const
std
::
vector
<
Wall
>
GetTrackWalls
(
Point
TrackStart
,
Point
TrackEnd
,
int
&
room_id
,
int
&
subroom_id
)
const
;
const
std
::
vector
<
std
::
pair
<
PointWall
,
PointWall
>
>
GetIntersectionPoints
(
const
std
::
vector
<
Transition
>
doors
,
const
std
::
vector
<
Wall
>
)
const
;
// ------------------------------------
...
...
geometry/Crossing.cpp
View file @
8326d0f1
...
...
@@ -94,6 +94,8 @@ bool Crossing::IsClose() const
bool
Crossing
::
IsTempClose
()
const
{
std
::
cout
<<
"
\n
enter istempclose with "
<<
this
->
GetID
()
<<
"
\n
"
;
return
_state
==
DoorState
::
TEMP_CLOSE
;
}
...
...
@@ -334,9 +336,9 @@ DoorState Crossing::GetState() const
return
_state
;
}
void
Crossing
::
SetState
(
DoorState
_
state
)
void
Crossing
::
SetState
(
DoorState
state
)
{
Crossing
::
_state
=
_
state
;
Crossing
::
_state
=
state
;
}
std
::
string
Crossing
::
toString
()
const
...
...
@@ -355,6 +357,9 @@ std::string Crossing::toString() const
case
DoorState
::
TEMP_CLOSE
:
tmp
<<
" temp_close"
;
break
;
case
DoorState
::
Error
:
tmp
<<
" Error"
;
break
;
}
return
tmp
.
str
();
...
...
geometry/SubRoom.cpp
View file @
8326d0f1
...
...
@@ -260,6 +260,7 @@ bool SubRoom::RemoveTransition(Transition * t)
}
bool
SubRoom
::
AddTransition
(
Transition
*
line
)
{
std
::
cout
<<
"subroom addtransition "
<<
line
->
GetID
()
<<
", "
<<
line
->
GetUniqueID
()
<<
"
\n
"
;
_transitions
.
push_back
(
line
);
_goalIDs
.
push_back
(
line
->
GetUniqueID
());
return
true
;
...
...
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