Search in sources :

Example 11 with QuadEdgeDelaunayTinBuilder

use of com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder in project com.revolsys.open by revolsys.

the class DelaunayTest method testBoundaryDo.

public void testBoundaryDo(final Geometry expected) {
    final QuadEdgeDelaunayTinBuilder tinBuilder = new QuadEdgeDelaunayTinBuilder(this.geometryFactory);
    tinBuilder.insertVertices(expected);
    final Geometry actual = tinBuilder.getBoundary();
    Assert.assertEquals(expected, actual);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) QuadEdgeDelaunayTinBuilder(com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)

Example 12 with QuadEdgeDelaunayTinBuilder

use of com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder in project com.revolsys.open by revolsys.

the class DelaunayTest method runDelaunay.

void runDelaunay(final String sitesWKT, final boolean computeTriangles, final String expectedWKT) throws ParseException {
    final Geometry sites = this.geometryFactory.geometry(sitesWKT);
    final QuadEdgeDelaunayTinBuilder builder = new QuadEdgeDelaunayTinBuilder(this.geometryFactory);
    builder.insertVertices(sites);
    Geometry result = null;
    if (computeTriangles) {
        result = builder.getTrianglesPolygonal();
    } else {
        result = builder.getEdges();
    }
    // System.out.println(result);
    Geometry expected = this.geometryFactory.geometry(expectedWKT);
    result = result.normalize();
    expected = expected.normalize();
    if (!expected.equalsExact(result, COMPARISON_TOLERANCE)) {
        System.err.println(expected.convertAxisCount(2));
        System.err.println(result.convertAxisCount(2));
        Assert.fail("Not equal");
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) QuadEdgeDelaunayTinBuilder(com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)

Example 13 with QuadEdgeDelaunayTinBuilder

use of com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder in project com.revolsys.open by revolsys.

the class TriangulationFunctions method delaunayTrianglesWithToleranceNoError.

public static Polygonal delaunayTrianglesWithToleranceNoError(final Geometry geom, final double tolerance) {
    GeometryFactory geometryFactory = geom.getGeometryFactory();
    geometryFactory = geometryFactory.convertScales(tolerance, tolerance, tolerance);
    final QuadEdgeDelaunayTinBuilder builder = new QuadEdgeDelaunayTinBuilder(geometryFactory);
    builder.insertVertices(geom);
    try {
        final Polygonal triangles = builder.getTrianglesPolygonal();
        return triangles;
    } catch (final LocateFailureException ex) {
        System.out.println(ex);
    // ignore this exception and drop thru
    }
    /**
     * Get the triangles created up until the error
     */
    final Polygonal triangles = builder.getSubdivision().getTrianglesPolygonal(geom.getGeometryFactory());
    return triangles;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Polygonal(com.revolsys.geometry.model.Polygonal) LocateFailureException(com.revolsys.elevation.tin.quadedge.LocateFailureException) QuadEdgeDelaunayTinBuilder(com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)

Example 14 with QuadEdgeDelaunayTinBuilder

use of com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder in project com.revolsys.open by revolsys.

the class TriangulationFunctions method delaunayTriangles.

public static Polygonal delaunayTriangles(final Geometry geometry) {
    final GeometryFactory geometryFactory = geometry.getGeometryFactory();
    final QuadEdgeDelaunayTinBuilder builder = new QuadEdgeDelaunayTinBuilder(geometryFactory);
    builder.insertVertices(geometry);
    final Polygonal triangles = builder.getTrianglesPolygonal();
    return triangles;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Polygonal(com.revolsys.geometry.model.Polygonal) QuadEdgeDelaunayTinBuilder(com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)

Aggregations

QuadEdgeDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)14 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)8 TriangulatedIrregularNetwork (com.revolsys.elevation.tin.TriangulatedIrregularNetwork)4 Geometry (com.revolsys.geometry.model.Geometry)3 Polygonal (com.revolsys.geometry.model.Polygonal)3 Stopwatch (com.revolsys.geometry.util.Stopwatch)3 Lineal (com.revolsys.geometry.model.Lineal)2 Point (com.revolsys.geometry.model.Point)2 LocateFailureException (com.revolsys.elevation.tin.quadedge.LocateFailureException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1