Commit c2329310 authored by Matthias Betz's avatar Matthias Betz
Browse files

fixed a bug where a degenerate triangle causing the all polygons wrong...

fixed a bug where a degenerate triangle causing the all polygons wrong orientation check to report false positives
parent 7346bcf0
Pipeline #12356 passed with stage
in 2 minutes and 19 seconds
...@@ -118,13 +118,15 @@ public class AllPolygonsWrongOrientationCheck extends Check { ...@@ -118,13 +118,15 @@ public class AllPolygonsWrongOrientationCheck extends Check {
// find the centroid of a triangle // find the centroid of a triangle
Vector3d centroid = t.getCentroid(); Vector3d centroid = t.getCentroid();
// create a point outside of the geometry // create a point outside of the geometry
Vector3d outsidePoint = bbox[0].minus(Vector3d.X, 5).minus(Vector3d.Y, 5).minus(Vector3d.Z, 5); Vector3d outsideDif1 = new Vector3d(5, 5, 5);
Vector3d outsidePoint = bbox[0].minus(outsideDif1);
// create a second point outside of the geometry // create a second point outside of the geometry
// the check can fail if the building is exactly oriented so that the ray is // the check can fail if the building is exactly oriented so that the ray is
// parallel to a side of the building // parallel to a side of the building
// in order to avoid this we check two rays, if one of those says it is oriented // in order to avoid this we check two rays, if one of those says it is oriented
// correctly it is oriented correctly // correctly it is oriented correctly
Vector3d secondOutsidePoint = bbox[0].minus(Vector3d.X, 5).minus(Vector3d.Y, 10).minus(Vector3d.Z, 5); Vector3d outsideDif2 = new Vector3d(7, 10, 5);
Vector3d secondOutsidePoint = bbox[0].minus(outsideDif2);
return checkIfGeometryIsWrongOriented(tessPolygons, centroid, outsidePoint) return checkIfGeometryIsWrongOriented(tessPolygons, centroid, outsidePoint)
|| checkIfGeometryIsWrongOriented(tessPolygons, centroid, secondOutsidePoint); || checkIfGeometryIsWrongOriented(tessPolygons, centroid, secondOutsidePoint);
} }
...@@ -164,8 +166,8 @@ public class AllPolygonsWrongOrientationCheck extends Check { ...@@ -164,8 +166,8 @@ public class AllPolygonsWrongOrientationCheck extends Check {
} }
private Triangle3d findSuitableTriangle(TesselatedPolygon p1) { private Triangle3d findSuitableTriangle(TesselatedPolygon p1) {
Triangle3d t = p1.getTriangles().get(0); Triangle3d t = null;
double maxArea = t.getArea(); double maxArea = Double.NEGATIVE_INFINITY;
for (Triangle3d tri : p1.getTriangles()) { for (Triangle3d tri : p1.getTriangles()) {
double area = tri.getArea(); double area = tri.getArea();
if (area > maxArea) { if (area > maxArea) {
...@@ -173,6 +175,9 @@ public class AllPolygonsWrongOrientationCheck extends Check { ...@@ -173,6 +175,9 @@ public class AllPolygonsWrongOrientationCheck extends Check {
t = tri; t = tri;
} }
} }
if (t == null) {
throw new IllegalStateException("No suitable triangle found");
}
return t; return t;
} }
......
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