Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
4294cf7d
Commit
4294cf7d
authored
May 16, 2020
by
Maxim Dudin
Browse files
#306
removed contact trajectories leaving only contact lines. painted peds in contact. changed icon
parent
fe9eb2c5
Pipeline
#256287
failed with stages
in 2 minutes and 58 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
VadereGui/resources/icons/contacts.png
View replaced file @
fe9eb2c5
View file @
4294cf7d
18.6 KB
|
W:
|
H:
10.4 KB
|
W:
|
H:
2-up
Swipe
Onion skin
VadereGui/src/org/vadere/gui/components/model/DefaultSimulationConfig.java
View file @
4294cf7d
...
...
@@ -31,7 +31,7 @@ public class DefaultSimulationConfig extends DefaultConfig {
private
boolean
showMeasurementArea
=
true
;
private
boolean
showStairs
=
true
;
private
boolean
showPedestrians
=
true
;
private
int
showContacts
=
0
;
private
boolean
showContacts
=
true
;
private
boolean
showWalkdirection
=
false
;
private
boolean
showTargetPotentialField
=
false
;
private
boolean
showTargetPotentielFieldMesh
=
false
;
...
...
@@ -103,11 +103,8 @@ public class DefaultSimulationConfig extends DefaultConfig {
return
showPedestrians
;
}
public
int
getShowContacts
()
{
return
showContacts
;
}
public
boolean
isShowContacts
()
{
return
showContacts
==
0
;
return
showContacts
;
}
...
...
@@ -129,7 +126,7 @@ public class DefaultSimulationConfig extends DefaultConfig {
setChanged
();
}
public
void
setShowContacts
(
int
showContacts
)
{
public
void
setShowContacts
(
boolean
showContacts
)
{
this
.
showContacts
=
showContacts
;
setChanged
();
}
...
...
VadereGui/src/org/vadere/gui/postvisualization/control/ActionOpenFile.java
View file @
4294cf7d
...
...
@@ -76,28 +76,13 @@ public class ActionOpenFile extends ActionVisualization {
Player
.
getInstance
(
model
).
stop
();
File
scenarioOutputDir
=
threadFile
.
isDirectory
()
?
threadFile
:
threadFile
.
getParentFile
();
File
[]
trajFiles
=
IOUtils
.
getFileList
(
scenarioOutputDir
,
IOUtils
.
TRAJECTORY_FILE_EXTENSION
);
Optional
<
File
>
trajectoryFile
=
Optional
.
empty
();
Optional
<
File
>
contactsTrajectoryFile
=
Optional
.
empty
();
for
(
File
f
:
trajFiles
)
{
if
(
f
.
getName
().
contains
(
"contacts"
))
{
contactsTrajectoryFile
=
Optional
.
of
(
f
);
}
else
{
trajectoryFile
=
Optional
.
of
(
f
);
}
}
//Optional<File> trajectoryFile =
// IOUtils.getFirstFile(scenarioOutputDir, IOUtils.TRAJECTORY_FILE_EXTENSION);
Optional
<
File
>
trajectoryFile
=
IOUtils
.
getFirstFile
(
scenarioOutputDir
,
IOUtils
.
TRAJECTORY_FILE_EXTENSION
);
Optional
<
File
>
snapshotFile
=
IOUtils
.
getFirstFile
(
scenarioOutputDir
,
IOUtils
.
SCENARIO_FILE_EXTENSION
);
if
(
trajectoryFile
.
isPresent
()
&&
snapshotFile
.
isPresent
())
{
Scenario
vadere
=
IOOutput
.
readScenario
(
snapshotFile
.
get
().
toPath
());
if
(
contactsTrajectoryFile
.
isPresent
())
{
model
.
init
(
IOOutput
.
readTrajectories
(
trajectoryFile
.
get
().
toPath
()),
IOOutput
.
readTrajectories
(
contactsTrajectoryFile
.
get
().
toPath
()),
vadere
,
contactsTrajectoryFile
.
get
().
getParent
());
}
else
{
model
.
init
(
IOOutput
.
readTrajectories
(
trajectoryFile
.
get
().
toPath
()),
vadere
,
trajectoryFile
.
get
().
getParent
());
}
model
.
init
(
IOOutput
.
readTrajectories
(
trajectoryFile
.
get
().
toPath
()),
vadere
,
trajectoryFile
.
get
().
getParent
());
model
.
notifyObservers
();
dialog
.
dispose
();
setLastDirectories
(
scenarioOutputDir
);
...
...
VadereGui/src/org/vadere/gui/postvisualization/view/PostvisualizationRenderer.java
View file @
4294cf7d
...
...
@@ -23,9 +23,6 @@ import tech.tablesaw.api.Table;
public
class
PostvisualizationRenderer
extends
SimulationRenderer
{
private
static
final
double
MIN_ARROW_LENGTH
=
0.1
;
private
static
final
boolean
SHOW_CONTACTS
=
true
;
private
static
final
boolean
CONTACT_LINES_INTEAD_OF_TRAJECTORIES
=
true
;
private
static
Logger
logger
=
Logger
.
getLogger
(
PostvisualizationRenderer
.
class
);
private
PostvisualizationModel
model
;
...
...
@@ -56,12 +53,8 @@ public class PostvisualizationRenderer extends SimulationRenderer {
private
void
renderPedestrians
(
final
Graphics2D
g
,
final
Color
color
)
{
if
(!
model
.
isEmpty
())
{
renderTrajectories
(
g
);
if
(
model
.
config
.
getShowContacts
()
!=
0
&&
model
.
getContactData
()
!=
null
)
{
if
(
model
.
config
.
getShowContacts
()
==
1
)
{
renderConnectingLinesByContact
(
g
);
}
else
if
(
model
.
config
.
getShowContacts
()
==
2
)
{
renderContactTrajectories
(
g
);
}
if
(
model
.
config
.
isShowContacts
()
&&
model
.
getContactData
()
!=
null
)
{
renderConnectingLinesByContact
(
g
);
}
}
}
...
...
@@ -79,42 +72,21 @@ public class PostvisualizationRenderer extends SimulationRenderer {
Table
pairs
=
model
.
getContactData
().
getPairsOfPedestriansInContactAt
(
model
.
getSimTimeInSec
());
for
(
Row
row:
pairs
)
{
VPoint
ped1Pos
=
pedPositions
.
get
(
row
.
getInt
(
0
));
VPoint
ped2Pos
=
pedPositions
.
get
(
row
.
getInt
(
1
));
int
id1
=
row
.
getInt
(
0
);
int
id2
=
row
.
getInt
(
1
);
VPoint
ped1Pos
=
pedPositions
.
get
(
id1
);
VPoint
ped2Pos
=
pedPositions
.
get
(
id2
);
Path2D
.
Double
path
=
new
Path2D
.
Double
();
path
.
moveTo
(
ped1Pos
.
x
,
ped1Pos
.
y
);
path
.
lineTo
(
ped2Pos
.
x
,
ped2Pos
.
y
);
draw
(
path
,
g
);
}
g
.
setStroke
(
stroke
);
g
.
setColor
(
color
);
}
private
void
renderContactTrajectories
(
Graphics2D
g
)
{
if
(!
model
.
config
.
isShowAllTrajectories
())
return
;
Color
color
=
g
.
getColor
();
Stroke
stroke
=
g
.
getStroke
();
g
.
setStroke
(
new
BasicStroke
(
getLineWidth
()
/
4.0f
));
g
.
setColor
(
Color
.
red
);
ContactData
contactData
=
model
.
getContactData
();
List
<
Table
>
trajectories
=
contactData
.
getTrajectoriesOfContactsUntil
(
model
.
getSimTimeInSec
());
Random
rand
=
new
Random
();
for
(
Table
trajectory:
trajectories
)
{
if
(
trajectory
.
column
(
0
).
size
()
!=
1
)
{
for
(
int
i
=
1
;
i
<
trajectory
.
column
(
0
).
size
();
i
++)
{
Path2D
.
Double
path
=
new
Path2D
.
Double
();
double
xPrev
=
Double
.
parseDouble
(
trajectory
.
getString
(
i
-
1
,
0
));
double
yPrev
=
Double
.
parseDouble
(
trajectory
.
getString
(
i
-
1
,
1
));
double
x
=
Double
.
parseDouble
(
trajectory
.
getString
(
i
,
0
));
double
y
=
Double
.
parseDouble
(
trajectory
.
getString
(
i
,
1
));
// draws noisy lines to emphasize the spots of prolonged contact without peds moving
path
.
moveTo
(
xPrev
+
rand
.
nextDouble
()
*
0.3
-
0.15
,
yPrev
+
rand
.
nextDouble
()
*
0.3
-
0.15
);
path
.
lineTo
(
x
+
rand
.
nextDouble
()
*
0.3
-
0.15
,
y
+
rand
.
nextDouble
()
*
0.3
-
0.15
);
draw
(
path
,
g
);
}
// paint agents in contact red
if
(
model
.
config
.
isShowPedestrians
())
{
agents
.
stream
().
filter
(
a
->
a
.
getId
()
==
id1
||
a
.
getId
()
==
id2
).
forEach
(
a
->
getAgentRender
().
render
(
a
,
Color
.
red
,
g
));
}
}
g
.
setStroke
(
stroke
);
g
.
setColor
(
color
);
}
...
...
VadereGui/src/org/vadere/gui/postvisualization/view/PostvisualizationWindow.java
View file @
4294cf7d
...
...
@@ -187,7 +187,7 @@ public class PostvisualizationWindow extends JPanel implements Observer, DropTar
model
)
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
model
.
config
.
setShowContacts
(
(
model
.
config
.
get
ShowContacts
()
+
1
)%
3
);
model
.
config
.
setShowContacts
(
!
model
.
config
.
is
ShowContacts
());
model
.
notifyObservers
();
}
...
...
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/datakey/PedestriansNearbyData.java
View file @
4294cf7d
package
org.vadere.simulator.projects.dataprocessing.datakey
;
import
org.vadere.state.scenario.DynamicElement
;
import
org.vadere.util.geometry.shapes.VPoint
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Random
;
public
class
PedestriansNearbyData
{
...
...
@@ -18,14 +15,6 @@ public class PedestriansNearbyData {
/*private PedestriansNearbyData() {
this.pedId1 = -1;
this.pedId2 = -1;
this.durationTimesteps = 1;
this.startTimestep = 1;
this.trajectory = new ArrayList<>();
}*/
public
int
getStartTimestep
()
{
return
startTimestep
;
}
...
...
@@ -68,30 +57,6 @@ public class PedestriansNearbyData {
public
String
[]
toStrings
(){
// printForPostVis is an ugly one time thing that shouldn't be merged
/*if (printForPostVis) {
StringBuilder ret = new StringBuilder();
List<VPoint> traj = getTrajectory();
for (int i = 0; i < traj.size(); i++) {
VPoint p = traj.get(i);
VPoint pNext;
if (i != traj.size() -1) {
pNext = traj.get(i + 1);
} else {
pNext = traj.get(i);
}
Random rand = new Random();
double r1 = rand.nextDouble();
r1 = r1*0.3 - 0.15;
double r2 = rand.nextDouble();
r2 = r2*0.3 - 0.15;
ret.append(hashCode()).append(" ").append(startTimestep*0.4 + i*0.4).append(" ").append(startTimestep*0.4 + (i+1)*0.4).append(" ").append(p.x + r2).append(" ").append(p.y + r1).append(" ").append(pNext.x + r1).append(" ").append(pNext.y + r2).append(" 9999");
if (i != traj.size() -1) {
ret.append("\r\n");
}
}
return new String[]{ret.toString()};
}*/
StringBuilder
ret
=
new
StringBuilder
();
List
<
VPoint
>
traj
=
getTrajectory
();
for
(
int
i
=
0
;
i
<
traj
.
size
();
i
++)
{
...
...
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/datakey/TimestepPedestriansNearbyIdKey.java
View file @
4294cf7d
...
...
@@ -24,7 +24,6 @@ public class TimestepPedestriansNearbyIdKey implements DataKey<TimestepPedestria
public
static
String
[]
getHeaders
(){
return
new
String
[]{
"startTimeStep"
,
"1stPedId"
,
"2ndPedId"
};
//return new String[]{"pedestrianId", "simTime"};
}
public
int
getTimeStep
()
{
...
...
@@ -40,11 +39,6 @@ public class TimestepPedestriansNearbyIdKey implements DataKey<TimestepPedestria
}
public
String
[]
toStrings
(){
// printForPostVis is an ugly one time thing that shouldn't be merged
/*if (printForPostVis) {
//return new String[]{Integer.toString(999), Double.toString(timeStep*0.4), Double.toString(timeStep*0.4 + 0.4)};
return new String[]{};
}*/
return
new
String
[]{
Integer
.
toString
(
timeStep
),
Integer
.
toString
(
pedId1
),
Integer
.
toString
(
pedId2
)};
}
...
...
@@ -92,7 +86,7 @@ public class TimestepPedestriansNearbyIdKey implements DataKey<TimestepPedestria
@Override
public
String
toString
()
{
return
"TimestepPedestrian
IdOverlap
Key{"
+
return
"TimestepPedestrian
sNearbyId
Key{"
+
"timeStep="
+
timeStep
+
", pedId1="
+
pedId1
+
", pedId2="
+
pedId2
+
...
...
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/PedestriansNearbyProcessor.java
View file @
4294cf7d
...
...
@@ -30,7 +30,6 @@ public class PedestriansNearbyProcessor extends DataProcessor<TimestepPedestrian
public
PedestriansNearbyProcessor
()
{
super
(
"durationTimesteps"
,
"xPath"
,
"yPath"
);
//super("endTime", "startX", "startY", "endX", "endY", "targetId");
setAttributes
(
new
AttributesPedestrianNearbyProcessor
());
}
...
...
@@ -52,8 +51,6 @@ public class PedestriansNearbyProcessor extends DataProcessor<TimestepPedestrian
.
map
(
p
->
{
double
xAverage
=
(
ped
.
getPosition
().
getX
()
+
p
.
getPosition
().
getX
())/
2
.;
double
yAverage
=
(
ped
.
getPosition
().
getY
()
+
p
.
getPosition
().
getY
())/
2
.;
//System.out.println("x1= " + ped.getPosition().getX() + "y1= " + ped.getPosition().getY() + "x2= " + p.getPosition().getX() + "y2= " + p.getPosition().getY() + "xAver= " + xAverage + "yAver= " + yAverage);
//System.out.println("x1= " + ped.getPosition().getX() + "y1= " + ped.getPosition().getY() + "x2= " + p.getPosition().getX() + "y2= " + p.getPosition().getY() + "xAver= " + xAverage + "yAver= " + yAverage);
VPoint
pointOfContact
=
new
VPoint
(
xAverage
,
yAverage
);
List
<
VPoint
>
trajectory
=
new
ArrayList
<>();
trajectory
.
add
(
pointOfContact
);
...
...
VadereSimulator/src/org/vadere/simulator/projects/io/IOOutput.java
View file @
4294cf7d
...
...
@@ -298,8 +298,8 @@ public abstract class IOOutput {
if
(
files
==
null
||
files
.
length
<
1
)
{
throw
new
IOException
(
"missing trajectory file with the extension "
+
fileExtension
);
//
} else if (files.length > 1) {
//
throw new IOException("multiply trajectory files with the extension " + fileExtension);
}
else
if
(
files
.
length
>
1
)
{
throw
new
IOException
(
"multiply trajectory files with the extension "
+
fileExtension
);
}
else
{
return
files
[
0
].
toPath
();
}
...
...
VadereSimulator/src/org/vadere/simulator/projects/io/TrajectoryReader.java
View file @
4294cf7d
...
...
@@ -42,7 +42,6 @@ public class TrajectoryReader {
dataFrame
=
Table
.
read
().
usingOptions
(
options
);
ColumnNames
columnNames
=
ColumnNames
.
getInstance
();
if
(
columnNames
.
hasDuplicates
(
dataFrame
))
{
//System.out.println("The header of table " + dataFrame + " is contains duplicates which can lead to unwanted side effects");
throw
new
IOException
(
"The header of table "
+
dataFrame
+
" is contains duplicates which can lead to unwanted side effects"
);
}
return
dataFrame
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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