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
b4848f39
Commit
b4848f39
authored
Sep 11, 2015
by
Andrijana Brkic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored functions,added more descriptions in .h
parent
466520a1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
28 deletions
+27
-28
voronoi-boost/VoronoiPositionGenerator.cpp
voronoi-boost/VoronoiPositionGenerator.cpp
+16
-20
voronoi-boost/VoronoiPositionGenerator.h
voronoi-boost/VoronoiPositionGenerator.h
+11
-8
No files found.
voronoi-boost/VoronoiPositionGenerator.cpp
View file @
b4848f39
...
...
@@ -36,7 +36,7 @@ using boost::polygon::low;
using
boost
::
polygon
::
high
;
//wrapping the boost objects
//wrapping the boost objects
(just the point object)
namespace
boost
{
namespace
polygon
{
template
<
>
...
...
@@ -62,7 +62,6 @@ using namespace std;
//functions
//TODO: refactor the function
//radius as a parametar in ini file?
bool
IsEnoughInSubroom
(
SubRoom
*
subroom
,
Point
&
pt
,
double
radius
)
{
//TODO: code refactoring:
...
...
@@ -71,11 +70,11 @@ bool IsEnoughInSubroom( SubRoom* subroom, Point& pt, double radius )
return
false
;
for
(
const
auto
&
trans
:
subroom
->
GetAllTransitions
()
)
if
(
trans
->
DistTo
(
pt
)
<
radius
)
if
(
trans
->
DistTo
(
pt
)
<
radius
+
0.2
)
return
false
;
for
(
const
auto
&
cross
:
subroom
->
GetAllCrossings
()
)
if
(
cross
->
DistTo
(
pt
)
<
radius
)
if
(
cross
->
DistTo
(
pt
)
<
radius
+
0.2
)
return
false
;
return
true
;
...
...
@@ -94,16 +93,15 @@ bool ComputeBestPositionVoronoiBoost(AgentsSource* src, std::vector<Pedestrian*>
std
::
vector
<
Pedestrian
*>
peds_without_place
;
building
->
GetPedestrians
(
roomID
,
subroomID
,
existing_peds
);
double
radius
=
0.3
;
//radius of a person
if
(
existing_peds
.
size
())
radius
=
existing_peds
[
0
]
->
GetEllipse
().
GetBmax
();
double
radius
=
0.3
;
//radius of a person, 0.3 is just some number(needed for the fake_peds bellow), will be changed afterwards
SubRoom
*
subroom
=
building
->
GetRoom
(
roomID
)
->
GetSubRoom
(
subroomID
);
double
factor
=
100
;
//factor for conversion to integer for the boost voronoi
vector
<
Point
>
fake_peds
;
//the positions of "fake" pedestrians converted to int
std
::
vector
<
Point
>
fake_peds
;
Point
temp
(
0
,
0
);
//fake_peds will be the positions of "fake" pedestrians, multiplied by factor and converted to int
for
(
auto
vert
:
subroom
->
GetPolygon
()
)
//room vertices
{
const
Point
&
center_pos
=
subroom
->
GetCentroid
();
...
...
@@ -121,7 +119,7 @@ bool ComputeBestPositionVoronoiBoost(AgentsSource* src, std::vector<Pedestrian*>
for
(
iter_ped
=
peds
.
begin
();
iter_ped
!=
peds
.
end
();
)
{
Pedestrian
*
ped
=
(
*
iter_ped
);
radius
=
ped
->
GetEllipse
().
GetBmax
();
radius
=
ped
->
GetEllipse
().
GetBmax
();
//max radius of the curren pedestrian
if
(
existing_peds
.
size
()
==
0
)
{
...
...
@@ -164,7 +162,8 @@ bool ComputeBestPositionVoronoiBoost(AgentsSource* src, std::vector<Pedestrian*>
}
//0
else
else
//more than one pedestrian
{
std
::
vector
<
Point
>
discrete_positions
;
std
::
vector
<
Point
>
velocities_vector
;
...
...
@@ -173,23 +172,22 @@ bool ComputeBestPositionVoronoiBoost(AgentsSource* src, std::vector<Pedestrian*>
double
no
=
0
;
//points from double to integer
for
(
auto
&&
iter
=
existing_peds
.
begin
();
iter
!=
existing_peds
.
end
();
++
iter
)
for
(
const
auto
&
eped
:
existing_peds
)
{
const
Point
&
pos
=
(
*
iter
)
->
GetPos
();
const
Point
&
pos
=
eped
->
GetPos
();
temp
.
SetX
(
(
int
)(
pos
.
GetX
()
*
factor
)
);
temp
.
SetY
(
(
int
)(
pos
.
GetY
()
*
factor
)
);
discrete_positions
.
push_back
(
temp
);
velocities_vector
.
push_back
(
(
*
iter
)
->
GetV
()
);
velocities_vector
.
push_back
(
eped
->
GetV
()
);
//calculating the mean, using it for the fake pedestrians
v
=
v
+
(
*
iter
)
->
GetV
();
v
=
v
+
eped
->
GetV
();
no
++
;
}
v
=
v
/
no
;
//this is the mean of all velocities
//adding fake people to the voronoi diagram
//adding fake people to the vector for constructing voronoi diagram
for
(
unsigned
int
i
=
0
;
i
<
subroom
->
GetPolygon
().
size
();
i
++
)
{
discrete_positions
.
push_back
(
fake_peds
[
i
]
);
...
...
@@ -218,11 +216,9 @@ bool ComputeBestPositionVoronoiBoost(AgentsSource* src, std::vector<Pedestrian*>
else
{
//reject the pedestrian:
// remove from the initial vector since it should only contain the pedestrians that could
// find a place. Put in a different queue, they will be put back in the source.
return_value
=
false
;
peds_without_place
.
push_back
(
*
iter_ped
);
iter_ped
=
peds
.
erase
(
iter_ped
);
peds_without_place
.
push_back
(
*
iter_ped
);
//Put in a different queue, they will be put back in the source.
iter_ped
=
peds
.
erase
(
iter_ped
);
// remove from the initial vector since it should only contain the pedestrians that could find a place
}
/*else //try with the maximum distance, don't need this if already using the VoronoiBestVertexMax function
...
...
voronoi-boost/VoronoiPositionGenerator.h
View file @
b4848f39
...
...
@@ -29,7 +29,7 @@ class Pedestrian;
class
Point
;
/**
* Calculates if a point (which is inside the subroom) is far enough from the walls ( > radius of a person)
* Calculates if a point (which is inside the subroom) is far enough from the walls
, transitions, crossings
( > radius of a person)
* @param subroom
* @param pt
*/
...
...
@@ -45,11 +45,12 @@ class Point;
/**
* Position incoming pedestrian on the vertex with the greatest distance
* @param discrete_positions
* @param discrete_positions
, positions of existing pedestrians + fake pedestrians (but multiplied with the factor)
* @param vd
* @param subroom
* @param max_it
* @param max_dis
* @param max_it, after calling the function this will be the iterator of the best vertex
* @param max_dis, after calling the function this will be the (distance*factor)^2 where distance is the distance to the chosen vertex
* @param radius, radius of a person
*/
void
VoronoiBestVertexMax
(
const
std
::
vector
<
Point
>&
discrete_positions
,
const
voronoi_diagram
<
double
>&
vd
,
SubRoom
*
subroom
,
double
factor
,
voronoi_diagram
<
double
>::
const_vertex_iterator
&
max_it
,
double
&
max_dis
,
double
radius
);
...
...
@@ -59,8 +60,9 @@ class Point;
* @param discrete_positions
* @param vd
* @param subroom
* @param max_it
* @param max_dis
* @param max_it, after calling the function this will be the iterator of the best vertex
* @param max_dis, after calling the function this will be the (distance*factor)^2 where distance is the distance to the chosen vertex
* @param radius, radius of a person
*/
void
VoronoiBestVertexRandMax
(
const
std
::
vector
<
Point
>&
discrete_positions
,
const
voronoi_diagram
<
double
>&
vd
,
SubRoom
*
subroom
,
double
factor
,
voronoi_diagram
<
double
>::
const_vertex_iterator
&
max_it
,
double
&
max_dis
,
double
radius
);
...
...
@@ -70,8 +72,9 @@ class Point;
* @param discrete_positions
* @param vd
* @param subroom
* @param max_it
* @param max_dis
* @param max_it, after calling the function this will be the iterator of the best vertex
* @param max_dis, after calling the function this will be the (distance*factor)^2 where distance is the distance to the chosen vertex
* @param radius, radius of a person
*/
void
VoronoiBestVertexRand
(
const
std
::
vector
<
Point
>&
discrete_positions
,
const
voronoi_diagram
<
double
>&
vd
,
SubRoom
*
subroom
,
double
factor
,
voronoi_diagram
<
double
>::
const_vertex_iterator
&
max_it
,
double
&
max_dis
,
double
radius
);
...
...
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