Commit 2799ce51 authored by Numanoglu's avatar Numanoglu
Browse files

Require explicit sweep tolerances

parent 7088483b
...@@ -29,7 +29,7 @@ public class HealPlanarPolygonSweep implements HealingMethod { ...@@ -29,7 +29,7 @@ public class HealPlanarPolygonSweep implements HealingMethod {
return false; return false;
} }
SweepUtilities utils = new SweepUtilities(err); SweepUtilities utils = new SweepUtilities(err, 0.001, 0.001);
utils.initialize(); utils.initialize();
if (utils.calculate()) { if (utils.calculate()) {
utils.doHeal(); utils.doHeal();
......
...@@ -15,20 +15,23 @@ import de.hft.stuttgart.citydoctor2.math.Plane; ...@@ -15,20 +15,23 @@ import de.hft.stuttgart.citydoctor2.math.Plane;
public class SweepUtilities { public class SweepUtilities {
private static final Logger logger = LogManager.getLogger(SweepUtilities.class); private static final Logger logger = LogManager.getLogger(SweepUtilities.class);
private static final double PI = Math.PI;
private Plane targetPlane; private Plane targetPlane;
private Polygon errorPolygon; private Polygon errorPolygon;
// todo: Toleranzen passend initialisieren private double minSweepEdgeLength;
private double minSweepEdgeLength = 0.001; // Mindestlaenge einer Kante private double pointOnPlaneTolerance;
private double maxPointPlaneDistance = 0.001; // Maximalabstand zur Ebene private double minLinePlaneAngle;
private double minLinePlaneAngle = PI / 180.0; // Mindestwinkel zwischen Gerade und Ebene im Bogenmass
private List<SweepVertex> sweepVertices; private List<SweepVertex> sweepVertices;
public SweepUtilities(NonPlanarPolygonDistancePlaneError err) { public SweepUtilities(NonPlanarPolygonDistancePlaneError err, double pointOnPlaneTolerance,
double sweepEdgeAndAngleTolerance) {
this.pointOnPlaneTolerance = pointOnPlaneTolerance;
minSweepEdgeLength = sweepEdgeAndAngleTolerance;
minLinePlaneAngle = sweepEdgeAndAngleTolerance;
if (err == null) { if (err == null) {
return; return;
...@@ -54,7 +57,7 @@ public class SweepUtilities { ...@@ -54,7 +57,7 @@ public class SweepUtilities {
for (SweepVertex v : sweepVertices) { for (SweepVertex v : sweepVertices) {
v.collectOutgoingEdges(errorPolygon, minSweepEdgeLength); v.collectOutgoingEdges(errorPolygon, minSweepEdgeLength);
v.initStatus(targetPlane, maxPointPlaneDistance); v.initStatus(targetPlane, pointOnPlaneTolerance);
} }
} }
...@@ -78,7 +81,7 @@ public class SweepUtilities { ...@@ -78,7 +81,7 @@ public class SweepUtilities {
/* /*
// If there is a new target plane, new initialization of status is necessary: // If there is a new target plane, new initialization of status is necessary:
for (SweepVertex v : verts) { for (SweepVertex v : verts) {
v.initStatus(targetPlane, maxPointPlaneDistance); v.initStatus(targetPlane, pointOnPlaneTolerance);
} }
*/ */
......
...@@ -71,14 +71,14 @@ public class SweepVertex { ...@@ -71,14 +71,14 @@ public class SweepVertex {
} }
} }
public void initStatus (Plane targetPlane, double maxPointPlaneDistance) { public void initStatus (Plane targetPlane, double pointOnPlaneTolerance) {
if (targetPlane == null) { if (targetPlane == null) {
status = SweepVertexStatus.ERROR; status = SweepVertexStatus.ERROR;
return; return;
} }
if ( targetPlane.getDistance(sweepVertex) < maxPointPlaneDistance ) { if ( targetPlane.getDistance(sweepVertex) < pointOnPlaneTolerance ) {
status = SweepVertexStatus.ON_PLANE; status = SweepVertexStatus.ON_PLANE;
} }
else if ( outgoingEdges.size() == 0 ) { else if ( outgoingEdges.size() == 0 ) {
......
...@@ -345,7 +345,7 @@ public class SweepUtilitiesStepTest { ...@@ -345,7 +345,7 @@ public class SweepUtilitiesStepTest {
private SweepUtilities createSweepUtilities(Polygon sweepPolygon, Plane targetPlane) { private SweepUtilities createSweepUtilities(Polygon sweepPolygon, Plane targetPlane) {
NonPlanarPolygonDistancePlaneError error = new NonPlanarPolygonDistancePlaneError(sweepPolygon, 0, null, NonPlanarPolygonDistancePlaneError error = new NonPlanarPolygonDistancePlaneError(sweepPolygon, 0, null,
targetPlane); targetPlane);
return new SweepUtilities(error); return new SweepUtilities(error, 0.001, 0.001);
} }
private Polygon getPolygonAtIndex(Building building, int index) { private Polygon getPolygonAtIndex(Building building, int index) {
......
...@@ -111,7 +111,7 @@ public class SweepUtilitiesSyntheticTest { ...@@ -111,7 +111,7 @@ public class SweepUtilitiesSyntheticTest {
private boolean runSweep(Polygon sweepPolygon, Plane targetPlane) { private boolean runSweep(Polygon sweepPolygon, Plane targetPlane) {
NonPlanarPolygonDistancePlaneError error = new NonPlanarPolygonDistancePlaneError(sweepPolygon, 0, null, NonPlanarPolygonDistancePlaneError error = new NonPlanarPolygonDistancePlaneError(sweepPolygon, 0, null,
targetPlane); targetPlane);
SweepUtilities utilities = new SweepUtilities(error); SweepUtilities utilities = new SweepUtilities(error, 0.001, 0.001);
utilities.initialize(); utilities.initialize();
if (!utilities.calculate()) { if (!utilities.calculate()) {
......
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