Search in sources :

Example 1 with InsufficientDataException

use of org.apache.commons.math3.exception.InsufficientDataException in project chordatlas by twak.

the class Concarnie method removeOverlaps.

private void removeOverlaps(List<Problem> current) {
    Closer<Problem> closer = new Closer();
    for (Problem a : current) {
        try {
            Region<Euclidean2D> ar = a.chull.createRegion();
            b: for (Problem b : current) if (a != b)
                for (Vector2D v : b.chull.getVertices()) {
                    Location vInA = ar.checkPoint(v);
                    if (vInA == Location.BOUNDARY || vInA == Location.INSIDE) {
                        closer.add(a, b);
                        continue b;
                    }
                }
        } catch (InsufficientDataException th) {
        } catch (MathIllegalArgumentException th) {
        }
    }
    for (Set<Problem> close : closer.close()) {
        List<Problem> intersecting = new ArrayList<Problem>(close);
        Collections.sort(intersecting, (a, b) -> -Double.compare(a.area(), b.area()));
        for (int i = 1; i < intersecting.size(); i++) {
            Problem togo = intersecting.get(i);
            togo.addPortal();
            current.remove(togo);
        }
    }
}
Also used : InsufficientDataException(org.apache.commons.math3.exception.InsufficientDataException) ArrayList(java.util.ArrayList) Euclidean2D(org.apache.commons.math3.geometry.euclidean.twod.Euclidean2D) Paint(java.awt.Paint) Vector2D(org.apache.commons.math3.geometry.euclidean.twod.Vector2D) MathIllegalArgumentException(org.apache.commons.math3.exception.MathIllegalArgumentException) Location(org.apache.commons.math3.geometry.partitioning.Region.Location)

Aggregations

Paint (java.awt.Paint)1 ArrayList (java.util.ArrayList)1 InsufficientDataException (org.apache.commons.math3.exception.InsufficientDataException)1 MathIllegalArgumentException (org.apache.commons.math3.exception.MathIllegalArgumentException)1 Euclidean2D (org.apache.commons.math3.geometry.euclidean.twod.Euclidean2D)1 Vector2D (org.apache.commons.math3.geometry.euclidean.twod.Vector2D)1 Location (org.apache.commons.math3.geometry.partitioning.Region.Location)1