Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
a8ea3976
Commit
a8ea3976
authored
Oct 17, 2018
by
Stefan Schuhbaeck
Browse files
Merge branch 'master' into messageSetup
parents
402295c4
9042126f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Tools/ContinuousIntegration/run_vadere_console_with_all_scenario_files.py
View file @
a8ea3976
...
...
@@ -34,7 +34,7 @@ def find_scenario_files(path="VadereModelTests", scenario_search_pattern = "*.sc
return
sorted
(
scenario_files
)
def
run_scenario_files_with_vadere_console
(
scenario_files
,
vadere_console
=
"Vadere
Gui
/target/vadere-console.jar"
,
scenario_timeout_in_sec
=
60
):
def
run_scenario_files_with_vadere_console
(
scenario_files
,
vadere_console
=
"Vadere
Simulator
/target/vadere-console.jar"
,
scenario_timeout_in_sec
=
60
):
output_dir
=
"output"
if
not
os
.
path
.
exists
(
output_dir
):
...
...
VadereGui/pom.xml
View file @
a8ea3976
...
...
@@ -73,25 +73,6 @@
<artifactId>
maven-assembly-plugin
</artifactId>
<version>
2.4
</version>
<executions>
<execution>
<id>
build-vadere-console
</id>
<!-- this is used for inheritance merges -->
<phase>
package
</phase>
<!-- bind to the packaging phase -->
<goals>
<goal>
single
</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>
org.vadere.simulator.entrypoints.cmd.VadereConsole
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>
jar-with-dependencies
</descriptorRef>
</descriptorRefs>
<finalName>
vadere-console
</finalName>
<appendAssemblyId>
false
</appendAssemblyId>
</configuration>
</execution>
<execution>
<id>
build-vadere
</id>
<!-- this is used for inheritance merges -->
<phase>
package
</phase>
<!-- bind to the packaging phase -->
...
...
VadereGui/src/org/vadere/gui/components/model/DefaultSimulationConfig.java
View file @
a8ea3976
...
...
@@ -72,6 +72,7 @@ public class DefaultSimulationConfig extends DefaultConfig {
public
void
setShowGroups
(
boolean
showGroups
)
{
this
.
showGroups
=
showGroups
;
setChanged
();
}
public
boolean
isShowLogo
()
{
...
...
VadereGui/src/org/vadere/gui/components/view/DefaultRenderer.java
View file @
a8ea3976
...
...
@@ -6,7 +6,10 @@ import org.vadere.state.scenario.Agent;
import
org.vadere.state.scenario.ScenarioElement
;
import
org.vadere.state.scenario.Stairs
;
import
org.vadere.util.geometry.Vector2D
;
import
org.vadere.util.geometry.shapes.VCircle
;
import
org.vadere.util.geometry.shapes.VLine
;
import
org.vadere.util.geometry.shapes.VPoint
;
import
org.vadere.util.geometry.shapes.VPolygon
;
import
org.vadere.util.geometry.shapes.VRectangle
;
import
org.vadere.util.math.MathUtil
;
import
org.vadere.util.potential.CellGrid
;
...
...
@@ -95,11 +98,11 @@ public abstract class DefaultRenderer {
protected
void
renderPostTransformation
(
final
Graphics2D
graphics2D
,
final
int
width
,
final
int
height
)
{
graphics2D
.
setColor
(
Color
.
WHITE
);
Rectangle2D
.
Double
topographyBound
=
defaultModel
.
getTopographyBound
();
graphics2D
.
fill
(
new
VRectangle
(
fill
(
new
VRectangle
(
topographyBound
.
getMinX
()
+
defaultModel
.
getBoundingBoxWidth
(),
topographyBound
.
getMinY
()
+
defaultModel
.
getBoundingBoxWidth
(),
(
defaultModel
.
getTopographyBound
().
getWidth
()
-
defaultModel
.
getBoundingBoxWidth
()
*
2
),
(
defaultModel
.
getTopographyBound
().
getHeight
()
-
defaultModel
.
getBoundingBoxWidth
()
*
2
)));
(
defaultModel
.
getTopographyBound
().
getHeight
()
-
defaultModel
.
getBoundingBoxWidth
()
*
2
))
,
graphics2D
);
}
...
...
@@ -107,6 +110,8 @@ public abstract class DefaultRenderer {
Rectangle2D
.
Double
topographyBound
=
defaultModel
.
getTopographyBound
();
mirrowHorizonzal
(
graphics2D
,
(
int
)
(
topographyBound
.
getHeight
()
*
defaultModel
.
getScaleFactor
()));
graphics2D
.
scale
(
defaultModel
.
getScaleFactor
(),
defaultModel
.
getScaleFactor
());
//graphics2D.translate(-topographyBound.getMinX(), -topographyBound.getMinY());
/*
...
...
@@ -126,12 +131,50 @@ public abstract class DefaultRenderer {
g
.
setColor
(
color
);
for
(
ScenarioElement
element
:
elements
)
{
g
.
fill
(
element
.
getShape
());
fill
(
element
.
getShape
()
,
g
);
}
g
.
setColor
(
tmpColor
);
}
public
static
void
fill
(
@NotNull
final
Shape
shape
,
@NotNull
final
Graphics2D
g
)
{
if
(
shape
instanceof
VCircle
)
{
g
.
fill
(
toPolygon
((
VCircle
)
shape
));
}
else
{
g
.
fill
(
shape
);
}
}
public
static
void
draw
(
@NotNull
final
Shape
shape
,
@NotNull
final
Graphics2D
g
)
{
if
(
shape
instanceof
VCircle
)
{
g
.
draw
(
toPolygon
((
VCircle
)
shape
));
}
else
{
g
.
draw
(
shape
);
}
}
private
static
VPolygon
toPolygon
(
final
VCircle
circle
)
{
int
n
=
15
;
double
alpha
=
2
*
Math
.
PI
/
n
;
VPoint
p
=
new
VPoint
(
0
,
circle
.
getRadius
());
Path2D
.
Double
path
=
new
Path2D
.
Double
();
VPoint
center
=
circle
.
getCenter
();
path
.
moveTo
(
center
.
x
+
p
.
x
,
center
.
y
+
p
.
y
);
for
(
int
i
=
1
;
i
<
n
;
i
++)
{
p
=
p
.
rotate
(
alpha
);
path
.
lineTo
(
center
.
x
+
p
.
x
,
center
.
y
+
p
.
y
);
///path.moveTo(pointList.get(i).x, pointList.get(i).y);
}
//path.closePath();
return
new
VPolygon
(
path
);
}
protected
void
renderStairs
(
final
Iterable
<
Stairs
>
stairs
,
final
Graphics2D
g
,
final
Color
color
){
for
(
Stairs
s
:
stairs
)
{
...
...
@@ -169,32 +212,32 @@ public abstract class DefaultRenderer {
final
Color
tmpColor
=
graphics
.
getColor
();
graphics
.
setColor
(
Color
.
black
);
graphics
.
fill
(
stairs
.
getShape
());
fill
(
stairs
.
getShape
()
,
graphics
);
Area
hatchArea
=
getStairShapeWithThreads
(
stairs
);
graphics
.
setColor
(
color
);
graphics
.
fill
(
hatchArea
);
fill
(
hatchArea
,
graphics
);
graphics
.
setColor
(
tmpColor
);
}
protected
void
renderFilledShape
(
ScenarioElement
element
,
final
Graphics2D
graphics
,
Color
color
){
final
Color
tmpColor
=
graphics
.
getColor
();
graphics
.
setColor
(
color
);
graphics
.
fill
(
element
.
getShape
());
fill
(
element
.
getShape
()
,
graphics
);
graphics
.
setColor
(
tmpColor
);
}
protected
void
renderSelectionShape
(
final
Graphics2D
graphics
)
{
graphics
.
setColor
(
defaultModel
.
getMouseSelectionMode
().
getSelectionColor
());
graphics
.
setStroke
(
new
BasicStroke
(
getSelectionBorderLineWid
h
t
()));
graphics
.
draw
(
defaultModel
.
getSelectionShape
());
graphics
.
setStroke
(
new
BasicStroke
(
getSelectionBorderLineWidt
h
()));
draw
(
defaultModel
.
getSelectionShape
()
,
graphics
);
}
protected
void
renderSelectionBorder
(
final
Graphics2D
graphics
)
{
graphics
.
setColor
(
Color
.
MAGENTA
);
graphics
.
setStroke
(
new
BasicStroke
(
getSelectedShapeBorderLineWidth
()));
graphics
.
draw
(
defaultModel
.
getSelectedElement
().
getShape
());
draw
(
defaultModel
.
getSelectedElement
().
getShape
()
,
graphics
);
}
protected
void
renderLogo
(
final
Graphics2D
graphics
,
double
scale
,
double
height
)
{
...
...
@@ -276,19 +319,18 @@ public abstract class DefaultRenderer {
defaultModel
.
getGridResolution
())
{
for
(
double
x
=
bound
.
getMinX
();
x
<=
bound
.
getMaxX
()
+
0.01
;
x
+=
defaultModel
.
getGridResolution
())
{
g
.
draw
(
new
Line2D
.
Double
(
x
-
defaultModel
.
getGridResolution
()
*
0.2
,
y
,
draw
(
new
Line2D
.
Double
(
x
-
defaultModel
.
getGridResolution
()
*
0.2
,
y
,
x
+
defaultModel
.
getGridResolution
()
*
0.2
,
y
));
g
.
draw
(
new
Line2D
.
Double
(
x
,
y
-
defaultModel
.
getGridResolution
()
*
0.2
,
x
,
*
0.2
,
y
),
g
);
draw
(
new
Line2D
.
Double
(
x
,
y
-
defaultModel
.
getGridResolution
()
*
0.2
,
x
,
y
+
defaultModel
.
getGridResolution
()
*
0.2
));
*
0.2
)
,
g
);
}
}
}
protected
float
getLineWidth
()
{
return
(
float
)
(
2
.0
/
defaultModel
.
getScaleFactor
());
return
(
float
)
(
1
.0
/
defaultModel
.
getScaleFactor
());
}
/*protected void paintPotentialField(final Graphics2D g, final Function<VPoint, Double> potentialField, final VRectangle bound) {
...
...
@@ -547,7 +589,7 @@ public abstract class DefaultRenderer {
}
/* Draw rectangle as pixel to image. */
g
.
fill
(
new
Rectangle2D
.
Double
(
coord
.
x
,
coord
.
y
,
pixToW
,
pixToW
));
fill
(
new
Rectangle2D
.
Double
(
coord
.
x
,
coord
.
y
,
pixToW
,
pixToW
)
,
g
);
}
}
}
...
...
@@ -579,8 +621,8 @@ public abstract class DefaultRenderer {
go
=
false
;
closed
=
true
;
}
else
{
g
.
draw
(
new
Line2D
.
Double
(
last
.
getOrigin
().
x
,
last
.
getOrigin
().
y
,
next
.
getOrigin
().
x
,
next
.
getOrigin
().
y
));
draw
(
new
Line2D
.
Double
(
last
.
getOrigin
().
x
,
last
.
getOrigin
().
y
,
next
.
getOrigin
().
x
,
next
.
getOrigin
().
y
)
,
g
);
if
(
next
==
outerComponent
)
{
go
=
false
;
...
...
@@ -600,8 +642,7 @@ public abstract class DefaultRenderer {
if
(
next
==
null
||
next
.
getOrigin
()
==
null
)
{
go
=
false
;
}
else
{
g
.
draw
(
new
Line2D
.
Double
(
last
.
getOrigin
().
x
,
last
.
getOrigin
().
y
,
next
.
getOrigin
().
x
,
next
.
getOrigin
().
y
));
draw
(
new
Line2D
.
Double
(
last
.
getOrigin
().
x
,
last
.
getOrigin
().
y
,
next
.
getOrigin
().
x
,
next
.
getOrigin
().
y
),
g
);
if
(
next
==
outerComponent
)
{
go
=
false
;
...
...
@@ -621,7 +662,7 @@ public abstract class DefaultRenderer {
return
getLineWidth
()
*
2
;
}
private
float
getSelectionBorderLineWid
h
t
()
{
private
float
getSelectionBorderLineWidt
h
()
{
return
getLineWidth
()
/
4
;
}
...
...
VadereGui/src/org/vadere/gui/components/view/SimulationRenderer.java
View file @
a8ea3976
...
...
@@ -140,7 +140,7 @@ public abstract class SimulationRenderer extends DefaultRenderer {
points
.
forEachOrdered
(
p
->
path
.
lineTo
(
p
.
getX
(),
p
.
getY
()));
g
.
draw
(
path
);
draw
(
path
,
g
);
g
.
setColor
(
color
);
// g.setStroke(stroke);
}
...
...
VadereGui/src/org/vadere/gui/renderer/agent/AgentRender.java
View file @
a8ea3976
...
...
@@ -4,11 +4,20 @@ import org.apache.log4j.LogManager;
import
org.apache.log4j.Logger
;
import
org.jetbrains.annotations.NotNull
;
import
org.vadere.gui.components.model.SimulationModel
;
import
org.vadere.gui.components.view.DefaultRenderer
;
import
org.vadere.state.scenario.Pedestrian
;
import
org.vadere.state.scenario.ScenarioElement
;
import
org.vadere.util.geometry.GeometryUtils
;
import
org.vadere.util.geometry.shapes.VCircle
;
import
org.vadere.util.geometry.shapes.VPoint
;
import
org.vadere.util.geometry.shapes.VPolygon
;
import
org.vadere.util.geometry.shapes.VShape
;
import
java.awt.*
;
import
java.awt.geom.Ellipse2D
;
import
java.awt.geom.Path2D
;
import
java.awt.geom.Rectangle2D
;
import
java.util.ArrayList
;
import
java.util.Random
;
import
java.util.concurrent.ConcurrentHashMap
;
...
...
@@ -23,7 +32,7 @@ public class AgentRender implements Renderer {
private
final
Color
defaultColor
;
private
ConcurrentHashMap
<
Integer
,
Color
>
colorMap
;
public
AgentRender
(
SimulationModel
model
)
{
public
AgentRender
(
@NotNull
final
SimulationModel
model
)
{
this
.
model
=
model
;
this
.
defaultColor
=
model
.
config
.
getPedestrianDefaultColor
();
this
.
colorMap
=
new
ConcurrentHashMap
<>();
...
...
@@ -51,12 +60,21 @@ public class AgentRender implements Renderer {
private
void
renderGroup
(
Pedestrian
ped
,
Graphics2D
g
)
{
g
.
setColor
(
getGroupColor
(
ped
));
g
.
fill
(
getShape
(
ped
));
DefaultRenderer
.
fill
(
getShape
(
ped
)
,
g
);
}
private
void
renderDefault
(
final
ScenarioElement
element
,
Graphics2D
g
,
Color
c
)
{
g
.
setColor
(
c
);
g
.
fill
(
element
.
getShape
());
/*VCircle circle = (VCircle) element.getShape();
Pedestrian ped = (Pedestrian) element;
Ellipse2D.Float ellipse = new Ellipse2D.Float((float)ped.getPosition().x, (float)ped.getPosition().y, (float)ped.getRadius() * 2, (float)ped.getRadius() * 2);
Rectangle2D.Double rect = new Rectangle2D.Double(ped.getPosition().x, ped.getPosition().y, ped.getRadius() * 2, ped.getRadius() * 2);*/
//g.fill(new VCircle(ped.getPosition(), ped.getRadius()));
DefaultRenderer
.
fill
(
element
.
getShape
(),
g
);
//g.draw(ellipse);
//DefaultRenderer.fill(ellipse, g);
//g.fill(ellipse);
//g.fill(rect);
}
private
Color
getHSBColor
(
int
groupId
)
{
...
...
VadereGui/src/org/vadere/gui/topographycreator/view/TopographyCreatorRenderer.java
View file @
a8ea3976
...
...
@@ -60,7 +60,7 @@ public class TopographyCreatorRenderer extends DefaultRenderer {
if
(
panelModel
.
isPrototypeVisble
())
{
graphics
.
setColor
(
Color
.
GRAY
);
graphics
.
fill
(
panelModel
.
getPrototypeShape
());
fill
(
panelModel
.
getPrototypeShape
()
,
graphics
);
}
if
(
panelModel
.
isElementSelected
())
{
...
...
@@ -84,10 +84,8 @@ public class TopographyCreatorRenderer extends DefaultRenderer {
final
VPoint
cursorPosition
=
panelModel
.
getMousePosition
();
double
absolutCursorX
=
cursorPosition
.
x
;
double
absolutCursorY
=
cursorPosition
.
y
;
g
.
draw
(
new
Line2D
.
Double
(
absolutCursorX
-
resolution
*
0.2
,
absolutCursorY
,
absolutCursorX
+
resolution
*
0.2
,
absolutCursorY
));
g
.
draw
(
new
Line2D
.
Double
(
absolutCursorX
,
absolutCursorY
-
resolution
*
0.2
,
absolutCursorX
,
absolutCursorY
+
resolution
*
0.2
));
draw
(
new
Line2D
.
Double
(
absolutCursorX
-
resolution
*
0.2
,
absolutCursorY
,
absolutCursorX
+
resolution
*
0.2
,
absolutCursorY
),
g
);
draw
(
new
Line2D
.
Double
(
absolutCursorX
,
absolutCursorY
-
resolution
*
0.2
,
absolutCursorX
,
absolutCursorY
+
resolution
*
0.2
),
g
);
}
/*
...
...
VadereSimulator/pom.xml
View file @
a8ea3976
...
...
@@ -111,6 +111,35 @@
<skipTests>
${skip.unit.tests}
</skipTests>
</configuration>
</plugin>
<plugin>
<!-- NOTE: We don't need a groupId specification because the group is
org.apache.maven.plugins ...which is assumed by default.
-->
<artifactId>
maven-assembly-plugin
</artifactId>
<version>
2.4
</version>
<executions>
<execution>
<id>
build-vadere-console
</id>
<!-- this is used for inheritance merges -->
<phase>
package
</phase>
<!-- bind to the packaging phase -->
<goals>
<goal>
single
</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>
org.vadere.simulator.entrypoints.cmd.VadereConsole
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>
jar-with-dependencies
</descriptorRef>
</descriptorRefs>
<finalName>
vadere-console
</finalName>
<appendAssemblyId>
false
</appendAssemblyId>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
...
...
VadereSimulator/src/org/vadere/simulator/control/SingleSourceController.java
View file @
a8ea3976
...
...
@@ -117,8 +117,9 @@ public class SingleSourceController extends SourceController {
VPoint
randomPoint
=
new
VPoint
(
rec
.
getMinX
()
+
random
.
nextDouble
()
*
rec
.
getWidth
(),
rec
.
getMinY
()
+
random
.
nextDouble
()
*
rec
.
getHeight
());
VShape
freeSpaceRequired
=
dynamicElementFactory
.
getDynamicElementRequiredPlace
(
randomPoint
);
// no intersection with other free spaces.
if
(
blockPedestrianShapes
.
stream
().
noneMatch
(
shape
->
shape
.
intersects
(
freeSpaceRequired
)))
{
// no intersection with other free spaces (obstacles & other pedestrians)
if
(
blockPedestrianShapes
.
stream
().
noneMatch
(
shape
->
shape
.
intersects
(
freeSpaceRequired
))
&&
this
.
getTopography
().
getObstacles
().
stream
().
noneMatch
(
obs
->
obs
.
getShape
().
intersects
(
freeSpaceRequired
)))
{
return
Optional
.
of
(
randomPoint
);
}
}
...
...
VadereSimulator/src/org/vadere/simulator/control/SourceController.java
View file @
a8ea3976
...
...
@@ -26,10 +26,11 @@ import java.util.Random;
public
abstract
class
SourceController
{
protected
final
double
NO_EVENT
=
Double
.
MAX_VALUE
;
public
static
final
double
SPAWN_BUFFER_SIZE
=
0.0
1
;
public
static
final
double
SPAWN_BUFFER_SIZE
=
0.0
3
;
protected
final
Source
source
;
private
final
DynamicElementFactory
dynamicElementFactory
;
private
final
Topography
topography
;
protected
final
Random
random
;
...
...
@@ -111,6 +112,10 @@ public abstract class SourceController {
abstract
protected
void
determineNumberOfSpawnsAndNextEvent
(
double
simTimeInSec
);
protected
Topography
getTopography
()
{
return
topography
;
}
protected
void
createNextEvent
()
{
if
(
isSourceWithOneSingleSpawnEvent
())
{
timeOfNextEvent
=
NO_EVENT
;
...
...
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