Commit 31b50e65 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

before richard wagner runtime measures.

parent 8516ef57
Pipeline #391801 passed with stages
in 123 minutes and 53 seconds
......@@ -54,21 +54,21 @@ public class ActionGenerateMesh extends AbstractAction {
MeshConstructor constructor = new MeshConstructor();
/*CompletableFuture.supplyAsync(
CompletableFuture.supplyAsync(
() -> constructor.pslgToAdaptivePMesh(pslg, hmin, hmax, true)).thenAccept(mesh -> saveFloorFieldMesh(mesh,""))
.exceptionally( ex -> {
ex.printStackTrace();
return null;
});*/
});
CompletableFuture.supplyAsync(
() -> constructor.pslgToAdaptivePMesh(pslg, hmin, hmax,true)).thenAccept(mesh -> saveFloorFieldMesh(mesh,""))
/*CompletableFuture.supplyAsync(
() -> constructor.pslgToUniformOptimalPMesh(pslg, hmin,true)).thenAccept(mesh -> saveFloorFieldMesh(mesh,""))
.exceptionally( ex -> {
ex.printStackTrace();
return null;
});
});*/
CompletableFuture.supplyAsync(
() -> constructor.pslgToCoarsePMesh(pslg, true)).thenAccept(mesh -> saveFloorFieldMesh(mesh,IOUtils.BACKGROUND_MESH_ENDING))
() -> constructor.pslgToCoarsePMesh(pslg, p -> Double.POSITIVE_INFINITY,true)).thenAccept(mesh -> saveFloorFieldMesh(mesh,IOUtils.BACKGROUND_MESH_ENDING))
.exceptionally( ex -> {
ex.printStackTrace();
return null;
......@@ -77,7 +77,7 @@ public class ActionGenerateMesh extends AbstractAction {
}
private void saveFloorFieldMesh(@NotNull final IMesh<PVertex, PHalfEdge, PFace> mesh, final String ending) {
logger.info("generate mesh");
logger.info("generate mesh (" + mesh.getMinEdgeLen() + ", " + mesh.getMaxEdgeLen() + ")");
File meshDir = new File(model.getCurrentProjectPath().concat("/" + IOUtils.SCENARIO_DIR + "/" + IOUtils.MESH_DIR));
File outputFile = new File(meshDir.getAbsoluteFile() + "/" + model.getCurrentScenario().getName() + ending + ".poly");
......
......@@ -143,11 +143,13 @@ public class OnlineVisualization implements PassiveCallback {
selectedAgent = (Agent)model.getSelectedElement();
}
if(model.config.isShowPotentialField() && selectedAgent != null && potentialField != null) {
/*if(model.config.isShowPotentialField() && selectedAgent != null && potentialField != null) {
pedPotentialField = IPotentialField.copyAgentField(potentialField, selectedAgent, new VRectangle(model.getTopographyBound()), 0.1);
}
}*/
//ObservationAreaSnapshotData data = new ObservationAreaSnapshotData(simTimeInSec, domain.clone(), pft, pedPotentialField, selectedAgent, discretizations);
ObservationAreaSnapshotData data = new ObservationAreaSnapshotData(simTimeInSec, domain, pft, pedPotentialField, selectedAgent, discretizations);
ObservationAreaSnapshotData data = new ObservationAreaSnapshotData(simTimeInSec, domain.clone(), pft, pedPotentialField, selectedAgent, discretizations);
model.pushObservationAreaSnapshot(data);
}
}
......
......@@ -40,7 +40,7 @@ public class EdgeLengthFunctionApprox implements IEdgeLengthFunction {
VRectangle bound = GeometryUtils.boundRelativeSquared(pslg.getSegmentBound().getPoints(), 0.3);
PSLG boundedPSLG = pslg.conclose(bound);
var ruppertsTriangulator = new PRuppertsTriangulator(boundedPSLG, circumRadiusFunc, 10, false);
var ruppertsTriangulator = new PRuppertsTriangulator(boundedPSLG, pslg, circumRadiusFunc, 10, false, false);
triangulation = ruppertsTriangulator.generate();
triangulation.enableCache();
......@@ -56,7 +56,7 @@ public class EdgeLengthFunctionApprox implements IEdgeLengthFunction {
if(!mesh.getBooleanData(mesh.getFace(e), "boundary")
|| !mesh.getBooleanData(mesh.getTwinFace(e), "boundary")) {
var u = triangulation.getMesh().getTwinVertex(e);
double len = v.distance(u) * (1.0 / (Math.sqrt(2)*4.0));
double len = v.distance(u) * (1.0 / (Math.sqrt(2) * 1.2/*4.0*/));
if(len < minEdgeLen) {
minEdgeLen = len;
}
......
......@@ -517,8 +517,8 @@ public class GenRegularRefinement<V extends IVertex, E extends IHalfEdge, F exte
boolean isGreen1 = !isBoundary1 && isGreen(getMesh().getFace(edge));
boolean isGreen2 = !isBoundary2 && isGreen(getMesh().getTwinFace(edge));
boolean isRed1 = isRed(getMesh().getFace(edge));
boolean isRed2 = isRed(getMesh().getTwinFace(edge));
// boolean isRed1 = isRed(getMesh().getFace(edge));
// boolean isRed2 = isRed(getMesh().getTwinFace(edge));
int level = getLevel(edge);
......
......@@ -32,6 +32,7 @@ import java.util.Set;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;
/**
* <p>Ruperts-Algorithm: not jet finished: Slow implementation!</p>
......@@ -54,6 +55,8 @@ public class GenRuppertsTriangulator<V extends IVertex, E extends IHalfEdge, F e
/**
* The (segment bounded) planar straight line graph which will be triangulated.
*/
private final PSLG pslgBound;
private final PSLG pslg;
/**
......@@ -135,11 +138,22 @@ public class GenRuppertsTriangulator<V extends IVertex, E extends IHalfEdge, F e
@NotNull Function<IPoint, Double> circumRadiusFunc,
final boolean createHoles,
final boolean allowSegmentFaces) {
this(meshSupplier, pslg, pslg, minAngle, circumRadiusFunc, createHoles, allowSegmentFaces);
}
public GenRuppertsTriangulator(
@NotNull final Supplier<IMesh<V, E, F>> meshSupplier,
@NotNull final PSLG pslgBound,
@NotNull final PSLG pslg,
final double minAngle,
@NotNull Function<IPoint, Double> circumRadiusFunc,
final boolean createHoles,
final boolean allowSegmentFaces) {
this.pslgBound = pslgBound;
this.pslg = pslg;
this.generated = false;
this.segments = new HashSet<>();
this.initialized = false;
this.generated = false;
this.minAngle = minAngle;
this.createHoles = createHoles;
this.allowSegmentFaces = allowSegmentFaces;
......@@ -151,7 +165,7 @@ public class GenRuppertsTriangulator<V extends IVertex, E extends IHalfEdge, F e
this.largeTriangleSet = new HashSet<>();
this.triangles = new HashMap<>();
this.qualities = new HashMap<>();
this.cdt = new GenConstrainedDelaunayTriangulator<>(meshSupplier, pslg, false);
this.cdt = new GenConstrainedDelaunayTriangulator<>(meshSupplier, pslgBound, false);
this.placementStrategy = new DelaunayPlacement<>(cdt.getMesh());
}
......@@ -235,7 +249,7 @@ public class GenRuppertsTriangulator<V extends IVertex, E extends IHalfEdge, F e
private void removeOutsideTriangles() {
// (1) remove triangles inside holes
for(VPolygon hole : pslg.getHoles()) {
for(VPolygon hole : pslgBound.getHoles()) {
Predicate<F> mergeCondition = f -> hole.contains(getMesh().toTriangle(f).midPoint());
Optional<F> optFace = getMesh().streamFaces(f -> !getMesh().isHole(f)).filter(mergeCondition).findAny();
if (optFace.isPresent()) {
......@@ -244,14 +258,14 @@ public class GenRuppertsTriangulator<V extends IVertex, E extends IHalfEdge, F e
}
// (2) remove triangles outside the boundary
if(pslg.getSegmentBound() != null) {
Predicate<F> mergeCondition = f -> !pslg.getSegmentBound().contains(getMesh().toTriangle(f).midPoint());
if(pslgBound.getSegmentBound() != null) {
Predicate<F> mergeCondition = f -> !pslgBound.getSegmentBound().contains(getMesh().toTriangle(f).midPoint());
triangulation.shrinkBorder(mergeCondition, true);
}
}
private void markOutsideTriangles() {
for(VPolygon hole : pslg.getHoles()) {
for(VPolygon hole : pslgBound.getHoles()) {
Predicate<F> markCondition = f -> !isMarked(f) && hole.contains(getMesh().toTriangle(f).midPoint());
Optional<F> optFace = getMesh().streamFaces(f -> !getMesh().isHole(f)).filter(markCondition).findAny();
if (optFace.isPresent()) {
......@@ -295,7 +309,29 @@ public class GenRuppertsTriangulator<V extends IVertex, E extends IHalfEdge, F e
refineSimplex2D();
} else if(!generated){
if(!allowSegmentFaces) {
split();
List<E> initialSegments = segments.stream().collect(Collectors.toList());
for (E segment : initialSegments) {
VLine line = getMesh().toLine(segment);
VLine smallest = null;
for (E edge : getMesh().getEdgeIt(getMesh().getVertex(segment))) {
VLine nLine = getMesh().toLine(edge);
if(smallest == null || smallest.length() > nLine.length()) {
smallest = nLine;
}
}
for (E edge : getMesh().getEdgeIt(getMesh().getTwinVertex(segment))) {
VLine nLine = getMesh().toLine(edge);
if(smallest == null || smallest.length() > nLine.length()) {
smallest = nLine;
}
}
if(smallest.length() < line.length() * 0.5) {
split(segment);
}
}
split();
}
generated = true;
} else {
......@@ -330,7 +366,7 @@ public class GenRuppertsTriangulator<V extends IVertex, E extends IHalfEdge, F e
private void addBadTriangle(@NotNull F face) {
VTriangle triangle = getMesh().toTriangle(face);
if(pslg.getSegmentBound().contains(triangle.midPoint())) {
if(pslgBound.getSegmentBound().contains(triangle.midPoint())) {
triangles.put(face, getMesh().toTriangle(face));
qualities.put(face, getTriangulation().faceToQuality(face));
if(!badTriangleSet.contains(face)) {
......@@ -363,7 +399,7 @@ public class GenRuppertsTriangulator<V extends IVertex, E extends IHalfEdge, F e
private void addLargeTriangle(@NotNull F face) {
VTriangle triangle = getMesh().toTriangle(face);
if(pslg.getSegmentBound().contains(triangle.midPoint())) {
if(pslgBound.getSegmentBound().contains(triangle.midPoint())) {
triangles.put(face, getMesh().toTriangle(face));
qualities.put(face, getTriangulation().faceToQuality(face));
if(!largeTriangleSet.contains(face)) {
......
......@@ -28,6 +28,15 @@ public class PRuppertsTriangulator extends GenRuppertsTriangulator<PVertex, PHal
super(() -> new PMesh(), pslg, minAngle, circumRadiusFunc, createHoles);
}
public PRuppertsTriangulator(
@NotNull final PSLG pslgBound,
@NotNull final PSLG pslg,
@NotNull final Function<IPoint, Double> circumRadiusFunc,
final double minAngle,
final boolean createHoles) {
this(pslgBound, pslg, circumRadiusFunc, minAngle, createHoles, true);
}
public PRuppertsTriangulator(
@NotNull final PSLG pslg,
@NotNull final Function<IPoint, Double> circumRadiusFunc,
......@@ -37,6 +46,17 @@ public class PRuppertsTriangulator extends GenRuppertsTriangulator<PVertex, PHal
super(() -> new PMesh(), pslg, minAngle, circumRadiusFunc, createHoles, allowSegmentFaces);
}
public PRuppertsTriangulator(
@NotNull final PSLG pslgBound,
@NotNull final PSLG pslg,
@NotNull final Function<IPoint, Double> circumRadiusFunc,
final double minAngle,
final boolean createHoles,
final boolean allowSegmentFaces) {
super(() -> new PMesh(), pslgBound, pslg, minAngle, circumRadiusFunc, createHoles, allowSegmentFaces);
}
public PRuppertsTriangulator(
@NotNull final PSLG pslg,
......
......@@ -17,6 +17,7 @@ import org.vadere.meshing.mesh.triangulation.improver.eikmesh.impl.PEikMesh;
import org.vadere.meshing.mesh.triangulation.triangulator.impl.PRuppertsTriangulator;
import org.vadere.meshing.utils.color.Colors;
import org.vadere.util.geometry.GeometryUtils;
import org.vadere.util.geometry.shapes.IPoint;
import org.vadere.util.geometry.shapes.VPolygon;
import org.vadere.util.geometry.shapes.VRectangle;
import org.vadere.util.logging.Logger;
......@@ -29,17 +30,17 @@ import java.util.function.Function;
public class MeshConstructor {
private static Logger logger = Logger.getLogger(MeshConstructor.class);
public IMesh<PVertex, PHalfEdge, PFace> pslgToCoarsePMesh(@NotNull final PSLG pslg, final boolean viszalize) {
public IMesh<PVertex, PHalfEdge, PFace> pslgToCoarsePMesh(@NotNull final PSLG pslg, final Function<IPoint, Double> circumRadiusFunc, final boolean viszalize) {
VRectangle bound = GeometryUtils.boundRelativeSquared(pslg.getSegmentBound().getPoints(), 0.3);
PSLG boundedPSLG = pslg.conclose(bound);
var ruppertsTriangulator = new PRuppertsTriangulator(boundedPSLG, p -> Double.POSITIVE_INFINITY, 10, false, false);
var ruppertsTriangulator = new PRuppertsTriangulator(boundedPSLG, pslg, circumRadiusFunc, 10, false, false);
IIncrementalTriangulation<PVertex, PHalfEdge, PFace> triangulation;
if(viszalize) {
var meshRenderer = new MeshRenderer<>(ruppertsTriangulator.getMesh(), f -> false, f -> Colors.YELLOW, e -> Color.BLACK, v -> Color.BLACK);
var meshPanel = new PMeshPanel(meshRenderer, 1024, 1024);
var meshPanel = new PMeshPanel(meshRenderer, 600, 600);
meshPanel.display("Ruppert's algorithm");
while(!ruppertsTriangulator.isFinished()) {
synchronized (ruppertsTriangulator.getMesh()) {
......@@ -257,4 +258,104 @@ public class MeshConstructor {
}
return meshImprover.getMesh();
}
public IMesh<PVertex, PHalfEdge, PFace> pslgToUniformOptimalPMesh(@NotNull final PSLG pslg, final double h0, final boolean viszalize) {
double smoothness = 0.2;
Collection<VPolygon> holes = pslg.getHoles();
VPolygon segmentBound = pslg.getSegmentBound();
IDistanceFunction distanceFunction = IDistanceFunction.create(segmentBound, holes);
logger.info("construct distance function");
IDistanceFunction distanceFunctionApproximation = new DistanceFunctionApproxBF(pslg, distanceFunction, () -> new PMesh());
((DistanceFunctionApproxBF) distanceFunctionApproximation).printPython();
//IEdgeLengthFunction circumRadiusFunc = p -> h0 / 2.0;
EdgeLengthFunctionApprox edgeLengthFunctionApprox = new EdgeLengthFunctionApprox(pslg, p -> Double.POSITIVE_INFINITY, p -> h0);
edgeLengthFunctionApprox.smooth(smoothness);
logger.info("construct element size function");
edgeLengthFunctionApprox.printPython();
//((DistanceFunctionApproxBF) distanceFunctionApproximation).printPython();
//edgeLengthFunctionApprox.printPython();
//edgeLengthFunctionApprox.printPython();
Collection<VPolygon> polygons = pslg.getAllPolygons();
//polygons.add(targetShape);
// (3) use EikMesh to improve the mesh
var meshImprover = new PEikMesh(
distanceFunctionApproximation,
edgeLengthFunctionApprox,
h0,
pslg.getBoundingBox(),
polygons
);
if(viszalize) {
Function<PVertex, Color> vertexColorFunction = v -> {
if(meshImprover.isSlidePoint(v)){
return Colors.BLUE;
} else if(meshImprover.isFixPoint(v)) {
return Colors.RED;
} else {
return Color.BLACK;
}
};
var meshRenderer = new MeshRenderer<>(meshImprover.getMesh(), f -> false, f -> Colors.YELLOW, e -> Color.BLACK, vertexColorFunction);
var meshPanel = new PMeshPanel(meshRenderer, 500, 500);
meshPanel.display("EikMesh h0 = " + h0);
/*try {
MovRecorder<PVertex, PHalfEdge, PFace> movRecorder = new MovRecorder<>(meshImprover, meshRenderer, 500, 500);
movRecorder.record();
movRecorder.finish();
} catch (IOException e) {
e.printStackTrace();
}*/
while (!meshImprover.isFinished()) {
synchronized (meshImprover.getMesh()) {
meshImprover.improve();
logger.info("quality = " + meshImprover.getQuality());
}
meshPanel.repaint();
}
logger.info("generation completed.");
/*BufferedWriter meshWriter = null;
try {
File dir = new File("/Users/bzoennchen/Development/workspaces/hmRepo/PersZoennchen/PhD/trash/generated/eikmesh/");
BufferedWriter bufferedWriterQualities1 = IOUtils.getWriter("qualities1_eik.csv", dir);
bufferedWriterQualities1.write("iteration quality\n");
BufferedWriter bufferedWriterQualities2 = IOUtils.getWriter("qualities2_eik.csv", dir);
bufferedWriterQualities2.write("iteration quality\n");
BufferedWriter bufferedWriterAngles = IOUtils.getWriter("angles_eik.csv", dir);
bufferedWriterAngles.write("iteration angle\n");
bufferedWriterQualities1.write(printQualities(200, meshImprover.getMesh(), f -> meshImprover.getTriangulation().faceToQuality(f)));
bufferedWriterQualities1.close();
bufferedWriterQualities2.write(printQualities(200, meshImprover.getMesh(), f -> meshImprover.getTriangulation().faceToLongestEdgeQuality(f)));
bufferedWriterQualities2.close();
bufferedWriterAngles.write(printAngles(200, meshImprover.getMesh()));
bufferedWriterAngles.close();
meshWriter = IOUtils.getWriter("kaiserslautern_mittel.tex", dir);
meshWriter.write(TexGraphGenerator.toTikz(meshImprover.getMesh(), f -> Colors.YELLOW, e -> Color.BLACK, vertexColorFunction, 1.0f, true));
meshWriter.close();
} catch (IOException e) {
e.printStackTrace();
}*/
} else {
meshImprover.generate();
}
return meshImprover.getMesh();
}
}
......@@ -41,48 +41,52 @@ public class UpdateSchemeEventDrivenParallel extends UpdateSchemeEventDriven {
private boolean[][] locked;
private double pedestrianPotentialWidth;
private int iteration = 0;
private ArrayList<ArrayList<Integer>> histgram;
private BufferedWriter bufferedWriter;
private double sideLength = -1;
public UpdateSchemeEventDrivenParallel(@NotNull final Topography topography, @NotNull final double pedestrianPotentialWidth) {
super(topography);
this.topography = topography;
this.pedestrianPotentialWidth = pedestrianPotentialWidth;
/*this.histgram = new ArrayList<>();
File dir = new File("/Users/bzoennchen/Development/workspaces/hmRepo/PersZoennchen/PhD/trash/generated/parallelOSM/");
try {
bufferedWriter = IOUtils.getWriter("histogram.csv", dir);
bufferedWriter.write("iteration round\n");
} catch (IOException e) {
e.printStackTrace();
}*/
}
}
@Override
public void update(final double timeStepInSec, final double currentTimeInSec) {
// histgram.add(new ArrayList<>());
// ArrayList<Integer> histo = histgram.get(iteration);
ArrayList<Integer> histUpdateable = new ArrayList<>();
topography.getElements(PedestrianOSM.class).parallelStream().forEach(pedestrianOSM -> pedestrianOSM.clearStrides());
double maxStepSize = topography.getElements(PedestrianOSM.class).parallelStream().mapToDouble(ped -> ped.getDesiredStepSize()).max().orElse(0);
double maxDesiredSpeed = topography.getElements(PedestrianOSM.class).parallelStream().mapToDouble(ped -> ped.getDesiredSpeed()).max().orElse(0);
if(sideLength <= 0) {
double maxStepSize = topography.getElements(PedestrianOSM.class).parallelStream().mapToDouble(ped -> ped.getDesiredStepSize()).max().orElse(0);
double maxDesiredSpeed = topography.getElements(PedestrianOSM.class).parallelStream().mapToDouble(ped -> ped.getDesiredSpeed()).max().orElse(0);
double stepSize = Math.max(maxStepSize, maxDesiredSpeed * timeStepInSec);
//double sideLength = (stepSize+pedestrianPotentialWidth) * 2.0;
double sideLength = (stepSize+pedestrianPotentialWidth) * 2.0 * 0.4;
//logger.debug("initial grid with a grid edge length equal to " + sideLength);
//double stepSize = Math.max(maxStepSize, maxDesiredSpeed * timeStepInSec);
//double sideLength = (stepSize+pedestrianPotentialWidth) * 2.0;
double stepSize = maxStepSize;
sideLength = (2.0*stepSize+pedestrianPotentialWidth); ;
//logger.debug("initial grid with a grid edge length equal to " + sideLength);
}
for(PedestrianOSM ped : pedestrianEventsQueue) {
ped.updateCount = -1;
}
int nCells = 0;
int counter = 1;
// event driven update ignores time credits
do {
linkedCellsGrid = new LinkedCellsGrid<>(new VRectangle(topography.getBounds()), sideLength);
locked = new boolean[linkedCellsGrid.getGridWidth()][linkedCellsGrid.getGridHeight()];
nCells = linkedCellsGrid.getGridWidth() * linkedCellsGrid.getGridHeight();
List<PedestrianOSM> updateAbleAgents = new LinkedList<>();
List<PedestrianOSM> notUpdateAbleAgents = new LinkedList<>();
......@@ -94,24 +98,24 @@ public class UpdateSchemeEventDrivenParallel extends UpdateSchemeEventDriven {
if(!locked[gridPos[0]][gridPos[1]]) {
updateAbleAgents.add(ped);
ped.updateCount = counter;
// lock neighbours
for(int y = -1; y <= 1; y++) {
for(int x = -1; x <= 1; x++) {
int col = Math.min(locked.length-1, Math.max(0, gridPos[0]+x));
int row = Math.min(locked[0].length-1, Math.max(0, gridPos[1]+y));
locked[col][row] = true;
}
}
} else {
notUpdateAbleAgents.add(ped);
ped.updateCount = -1;
}
// lock neighbours
for(int y = -1; y <= 1; y++) {
for(int x = -1; x <= 1; x++) {
int col = Math.min(locked.length-1, Math.max(0, gridPos[0]+x));
int row = Math.min(locked[0].length-1, Math.max(0, gridPos[1]+y));
locked[col][row] = true;
}
}
}
/*logger.debug("update " + updateAbleAgents.size() + " in parallel in round " + counter + ".");
histo.add(updateAbleAgents.size());
logger.debug("not updated " + notUpdateAbleAgents.size() + " " + counter + ".");*/
histUpdateable.add(updateAbleAgents.size());
//logger.debug("not updated " + notUpdateAbleAgents.size() + " " + counter + ".");
updateAbleAgents.parallelStream().forEach(ped -> {
//logger.info(ped.getTimeOfNextStep());
//System.out.println(ped.getId());
......@@ -123,11 +127,11 @@ public class UpdateSchemeEventDrivenParallel extends UpdateSchemeEventDriven {
counter++;
} while (!pedestrianEventsQueue.isEmpty() && pedestrianEventsQueue.peek().getTimeOfNextStep() < currentTimeInSec);
iteration++;
/*try {
logger.debug("rounds: " + counter + ", #peds: " + topography.getPedestrianDynamicElements().getElements().size() + ", cells: " + nCells + ", sideLen:" + sideLength);
try {
StringBuilder builder = new StringBuilder();
for(int round = 1; round <= histo.size(); round++) {
for(int i = 0; i < histo.get(round-1); i++) {
for(int round = 1; round <= histUpdateable.size(); round++) {
for(int i = 0; i < histUpdateable.get(round-1); i++) {
builder.append(iteration);
builder.append(" ");
builder.append(round);
......@@ -138,6 +142,6 @@ public class UpdateSchemeEventDrivenParallel extends UpdateSchemeEventDriven {
bufferedWriter.flush();
} catch (IOException e) {
e.printStackTrace();
}*/
}
}
}
......@@ -113,6 +113,11 @@ public class PedestrianRepulsionPotentialCycle implements
throw new UnsupportedOperationException();
}
@Override
public double getMaximalInfluenceRadius() {
return potentialFieldPedestrian.getMaximalInfluenceRadius();
}
@Override
public Collection<? extends Agent> getRelevantAgents(VCircle relevantArea,
Agent pedestrian, Topography scenario) {
......
......@@ -22,6 +22,7 @@ import org.vadere.simulator.models.potential.solver.timecost.ITimeCostFunctionMe
import org.vadere.util.geometry.GeometryUtils;
import org.vadere.util.geometry.shapes.IPoint;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VShape;
import org.vadere.util.geometry.shapes.VTriangle;
import org.vadere.util.math.IDistanceFunction;
import org.vadere.util.math.InterpolationUtil;
......@@ -123,6 +124,24 @@ public abstract class AMeshEikonalSolver<V extends IVertex, E extends IHalfEdge,
}
}
protected List<V> findInitialVertices(final Collection<VShape> targetShapes) {
//TODO a more clever init!
List<V> initialVertices = new ArrayList<>();
for(VShape shape : targetShapes) {
getMesh().streamVertices()
.filter(v -> shape.contains(getMesh().toPoint(v)))
.forEach(v -> {
for(V u : getMesh().getAdjacentVertexIt(v)) {
initialVertices.add(u);
setAsInitialVertex(u);
}
initialVertices.add(v);
setAsInitialVertex(v);
});
}
return initialVertices;
}
protected void unsolve() {
triangulation.getMesh().streamVerticesParallel().filter(v -> !isInitialVertex(v)).forEach(v -> {
setUndefined(v);
......
......@@ -105,7 +105,7 @@ public abstract class AMeshEikonalSolverFMM<V extends IVertex, E extends IHalfEd
*/
protected void updatePotentialOfNeighbours(@NotNull final V vertex) {