Commit c137a8c1 authored by Daniel Lehmberg's avatar Daniel Lehmberg

fix issue #64: abort simulation when pedestrian leaves topology bounds and assertions are enabled

parent 47bd1e8d
Pipeline #53505 passed with stage
in 44 seconds
......@@ -11,14 +11,13 @@ import org.vadere.simulator.projects.ScenarioStore;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.state.attributes.AttributesSimulation;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Source;
import org.vadere.state.scenario.Target;
import org.vadere.state.scenario.Topography;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.awt.geom.Rectangle2D;
import java.util.*;
public class Simulation {
......@@ -181,6 +180,7 @@ public class Simulation {
c.preUpdate(simTimeInSec);
}
assert assertAllPedestrianInBounds();
updateCallbacks(simTimeInSec);
updateWriters(simTimeInSec);
processorManager.update(this.simulationState);
......@@ -215,6 +215,12 @@ public class Simulation {
}
}
private boolean assertAllPedestrianInBounds() {
Rectangle2D.Double bounds = topography.getBounds();
Collection<Pedestrian> peds = topography.getElements(Pedestrian.class);
return peds.stream().map(ped -> ped.getPosition()).anyMatch(pos -> !bounds.contains(pos.getX(), pos.getY()));
}
private SimulationState initialSimulationState() {
SimulationState state =
new SimulationState(name, topography.clone(), scenarioStore, simTimeInSec, step, mainModel);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment