Commit 02de0a22 authored by Riegel's avatar Riegel
Browse files

Reformat code

parent ad3589e8
Pipeline #10297 passed with stage
in 1 minute and 5 seconds
...@@ -11,12 +11,18 @@ import de.hft.stuttgart.citydoctor2.utils.CopyHandler; ...@@ -11,12 +11,18 @@ import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable; import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial; import java.io.Serial;
import java.util.*; import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/** /**
* Dataholding class for parsing and resolving of CompositeSurfaces. * Pseudo-abstract polygon class for parsing and resolving of CompositeSurfaces and references to them.
* <p>CompositePolygons have no exterior or interior LinearRings themselves and need to be filtered out from
* the polygons of a CityObject geometry before further processing steps.
*
* @author Riegel
*/ */
public final class CompositePolygon extends ConcretePolygon{ public final class CompositePolygon extends ConcretePolygon {
@Serial @Serial
private static final long serialVersionUID = -1867197873443341287L; private static final long serialVersionUID = -1867197873443341287L;
...@@ -32,7 +38,8 @@ public final class CompositePolygon extends ConcretePolygon{ ...@@ -32,7 +38,8 @@ public final class CompositePolygon extends ConcretePolygon{
} }
@Override @Override
public void accept(Check c){} public void accept(Check c) {
}
@Override @Override
public Class<? extends Checkable> getCheckClass() { public Class<? extends Checkable> getCheckClass() {
...@@ -40,24 +47,25 @@ public final class CompositePolygon extends ConcretePolygon{ ...@@ -40,24 +47,25 @@ public final class CompositePolygon extends ConcretePolygon{
} }
@Override @Override
public boolean containsAnyError(){ public boolean containsAnyError() {
return false; return false;
} }
@Override @Override
public void collectContainedErrors(List<CheckError> errors) {} public void collectContainedErrors(List<CheckError> errors) {
}
@Override @Override
public void clearAllContainedCheckResults() { public void clearAllContainedCheckResults() {
} }
public void addCompositeMember(ConcretePolygon p){ public void addCompositeMember(ConcretePolygon p) {
compositeMembers.add(p); compositeMembers.add(p);
p.setPartOfComposite(this); p.setPartOfComposite(this);
} }
public List<ConcretePolygon> getCompositeMembers(){ public List<ConcretePolygon> getCompositeMembers() {
return compositeMembers; return compositeMembers;
} }
...@@ -67,7 +75,6 @@ public final class CompositePolygon extends ConcretePolygon{ ...@@ -67,7 +75,6 @@ public final class CompositePolygon extends ConcretePolygon{
} }
@Override @Override
public Vector3d calculateNormal() { public Vector3d calculateNormal() {
return compositeMembers.get(0).calculateNormal(); return compositeMembers.get(0).calculateNormal();
...@@ -76,7 +83,7 @@ public final class CompositePolygon extends ConcretePolygon{ ...@@ -76,7 +83,7 @@ public final class CompositePolygon extends ConcretePolygon{
@Override @Override
public TesselatedPolygon tesselate() { public TesselatedPolygon tesselate() {
List<Triangle3d> tessPolys = new ArrayList<>(); List<Triangle3d> tessPolys = new ArrayList<>();
return new TesselatedPolygon(tessPolys,this ); return new TesselatedPolygon(tessPolys, this);
} }
@Override @Override
...@@ -190,7 +197,6 @@ public final class CompositePolygon extends ConcretePolygon{ ...@@ -190,7 +197,6 @@ public final class CompositePolygon extends ConcretePolygon{
} }
@Override @Override
public void collectInstances(CopyHandler handler) { public void collectInstances(CopyHandler handler) {
......
...@@ -53,9 +53,7 @@ public class ConcretePolygon extends Polygon { ...@@ -53,9 +53,7 @@ public class ConcretePolygon extends Polygon {
private Geometry parent; private Geometry parent;
private LinkedPolygon linkedFromPolygon; private LinkedPolygon linkedFromPolygon;
public ConcretePolygon() { public ConcretePolygon() {}
// TODO Auto-generated constructor stub
}
/* /*
* (non-Javadoc) * (non-Javadoc)
......
/*- /*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart * Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
* *
* This file is part of CityDoctor2. * This file is part of CityDoctor2.
* *
* CityDoctor2 is free software: you can redistribute it and/or modify * CityDoctor2 is free software: you can redistribute it and/or modify
...@@ -18,202 +18,201 @@ ...@@ -18,202 +18,201 @@
*/ */
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
/** /**
* Representing an edge between two consecutive points of a linear ring * Representing an edge between two consecutive points of a linear ring
*
* @author Matthias Betz
* *
* @author Matthias Betz
*/ */
public class Edge implements Serializable, Copyable { public class Edge implements Serializable, Copyable {
@Serial @Serial
private static final long serialVersionUID = -504694863498128296L; private static final long serialVersionUID = -504694863498128296L;
private final List<Polygon> adjacentPolygons = new ArrayList<>(2); private final List<Polygon> adjacentPolygons = new ArrayList<>(2);
private final List<LinearRing> adjacentRings = new ArrayList<>(2); private final List<LinearRing> adjacentRings = new ArrayList<>(2);
private Vertex from; private Vertex from;
private Vertex to; private Vertex to;
// start with 1 for a new edge // start with 1 for a new edge
private int numberOfHalfEdges = 1; private int numberOfHalfEdges = 1;
private int numberOfOppositeHalfEdges; private int numberOfOppositeHalfEdges;
public Edge(Vertex from, Vertex to) { public Edge(Vertex from, Vertex to) {
this.from = from; this.from = from;
this.to = to; this.to = to;
} }
private Edge() { private Edge() {
} }
public Vertex getFrom() { public Vertex getFrom() {
return from; return from;
} }
public Vertex getTo() { public Vertex getTo() {
return to; return to;
} }
public void addHalfEdge(Vertex v0, Vertex v1) { public void addHalfEdge(Vertex v0, Vertex v1) {
if (v0 == null || v1 == null) { if (v0 == null || v1 == null) {
return; return;
} }
if (isPointOfEdge(v0, from) && isPointOfEdge(v1, to)) { if (isPointOfEdge(v0, from) && isPointOfEdge(v1, to)) {
numberOfHalfEdges++; numberOfHalfEdges++;
return; return;
} }
if (isPointOfEdge(v1, from) && isPointOfEdge(v0, to)) { if (isPointOfEdge(v1, from) && isPointOfEdge(v0, to)) {
numberOfOppositeHalfEdges++; numberOfOppositeHalfEdges++;
return; return;
} }
throw new IllegalStateException( throw new IllegalStateException(
"The given vertices do not form this edge\n v0=" + v0 + ", v1=" + v1 + ", edge" + this); "The given vertices do not form this edge\n v0=" + v0 + ", v1=" + v1 + ", edge" + this);
} }
private boolean isPointOfEdge(Vertex v0, Vertex edgePoint) { private boolean isPointOfEdge(Vertex v0, Vertex edgePoint) {
return v0.equals(edgePoint); return v0.equals(edgePoint);
} }
public boolean formedByIgnoreDirection(Vertex v1, Vertex v2) { public boolean formedByIgnoreDirection(Vertex v1, Vertex v2) {
return (v1 == from && v2 == to) || (v1 == to && v2 == from); return (v1 == from && v2 == to) || (v1 == to && v2 == from);
} }
public boolean equalsIgnoreDirection(Edge other) { public boolean equalsIgnoreDirection(Edge other) {
return (other.from.equals(from) && other.to.equals(to)) || (other.from.equals(to) && other.to.equals(from)); return (other.from.equals(from) && other.to.equals(to)) || (other.from.equals(to) && other.to.equals(from));
} }
public int getNumberOfHalfEdges() { public int getNumberOfHalfEdges() {
return numberOfHalfEdges; return numberOfHalfEdges;
} }
public int getNumberOppositeHalfEdges() { public int getNumberOppositeHalfEdges() {
return numberOfOppositeHalfEdges; return numberOfOppositeHalfEdges;
} }
public int getNumberOfAllHalfEdges() { public int getNumberOfAllHalfEdges() {
return numberOfHalfEdges + numberOfOppositeHalfEdges; return numberOfHalfEdges + numberOfOppositeHalfEdges;
} }
public List<Polygon> getAdjacentPolygons() { public List<Polygon> getAdjacentPolygons() {
return adjacentPolygons; return adjacentPolygons;
} }
public List<LinearRing> getAdjacentRings() { public List<LinearRing> getAdjacentRings() {
return adjacentRings; return adjacentRings;
} }
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + ((from == null) ? 0 : from.hashCode()); result = prime * result + ((from == null) ? 0 : from.hashCode());
result = prime * result + ((to == null) ? 0 : to.hashCode()); result = prime * result + ((to == null) ? 0 : to.hashCode());
return result; return result;
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
if (obj == null) { if (obj == null) {
return false; return false;
} }
if (getClass() != obj.getClass()) { if (getClass() != obj.getClass()) {
return false; return false;
} }
Edge other = (Edge) obj; Edge other = (Edge) obj;
if (from == null) { if (from == null) {
if (other.from != null) { if (other.from != null) {
return false; return false;
} }
} else if (!from.equals(other.from)) { } else if (!from.equals(other.from)) {
return false; return false;
} }
if (to == null) { if (to == null) {
return other.to == null; return other.to == null;
} else return to.equals(other.to); } else return to.equals(other.to);
} }
public void addAdjacentPolygon(Polygon p) { public void addAdjacentPolygon(Polygon p) {
adjacentPolygons.add(p); adjacentPolygons.add(p);
} }
public void addAdjacentRing(LinearRing lr) { public void addAdjacentRing(LinearRing lr) {
adjacentRings.add(lr); adjacentRings.add(lr);
} }
@Override @Override
public String toString() { public String toString() {
return "Edge [from=" + from + ", to=" + to + "]"; return "Edge [from=" + from + ", to=" + to + "]";
} }
public boolean contains(Vertex v) { public boolean contains(Vertex v) {
return v == from || v == to; return v == from || v == to;
} }
public Vertex getConnectionPoint(Edge e) { public Vertex getConnectionPoint(Edge e) {
if (from == e.getTo() || from == e.getFrom()) { if (from == e.getTo() || from == e.getFrom()) {
return from; return from;
} }
if (to == e.getTo() || to == e.getFrom()) { if (to == e.getTo() || to == e.getFrom()) {
return to; return to;
} }
return null; return null;
} }
/** /**
* finds the point on the other end of the edge if the given vertex is one of * finds the point on the other end of the edge if the given vertex is one of
* the end points. * the end points.
* *
* @param c the given vertex * @param c the given vertex
* @return the opposite vertex or null if the given vertex is not an end point. * @return the opposite vertex or null if the given vertex is not an end point.
*/ */
public Vertex getOppositeVertex(Vertex c) { public Vertex getOppositeVertex(Vertex c) {
if (c == from) { if (c == from) {
return to; return to;
} }
if (c == to) { if (c == to) {
return from; return from;
} }
return null; return null;
} }
@Override @Override
public void collectInstances(CopyHandler handler) { public void collectInstances(CopyHandler handler) {
handler.addInstance(from); handler.addInstance(from);
handler.addInstance(to); handler.addInstance(to);
handler.addInstance(adjacentPolygons); handler.addInstance(adjacentPolygons);
handler.addInstance(adjacentRings); handler.addInstance(adjacentRings);
} }
@Override @Override
public Copyable createCopyInstance() { public Copyable createCopyInstance() {
return new Edge(); return new Edge();
} }
@Override @Override
public void fillValues(Copyable original, CopyHandler handler) { public void fillValues(Copyable original, CopyHandler handler) {
Edge originalEdge = (Edge) original; Edge originalEdge = (Edge) original;
from = handler.getCopyInstance(originalEdge.from); from = handler.getCopyInstance(originalEdge.from);
to = handler.getCopyInstance(originalEdge.to); to = handler.getCopyInstance(originalEdge.to);
numberOfHalfEdges = originalEdge.numberOfHalfEdges; numberOfHalfEdges = originalEdge.numberOfHalfEdges;
numberOfOppositeHalfEdges = originalEdge.numberOfOppositeHalfEdges; numberOfOppositeHalfEdges = originalEdge.numberOfOppositeHalfEdges;
for (Polygon originalPoly : originalEdge.adjacentPolygons) { for (Polygon originalPoly : originalEdge.adjacentPolygons) {
adjacentPolygons.add(handler.getCopyInstance(originalPoly)); adjacentPolygons.add(handler.getCopyInstance(originalPoly));
} }
for (LinearRing originalRing : originalEdge.adjacentRings) { for (LinearRing originalRing : originalEdge.adjacentRings) {
adjacentRings.add(handler.getCopyInstance(originalRing)); adjacentRings.add(handler.getCopyInstance(originalRing));
} }
} }
} }
/*- /*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart * Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
* *
* This file is part of CityDoctor2. * This file is part of CityDoctor2.
* *
* CityDoctor2 is free software: you can redistribute it and/or modify * CityDoctor2 is free software: you can redistribute it and/or modify
...@@ -20,13 +20,12 @@ package de.hft.stuttgart.citydoctor2.datastructure; ...@@ -20,13 +20,12 @@ package de.hft.stuttgart.citydoctor2.datastructure;
/** /**
* Possible feature types in CityGML * Possible feature types in CityGML
*
* @author Matthias Betz
* *
* @author Matthias Betz
*/ */
public enum FeatureType { public enum FeatureType {
BUILDING, TRANSPORTATION, VEGETATION, BRIDGE, LAND, WATER, BOUNDARY_SURFACE, INSTALLATION, OPENING, BUILDING, TRANSPORTATION, VEGETATION, BRIDGE, LAND, WATER, BOUNDARY_SURFACE, INSTALLATION, OPENING,
BUILDING_PART, BUILDING_SUBDIVISION, BRIDGE_CONSTRUCTION_ELEMENT, BRIDGE_INSTALLATION, ROOM, FURNITURE, CITY_FURNITURE, BUILDING_PART, BUILDING_SUBDIVISION, BRIDGE_CONSTRUCTION_ELEMENT, BRIDGE_INSTALLATION, ROOM, FURNITURE, CITY_FURNITURE,
GENERIC_CITY_OBJECT, TUNNEL, TUNNEL_PART GENERIC_CITY_OBJECT, TUNNEL, TUNNEL_PART
} }
...@@ -24,7 +24,7 @@ import java.util.List; ...@@ -24,7 +24,7 @@ import java.util.List;
/** /**
* *
*/ */
public class GenericCityObject extends CityObject{ public class GenericCityObject extends CityObject {
@Serial @Serial
private static final long serialVersionUID = 5886527664552294353L; private static final long serialVersionUID = 5886527664552294353L;
...@@ -49,7 +49,7 @@ public class GenericCityObject extends CityObject{ ...@@ -49,7 +49,7 @@ public class GenericCityObject extends CityObject{
@Override @Override
public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) { public void reCreateGeometries(GeometryFactory factory, ParserConfiguration config) {
for (Geometry geom : getGeometries()) { for (Geometry geom : getGeometries()) {
if (geom instanceof ImplicitGeometryHolder){ if (geom instanceof ImplicitGeometryHolder) {
continue; continue;
} }
if (geom.getType() == GeometryType.MULTI_SURFACE) { if (geom.getType() == GeometryType.MULTI_SURFACE) {
...@@ -213,7 +213,7 @@ public class GenericCityObject extends CityObject{ ...@@ -213,7 +213,7 @@ public class GenericCityObject extends CityObject{
} }
} }
public void setGmlObject(org.citygml4j.core.model.generics.GenericOccupiedSpace gos){ public void setGmlObject(org.citygml4j.core.model.generics.GenericOccupiedSpace gos) {
this.cgmlGos = gos; this.cgmlGos = gos;
} }
......
/*- /*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart * Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
* *
* This file is part of CityDoctor2. * This file is part of CityDoctor2.
* *
* CityDoctor2 is free software: you can redistribute it and/or modify * CityDoctor2 is free software: you can redistribute it and/or modify
...@@ -20,12 +20,11 @@ package de.hft.stuttgart.citydoctor2.datastructure; ...@@ -20,12 +20,11 @@ package de.hft.stuttgart.citydoctor2.datastructure;
/** /**
* Available geometry types * Available geometry types
*
* @author Matthias Betz
* *
* @author Matthias Betz
*/ */
public enum GeometryType { public enum GeometryType {
MULTI_SURFACE, SOLID, COMPOSITE_SURFACE MULTI_SURFACE, SOLID, COMPOSITE_SURFACE
} }
/*- /*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart * Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
* *
* This file is part of CityDoctor2. * This file is part of CityDoctor2.
* *
* CityDoctor2 is free software: you can redistribute it and/or modify * CityDoctor2 is free software: you can redistribute it and/or modify
...@@ -26,38 +26,37 @@ import java.io.Serial; ...@@ -26,38 +26,37 @@ import java.io.Serial;
/** /**
* A general GML element that has a gml id * A general GML element that has a gml id
*
* @author Matthias Betz
* *
* @author Matthias Betz
*/ */
public abstract class GmlElement extends Checkable implements Copyable { public abstract class GmlElement extends Checkable implements Copyable {
@Serial @Serial
private static final long serialVersionUID = -3242505393303017359L; private static final long serialVersionUID = -3242505393303017359L;
private GmlId gmlId; private GmlId gmlId;
public void setGmlId(GmlId id) { public void setGmlId(GmlId id) {
gmlId = id; gmlId = id;
} }
@Override @Override
public GmlId getGmlId() { public GmlId getGmlId() {
if (gmlId == null) { if (gmlId == null) {
gmlId = GmlId.generateId(); gmlId = GmlId.generateId();
} }
return gmlId; return gmlId;
} }
public boolean hasExistingGmlId() { public boolean hasExistingGmlId() {
return gmlId != null && !gmlId.isGenerated(); return gmlId != null && !gmlId.isGenerated();
} }
@Override @Override
public void fillValues(Copyable original, CopyHandler handler) { public void fillValues(Copyable original, CopyHandler handler) {
GmlElement originalElement = (GmlElement) original; GmlElement originalElement = (GmlElement) original;
// generate gml id before copying // generate gml id before copying
gmlId = originalElement.getGmlId(); gmlId = originalElement.getGmlId();
} }
} }
/*- /*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart * Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
* *
* This file is part of CityDoctor2. * This file is part of CityDoctor2.
* *
* CityDoctor2 is free software: you can redistribute it and/or modify * CityDoctor2 is free software: you can redistribute it and/or modify
...@@ -20,12 +20,11 @@ package de.hft.stuttgart.citydoctor2.datastructure; ...@@ -20,12 +20,11 @@ package de.hft.stuttgart.citydoctor2.datastructure;
/** /**
* The available opening types in CityGML * The available opening types in CityGML
*
* @author Matthias Betz
* *
* @author Matthias Betz
*/ */
public enum OpeningType { public enum OpeningType {
DOOR, WINDOW, UNKNOWN DOOR, WINDOW, UNKNOWN
} }
Supports Markdown
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