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

Code cleaning Ref #69

parent 5a6f4b46
...@@ -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.Objects; import java.util.Objects;
...@@ -26,7 +27,7 @@ public class MeshSurfaceUtils { ...@@ -26,7 +27,7 @@ public class MeshSurfaceUtils {
public static List<PolygonPolygonIntersection> selfIntersects(MeshSurface ms, double epsilon, double angleEpsilon) { public static List<PolygonPolygonIntersection> selfIntersects(MeshSurface ms, double epsilon, double angleEpsilon) {
Objects.requireNonNull(ms); Objects.requireNonNull(ms);
List<CDPolygonNs> polygons = ms.getPolygons(); List<CDPolygonNs> polygons = ms.polygons();
List<PolygonPolygonIntersection> intersections = new ArrayList<>(); List<PolygonPolygonIntersection> intersections = new ArrayList<>();
for (int i = 0; i < polygons.size() - 1; i++) { for (int i = 0; i < polygons.size() - 1; i++) {
EdgePolygon p1 = polygons.get(i); EdgePolygon p1 = polygons.get(i);
......
...@@ -20,8 +20,8 @@ package de.hft.stuttgart.citydoctor2.edge; ...@@ -20,8 +20,8 @@ package de.hft.stuttgart.citydoctor2.edge;
public class Point2d { public class Point2d {
private double x; private final double x;
private double y; private final double y;
public Point2d(double x, double y) { public Point2d(double x, double y) {
this.x = x; this.x = x;
......
...@@ -18,11 +18,12 @@ ...@@ -18,11 +18,12 @@
*/ */
package de.hft.stuttgart.citydoctor2.edge; package de.hft.stuttgart.citydoctor2.edge;
public class Point3d { public class Point3d {
private double x; private final double x;
private double y; private final double y;
private double z; private final double z;
public Point3d(double x, double y, double z) { public Point3d(double x, double y, double z) {
this.x = x; this.x = x;
......
...@@ -23,7 +23,7 @@ import java.util.List; ...@@ -23,7 +23,7 @@ import java.util.List;
public class PolyLine2d extends BaseEntity { public class PolyLine2d extends BaseEntity {
private PolyLineSegment2d mpFirst; private final PolyLineSegment2d mpFirst;
private PolyLineSegment2d mpLast; private PolyLineSegment2d mpLast;
public PolyLine2d(PolyLineSegment2d pStart) { public PolyLine2d(PolyLineSegment2d pStart) {
......
...@@ -25,8 +25,8 @@ public class PolyLineSegment extends BaseEntity { ...@@ -25,8 +25,8 @@ public class PolyLineSegment extends BaseEntity {
private static final Logger logger = LogManager.getLogger(PolyLineSegment.class); private static final Logger logger = LogManager.getLogger(PolyLineSegment.class);
private Coordinate3d mpStart; private final Coordinate3d mpStart;
private Coordinate3d mpEnd; private final Coordinate3d mpEnd;
private PolyLineSegment mpNext; private PolyLineSegment mpNext;
......
...@@ -104,16 +104,14 @@ public class Polygon2d extends BaseEntity { ...@@ -104,16 +104,14 @@ public class Polygon2d extends BaseEntity {
point = halfEdge.getStart().getPoint(); point = halfEdge.getStart().getPoint();
lowerU = (point.getX() < lowerU) ? point.getX() : lowerU; lowerU = Math.min(point.getX(), lowerU);
lowerV = (point.getY() < lowerV) ? point.getY() : lowerV; lowerV = Math.min(point.getY(), lowerV);
upperU = (point.getX() > upperU) ? point.getX() : upperU; upperU = Math.max(point.getX(), upperU);
upperV = (point.getY() > upperV) ? point.getY() : upperV; upperV = Math.max(point.getY(), upperV);
} }
Box2d box = new Box2d(new Point2d(lowerU, lowerV), new Point2d(upperU, upperV)); return new Box2d(new Point2d(lowerU, lowerV), new Point2d(upperU, upperV));
return box;
} }
public static void connectHalfEdges(List<HalfEdge2d> rHalfEdges) { public static void connectHalfEdges(List<HalfEdge2d> rHalfEdges) {
......
...@@ -18,12 +18,13 @@ ...@@ -18,12 +18,13 @@
*/ */
package de.hft.stuttgart.citydoctor2.edge; package de.hft.stuttgart.citydoctor2.edge;
public class Polygon2dPolygon2dInt { public class Polygon2dPolygon2dInt {
private Polygon2d mcpPolygon1; private final Polygon2d mcpPolygon1;
private Polygon2d mcpPolygon2; private final Polygon2d mcpPolygon2;
private PolyLine2d line; private final PolyLine2d line;
private IntersectionType intType; private final IntersectionType intType;
public Polygon2dPolygon2dInt(Polygon2d mcpPolygon1, Polygon2d mcpPolygon2, PolyLine2d line, public Polygon2dPolygon2dInt(Polygon2d mcpPolygon1, Polygon2d mcpPolygon2, PolyLine2d line,
IntersectionType intType) { IntersectionType intType) {
......
...@@ -18,12 +18,13 @@ ...@@ -18,12 +18,13 @@
*/ */
package de.hft.stuttgart.citydoctor2.edge; package de.hft.stuttgart.citydoctor2.edge;
public class PolygonPolygonIntersection { public class PolygonPolygonIntersection {
private EdgePolygon p1; private final EdgePolygon p1;
private EdgePolygon p2; private final EdgePolygon p2;
private PolyLine polyLine; private final PolyLine polyLine;
private IntersectionType type; private final IntersectionType type;
public PolygonPolygonIntersection(EdgePolygon p1, EdgePolygon p2, PolyLine polyLine, IntersectionType type) { public PolygonPolygonIntersection(EdgePolygon p1, EdgePolygon p2, PolyLine polyLine, IntersectionType type) {
this.p1 = p1; this.p1 = p1;
......
...@@ -18,10 +18,11 @@ ...@@ -18,10 +18,11 @@
*/ */
package de.hft.stuttgart.citydoctor2.edge; package de.hft.stuttgart.citydoctor2.edge;
public class ProjectedPoint3d { public class ProjectedPoint3d {
private Point3d point; private final Point3d point;
private double parameter; private final double parameter;
public ProjectedPoint3d(Point3d point, double d) { public ProjectedPoint3d(Point3d point, double d) {
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;
public class UnitVector3d extends Vector3d { public class UnitVector3d extends Vector3d {
public static UnitVector3d of(Vector3d vec) { public static UnitVector3d of(Vector3d vec) {
...@@ -37,13 +38,7 @@ public class UnitVector3d extends Vector3d { ...@@ -37,13 +38,7 @@ public class UnitVector3d extends Vector3d {
public double dot(UnitVector3d other) { public double dot(UnitVector3d other) {
double scalar = getX() * other.getX() + getY() * other.getY() + getZ() * other.getZ(); double scalar = getX() * other.getX() + getY() * other.getY() + getZ() * other.getZ();
if (scalar > 1.0) { return (scalar >= 0) ? Math.min(scalar, 1.0) : Math.max(scalar, -1.0);
return 1.0;
}
if (scalar < -1.0) {
return -1.0;
}
return scalar;
} }
......
...@@ -18,16 +18,18 @@ ...@@ -18,16 +18,18 @@
*/ */
package de.hft.stuttgart.citydoctor2.edge; package de.hft.stuttgart.citydoctor2.edge;
public class Vector2d { public class Vector2d {
private double x; private final double x;
private double y; private final double y;
public Vector2d(double x, double y) { public Vector2d(double x, double y) {
this.x = x; this.x = x;
this.y = y; this.y = y;
} }
@SuppressWarnings("SuspiciousNameCombination")
public Vector2d getPerpendicularVector() { public Vector2d getPerpendicularVector() {
return new Vector2d(y, -x); return new Vector2d(y, -x);
} }
......
...@@ -18,11 +18,12 @@ ...@@ -18,11 +18,12 @@
*/ */
package de.hft.stuttgart.citydoctor2.edge; package de.hft.stuttgart.citydoctor2.edge;
import java.util.Arrays; import java.util.Arrays;
public class Vector3d { public class Vector3d {
private double[] val = new double[3]; private final double[] val = new double[3];
public Vector3d(double x, double y, double z) { public Vector3d(double x, double y, double z) {
val[0] = x; val[0] = x;
...@@ -46,9 +47,9 @@ public class Vector3d { ...@@ -46,9 +47,9 @@ public class Vector3d {
val[1] = 0; val[1] = 0;
val[2] = 0; val[2] = 0;
} else { } else {
val[0] = val[0] /= length; val[0] /= length;
val[1] = val[1] /= length; val[1] /= length;
val[2] = val[2] /= length; val[2] /= length;
} }
} }
......
...@@ -103,11 +103,11 @@ public class IntersectionErrorsTest { ...@@ -103,11 +103,11 @@ public class IntersectionErrorsTest {
} }
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, edgePoly2, 0.000001, 0.001); List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, edgePoly2, 0.000001, 0.001);
......
...@@ -77,7 +77,7 @@ public class MeshSurfaceUtilsTest { ...@@ -77,7 +77,7 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v1); ext.addVertex(v1);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = polygons.get(0); CDPolygonNs edgePoly1 = polygons.get(0);
List<Coordinate3d> coordinates = edgePoly1.getCoordinates(); List<Coordinate3d> coordinates = edgePoly1.getCoordinates();
...@@ -147,7 +147,7 @@ public class MeshSurfaceUtilsTest { ...@@ -147,7 +147,7 @@ public class MeshSurfaceUtilsTest {
List<Coordinate3d> coordChildren = firstHalfEdge.getChildren(Coordinate3d.class); List<Coordinate3d> coordChildren = firstHalfEdge.getChildren(Coordinate3d.class);
assertEquals(2, coordChildren.size()); assertEquals(2, coordChildren.size());
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1,
edgePoly2, 0.000001, 0.001); edgePoly2, 0.000001, 0.001);
assertNotNull(intersectPolygons); assertNotNull(intersectPolygons);
...@@ -195,11 +195,11 @@ public class MeshSurfaceUtilsTest { ...@@ -195,11 +195,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v6); ext.addVertex(v6);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1,
edgePoly2, 0.000001, 0.001); edgePoly2, 0.000001, 0.001);
assertNotNull(intersectPolygons); assertNotNull(intersectPolygons);
...@@ -248,11 +248,11 @@ public class MeshSurfaceUtilsTest { ...@@ -248,11 +248,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v6); ext.addVertex(v6);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1,
edgePoly2, 0.000001, 0.001); edgePoly2, 0.000001, 0.001);
...@@ -311,11 +311,11 @@ public class MeshSurfaceUtilsTest { ...@@ -311,11 +311,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v2); ext.addVertex(v2);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1,
edgePoly2, 0.000001, 0.001); edgePoly2, 0.000001, 0.001);
...@@ -375,11 +375,11 @@ public class MeshSurfaceUtilsTest { ...@@ -375,11 +375,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v6); ext.addVertex(v6);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1,
edgePoly2, 0.000001, 0.001); edgePoly2, 0.000001, 0.001);
...@@ -429,11 +429,11 @@ public class MeshSurfaceUtilsTest { ...@@ -429,11 +429,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v6); ext.addVertex(v6);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1,
edgePoly2, 0.000001, 0.001); edgePoly2, 0.000001, 0.001);
...@@ -482,11 +482,11 @@ public class MeshSurfaceUtilsTest { ...@@ -482,11 +482,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v6); ext.addVertex(v6);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
DebugUtils.printGeoknechtPolygon(edgePoly1, edgePoly2); DebugUtils.printGeoknechtPolygon(edgePoly1, edgePoly2);
...@@ -543,11 +543,11 @@ public class MeshSurfaceUtilsTest { ...@@ -543,11 +543,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v6); ext.addVertex(v6);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1,
edgePoly2, 0.000001, 0.001); edgePoly2, 0.000001, 0.001);
...@@ -596,11 +596,11 @@ public class MeshSurfaceUtilsTest { ...@@ -596,11 +596,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v4); ext.addVertex(v4);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
DebugUtils.printGeoknechtPolygon(edgePoly1, edgePoly2); DebugUtils.printGeoknechtPolygon(edgePoly1, edgePoly2);
...@@ -652,11 +652,11 @@ public class MeshSurfaceUtilsTest { ...@@ -652,11 +652,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v6); ext.addVertex(v6);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1,
edgePoly2, 0.000001, 0.001); edgePoly2, 0.000001, 0.001);
...@@ -706,11 +706,11 @@ public class MeshSurfaceUtilsTest { ...@@ -706,11 +706,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v6); ext.addVertex(v6);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1,
edgePoly2, 0.000001, 0.001); edgePoly2, 0.000001, 0.001);
...@@ -760,11 +760,11 @@ public class MeshSurfaceUtilsTest { ...@@ -760,11 +760,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v6); ext.addVertex(v6);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1,
edgePoly2, 0.000001, 0.001); edgePoly2, 0.000001, 0.001);
...@@ -810,11 +810,11 @@ public class MeshSurfaceUtilsTest { ...@@ -810,11 +810,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v6); ext.addVertex(v6);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1,
edgePoly2, 0.000001, 0.001); edgePoly2, 0.000001, 0.001);
...@@ -866,11 +866,11 @@ public class MeshSurfaceUtilsTest { ...@@ -866,11 +866,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v6); ext.addVertex(v6);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1,
edgePoly2, 0.000001, 0.001); edgePoly2, 0.000001, 0.001);
...@@ -922,11 +922,11 @@ public class MeshSurfaceUtilsTest { ...@@ -922,11 +922,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v6); ext.addVertex(v6);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1,
edgePoly2, 0.000001, 0.001); edgePoly2, 0.000001, 0.001);
...@@ -978,11 +978,11 @@ public class MeshSurfaceUtilsTest { ...@@ -978,11 +978,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v6); ext.addVertex(v6);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1,
edgePoly2, 0.000001, 0.001); edgePoly2, 0.000001, 0.001);
...@@ -1049,11 +1049,11 @@ public class MeshSurfaceUtilsTest { ...@@ -1049,11 +1049,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v5); ext.addVertex(v5);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1,
edgePoly2, 0.000001, 0.001); edgePoly2, 0.000001, 0.001);
...@@ -1110,11 +1110,11 @@ public class MeshSurfaceUtilsTest { ...@@ -1110,11 +1110,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v11); ext.addVertex(v11);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1,
edgePoly2, 0.000001, 0.001); edgePoly2, 0.000001, 0.001);
...@@ -1173,11 +1173,11 @@ public class MeshSurfaceUtilsTest { ...@@ -1173,11 +1173,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v11); ext.addVertex(v11);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1,
edgePoly2, 0.000001, 0.001); edgePoly2, 0.000001, 0.001);
...@@ -1238,11 +1238,11 @@ public class MeshSurfaceUtilsTest { ...@@ -1238,11 +1238,11 @@ public class MeshSurfaceUtilsTest {
ext.addVertex(v5); ext.addVertex(v5);
MeshSurface meshSurface = MeshSurface.of(geom); MeshSurface meshSurface = MeshSurface.of(geom);
List<CDPolygonNs> polygons = meshSurface.getPolygons(); List<CDPolygonNs> polygons = meshSurface.polygons();
assertEquals(2, polygons.size()); assertEquals(2, polygons.size());
CDPolygonNs edgePoly1 = meshSurface.getPolygons().get(0); CDPolygonNs edgePoly1 = meshSurface.polygons().get(0);
CDPolygonNs edgePoly2 = meshSurface.getPolygons().get(1); CDPolygonNs edgePoly2 = meshSurface.polygons().get(1);
List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1, List<PolygonPolygonIntersection> intersectPolygons = IntersectPlanarPolygons.intersectPolygons(edgePoly1,
edgePoly2, 0.000001, 0.001); edgePoly2, 0.000001, 0.001);
......
...@@ -67,7 +67,7 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; ...@@ -67,7 +67,7 @@ import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
*/ */
public abstract class Check { public abstract class Check {
private List<Class<Checkable>> applicableToClasses = new ArrayList<>(2); private final List<Class<Checkable>> applicableToClasses = new ArrayList<>(2);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected Check() { protected Check() {
......
...@@ -79,7 +79,7 @@ public interface CheckError extends Serializable { ...@@ -79,7 +79,7 @@ public interface CheckError extends Serializable {
* implementor of the error decides which information is written into the report * implementor of the error decides which information is written into the report
* or shown on the GUI. * or shown on the GUI.
* *
* @param report * @param report the ErrorReport.
*/ */
public void report(ErrorReport report); public void report(ErrorReport report);
......
...@@ -18,10 +18,12 @@ ...@@ -18,10 +18,12 @@
*/ */
package de.hft.stuttgart.citydoctor2.check; package de.hft.stuttgart.citydoctor2.check;
import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
public class CheckId implements Serializable { public record CheckId(String name) implements Serializable {
@Serial
private static final long serialVersionUID = -6267337828874296004L; private static final long serialVersionUID = -6267337828874296004L;
public static final CheckId C_GE_R_TOO_FEW_POINTS = new CheckId("C_GE_R_TOO_FEW_POINTS"); public static final CheckId C_GE_R_TOO_FEW_POINTS = new CheckId("C_GE_R_TOO_FEW_POINTS");
...@@ -55,23 +57,6 @@ public class CheckId implements Serializable { ...@@ -55,23 +57,6 @@ public class CheckId implements Serializable {
public static final CheckId C_GE_P_ORIENTATION_RINGS_SAME = new CheckId("C_GE_P_ORIENTATION_RINGS_SAME"); public static final CheckId C_GE_P_ORIENTATION_RINGS_SAME = new CheckId("C_GE_P_ORIENTATION_RINGS_SAME");
public static final CheckId C_SE_POLYGON_WITHOUT_SURFACE = new CheckId("C_SE_POLYGON_WITHOUT_SURFACE"); public static final CheckId C_SE_POLYGON_WITHOUT_SURFACE = new CheckId("C_SE_POLYGON_WITHOUT_SURFACE");
private String name;
public CheckId(String name) {
this.name = name;
}
public String getName() {
return name;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.check; package de.hft.stuttgart.citydoctor2.check;
import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
/** /**
...@@ -29,6 +30,7 @@ import java.io.Serializable; ...@@ -29,6 +30,7 @@ import java.io.Serializable;
*/ */
public class CheckResult implements Serializable { public class CheckResult implements Serializable {
@Serial
private static final long serialVersionUID = -8775678793477525693L; private static final long serialVersionUID = -8775678793477525693L;
private final CheckId id; private final CheckId id;
...@@ -38,7 +40,7 @@ public class CheckResult implements Serializable { ...@@ -38,7 +40,7 @@ public class CheckResult implements Serializable {
/** /**
* Constructor for this container * Constructor for this container
* *
* @param c the check which produced this result * @param id the check which produced this result
* @param s the status of the result * @param s the status of the result
* @param err an optional error object * @param err an optional error object
*/ */
...@@ -66,15 +68,7 @@ public class CheckResult implements Serializable { ...@@ -66,15 +68,7 @@ public class CheckResult implements Serializable {
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); return String.format("CheckResult [id=%s, status=%s, error=%s]", id, status, err);
builder.append("CheckResult [id=");
builder.append(id);
builder.append(", status=");
builder.append(status);
builder.append(", error=");
builder.append(err);
builder.append("]");
return builder.toString();
} }
} }
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.check; package de.hft.stuttgart.citydoctor2.check;
import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -36,11 +37,12 @@ import de.hft.stuttgart.citydoctor2.datastructure.GmlId; ...@@ -36,11 +37,12 @@ import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
*/ */
public abstract class Checkable implements Serializable { public abstract class Checkable implements Serializable {
@Serial
private static final long serialVersionUID = -1707871839265057882L; private static final long serialVersionUID = -1707871839265057882L;
private static final Logger logger = LogManager.getLogger(Checkable.class); private static final Logger logger = LogManager.getLogger(Checkable.class);
private Map<CheckId, CheckResult> checkResults = new HashMap<>(); private final Map<CheckId, CheckResult> checkResults = new HashMap<>();
private boolean isValidated = false; private boolean isValidated = false;
protected void setValidated(boolean validated) { protected void setValidated(boolean validated) {
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
package de.hft.stuttgart.citydoctor2.check; package de.hft.stuttgart.citydoctor2.check;
import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
/** /**
...@@ -30,11 +31,12 @@ import java.io.Serializable; ...@@ -30,11 +31,12 @@ import java.io.Serializable;
*/ */
public class DefaultParameter implements Serializable { public class DefaultParameter implements Serializable {
@Serial
private static final long serialVersionUID = -4587211298078974066L; private static final long serialVersionUID = -4587211298078974066L;
private String name; private final String name;
private String value; private final String value;
private Unit unitType; private final Unit unitType;
public DefaultParameter(String name, String defaultValue, Unit unitType) { public DefaultParameter(String name, String defaultValue, Unit unitType) {
this.name = name; this.name = name;
......
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