Skip to content

Commit

Permalink
Rename Target to Output when referring to output formats
Browse files Browse the repository at this point in the history
  • Loading branch information
tordanik committed Feb 13, 2025
1 parent 6c68643 commit 7f6f904
Show file tree
Hide file tree
Showing 260 changed files with 1,219 additions and 1,212 deletions.
38 changes: 19 additions & 19 deletions core/src/main/java/org/osm2world/ConversionFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
import org.osm2world.osm.creation.OSMDataReader;
import org.osm2world.osm.creation.OSMFileReader;
import org.osm2world.osm.data.OSMData;
import org.osm2world.target.Target;
import org.osm2world.target.TargetUtil;
import org.osm2world.target.common.material.Materials;
import org.osm2world.target.common.model.Models;
import org.osm2world.output.Output;
import org.osm2world.output.OutputUtil;
import org.osm2world.output.common.material.Materials;
import org.osm2world.output.common.model.Models;
import org.osm2world.util.FaultTolerantIterationUtil;
import org.osm2world.util.functions.Factory;
import org.osm2world.world.attachment.AttachmentConnector;
Expand Down Expand Up @@ -167,12 +167,12 @@ public void setTerrainEleInterpolatorFactory(@Nullable Factory<? extends Terrain
* in the result; null to use a default module list
* @param config set of parameters that controls various aspects
* of the modules' behavior; null to use defaults
* @param targets receivers of the conversion results; can be null if
* @param outputs receivers of the conversion results; can be null if
* you want to handle the returned results yourself
*/
public Results createRepresentations(File osmFile,
@Nullable List<? extends WorldModule> worldModules, @Nullable O2WConfig config,
@Nullable List<? extends Target> targets)
@Nullable List<? extends Output> outputs)
throws IOException {

if (osmFile == null) {
Expand All @@ -181,7 +181,7 @@ public Results createRepresentations(File osmFile,

OSMData osmData = new OSMFileReader(osmFile).getAllData();

return createRepresentations(osmData, worldModules, config, targets);
return createRepresentations(osmData, worldModules, config, outputs);

}

Expand All @@ -197,12 +197,12 @@ public Results createRepresentations(File osmFile,
* in the result; null to use a default module list
* @param config set of parameters that controls various aspects
* of the modules' behavior; null to use defaults
* @param targets receivers of the conversion results; can be null if
* @param outputs receivers of the conversion results; can be null if
* you want to handle the returned results yourself
*/
public Results createRepresentations(OSMData osmData,
@Nullable List<? extends WorldModule> worldModules, @Nullable O2WConfig config,
@Nullable List<? extends Target> targets)
@Nullable List<? extends Output> outputs)
throws IOException {

/* check the inputs */
Expand Down Expand Up @@ -231,7 +231,7 @@ public Results createRepresentations(OSMData osmData,

/* perform the rest of the conversion */

return createRepresentations(mapProjection, mapData, worldModules, config, targets);
return createRepresentations(mapProjection, mapData, worldModules, config, outputs);

}

Expand All @@ -244,7 +244,7 @@ public Results createRepresentations(OSMData osmData,
*/
public Results createRepresentations(@Nullable MapProjection mapProjection, MapData mapData,
@Nullable List<? extends WorldModule> worldModules, @Nullable O2WConfig config,
@Nullable List<? extends Target> targets) {
@Nullable List<? extends Output> outputs) {

/* check the inputs */

Expand Down Expand Up @@ -292,19 +292,19 @@ public Results createRepresentations(@Nullable MapProjection mapProjection, MapD
attachConnectors(mapData);

/* convert 3d scene to target representation */
updatePhase(Phase.TARGET);
updatePhase(Phase.OUTPUT);

boolean underground = config.getBoolean("renderUnderground", true);

if (targets != null) {
for (Target target : targets) {
target.setConfiguration(config);
TargetUtil.renderWorldObjects(target, mapData, underground);
target.finish();
if (outputs != null) {
for (Output output : outputs) {
output.setConfiguration(config);
OutputUtil.renderWorldObjects(output, mapData, underground);
output.finish();
}
}

/* supply results to targets */
/* supply results to outputs */
updatePhase(Phase.FINISHED);

return new Results(mapProjection, mapData, eleData);
Expand Down Expand Up @@ -456,7 +456,7 @@ public enum Phase {
REPRESENTATION,
ELEVATION,
TERRAIN,
TARGET,
OUTPUT,
FINISHED
}

Expand Down
14 changes: 7 additions & 7 deletions core/src/main/java/org/osm2world/O2WConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.osm2world.math.geo.MapProjection;
import org.osm2world.osm.creation.OSMDataReader;
import org.osm2world.osm.data.OSMData;
import org.osm2world.target.Target;
import org.osm2world.output.Output;

/**
* This is the main class for using OSM2World as a library.
Expand Down Expand Up @@ -43,17 +43,17 @@ public void setConfig(O2WConfig config) {
* be used, e.g. if the data source is a small local .osm file.
* @param mapProjection projection for converting between {@link LatLon} and local coordinates in {@link MapData}.
* May be null, in which case a default map projection will be used.
* @param targets receivers of the conversion results
* @param outputs receivers of the conversion results
*/
public void convert(OSMDataReader osmDataReader, @Nullable GeoBounds bounds, @Nullable MapProjection mapProjection,
Target... targets) throws IOException {
Output... outputs) throws IOException {

OSMData osmData = (bounds != null)
? osmDataReader.getData(bounds.latLonBounds())
: osmDataReader.getAllData();

var cf = new ConversionFacade();
cf.createRepresentations(osmData, null, config, asList(targets));
cf.createRepresentations(osmData, null, config, asList(outputs));

}

Expand All @@ -64,12 +64,12 @@ public void convert(OSMDataReader osmDataReader, @Nullable GeoBounds bounds, @Nu
* or created with {@link MapDataBuilder}.
* @param mapProjection projection for converting between {@link LatLon} and local coordinates in {@link MapData}.
* May be null, but that prevents accessing additional data sources such as {@link SRTMData}.
* @param targets receivers of the conversion results
* @param outputs receivers of the conversion results
*/
public void convert(MapData mapData, @Nullable MapProjection mapProjection, Target... targets) throws IOException {
public void convert(MapData mapData, @Nullable MapProjection mapProjection, Output... outputs) throws IOException {

var cf = new ConversionFacade();
cf.createRepresentations(mapProjection, mapData, null, config, asList(targets));
cf.createRepresentations(mapProjection, mapData, null, config, asList(outputs));

}

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/osm2world/conversion/O2WConfig.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.osm2world.conversion;

import static org.osm2world.target.common.mesh.LevelOfDetail.*;
import static org.osm2world.output.common.mesh.LevelOfDetail.*;

import java.awt.*;
import java.io.File;
Expand All @@ -24,7 +24,7 @@
import org.osm2world.math.geo.MapProjection;
import org.osm2world.math.geo.MetricMapProjection;
import org.osm2world.math.geo.OrthographicAzimuthalMapProjection;
import org.osm2world.target.common.mesh.LevelOfDetail;
import org.osm2world.output.common.mesh.LevelOfDetail;

/**
* a set of configuration options for OSM2World.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.osm2world.target;
package org.osm2world.output;

import static java.util.Collections.nCopies;
import static org.osm2world.math.VectorXYZ.NULL_VECTOR;
import static org.osm2world.math.algorithms.GeometryUtil.trianglesFromTriangleFan;
import static org.osm2world.math.algorithms.GeometryUtil.trianglesFromTriangleStrip;
import static org.osm2world.target.common.texcoord.NamedTexCoordFunction.GLOBAL_X_Y;
import static org.osm2world.target.common.texcoord.TexCoordUtil.texCoordLists;
import static org.osm2world.output.common.texcoord.NamedTexCoordFunction.GLOBAL_X_Y;
import static org.osm2world.output.common.texcoord.TexCoordUtil.texCoordLists;
import static org.osm2world.world.modules.common.WorldModuleGeometryUtil.transformShape;

import java.util.*;
Expand All @@ -20,17 +20,17 @@
import org.osm2world.math.shapes.ShapeXZ;
import org.osm2world.math.shapes.TriangleXYZ;
import org.osm2world.math.shapes.TriangleXZ;
import org.osm2world.target.common.ExtrudeOption;
import org.osm2world.target.common.material.Material;
import org.osm2world.target.common.mesh.ExtrusionGeometry;
import org.osm2world.target.common.mesh.Mesh;
import org.osm2world.target.common.mesh.MeshUtil;
import org.osm2world.target.common.mesh.TriangleGeometry;
import org.osm2world.target.common.model.ModelInstance;
import org.osm2world.output.common.ExtrudeOption;
import org.osm2world.output.common.material.Material;
import org.osm2world.output.common.mesh.ExtrusionGeometry;
import org.osm2world.output.common.mesh.Mesh;
import org.osm2world.output.common.mesh.MeshUtil;
import org.osm2world.output.common.mesh.TriangleGeometry;
import org.osm2world.output.common.model.ModelInstance;
import org.osm2world.world.data.ProceduralWorldObject;

/**
* contains methods and functionality shared between {@link Target} and {@link ProceduralWorldObject.Target}.
* contains methods and functionality shared between {@link Output} and {@link ProceduralWorldObject.Target}.
* This is a transitional solution: Classes representing output formats will move to a different solution.
*/
public interface CommonTarget {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package org.osm2world.target;
package org.osm2world.output;

import javax.annotation.Nullable;

import org.osm2world.conversion.O2WConfig;
import org.osm2world.target.common.MeshStore;
import org.osm2world.target.common.mesh.LevelOfDetail;
import org.osm2world.target.common.mesh.Mesh;
import org.osm2world.target.common.mesh.TriangleGeometry;
import org.osm2world.output.common.MeshStore;
import org.osm2world.output.common.mesh.LevelOfDetail;
import org.osm2world.output.common.mesh.Mesh;
import org.osm2world.output.common.mesh.TriangleGeometry;
import org.osm2world.world.data.WorldObject;

/**
* A sink for rendering/writing {@link WorldObject}s to.
*/
public interface Target extends CommonTarget {
public interface Output extends CommonTarget {

void setConfiguration(O2WConfig config);
O2WConfig getConfiguration();
Expand All @@ -22,8 +22,8 @@ default LevelOfDetail getLod() {
}

/**
* announces the begin of the draw* calls for a {@link WorldObject}.
* This allows targets to group them, if desired.
* announces the beginning of the draw* calls for a {@link WorldObject}.
* This makes it possible for implementations to group them, if desired.
* Otherwise, this can be ignored.
*
* @param object the object that all draw method calls until the next beginObject belong to; can be null
Expand All @@ -39,7 +39,7 @@ public default void drawMesh(Mesh mesh) {
}

/**
* gives the target the chance to perform finish/cleanup operations
* gives this output the chance to perform finish/cleanup operations
* after all objects have been drawn.
*/
void finish();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.osm2world.target;
package org.osm2world.output;

import static java.util.stream.Collectors.toList;
import static org.osm2world.util.FaultTolerantIterationUtil.DEFAULT_EXCEPTION_HANDLER;
Expand All @@ -24,37 +24,37 @@

import com.google.gson.JsonIOException;

public final class TargetUtil {
public final class OutputUtil {

public enum Compression { NONE, ZIP, GZ }

private TargetUtil() {}
private OutputUtil() {}

/**
* render all world objects to a target instance
* that are compatible with that target type
* renders all {@link WorldObject}s to an output.
* Also sends {@link Output#beginObject(WorldObject)} calls.
*/
public static void renderWorldObjects(Target target, MapData mapData, boolean renderUnderground) {
public static void renderWorldObjects(Output output, MapData mapData, boolean renderUnderground) {

for (MapElement mapElement : mapData.getMapElements()) {
forEach(mapElement.getRepresentations(), (WorldObject r) -> {
if (r.getParent() == null) {
if (renderUnderground || r.getGroundState() != GroundState.BELOW) {
renderObject(target, r);
renderObject(output, r);
}
}
}, (e, r) -> DEFAULT_EXCEPTION_HANDLER.accept(e, r.getPrimaryMapElement()));
}
}

/**
* renders any object to a target instance.
* Also sends {@link Target#beginObject(WorldObject)} calls.
* renders one {@link WorldObject} to an output.
* Also sends {@link Output#beginObject(WorldObject)} calls.
*/
public static final void renderObject(Target target, WorldObject object) {
target.beginObject(object);
object.buildMeshes().forEach(target::drawMesh);
object.getSubModels().forEach(it -> it.render(target));
public static final void renderObject(Output output, WorldObject object) {
output.beginObject(object);
object.buildMeshes().forEach(output::drawMesh);
object.getSubModels().forEach(it -> it.render(output));
}

public static final List<List<VectorXZ>> flipTexCoordsVertically(List<List<VectorXZ>> texCoordLists) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package org.osm2world.target.common;
package org.osm2world.output.common;

import javax.annotation.Nonnull;

import org.osm2world.conversion.O2WConfig;
import org.osm2world.target.Target;
import org.osm2world.output.Output;

/**
* superclass for {@link Target} implementations that defines some
* superclass for {@link Output} implementations that defines some
* of the required methods using others. Extending it reduces the number of
* methods that have to be provided by the implementation
*/
public abstract class AbstractTarget implements Target {
public abstract class AbstractOutput implements Output {

protected @Nonnull O2WConfig config = new O2WConfig();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package org.osm2world.target.common;
package org.osm2world.output.common;

import java.util.List;
import java.util.Set;

import org.osm2world.math.shapes.ShapeXZ;
import org.osm2world.target.Target;
import org.osm2world.target.common.material.Material;
import org.osm2world.output.Output;
import org.osm2world.output.common.material.Material;

/**
* Flags describing available options for
* {@link Target#drawExtrudedShape(Material, ShapeXZ, List, List, List, List, Set)}.
* {@link Output#drawExtrudedShape(Material, ShapeXZ, List, List, List, List, Set)}.
*/
public enum ExtrudeOption {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.osm2world.target.common;
package org.osm2world.output.common;

import static java.lang.Math.abs;
import static java.util.Collections.nCopies;
Expand All @@ -14,7 +14,7 @@
import org.osm2world.math.VectorXYZ;
import org.osm2world.math.VectorXZ;
import org.osm2world.math.shapes.TriangleXYZ;
import org.osm2world.target.common.material.Material;
import org.osm2world.output.common.material.Material;
import org.osm2world.world.data.WorldObject;

import com.google.common.collect.HashMultimap;
Expand All @@ -27,7 +27,7 @@
*
* TODO: this currently produces faces that are not convex
*/
public abstract class FaceTarget extends AbstractTarget {
public abstract class FaceOutput extends AbstractOutput {

abstract public void drawFace(Material material, List<VectorXYZ> vs,
List<VectorXYZ> normals, List<List<VectorXZ>> texCoordLists);
Expand Down
Loading

0 comments on commit 7f6f904

Please sign in to comment.