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

Code cleaning Ref #69

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