Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
V
vadere
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
110
Issues
110
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
4
Merge Requests
4
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vadere
vadere
Commits
fabe52d0
Commit
fabe52d0
authored
Oct 30, 2018
by
Benedikt Zoennchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gui: one can now display the mesh on which the eikonal equation was solved.
parent
7cce3d9c
Pipeline
#73531
failed with stages
in 32 seconds
Changes
17
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
128 additions
and
204 deletions
+128
-204
VadereGui/resources/messages.properties
VadereGui/resources/messages.properties
+1
-0
VadereGui/resources/messages_de_DE.properties
VadereGui/resources/messages_de_DE.properties
+2
-0
VadereGui/src/org/vadere/gui/components/model/DefaultModel.java
...Gui/src/org/vadere/gui/components/model/DefaultModel.java
+0
-138
VadereGui/src/org/vadere/gui/components/model/IDefaultModel.java
...ui/src/org/vadere/gui/components/model/IDefaultModel.java
+0
-4
VadereGui/src/org/vadere/gui/components/view/DefaultRenderer.java
...i/src/org/vadere/gui/components/view/DefaultRenderer.java
+5
-2
VadereGui/src/org/vadere/gui/components/view/SimulationRenderer.java
...rc/org/vadere/gui/components/view/SimulationRenderer.java
+2
-2
VadereGui/src/org/vadere/gui/onlinevisualization/OnlineVisualization.java
...g/vadere/gui/onlinevisualization/OnlineVisualization.java
+4
-1
VadereGui/src/org/vadere/gui/onlinevisualization/control/ActionShowMesh.java
...adere/gui/onlinevisualization/control/ActionShowMesh.java
+28
-0
VadereGui/src/org/vadere/gui/onlinevisualization/model/OnlineVisualizationModel.java
...i/onlinevisualization/model/OnlineVisualizationModel.java
+2
-2
VadereGui/src/org/vadere/gui/onlinevisualization/view/OnlineVisualisationWindow.java
...i/onlinevisualization/view/OnlineVisualisationWindow.java
+6
-1
VadereGui/src/org/vadere/gui/postvisualization/model/PostvisualizationModel.java
...e/gui/postvisualization/model/PostvisualizationModel.java
+0
-4
VadereGui/src/org/vadere/gui/postvisualization/view/PostvisualizationWindow.java
...e/gui/postvisualization/view/PostvisualizationWindow.java
+0
-19
VadereMeshing/src/org/vadere/meshing/mesh/gen/MeshRenderer.java
...Meshing/src/org/vadere/meshing/mesh/gen/MeshRenderer.java
+44
-22
VadereSimulator/src/org/vadere/simulator/models/potential/fields/IPotentialField.java
...re/simulator/models/potential/fields/IPotentialField.java
+14
-6
VadereSimulator/src/org/vadere/simulator/models/potential/fields/PotentialFieldTargetRingExperiment.java
.../potential/fields/PotentialFieldTargetRingExperiment.java
+9
-1
VadereSimulator/src/org/vadere/simulator/models/potential/solver/calculators/cartesian/GridEikonalSolver.java
...ntial/solver/calculators/cartesian/GridEikonalSolver.java
+2
-1
VadereSimulator/src/org/vadere/simulator/models/queuing/PotentialFieldTargetQueuingGrid.java
...lator/models/queuing/PotentialFieldTargetQueuingGrid.java
+9
-1
No files found.
VadereGui/resources/messages.properties
View file @
fabe52d0
...
...
@@ -267,6 +267,7 @@ SettingsDialog.lblPedestrianNoTarget.text=Without Target (-1)
ProjectView.menuOpenFloorFieldFile.title
=
Add Floor Field File...
ProjectView.btnDrawVoronoiDiagram.tooltip
=
Draw and display a Voronoi Diagram
ProjectView.btnDrawMesh.tooltip
=
Draw and display a mesh
SettingsDialog.chbLogo.text
=
Show the Vadere logo
ProjectView.btnShowWalkingDirection.tooltip
=
Show the walking direction of all pedestrians
ProjectView.btnShowGroupInformation.tooltip
=
Draw pedestrians within one group with same shape and color
...
...
VadereGui/resources/messages_de_DE.properties
View file @
fabe52d0
...
...
@@ -273,6 +273,8 @@ ProjectView.btnShowDensity.tooltip=Dichte anzeigen
ProjectView.btnSettings.tooltip
=
Einstellungen
ProjectView.btnOk
=
OK
ProjectView.btnCancel
=
Abbrechen
ProjectView.btnDrawVoronoiDiagram.tooltip
=
Voronoi-Diagramm zeichnen und anzeigen
ProjectView.btnDrawMesh.tooltip
=
Mesh zeichnen und anzeigen
TopographyCreator.btnMergeObstacles.tooltip
=
Hindernisse zusammenf
\u
00fchren
TopographyCreator.btnMinimizeTopography.tooltip
=
Select Viewport area
...
...
VadereGui/src/org/vadere/gui/components/model/DefaultModel.java
View file @
fabe52d0
...
...
@@ -6,40 +6,17 @@ import org.apache.log4j.LogManager;
import
org.apache.log4j.Logger
;
import
org.vadere.gui.components.control.*
;
import
org.vadere.gui.components.view.ISelectScenarioElementListener
;
import
org.vadere.simulator.models.potential.fields.IPotentialField
;
import
org.vadere.simulator.models.potential.fields.PotentialFieldDistancesBruteForce
;
import
org.vadere.simulator.utils.TexGraphGenerator
;
import
org.vadere.state.attributes.models.AttributesFloorField
;
import
org.vadere.state.scenario.Obstacle
;
import
org.vadere.state.scenario.ScenarioElement
;
import
org.vadere.state.scenario.Topography
;
import
org.vadere.state.types.ScenarioElementType
;
import
org.vadere.util.geometry.shapes.VPoint
;
import
org.vadere.util.geometry.shapes.VRectangle
;
import
org.vadere.util.geometry.shapes.VShape
;
import
org.vadere.meshing.mesh.gen.PFace
;
import
org.vadere.meshing.mesh.gen.PHalfEdge
;
import
org.vadere.meshing.mesh.gen.PVertex
;
import
org.vadere.meshing.mesh.inter.IIncrementalTriangulation
;
import
org.vadere.util.geometry.shapes.IPoint
;
import
org.vadere.util.geometry.shapes.VPolygon
;
import
org.vadere.util.geometry.shapes.VTriangle
;
import
org.vadere.util.data.cellgrid.CellGrid
;
import
org.vadere.util.data.cellgrid.CellState
;
import
org.vadere.util.data.cellgrid.PathFindingTag
;
import
org.vadere.util.math.DistanceFunction
;
import
org.vadere.util.math.IDistanceFunction
;
import
org.vadere.meshing.mesh.triangulation.improver.eikmesh.EikMeshPoint
;
import
org.vadere.meshing.mesh.triangulation.improver.eikmesh.impl.PEikMesh
;
import
org.vadere.util.voronoi.VoronoiDiagram
;
import
java.awt.*
;
import
java.awt.geom.Rectangle2D
;
import
java.util.*
;
import
java.util.List
;
import
java.util.function.Function
;
import
java.util.function.Predicate
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
java.util.stream.StreamSupport
;
...
...
@@ -63,8 +40,6 @@ public abstract class DefaultModel<T extends DefaultConfig> extends Observable i
private
boolean
showVoroniDiagram
;
private
boolean
showTriangulation
;
private
VPoint
cursorWorldPosition
;
private
VPoint
startSelectionPoint
;
...
...
@@ -87,12 +62,6 @@ public abstract class DefaultModel<T extends DefaultConfig> extends Observable i
public
T
config
;
private
IIncrementalTriangulation
<
EikMeshPoint
,
PVertex
<
EikMeshPoint
>,
PHalfEdge
<
EikMeshPoint
>,
PFace
<
EikMeshPoint
>>
triangulation
;
private
Collection
<
VTriangle
>
triangles
;
protected
boolean
triangulationTriggered
=
false
;
public
DefaultModel
(
final
T
config
)
{
this
.
config
=
config
;
this
.
scaleFactor
=
50
;
...
...
@@ -101,13 +70,11 @@ public abstract class DefaultModel<T extends DefaultConfig> extends Observable i
this
.
cursorWorldPosition
=
VPoint
.
ZERO
;
this
.
selectScenarioElementListener
=
new
LinkedList
<>();
this
.
voronoiDiagram
=
null
;
this
.
showTriangulation
=
false
;
this
.
showVoroniDiagram
=
true
;
this
.
showSelection
=
false
;
this
.
mouseSelectionMode
=
new
DefaultSelectionMode
(
this
);
this
.
viewportChangeListeners
=
new
ArrayList
<>();
this
.
scaleChangeListeners
=
new
ArrayList
<>();
this
.
triangulation
=
null
;
}
@Override
...
...
@@ -192,10 +159,6 @@ public abstract class DefaultModel<T extends DefaultConfig> extends Observable i
}
}
public
boolean
isTriangulationVisible
()
{
return
showTriangulation
;
}
@Override
public
void
notifyScaleListeners
()
{
for
(
IScaleChangeListener
listener
:
scaleChangeListeners
)
{
...
...
@@ -385,18 +348,6 @@ public abstract class DefaultModel<T extends DefaultConfig> extends Observable i
setChanged
();
}
@Override
public
void
showTriangulation
()
{
showTriangulation
=
true
;
setChanged
();
}
@Override
public
void
hideTriangulation
()
{
showTriangulation
=
false
;
setChanged
();
}
@Override
public
void
showSelection
()
{
showSelection
=
true
;
...
...
@@ -543,95 +494,6 @@ public abstract class DefaultModel<T extends DefaultConfig> extends Observable i
return
config
;
}
/*
* returns the adaptive triangulation (see persson-2004 'A Simple Mesh Generator in MATLAB.')
*/
public
void
startTriangulation
()
{
if
(!
triangulationTriggered
)
{
triangulationTriggered
=
true
;
VRectangle
bound
=
new
VRectangle
(
getTopographyBound
());
Collection
<
Obstacle
>
obstacles
=
Topography
.
createObstacleBoundary
(
getTopography
());
obstacles
.
addAll
(
getTopography
().
getObstacles
());
List
<
VShape
>
shapes
=
obstacles
.
stream
().
map
(
obstacle
->
obstacle
.
getShape
()).
collect
(
Collectors
.
toList
());
IPotentialField
distanceField
=
new
PotentialFieldDistancesBruteForce
(
getTopography
().
getObstacles
().
stream
().
map
(
obs
->
obs
.
getShape
()).
collect
(
Collectors
.
toList
()),
new
VRectangle
(
getTopography
().
getBounds
()),
new
AttributesFloorField
());
Function
<
IPoint
,
Double
>
obstacleDistance
=
p
->
distanceField
.
getPotential
(
p
,
null
);
IDistanceFunction
distanceFunc
=
new
DistanceFunction
(
bound
,
shapes
);
CellGrid
cellGrid
=
new
CellGrid
(
bound
.
getWidth
(),
bound
.
getHeight
(),
0.1
,
new
CellState
(),
bound
.
getMinX
(),
bound
.
getMinY
());
cellGrid
.
pointStream
().
forEach
(
p
->
cellGrid
.
setValue
(
p
,
new
CellState
(
distanceFunc
.
apply
(
cellGrid
.
pointToCoord
(
p
)),
PathFindingTag
.
Reachable
)));
Function
<
IPoint
,
Double
>
interpolationFunction
=
cellGrid
.
getInterpolationFunction
();
IDistanceFunction
approxDistance
=
p
->
interpolationFunction
.
apply
(
p
);
/*PPSMeshing meshImprover = new PPSMeshing(
distanceFunc,
p -> Math.min(1.0 + Math.pow(Math.max(-distanceFunc.apply(p), 0)*0.8, 2), 6.0),
0.3,
bound, getTopography().getObstacles().stream().map(obs -> obs.getShape()).collect(Collectors.toList()));*/
PEikMesh
meshImprover
=
new
PEikMesh
(
distanceFunc
,
p
->
Math
.
min
(
1.0
+
Math
.
max
(
approxDistance
.
apply
(
p
)*
approxDistance
.
apply
(
p
),
0
)*
0.3
,
5.0
),
0.35
,
bound
,
getTopography
().
getObstacles
().
stream
().
map
(
obs
->
obs
.
getShape
()).
collect
(
Collectors
.
toList
()));
/*PPSMeshing meshImprover = new PPSMeshing(
distanceFunc,
p -> 1.0,
1.0,
bound, getTopography().getObstacles().stream().map(obs -> obs.getShape()).collect(Collectors.toList()));*/
triangulation
=
meshImprover
.
getTriangulation
();
Thread
t
=
new
Thread
(()
->
{
while
(!
meshImprover
.
isFinished
())
{
meshImprover
.
improve
();
/*try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}*/
setChanged
();
notifyObservers
();
}
//meshImprover.improve();
Function
<
PFace
<
EikMeshPoint
>,
Color
>
colorFunction
=
f
->
{
float
grayScale
=
(
float
)
meshImprover
.
faceToQuality
(
f
);
return
triangulation
.
isValid
(
f
)
?
new
Color
(
grayScale
,
grayScale
,
grayScale
)
:
Color
.
RED
;
};
log
.
info
(
TexGraphGenerator
.
toTikz
(
meshImprover
.
getMesh
(),
colorFunction
,
1.0f
));
log
.
info
(
"number of points = "
+
meshImprover
.
getMesh
().
getVertices
().
size
());
log
.
info
(
"number of triangle = "
+
meshImprover
.
getMesh
().
getFaces
().
size
());
log
.
info
(
"avg-quality = "
+
meshImprover
.
getQuality
());
log
.
info
(
"min-quality = "
+
meshImprover
.
getMinQuality
());
});
t
.
start
();
}
}
public
Collection
<
VTriangle
>
getTriangles
()
{
if
(
triangulation
==
null
)
{
return
Collections
.
EMPTY_LIST
;
}
synchronized
(
triangulation
.
getMesh
())
{
return
triangulation
.
streamTriangles
().
collect
(
Collectors
.
toList
());
}
}
public
Collection
<
VPolygon
>
getHoles
()
{
if
(
triangulation
==
null
)
{
return
Collections
.
EMPTY_LIST
;
}
synchronized
(
triangulation
.
getMesh
())
{
return
triangulation
.
getMesh
().
streamHoles
().
map
(
f
->
triangulation
.
getMesh
().
toPolygon
(
f
)).
collect
(
Collectors
.
toList
());
}
}
/*public void startTriangulation() {
if(!triangulationTriggered) {
triangulationTriggered = true;
...
...
VadereGui/src/org/vadere/gui/components/model/IDefaultModel.java
View file @
fabe52d0
...
...
@@ -297,9 +297,5 @@ public interface IDefaultModel<T extends DefaultConfig> extends Iterable<Scenari
*/
void
notifyObservers
(
final
Object
args
);
void
hideTriangulation
();
void
showTriangulation
();
T
getConfig
();
}
VadereGui/src/org/vadere/gui/components/view/DefaultRenderer.java
View file @
fabe52d0
...
...
@@ -596,9 +596,12 @@ public abstract class DefaultRenderer {
}
}
protected
void
renderMesh
(
final
Graphics2D
g
,
@NotNull
final
IMesh
<?
extends
IPotentialPoint
,
?,
?,
?>
mesh
,
final
int
width
,
final
int
height
)
{
protected
void
renderMesh
(
@NotNull
final
Graphics2D
g
,
@NotNull
final
IMesh
<?
extends
IPotentialPoint
,
?,
?,
?>
mesh
,
@NotNull
final
VRectangle
bound
)
{
MeshRenderer
<?
extends
IPotentialPoint
,
?,
?,
?>
meshRenderer
=
new
MeshRenderer
<>(
mesh
);
meshRenderer
.
render
(
g
,
width
,
height
);
meshRenderer
.
render
Graphics
(
g
,
bound
);
}
protected
void
renderVoronoiDiagram
(
final
Graphics2D
g
,
final
VoronoiDiagram
voronoiDiagram
)
{
...
...
VadereGui/src/org/vadere/gui/components/view/SimulationRenderer.java
View file @
fabe52d0
...
...
@@ -100,7 +100,7 @@ public abstract class SimulationRenderer extends DefaultRenderer {
}
if
(
model
.
config
.
isShowTargetPotentielFieldMesh
())
{
renderMesh
(
graphics
,
model
.
getDiscretization
(),
width
,
height
);
renderMesh
(
graphics
,
model
.
getDiscretization
(),
new
VRectangle
(
model
.
getTopographyBound
())
);
}
renderSimulationContent
(
graphics
);
...
...
@@ -181,7 +181,7 @@ public abstract class SimulationRenderer extends DefaultRenderer {
private
void
renderPotentialFieldOnViewport
(
final
Graphics2D
g
,
final
int
xPos
,
final
int
yPos
,
final
int
width
,
final
int
height
)
{
logger
.
info
(
"resolution = "
+
width
+
", "
+
height
);
//
logger.info("resolution = " + width + ", " + height);
/*
* This calculation we need since the viewport.y = 0 if the user scrolls to the bottom
*/
...
...
VadereGui/src/org/vadere/gui/onlinevisualization/OnlineVisualization.java
View file @
fabe52d0
...
...
@@ -128,8 +128,11 @@ public class OnlineVisualization implements PassiveCallback {
IPotentialField
pedPotentialField
=
null
;
Agent
selectedAgent
=
null
;
if
(
model
.
config
.
isShowPotentialField
()
&&
model
.
getSelectedElement
()
instanceof
Agent
&&
potentialField
!=
null
)
{
if
(
model
.
getSelectedElement
()
instanceof
Agent
)
{
selectedAgent
=
(
Agent
)
model
.
getSelectedElement
();
}
if
(
model
.
config
.
isShowPotentialField
()
&&
selectedAgent
!=
null
&&
potentialField
!=
null
)
{
pedPotentialField
=
IPotentialField
.
copyAgentField
(
potentialField
,
selectedAgent
,
new
VRectangle
(
model
.
getTopographyBound
()),
0.1
);
}
...
...
VadereGui/src/org/vadere/gui/onlinevisualization/control/ActionShowMesh.java
0 → 100644
View file @
fabe52d0
package
org.vadere.gui.onlinevisualization.control
;
import
org.apache.log4j.LogManager
;
import
org.apache.log4j.Logger
;
import
org.vadere.gui.components.control.simulation.ActionVisualization
;
import
org.vadere.gui.components.model.DefaultSimulationConfig
;
import
org.vadere.gui.components.model.SimulationModel
;
import
java.awt.event.ActionEvent
;
import
javax.swing.*
;
public
class
ActionShowMesh
extends
ActionVisualization
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
ActionShowMesh
.
class
);
public
ActionShowMesh
(
final
String
name
,
Icon
icon
,
final
SimulationModel
<?
extends
DefaultSimulationConfig
>
model
)
{
super
(
name
,
icon
,
model
);
}
@Override
public
void
actionPerformed
(
final
ActionEvent
e
)
{
model
.
config
.
setShowTargetPotentielFieldMesh
(!
model
.
config
.
isShowTargetPotentielFieldMesh
());
model
.
notifyObservers
();
super
.
actionPerformed
(
e
);
}
}
VadereGui/src/org/vadere/gui/onlinevisualization/model/OnlineVisualizationModel.java
View file @
fabe52d0
...
...
@@ -195,7 +195,7 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
public
Function
<
IPoint
,
Double
>
getPotentialField
()
{
Function
<
IPoint
,
Double
>
f
=
pos
->
0.0
;
if
(
potentialField
!=
null
&&
config
.
isShowPotentialField
()
&&
agent
.
equals
(
getSelectedElement
()))
{
if
(
agent
!=
null
&&
potentialField
!=
null
&&
config
.
isShowPotentialField
()
&&
agent
.
equals
(
getSelectedElement
()))
{
f
=
pos
->
potentialField
.
getPotential
(
pos
,
agent
);
}
else
if
(
potentialFieldTarget
!=
null
&&
config
.
isShowTargetPotentialField
())
{
...
...
@@ -210,7 +210,7 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
@Override
public
IMesh
<?
extends
IPotentialPoint
,
?,
?,
?>
getDiscretization
()
{
if
(
discretizations
!=
null
&&
config
.
isShowTargetPotentielFieldMesh
()
&&
agent
.
equals
(
getSelectedElement
()))
{
if
(
agent
!=
null
&&
discretizations
!=
null
&&
config
.
isShowTargetPotentielFieldMesh
()
&&
agent
.
equals
(
getSelectedElement
()))
{
return
discretizations
.
apply
(
agent
);
}
...
...
VadereGui/src/org/vadere/gui/onlinevisualization/view/OnlineVisualisationWindow.java
View file @
fabe52d0
...
...
@@ -17,6 +17,7 @@ import org.vadere.gui.components.control.simulation.ActionGeneratePNG;
import
org.vadere.gui.components.control.simulation.ActionGenerateSVG
;
import
org.vadere.gui.components.control.simulation.ActionGenerateTikz
;
import
org.vadere.gui.onlinevisualization.control.ActionOnlineVisMenu
;
import
org.vadere.gui.onlinevisualization.control.ActionShowMesh
;
import
org.vadere.gui.onlinevisualization.control.ActionShowPotentialField
;
import
org.vadere.gui.onlinevisualization.model.OnlineVisualizationModel
;
import
org.vadere.gui.components.control.simulation.ActionSwapSelectionMode
;
...
...
@@ -126,6 +127,9 @@ public class OnlineVisualisationWindow extends JPanel implements Observer {
AbstractAction
drawVoronoiDiagram
=
new
ActionSwapSelectionMode
(
"draw_voronoi_diagram"
,
resources
.
getIcon
(
"voronoi.png"
,
iconWidth
,
iconHeight
),
model
);
AbstractAction
drawMesh
=
new
ActionShowMesh
(
"draw_mesh"
,
resources
.
getIcon
(
"triangulation.png"
,
iconWidth
,
iconHeight
),
model
);
AbstractAction
paintGridAction
=
new
AbstractAction
(
"paintGridAction"
,
resources
.
getIcon
(
"grid.png"
,
iconWidth
,
iconHeight
))
{
...
...
@@ -204,7 +208,8 @@ public class OnlineVisualisationWindow extends JPanel implements Observer {
Messages
.
getString
(
"ProjectView.btnShowGroupInformation.tooltip"
));
SwingUtils
.
addActionToToolbar
(
toolbar
,
drawVoronoiDiagram
,
Messages
.
getString
(
"ProjectView.btnDrawVoronoiDiagram.tooltip"
));
SwingUtils
.
addActionToToolbar
(
toolbar
,
drawMesh
,
Messages
.
getString
(
"ProjectView.btnDrawMesh.tooltip"
));
toolbar
.
addSeparator
();
...
...
VadereGui/src/org/vadere/gui/postvisualization/model/PostvisualizationModel.java
View file @
fabe52d0
...
...
@@ -145,10 +145,6 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon
}
public
void
init
(
final
Scenario
vadere
,
final
String
projectPath
)
{
// avoid the long computation
this
.
hideTriangulation
();
this
.
triangulationTriggered
=
false
;
this
.
vadere
=
vadere
;
this
.
agentsByStep
=
new
HashMap
<>();
this
.
steps
=
new
ArrayList
<>();
...
...
VadereGui/src/org/vadere/gui/postvisualization/view/PostvisualizationWindow.java
View file @
fabe52d0
...
...
@@ -166,25 +166,6 @@ public class PostvisualizationWindow extends JPanel implements Observer {
},
"ProjectView.btnShowTrajectories.tooltip"
);
addActionToToolbar
(
toolbar
,
new
ActionVisualization
(
"show_triangulation"
,
resources
.
getIcon
(
"triangulation.png"
,
iconWidth
,
iconHeight
),
model
)
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
if
(
model
.
isTriangulationVisible
())
{
model
.
hideTriangulation
();
}
else
{
model
.
showTriangulation
();
}
model
.
notifyObservers
();
}
;
},
"View.btnShowTriangulation.tooltip"
);
addActionToToolbar
(
toolbar
,
new
ActionVisualization
(
"show_direction"
,
resources
.
getIcon
(
"walking_direction.png"
,
iconWidth
,
iconHeight
),
model
)
{
...
...
VadereMeshing/src/org/vadere/meshing/mesh/gen/MeshRenderer.java
View file @
fabe52d0
...
...
@@ -3,6 +3,7 @@ package org.vadere.meshing.mesh.gen;
import
org.apache.log4j.LogManager
;
import
org.apache.log4j.Logger
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.vadere.meshing.mesh.inter.IFace
;
import
org.vadere.meshing.mesh.inter.IHalfEdge
;
import
org.vadere.meshing.mesh.inter.IMesh
;
...
...
@@ -52,7 +53,7 @@ public class MeshRenderer<P extends IPoint, V extends IVertex<P>, E extends IHal
/**
* A function which decides by which color the face should be filled.
*/
private
Function
<
F
,
Color
>
colorFunction
;
@Nullable
private
Function
<
F
,
Color
>
colorFunction
;
/**
...
...
@@ -65,7 +66,7 @@ public class MeshRenderer<P extends IPoint, V extends IVertex<P>, E extends IHal
public
MeshRenderer
(
@NotNull
final
IMesh
<
P
,
V
,
E
,
F
>
mesh
,
@NotNull
final
Predicate
<
F
>
alertPred
,
@N
otNull
final
Function
<
F
,
Color
>
colorFunction
)
{
@N
ullable
final
Function
<
F
,
Color
>
colorFunction
)
{
this
.
mesh
=
mesh
;
this
.
alertPred
=
alertPred
;
this
.
faces
=
new
ArrayList
<>();
...
...
@@ -73,7 +74,7 @@ public class MeshRenderer<P extends IPoint, V extends IVertex<P>, E extends IHal
}
/**
* Construct a mesh
panel filling all faces with the color white
.
* Construct a mesh
renderer which will not fill the faces
.
*
* @param mesh the mesh which will be rendered
* @param alertPred a {@link Predicate} of {@link F} which marks a face to be drawn in a special way.
...
...
@@ -81,51 +82,53 @@ public class MeshRenderer<P extends IPoint, V extends IVertex<P>, E extends IHal
public
MeshRenderer
(
@NotNull
final
IMesh
<
P
,
V
,
E
,
F
>
mesh
,
@NotNull
final
Predicate
<
F
>
alertPred
)
{
this
(
mesh
,
alertPred
,
f
->
Color
.
WHITE
);
this
(
mesh
,
alertPred
,
null
);
}
/**
* Construct a mesh
panel filling all faces with the color white
.
* Construct a mesh
renderer which will not fill the faces
.
*
* @param mesh the mesh which will be rendered
*/
public
MeshRenderer
(
@NotNull
final
IMesh
<
P
,
V
,
E
,
F
>
mesh
)
{
this
(
mesh
,
f
->
false
,
f
->
Color
.
WHITE
);
this
(
mesh
,
f
->
false
,
null
);
}
public
void
render
(
final
Graphics2D
targetGraphics2D
,
final
int
width
,
final
int
height
)
{
public
void
render
(
@NotNull
final
Graphics2D
targetGraphics2D
,
final
int
width
,
final
int
height
)
{
render
(
targetGraphics2D
,
0
,
0
,
width
,
height
);
}
public
void
render
(
final
Graphics2D
targetGraphics2D
,
final
int
x
,
final
int
y
,
final
int
width
,
final
int
height
)
{
public
void
render
(
@NotNull
final
Graphics2D
targetGraphics2D
,
final
int
x
,
final
int
y
,
final
int
width
,
final
int
height
)
{
targetGraphics2D
.
drawImage
(
renderImage
(
width
,
height
),
x
,
y
,
null
);
targetGraphics2D
.
dispose
();
}
public
void
renderGraphics
(
final
Graphics2D
graphics
,
final
double
width
,
final
double
height
)
{
public
void
renderGraphics
(
@NotNull
final
Graphics2D
graphics
,
@NotNull
final
VRectangle
bound
)
{
renderGraphics
(
graphics
,
1.0
,
bound
);
}
VRectangle
bound
;
private
void
renderGraphics
(
@NotNull
final
Graphics2D
graphics
,
final
double
scale
,
@NotNull
final
VRectangle
bound
)
{
//graphics.setColor(Color.WHITE);
//graphics.fill(new VRectangle(0, 0, width, height));
/*Font currentFont = graphics.getFont();
Font newFont = currentFont.deriveFont(currentFont.getSize() * 0.064f);
graphics.setFont(newFont);
graphics.setColor(Color.GRAY);*/
Color
c
=
graphics
.
getColor
();
Stroke
stroke
=
graphics
.
getStroke
();
synchronized
(
mesh
)
{
faces
=
mesh
.
clone
().
getFaces
();
bound
=
mesh
.
getBound
();
}
double
scale
=
Math
.
min
(
width
/
bound
.
getWidth
(),
height
/
bound
.
getHeight
());
graphics
.
setColor
(
Color
.
WHITE
);
graphics
.
fill
(
new
VRectangle
(
0
,
0
,
width
,
height
));
Font
currentFont
=
graphics
.
getFont
();
Font
newFont
=
currentFont
.
deriveFont
(
currentFont
.
getSize
()
*
0.064f
);
graphics
.
setFont
(
newFont
);
graphics
.
setColor
(
Color
.
GRAY
);
graphics
.
translate
(-
bound
.
getMinX
()
*
scale
,
-
bound
.
getMinY
()
*
scale
);
graphics
.
scale
(
scale
,
scale
);
//graphics.translate(-bound.getMinX()+(0.5*Math.max(0, bound.getWidth()-bound.getHeight())), -bound.getMinY() + (bound.getHeight()-height / scale));
graphics
.
setStroke
(
new
BasicStroke
(
0.003f
));
graphics
.
setColor
(
Color
.
BLACK
);
graphics
.
setRenderingHint
(
RenderingHints
.
KEY_ANTIALIASING
,
RenderingHints
.
VALUE_ANTIALIAS_ON
);
//
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
/*int groupSize = 64;
...
...
@@ -133,8 +136,12 @@ public class MeshRenderer<P extends IPoint, V extends IVertex<P>, E extends IHal
for
(
F
face
:
faces
)
{
VPolygon
polygon
=
mesh
.
toTriangle
(
face
);
graphics
.
setColor
(
colorFunction
.
apply
(
face
));
graphics
.
fill
(
polygon
);
if
(
colorFunction
!=
null
)
{
graphics
.
setColor
(
colorFunction
.
apply
(
face
));
graphics
.
fill
(
polygon
);
}
if
(
alertPred
.
test
(
face
))
{
graphics
.
setColor
(
Color
.
RED
);
...
...
@@ -145,6 +152,21 @@ public class MeshRenderer<P extends IPoint, V extends IVertex<P>, E extends IHal
graphics
.
draw
(
polygon
);
}
}
graphics
.
setColor
(
c
);
graphics
.
setStroke
(
stroke
);
graphics
.
scale
(
1.0
/
scale
,
1.0
/
scale
);
graphics
.
translate
(
bound
.
getMinX
()
*
scale
,
bound
.
getMinY
()
*
scale
);
}
public
void
renderGraphics
(
@NotNull
final
Graphics2D
graphics
,
final
double
width
,
final
double
height
)
{
VRectangle
bound
;
synchronized
(
mesh
)
{
bound
=
mesh
.
getBound
();
}
double
scale
=
Math
.
min
(
width
/
bound
.
getWidth
(),
height
/
bound
.
getHeight
());
renderGraphics
(
graphics
,
scale
,
bound
);
}
public
BufferedImage
renderImage
(
final
int
width
,
final
int
height
)
{
...
...
VadereSimulator/src/org/vadere/simulator/models/potential/fields/IPotentialField.java
View file @
fabe52d0
...
...
@@ -2,6 +2,9 @@ package org.vadere.simulator.models.potential.fields;
import
org.apache.log4j.LogManager
;
import
org.apache.log4j.Logger
;
import
org.vadere.meshing.mesh.triangulation.IEdgeLengthFunction
;
import
org.vadere.meshing.mesh.triangulation.improver.eikmesh.gen.PEikMeshGen
;
import
org.vadere.simulator.models.potential.solver.calculators.mesh.PotentialPoint
;
import
org.vadere.simulator.models.potential.timeCostFunction.TimeCostFunctionFactory
;
import
org.vadere.state.attributes.models.AttributesFloorField
;
import
org.vadere.state.attributes.scenario.AttributesAgent
;
...
...
@@ -145,19 +148,20 @@ public interface IPotentialField {
Collection
<
VShape
>
holes
=
new
ArrayList
<>();
holes
.
addAll
(
topography
.
getObstacles
().
stream
().
map
(
obs
->
obs
.
getShape
()).
collect
(
Collectors
.
toList
()));
//
holes.addAll(topography.getTargets(targetId).stream().map(target -> target.getShape()).collect(Collectors.toList()));
holes
.
addAll
(
topography
.
getTargets
(
targetId
).
stream
().
map
(
target
->
target
.
getShape
()).
collect
(
Collectors
.
toList
()));
VRectangle
bbox
=
new
VRectangle
(
bounds
);
/**
* A default distance function which uses all shapes to compute the distance.
*/
IDistanceFunction
distanceFunc
=
new
DistanceFunction
(
bbox
,
holes
);
IEdgeLengthFunction
edgeLengthFunction
=
p
->
1.0
+
Math
.
max
(
0
,
-
distanceFunc
.
apply
(
p
));
/**
* Generate the mesh, we use the pointer based implementation here.
*/
PEikMesh
meshGenerator
=
new
PEikMesh
(
distanceFunc
,
p
->
1.0
,
3.0
,
bbox
,
holes
);
meshGenerator
.
generate
();
PEikMesh
Gen
<
PotentialPoint
>
meshGenerator
=
new
PEikMeshGen
<>(
distanceFunc
,
edgeLengthFunction
,
0.7
,
bbox
,
holes
,
(
x
,
y
)
->
new
PotentialPoint
(
x
,
y
)
);
IIncrementalTriangulation
<
PotentialPoint
,
PVertex
<
PotentialPoint
>,
PHalfEdge
<
PotentialPoint
>,
PFace
<
PotentialPoint
>>
triangulation
=
meshGenerator
.
generate
();
ITimeCostFunction
timeCost
=
TimeCostFunctionFactory
.
create
(
attributesPotential
.
getTimeCostAttributes
(),
...
...
@@ -167,9 +171,13 @@ public interface IPotentialField {
//TODO [refactoring]: this attribute value is used in an not intuitive way, we should introduce an extra attribute value!
1.0
/
attributesPotential
.
getPotentialFieldResolution
());
IIncrementalTriangulation
<
EikMeshPoint
,
PVertex
<
EikMeshPoint
>,
PHalfEdge
<
EikMeshPoint
>,
PFace
<
EikMeshPoint
>>
triangulation
=
meshGenerator
.
getTriangulation
();