Commit c13aceec authored by Mario Teixeira Parente's avatar Mario Teixeira Parente
Browse files

Add FloorFieldProcessor

This floor field processor is independent of the discretization method and has a different output structure than the (old) floor field (grid) processor.
parent 9a67c708
......@@ -24,6 +24,10 @@
"type": "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepRowOutputFile",
"filename": "output_ts_row.txt",
"processors": [ 20 ]
}, {
"type": "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPositionOutputFile",
"filename": "output_ts_pos.txt",
"processors": [ 21 ]
} ],
"processors": [ {
"type": "org.vadere.simulator.projects.dataprocessing.processor.PedestrianPositionProcessor",
......@@ -171,6 +175,17 @@
"id": 19
}, {
"type": "org.vadere.simulator.projects.dataprocessing.processor.FloorFieldGridProcessor",
"id": 20
"id": 20,
"attributesType": "org.vadere.state.attributes.processor.AttributesFloorFieldProcessor",
"attributes": {
"targetId": 1
}
}, {
"type": "org.vadere.simulator.projects.dataprocessing.processor.FloorFieldProcessor",
"id": 21,
"attributesType": "org.vadere.state.attributes.processor.AttributesFloorFieldProcessor",
"attributes": {
"targetId": 1
}
} ]
}
package org.vadere.simulator.projects.dataprocessing.datakey;
import org.jetbrains.annotations.NotNull;
import org.vadere.util.geometry.shapes.VPoint;
/**
* @author Mario Teixeira Parente
*/
public class TimestepPositionKey implements DataKey<TimestepPositionKey> {
private int timeStep;
private VPoint position;
public TimestepPositionKey(int timeStep, VPoint position) {
this.timeStep = timeStep;
this.position = position;
}
public int getTimeStep() {
return this.timeStep;
}
public VPoint getPosition() {
return this.position;
}
@Override
public int compareTo(@NotNull TimestepPositionKey o) {
int result = Integer.compare(this.timeStep, o.timeStep);
if (result == 0) {
result = Double.compare(this.position.x, o.position.x);
if (result == 0) {
result = Double.compare(this.position.y, o.position.y);
}
}
return result;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TimestepPositionKey that = (TimestepPositionKey) o;
if (timeStep != that.timeStep) return false;
return position.equals(that.position);
}
@Override
public int hashCode() {
int result = timeStep;
result = 31 * result + position.hashCode();
return result;
}
public static String[] getHeaders() {
return new String[] { "timeStep", "x", "y" };
}
}
package org.vadere.simulator.projects.dataprocessing.outputfile;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepPositionKey;
public class TimestepPositionOutputFile extends OutputFile<TimestepPositionKey> {
public TimestepPositionOutputFile() {
super(TimestepPositionKey.getHeaders());
}
@Override
public String[] toStrings(TimestepPositionKey key) {
return new String[] { Integer.toString(key.getTimeStep()), Double.toString(key.getPosition().x), Double.toString(key.getPosition().y) };
}
}
......@@ -3,7 +3,7 @@ package org.vadere.simulator.projects.dataprocessing.processor;
import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepRowKey;
import org.vadere.state.attributes.processor.AttributesFloorFieldGridProcessor;
import org.vadere.state.attributes.processor.AttributesFloorFieldProcessor;
import org.vadere.util.data.FloorFieldGridRow;
public class FloorFieldGridProcessor extends DataProcessor<TimestepRowKey, FloorFieldGridRow> {
......@@ -19,7 +19,7 @@ public class FloorFieldGridProcessor extends DataProcessor<TimestepRowKey, Floor
@Override
public void init(ProcessorManager manager) {
AttributesFloorFieldGridProcessor att = (AttributesFloorFieldGridProcessor) this.getAttributes();
AttributesFloorFieldProcessor att = (AttributesFloorFieldProcessor) this.getAttributes();
this.targetId = att.getTargetId();
}
......
package org.vadere.simulator.projects.dataprocessing.processor;
import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepPositionKey;
import org.vadere.state.attributes.processor.AttributesFloorFieldProcessor;
import org.vadere.util.geometry.shapes.VPoint;
/**
* @author Mario Teixeira Parente
*/
public class FloorFieldProcessor extends DataProcessor<TimestepPositionKey, Double> {
private int targetId;
public FloorFieldProcessor() {
super("potential");
}
@Override
protected void doUpdate(SimulationState state) {
// First try, TODO: Implementation
for (int x = 0; x < 50; ++x) {
for (int y = 0; y < 50; ++y) {
this.setValue(new TimestepPositionKey(state.getStep(), new VPoint(x, y)), 0.0);
}
}
}
@Override
public void init(ProcessorManager manager) {
AttributesFloorFieldProcessor att = (AttributesFloorFieldProcessor) this.getAttributes();
this.targetId = att.getTargetId();
}
}
package org.vadere.state.attributes.processor;
public class AttributesFloorFieldGridProcessor extends AttributesProcessor {
public class AttributesFloorFieldProcessor extends AttributesProcessor {
private int targetId;
public int getTargetId() {
......
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