Commit 1745865f authored by Riegel's avatar Riegel
Browse files

Code cleaning Ref #69

parent 5a6f4b46
......@@ -18,8 +18,11 @@
*/
package de.hft.stuttgart.citydoctor2.checkresult.utility;
import java.io.Serial;
public class CheckReportParseException extends Exception {
@Serial
private static final long serialVersionUID = 6043371305010386110L;
public CheckReportParseException() {
......
......@@ -18,8 +18,11 @@
*/
package de.hft.stuttgart.citydoctor2.checkresult.utility;
import java.io.Serial;
public class CheckReportWriteException extends Exception {
@Serial
private static final long serialVersionUID = 1769358555887675233L;
public CheckReportWriteException() {
......
......@@ -34,7 +34,7 @@ public class IndentationXmlStreamWriter implements XMLStreamWriter {
private static final String INDENTATION = " ";
private XMLStreamWriter writer;
private final XMLStreamWriter writer;
private int depth = -1;
boolean sameElement = true;
......
......@@ -18,6 +18,7 @@
*/
package de.hft.stuttgart.citydoctor2.edge;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
......@@ -25,8 +26,8 @@ import java.util.Set;
public class BaseEntity {
private List<BaseEntity> parents = new ArrayList<>(2);
private List<BaseEntity> children = new ArrayList<>(2);
private final List<BaseEntity> parents = new ArrayList<>(2);
private final List<BaseEntity> children = new ArrayList<>(2);
public void addChild(BaseEntity e) {
children.add(e);
......
......@@ -20,8 +20,8 @@ package de.hft.stuttgart.citydoctor2.edge;
public class Box2d {
private Point2d mMin;
private Point2d mMax;
private final Point2d mMin;
private final Point2d mMax;
public Box2d(Point2d min, Point2d max) {
mMin = min;
......
......@@ -18,6 +18,7 @@
*/
package de.hft.stuttgart.citydoctor2.edge;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -30,7 +31,7 @@ import de.hft.stuttgart.citydoctor2.math.Vector3d;
public class CDPolygonNs extends PolygonNs {
private List<List<HalfEdge>> innerHalfEdges = new ArrayList<>();
private final List<List<HalfEdge>> innerHalfEdges = new ArrayList<>();
public static CDPolygonNs of(Polygon p, Map<Vector3d, Coordinate3d> pointMap) {
List<List<Coordinate3d>> loopCoordinates = new ArrayList<>();
......
......@@ -18,6 +18,7 @@
*/
package de.hft.stuttgart.citydoctor2.edge;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
......@@ -25,7 +26,7 @@ import java.util.Set;
public class Coordinate3d extends BaseEntity {
private Point3d point;
private final Point3d point;
public Coordinate3d(Point3d point) {
this.point = point;
......
......@@ -18,6 +18,7 @@
*/
package de.hft.stuttgart.citydoctor2.edge;
import java.util.ArrayList;
import java.util.List;
......@@ -25,8 +26,8 @@ import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
public class EdgePolygon extends BaseEntity {
private Polygon original;
private List<HalfEdge> halfEdges;
private final Polygon original;
private final List<HalfEdge> halfEdges;
public EdgePolygon(List<HalfEdge> halfEdges, Polygon original) {
for (HalfEdge he : halfEdges) {
......@@ -80,12 +81,6 @@ public class EdgePolygon extends BaseEntity {
for (HalfEdge he : halfEdges) {
coords.add(he.getStart());
}
// HalfEdge firstHE = Objects.requireNonNull(getFirstHalfEdge());
// HalfEdge currHE = firstHE;
// do {
// coords.add(currHE.getStart());
// currHE = currHE.getNext();
// } while (currHE != firstHE);
return coords;
}
......
......@@ -18,26 +18,25 @@
*/
package de.hft.stuttgart.citydoctor2.edge;
import java.util.Comparator;
public class Global {
private static final double DBL_EPSILON = 2.2204460492503131e-16;
private static double mZeroAngleCosinus = 1.0e-9;
private static double mTolVectorsParallel = 1e-9;
private static double mHighAccuracyTol = DBL_EPSILON * 5;
private static double mTolPointsEqual = 1e-3;
private static final double M_ZERO_ANGLE_COSINUS = 1.0e-9;
private static final double M_TOL_VECTORS_PARALLEL = 1e-9;
private static final double M_HIGH_ACCURACY_TOL = DBL_EPSILON * 5;
private static final double M_TOL_POINTS_EQUAL = 1e-3;
private Global() {
}
public static double getTolPointsEquals() {
return mTolPointsEqual;
}
public static double getTolPointsEquals() { return M_TOL_POINTS_EQUAL; }
public static double getHighAccuracyTolerance() {
return mHighAccuracyTol;
return M_HIGH_ACCURACY_TOL;
}
public static Comparator<Double> getDoubleTolCompare(double epsilon) {
......@@ -50,12 +49,10 @@ public class Global {
};
}
public static double getZeroAngleCosinus() {
return mZeroAngleCosinus;
}
public static double getZeroAngleCosinus() { return M_ZERO_ANGLE_COSINUS; }
public static double getTolVectorsParallel() {
return mTolVectorsParallel;
return M_TOL_VECTORS_PARALLEL;
}
}
......@@ -18,6 +18,7 @@
*/
package de.hft.stuttgart.citydoctor2.edge;
public class GmBoundedStraight2d extends GmStraight2d {
private double length;
......@@ -54,10 +55,7 @@ public class GmBoundedStraight2d extends GmStraight2d {
parameter = length;
}
if (0 <= parameter && parameter <= length) {
return true;
}
return false;
return 0 <= parameter && parameter <= length;
}
public double getLength() {
......
......@@ -18,26 +18,27 @@
*/
package de.hft.stuttgart.citydoctor2.edge;
import java.util.ArrayList;
import java.util.List;
public class GmPlane {
private Point3d x0;
private final Point3d x0;
private UnitVector3d r1;
private UnitVector3d r2;
private final UnitVector3d r1;
private final UnitVector3d r2;
private UnitVector3d n;
private double d;
private final UnitVector3d n;
private final double d;
public GmPlane(Point3d point, UnitVector3d normalVector) {
x0 = point;
n = normalVector;
d = new Vector3d(point).dot(n);
r1 = UnitVector3d.of(n.getZ(), n.getX(), n.getY());
r2 = n.cross(r1).toUnitVector();
UnitVector3d r = UnitVector3d.of(n.getZ(), n.getX(), n.getY());
r2 = n.cross(r).toUnitVector();
// r1 ist nicht in allen Faellen rechtwinklig zur Flaechennormalen
// daher nochmal eine neu Berechnung;
......
......@@ -18,10 +18,11 @@
*/
package de.hft.stuttgart.citydoctor2.edge;
public class GmStraight {
private Point3d org;
private UnitVector3d dir;
private final Point3d org;
private final UnitVector3d dir;
public GmStraight(Point3d org, Vector3d dir) {
this.org = org;
......@@ -74,11 +75,7 @@ public class GmStraight {
Point3d rOrigin2 = straight2.getOrigin();
Point3d foot2 = project(rOrigin2).getPoint();
if ((foot2.minus(rOrigin2)).getLength() > epsilon) {
return false;
}
return true;
return ((foot2.minus(rOrigin2)).getLength() <= epsilon);
}
public Point3d getOrigin() {
......
......@@ -20,8 +20,8 @@ package de.hft.stuttgart.citydoctor2.edge;
public class GmStraight2d {
private Point2d origin;
private UnitVector2d direction;
private final Point2d origin;
private final UnitVector2d direction;
public GmStraight2d(Point2d org, UnitVector2d dir) {
this.direction = dir;
......
......@@ -18,15 +18,16 @@
*/
package de.hft.stuttgart.citydoctor2.edge;
public class GmStraight2dIntersectionResult {
private double paramHE;
private double paramInt;
private final double paramHE;
private final double paramInt;
private GmStraight2d straightHE;
private GmStraight2d straightInt;
private final GmStraight2d straightHE;
private final GmStraight2d straightInt;
private boolean areParallel;
private final boolean areParallel;
public static GmStraight2dIntersectionResult parallel(GmStraight2d s1, GmStraight2d s2) {
return new GmStraight2dIntersectionResult(0, 0, s1, s2, true);
......
......@@ -108,7 +108,7 @@ public class HalfEdge extends BaseEntity {
HalfEdge pNextPartner = this.partner;
while (pNextPartner != this) {
if (pNextPartner == partner) {
logger.debug("(HalfEdge " + partner + " already exits in chain");
logger.debug(String.format("(HalfEdge %s already exits in chain", partner));
return;
}
pNextPartner = pNextPartner.partner;
......@@ -141,7 +141,7 @@ public class HalfEdge extends BaseEntity {
pPreviousPartner.partner = this;
this.partner = partner;
} else {
/**
/*
* TODO : das riecht nach einer Ringverzeigerung : 3 Polygonraender treffen auf
* einander
*/
......
......@@ -22,8 +22,8 @@ import java.util.List;
public class HalfEdge2d extends BaseEntity {
private Coordinate2d start;
private Coordinate2d end;
private final Coordinate2d start;
private final Coordinate2d end;
private HalfEdge2d partner;
......@@ -71,7 +71,7 @@ public class HalfEdge2d extends BaseEntity {
return pPartner;
}
private HalfEdge2d setPartner(HalfEdge2d pPartner) {
private void setPartner(HalfEdge2d pPartner) {
if (partner != null) {
if (pPartner != null) {
throw new IllegalStateException("cannot overwrite existing partner-connection");
......@@ -92,7 +92,6 @@ public class HalfEdge2d extends BaseEntity {
}
}
}
return pPartner;
}
public HalfEdge2d getPartner() {
......
......@@ -354,10 +354,8 @@ public class IntersectPlanarPolygons {
if (i < valuesList.size()) {
double i2 = valuesList.get(i);
// check if the double values are corner points of the polygon
boolean gotPolygonPoint = false;
if (intersectedPolygonPoints.contains(i1) || intersectedPolygonPoints.contains(i2)) {
gotPolygonPoint = true;
}
boolean gotPolygonPoint = intersectedPolygonPoints.contains(i1) ||
intersectedPolygonPoints.contains(i2);
if (gotPolygonPoint) {
// maybe an interval
......@@ -577,14 +575,6 @@ public class IntersectPlanarPolygons {
Polygon2d poly2d1 = new Polygon2dNs(poly2dCoords1, true);
Polygon2d poly2d2 = new Polygon2dNs(poly2dCoords2, true);
List<HalfEdge2d> halfEdges = poly2d1.getHalfEdges();
for (HalfEdge2d he : halfEdges) {
if (he.getPartner() == null) {
}
}
halfEdges = poly2d2.getHalfEdges();
List<PolygonPolygonIntersection> result = new ArrayList<>();
List<Polygon2dPolygon2dInt> ppi2ds = IntersectPolygon2d.getIntersections(poly2d1, poly2d2, epsilon);
for (Polygon2dPolygon2dInt ppi2d : ppi2ds) {
......
......@@ -164,11 +164,9 @@ public class IntersectPolygonAndStraight2d {
for (Double d : crIntersectedPolygonPoints) {
boolean pntIsPartOfExistingInterval = false;
for (Interval interval : mIntersectionIntervals) {
if (pntIsPartOfExistingInterval) {
break;
}
if (interval.getStart() == d || interval.getEnd() == d) {
pntIsPartOfExistingInterval = true;
break;
}
}
......
......@@ -18,12 +18,13 @@
*/
package de.hft.stuttgart.citydoctor2.edge;
public class Interval {
private static final Interval INVALID_INTERVAL = new Interval(1, 0);
private double start;
private double end;
private final double start;
private final double end;
public Interval(double start, double end) {
this.start = start;
......
......@@ -18,6 +18,7 @@
*/
package de.hft.stuttgart.citydoctor2.edge;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -28,9 +29,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.math.MovedPolygon;
import de.hft.stuttgart.citydoctor2.math.Vector3d;
public class MeshSurface {
private List<CDPolygonNs> polygons;
public record MeshSurface(List<CDPolygonNs> polygons) {
public static MeshSurface of(Geometry geom) {
List<CDPolygonNs> polygonList = new ArrayList<>();
......@@ -45,12 +44,5 @@ public class MeshSurface {
return new MeshSurface(polygonList);
}
public MeshSurface(List<CDPolygonNs> polygons) {
this.polygons = polygons;
}
public List<CDPolygonNs> getPolygons() {
return polygons;
}
}
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