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