Commit 91c1015e authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

Merge branch 'master' into psychology

parents e9fa7143 b6749eab
Pipeline #225927 passed with stages
in 132 minutes and 9 seconds
......@@ -26,7 +26,6 @@ VadereGui/*.svg
VadereGui/*.mov
VadereGui/testResources/**/*.legacy
VadereUtils/testreports/*.txt
VadereSimulator/resources/current_commit_hash.txt
VadereSimulator/testResources/**/*.legacy
# Python (byte-compiled, optimized, DLL files etc.)
......
......@@ -6,6 +6,7 @@
### Added
- Added "--version" to "vadere-console.jar".
- Added a Vadere logo (a simple "V") as window and task bar icon to get rid of the lame default Java icon.
- Added "Psychology" tab in GUI which shows all psychology-related attributes of a scenario (which are stored in JSON node "attributesPsychology").
- Add `PedestrianPotentialProcessor` which writes out different potentials (TARGET (target potential), OBSTACLE (obstacle potential), PEDESTRIAN (agent potential), ALL (sum of all)) configureable via its `Attributes`. It only writes those potentials if the used main model for the simulation is a `PotentialFieldModel`.
......
......@@ -68,8 +68,9 @@ ProjectView.JSONDisplay.label=Nothing selected
ProjectView.btnAbout.tooltip=About
ProjectView.about.title=About
ProjectView.title=Vadere
ProjectView.version= Version {0}
ProjectView.license.text=This software is licensed under the {0}
ProjectView.version.release=Version
ProjectView.version.commit=Commit hash
ProjectView.license.text=License
ProjectView.aboutDialog.label=About Vadere
ProjectView.startDialog.label=Vadere GUI
ProjectView.startDialog.text=Create a new Project or load an existing project
......
......@@ -68,8 +68,9 @@ ProjectView.warning.lwjgl.title=Warnung
ProjectView.warning.opencl.title=Warnung
ProjectView.warning.opencl.text=OpenCL-Beschleunigung deaktiviert.\nEs konnte keine OpenCL Unterst\u00FCtzung gefunden werden.\nTreiber-Aktualisierung kann das Problem beheben.
ProjectView.title=Vadere
ProjectView.version= Version {0}
ProjectView.license.text=Dieses Software ist unter der {0} lizenziert
ProjectView.version.release=Version
ProjectView.version.commit=Commit-Hash
ProjectView.license.text=Lizenz
ProjectView.aboutDialog.label=\u00DCber Vadere
ProjectView.startDialog.label=Vadere GUI
ProjectView.startDialog.text=Erstellen oder laden Sie ein existierendes Projekt
......
......@@ -20,7 +20,7 @@ public class PostVisualisation {
ArgumentParser argumentParser = vadereArgumentParser.getArgumentParser();
try {
vadereArgumentParser.parseArgsAndProcessOptions(args);
vadereArgumentParser.parseArgsAndProcessInitialOptions(args);
} catch (UnsatisfiedLinkError linkError) {
System.err.println("[LWJGL]: " + linkError.getMessage());
} catch (ArgumentParserException e) {
......
......@@ -35,7 +35,7 @@ public class VadereApplication {
Namespace ns;
try {
ns = vadereArgumentParser.parseArgsAndProcessOptions(args);
ns = vadereArgumentParser.parseArgsAndProcessInitialOptions(args);
Messages.loadLanguageFromPreferences(VadereApplication.class);
ProjectView.start(ns.getString("project-path"));
} catch (UnsatisfiedLinkError linkError) {
......
......@@ -4,7 +4,7 @@ import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.projectview.model.ProjectViewModel;
import org.vadere.gui.projectview.view.ProjectView;
import org.vadere.gui.projectview.view.VDialogManager;
import org.vadere.simulator.entrypoints.Version;
import org.vadere.util.version.Version;
import org.vadere.simulator.projects.VadereProject;
import org.vadere.simulator.projects.io.IOVadere;
import org.vadere.simulator.projects.migration.MigrationOptions;
......
......@@ -4,7 +4,7 @@ import javax.swing.*;
import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.components.utils.Resources;
import org.vadere.simulator.entrypoints.Version;
import org.vadere.util.version.Version;
import java.awt.event.ActionEvent;
import java.text.MessageFormat;
......@@ -20,12 +20,17 @@ public class ActionShowAboutDialog extends AbstractAction {
@Override
public void actionPerformed(final ActionEvent event) {
String releaseVersion = String.format("%s: %s", Messages.getString("ProjectView.version.release"), Version.releaseNumber());
String versionControlInfo = String.format("%s: %s", Messages.getString("ProjectView.version.commit"), Version.getVersionControlCommitHash());
String license = String.format("%s: %s", Messages.getString("ProjectView.license.text"), "GNU Lesser General Public License (LGPL)");
String text = "";
text += "<html>";
text += "<font size =\"3\"><em>" + MessageFormat.format(Messages.getString("ProjectView.version"), Version.releaseNumber()) + "</em></font><br>";
text += "<font size =\"3\"><em>" + releaseVersion + "</em></font><br>";
text += "<font size =\"3\"><em>" + versionControlInfo + "</em></font><br>";
text += "<font size =\"3\"><em>" + license + "</em></font><br>";
text += "<br>";
text += "<font size =\"3\">www.vadere.org</font><br>";
text += "<font size =\"3\">" + MessageFormat.format(Messages.getString("ProjectView.license.text"), "GNU Lesser General Public License (<em>LGPL</em>).") + "</font>";
text += "<font size =\"3\">www.vadere.org</font>";
text += "</html>";
JOptionPane.showMessageDialog(null,
......
......@@ -1939,6 +1939,13 @@ public interface IMesh<V extends IVertex, E extends IHalfEdge, F extends IFace>
return result;
}
default String getMeshInformations() {
// here we divide the number of half-edges by 2 because each edge is represented by 2 half-edges
return "#vertices = " + getNumberOfVertices() +
", #edges = " + getNumberOfEdges() / 2 +
", #faces = " + getNumberOfFaces();
}
/**
* This method is for synchronizing resources if multiple threads are used.
* It tries to lock the vertex which might be uses to modify the mesh data structure
......
......@@ -48,29 +48,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>write-version-control-info-to-file</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<!-- Write a file with current version of Vadere to get reproducible simulations. -->
<configuration>
<executable>git</executable>
<arguments>
<argument>rev-parse</argument>
<argument>HEAD</argument>
</arguments>
<outputFile>resources/current_commit_hash.txt</outputFile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
......
......@@ -7,7 +7,7 @@ import net.sourceforge.argparse4j.inf.Namespace;
import net.sourceforge.argparse4j.inf.Subparser;
import net.sourceforge.argparse4j.inf.Subparsers;
import org.vadere.simulator.entrypoints.Version;
import org.vadere.util.version.Version;
import org.vadere.simulator.entrypoints.cmd.commands.MigrationSubCommand;
import org.vadere.simulator.entrypoints.cmd.commands.ProjectRunSubCommand;
import org.vadere.simulator.entrypoints.cmd.commands.ScenarioRunSubCommand;
......@@ -34,7 +34,7 @@ public class VadereConsole {
addSubCommandsToParser(argumentParser);
try {
Namespace ns = vadereArgumentParser.parseArgsAndProcessOptions(args);
Namespace ns = vadereArgumentParser.parseArgsAndProcessInitialOptions(args);
SubCommandRunner sRunner = ns.get("func");
StdOutErrLog.addStdOutErrToLog();
sRunner.run(ns, argumentParser);
......
......@@ -3,7 +3,7 @@ package org.vadere.simulator.entrypoints.cmd.commands;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.vadere.simulator.entrypoints.Version;
import org.vadere.util.version.Version;
import org.vadere.simulator.entrypoints.cmd.SubCommandRunner;
import org.vadere.simulator.projects.migration.jsontranformation.JsonMigrationAssistant;
import org.vadere.simulator.projects.migration.MigrationAssistant;
......
......@@ -5,7 +5,7 @@ import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.commons.lang3.tuple.Pair;
import org.vadere.simulator.entrypoints.ScenarioFactory;
import org.vadere.simulator.entrypoints.Version;
import org.vadere.util.version.Version;
import org.vadere.simulator.entrypoints.cmd.SubCommandRunner;
import org.vadere.simulator.models.potential.fields.IPotentialField;
import org.vadere.simulator.models.potential.fields.PotentialFieldDistancesBruteForce;
......@@ -38,8 +38,6 @@ public class UtilsSubCommand implements SubCommandRunner {
methods.put("getHash", Pair.of("[-i: file, -o: ignored]", this::getHash));
methods.put("binCache", Pair.of("[-i: file, -o: directory]",this::calculateBinCache));
methods.put("txtCache", Pair.of("[-i: file, -o: directory]",this::calculateTextCache));
methods.put("getVersion", Pair.of("returns version",this::getVersion));
methods.put("getCommitHash", Pair.of("returns commit hash",this::getCommitHash));
}
public String[] methodsString(){
......@@ -90,20 +88,6 @@ public class UtilsSubCommand implements SubCommandRunner {
calculateCache(ns, parser, CacheType.TXT_CACHE);
}
/**
* Returns the current version
*/
private void getVersion(Namespace ns, ArgumentParser parser) throws Exception{
System.out.println(Version.releaseNumber());
}
private void getCommitHash(Namespace ns, ArgumentParser parser) throws Exception{
System.out.println(Version.commitHash());
/* String filename = Resources.class.getResource("/current_commit_hash.txt").getFile();
String commit_hash = (new BufferedReader(new FileReader(filename))).readLine();
System.out.println(commit_hash); */
}
private void calculateBinCache(Namespace ns, ArgumentParser parser) throws Exception{
calculateCache(ns, parser, CacheType.BIN_CACHE);
}
......
package org.vadere.simulator.projects.dataprocessing.datakey;
import org.jetbrains.annotations.NotNull;
import org.vadere.simulator.projects.dataprocessing.outputfile.TimeGridOutputFile;
import java.util.Objects;
@OutputFileMap(outputFileClass = TimeGridOutputFile.class)
public class TimeGridKey implements DataKey<TimeGridKey> {
private final int timestep;
private final double x;
private final double y;
private final double size;
public TimeGridKey(int timestep, double x, double y, double size) {
this.timestep = timestep;
this.x = x;
this.y = y;
this.size = size;
}
public int getTimestep() {
return timestep;
}
public double getX() {
return x;
}
public double getY() {
return y;
}
public double getSize() {
return size;
}
public static String[] getHeaders() {
return new String[] { TimestepKey.getHeader(), "x", "y", "size"};
}
public String[] toStrings(){
return new String[]{Integer.toString(timestep), Double.toString(x), Double.toString(y), Double.toString(size)};
}
@Override
public int compareTo(@NotNull TimeGridKey other) {
int ret;
if ((ret = Integer.compare(timestep, other.timestep))==0){
if ((ret = Double.compare(x, other.x)) == 0){
if ((ret = Double.compare(y, other.y)) == 0){
if ((ret = Double.compare(size, other.size)) == 0){
return 0;
}
return ret;
}
return ret;
}
return ret;
}
return ret;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TimeGridKey that = (TimeGridKey) o;
return timestep == that.timestep &&
Double.compare(that.x, x) == 0 &&
Double.compare(that.y, y) == 0 &&
Double.compare(that.size, size) == 0;
}
@Override
public int hashCode() {
return Objects.hash(timestep, x, y, size);
}
}
package org.vadere.simulator.projects.dataprocessing.outputfile;
import org.vadere.annotation.factories.outputfiles.OutputFileClass;
import org.vadere.simulator.projects.dataprocessing.datakey.TimeGridKey;
@OutputFileClass(dataKeyMapping = TimeGridKey.class)
public class TimeGridOutputFile extends OutputFile<TimeGridKey> {
public TimeGridOutputFile(String... dataIndices) {
super(TimeGridKey.getHeaders());
}
public String[] toStrings(TimeGridKey key) {
return key.toStrings();
}
}
package org.vadere.simulator.projects.dataprocessing.processor;
import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.simulator.control.simulation.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.TimeGridKey;
import org.vadere.state.attributes.processor.AttributesAreaDensityGridCountingProcessor;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.util.geometry.LinkedCellsGrid;
@DataProcessorClass(label = "AreaDensityGridCountingProcessor")
public class AreaDensityGridCountingProcessor extends DataProcessor<TimeGridKey, Integer> {
public AreaDensityGridCountingProcessor() {
super("gridCount");
setAttributes(new AttributesAreaDensityGridCountingProcessor());
}
@Override
protected void doUpdate(SimulationState state) {
int step = state.getStep();
AttributesAreaDensityGridCountingProcessor attr = (AttributesAreaDensityGridCountingProcessor)getAttributes();
LinkedCellsGrid<Pedestrian> cellsElements = new LinkedCellsGrid<Pedestrian>(
state.getTopography().getBounds().x,
state.getTopography().getBounds().y,
state.getTopography().getBounds().width,
state.getTopography().getBounds().height,
attr.getCellSize());
state.getTopography().getPedestrianDynamicElements().getElements().forEach(cellsElements::addObject);
int[][] count = cellsElements.getCellObjectCount();
int pedCount;
for (int r = 0; r < count.length; r++) {
for (int c = 0; c < count[r].length; c++) {
pedCount = count[r][c];
this.putValue(new TimeGridKey(step,r*attr.getCellSize(),c*attr.getCellSize(), attr.getCellSize()), pedCount);
}
}
}
@Override
public void init(ProcessorManager manager) {
super.init(manager);
}
}
......@@ -25,7 +25,6 @@ public class MaxOverlapProcessor extends NoDataKeyProcessor<Double> {
public MaxOverlapProcessor() {
super("max_size_overlap");
setAttributes(new AttributesMaxOverlapProcessor());
}
@Override
......
......@@ -2,21 +2,46 @@ package org.vadere.simulator.projects.dataprocessing.processor;
import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
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.meshing.mesh.inter.IMesh;
import org.vadere.simulator.control.simulation.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepFaceIdKey;
import org.vadere.state.attributes.processor.AttributesMeshTimestepProcessor;
import org.vadere.state.attributes.processor.AttributesMeshDensityCountingProcessor;
import org.vadere.state.scenario.MeasurementArea;
import org.vadere.state.scenario.Pedestrian;
import java.util.Collection;
@DataProcessorClass()
public class MeshDensityCountingProcessor extends MeshTimestepDataProcessor<Integer>{
@DataProcessorClass(label = "MeshDensityCountingProcessor")
public class MeshDensityCountingProcessor extends DataProcessor<TimestepFaceIdKey, Integer> {
private final static String propertyNameNumberOfPedestrians = "numberOfPedestrians";
private MeshProcessor meshProcessor;
public MeshDensityCountingProcessor() {
super("meshDensityCounting");
setAttributes(new AttributesMeshTimestepProcessor());
setAttributes(new AttributesMeshDensityCountingProcessor());
}
@Override
public void init(ProcessorManager manager) {
super.init(manager);
this.meshProcessor = (MeshProcessor) manager.getProcessor(getAttributes().getMeshProcessorId());
}
private IMesh<PVertex, PHalfEdge, PFace> getMesh() {
return meshProcessor.getTriangulation().getMesh();
}
private MeasurementArea getMeasurementArea() {
return meshProcessor.getMeasurementArea();
}
private IIncrementalTriangulation<PVertex, PHalfEdge, PFace> getTriangulation() {
return meshProcessor.getTriangulation();
}
@Override
......@@ -48,4 +73,11 @@ public class MeshDensityCountingProcessor extends MeshTimestepDataProcessor<Inte
}
}
@Override
public AttributesMeshDensityCountingProcessor getAttributes() {
if(super.getAttributes() == null) {
setAttributes(new AttributesMeshDensityCountingProcessor());
}
return (AttributesMeshDensityCountingProcessor)super.getAttributes();
}
}
......@@ -2,7 +2,6 @@ package org.vadere.simulator.projects.dataprocessing.processor;
import org.jetbrains.annotations.NotNull;
import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.meshing.mesh.gen.IncrementalTriangulation;
import org.vadere.meshing.mesh.gen.MeshRenderer;
import org.vadere.meshing.mesh.gen.PFace;
import org.vadere.meshing.mesh.gen.PHalfEdge;
......@@ -12,60 +11,69 @@ import org.vadere.meshing.mesh.impl.PMeshPanel;
import org.vadere.meshing.mesh.inter.IIncrementalTriangulation;
import org.vadere.meshing.mesh.inter.IMesh;
import org.vadere.meshing.mesh.triangulation.improver.eikmesh.gen.GenEikMesh;
import org.vadere.meshing.utils.color.Colors;
import org.vadere.meshing.utils.io.poly.MeshPolyWriter;
import org.vadere.simulator.control.simulation.SimulationState;
import org.vadere.simulator.projects.SimulationResult;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepFaceIdKey;
import org.vadere.state.attributes.processor.AttributesMeshTimestepProcessor;
import org.vadere.simulator.projects.dataprocessing.datakey.NoDataKey;
import org.vadere.state.attributes.processor.AttributesMeshProcessor;
import org.vadere.state.scenario.MeasurementArea;
import org.vadere.util.geometry.GeometryUtils;
import org.vadere.util.geometry.shapes.VPolygon;
import org.vadere.util.geometry.shapes.VRectangle;
import org.vadere.util.math.DistanceFunction;
import java.awt.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.function.Function;
import java.util.function.Predicate;
/**
* @author Benedikt Zoennchen
*
* @param <V>
*/
@DataProcessorClass(label = "MeshTimestepDataProcessor")
public abstract class MeshTimestepDataProcessor<V> extends DataProcessor<TimestepFaceIdKey, V> {
@DataProcessorClass(label = "MeshProcessor")
public class MeshProcessor extends NoDataKeyProcessor<IMesh<PVertex, PHalfEdge, PFace>> {
private IMesh<PVertex, PHalfEdge, PFace> mesh;
private IIncrementalTriangulation<PVertex, PHalfEdge, PFace> triangulation;
private MeasurementArea measurementArea;
protected MeshTimestepDataProcessor(final String... headers) {
super(headers);
public MeshProcessor() {
super("mesh");
setAttributes(new AttributesMeshProcessor());
}
@Override
public void init(final ProcessorManager manager) {
public void init(ProcessorManager manager) {
super.init(manager);
AttributesMeshTimestepProcessor att = this.getAttributes();
AttributesMeshProcessor att = getAttributes();
this.measurementArea = manager.getMeasurementArea(att.getMeasurementAreaId(), false);
}
/*
@NotNull final IDistanceFunction distanceFunc,
@NotNull final IEdgeLengthFunction edgeLengthFunc,
@NotNull final Collection<? extends IPoint> fixPoints,
final double initialEdgeLen,
@NotNull final VRectangle bound,
@NotNull final Collection<? extends VShape> shapes,
@NotNull final IMeshSupplier<V, E, F> meshSupplier)
*/
public IIncrementalTriangulation<PVertex, PHalfEdge, PFace> getTriangulation() {
return triangulation;
}
public MeasurementArea getMeasurementArea() {
return measurementArea;
}
@Override
public void preLoop(@NotNull final SimulationState state) {
super.preLoop(state);
public void postLoopAddResultInfo(@NotNull final SimulationState state, @NotNull final SimulationResult result){
result.addData(getSimulationResultHeader(), getTriangulation().getMesh().getMeshInformations());
}
@Override
public String getSimulationResultHeader() {
return "mesh (" + getTriangulation().getMesh().hashCode() + ")";
}
@Override
public String[] toStrings(final NoDataKey key) {
MeshPolyWriter<PVertex, PHalfEdge, PFace> meshPolyWriter = new MeshPolyWriter<>();
return new String[] { this.hasValue(key) ? meshPolyWriter.to2DPoly(this.getValue(key)) : "NA" };
}
@Override
public void preLoop(SimulationState state) {
super.preLoop(state);
VPolygon measurementPolygon = measurementArea.asPolygon();
GenEikMesh<PVertex, PHalfEdge, PFace> meshImprover = new GenEikMesh(
......@@ -107,29 +115,22 @@ public abstract class MeshTimestepDataProcessor<V> extends DataProcessor<Timeste
triangulation = meshImprover.getTriangulation();
mesh = triangulation.getMesh();
this.putValue(NoDataKey.key() ,mesh);
var meshRenderer = new MeshRenderer<>(meshImprover.getMesh(), f -> false, f -> Color.WHITE, e -> Color.GRAY);
var meshPanel = new PMeshPanel(meshRenderer, 300, 300);
meshPanel.display();
//System.out.println(mesh.toPythonTriangulation(null));
}
public IMesh<PVertex, PHalfEdge, PFace> getMesh() {
return mesh;
}
public MeasurementArea getMeasurementArea() {
return this.measurementArea;
}
public IIncrementalTriangulation<PVertex, PHalfEdge, PFace> getTriangulation() {
return triangulation;
}
@Override
protected void doUpdate(@NotNull final SimulationState state) {}
@Override
public AttributesMeshTimestepProcessor getAttributes() {