Search in sources :

Example 1 with Triangle

use of com.revolsys.geometry.model.Triangle in project com.revolsys.open by revolsys.

the class IntArrayScaleTriangulatedIrregularNetwork method forEachTriangle.

@Override
public void forEachTriangle(final Consumer<? super Triangle> action) {
    for (int i = 0; i < this.triangleCount; i++) {
        final Triangle triangle = newTriangle(i);
        action.accept(triangle);
    }
}
Also used : AbstractTriangle(com.revolsys.geometry.model.impl.AbstractTriangle) Triangle(com.revolsys.geometry.model.Triangle) Point(com.revolsys.geometry.model.Point)

Example 2 with Triangle

use of com.revolsys.geometry.model.Triangle in project com.revolsys.open by revolsys.

the class IntArrayScaleTriangulatedIrregularNetwork method getTriangleSpatialIndex.

public QuadTree<Triangle> getTriangleSpatialIndex() {
    if (this.triangleSpatialIndex == null) {
        final QuadTree<Triangle> index = new QuadTree<>(this.geometryFactory);
        forEachTriangle((x1, y1, z1, x2, y2, z2, x3, y3, z3) -> {
            final Triangle triangle = new TriangleDoubleXYZ(x1, y1, z1, x2, y2, z2, x3, y3, z3);
            final BoundingBox boundingBox = triangle.getBoundingBox();
            index.insertItem(boundingBox, triangle);
        });
        this.triangleSpatialIndex = index;
    }
    return this.triangleSpatialIndex;
}
Also used : IdObjectQuadTree(com.revolsys.geometry.index.quadtree.IdObjectQuadTree) QuadTree(com.revolsys.geometry.index.quadtree.QuadTree) BaseBoundingBox(com.revolsys.geometry.model.impl.BaseBoundingBox) BoundingBox(com.revolsys.geometry.model.BoundingBox) AbstractTriangle(com.revolsys.geometry.model.impl.AbstractTriangle) Triangle(com.revolsys.geometry.model.Triangle) TriangleDoubleXYZ(com.revolsys.geometry.model.impl.TriangleDoubleXYZ)

Example 3 with Triangle

use of com.revolsys.geometry.model.Triangle in project com.revolsys.open by revolsys.

the class IntArrayScaleTriangulatedIrregularNetwork method forEachTriangle.

@Override
public void forEachTriangle(final BoundingBox boundingBox, final Consumer<? super Triangle> action) {
    if (this.spatialIndexUseTriangles) {
        final QuadTree<Triangle> index = getTriangleSpatialIndex();
        index.forEach(boundingBox, (triangle) -> {
            action.accept(triangle);
        });
    } else {
        final QuadTree<Integer> index = getTriangleIdSpatialIndex();
        index.forEach(boundingBox, triangleIndex -> {
            final Triangle triangle = newTriangle(triangleIndex);
            if (triangle != null) {
                action.accept(triangle);
            }
        });
    }
}
Also used : AbstractTriangle(com.revolsys.geometry.model.impl.AbstractTriangle) Triangle(com.revolsys.geometry.model.Triangle)

Example 4 with Triangle

use of com.revolsys.geometry.model.Triangle in project com.revolsys.open by revolsys.

the class TriangulatedIrregularNetwork method getTriangles.

default List<Triangle> getTriangles(final LineSegment segment) {
    final BoundingBox boundingBox = segment.getBoundingBox();
    final List<Triangle> triangles = new ArrayList<>();
    forEachTriangle(boundingBox, triangles::add);
    return triangles;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) Triangle(com.revolsys.geometry.model.Triangle) ArrayList(java.util.ArrayList)

Example 5 with Triangle

use of com.revolsys.geometry.model.Triangle in project com.revolsys.open by revolsys.

the class QuadEdgeSubdivision method getTrianglesPolygonal.

/**
 * Gets the geometry for the triangles in a triangulated subdivision as a {@link Polygonal}.
 *
 * @param geometryFactory the GeometryFactory to use
 * @return a GeometryCollection of triangular Polygons
 */
public Polygonal getTrianglesPolygonal(final GeometryFactory geometryFactory) {
    final List<Triangle> triangles = new ArrayList<>();
    forEachTriangle((final double x1, final double y1, final double z1, final double x2, final double y2, final double z2, final double x3, final double y3, final double z3) -> {
        final Triangle triangle = new TriangleDoubleXYZ(x1, y1, z1, x2, y2, z2, x3, y3, z3);
        triangles.add(triangle);
    });
    return geometryFactory.polygonal(triangles);
}
Also used : Triangle(com.revolsys.geometry.model.Triangle) ArrayList(java.util.ArrayList) TriangleDoubleXYZ(com.revolsys.geometry.model.impl.TriangleDoubleXYZ)

Aggregations

Triangle (com.revolsys.geometry.model.Triangle)16 Point (com.revolsys.geometry.model.Point)6 BoundingBox (com.revolsys.geometry.model.BoundingBox)5 AbstractTriangle (com.revolsys.geometry.model.impl.AbstractTriangle)5 ArrayList (java.util.ArrayList)5 Geometry (com.revolsys.geometry.model.Geometry)4 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)3 PointDoubleXYZ (com.revolsys.geometry.model.impl.PointDoubleXYZ)3 TriangleDoubleXYZ (com.revolsys.geometry.model.impl.TriangleDoubleXYZ)3 LineSegment (com.revolsys.geometry.model.segment.LineSegment)3 LineSegmentDoubleGF (com.revolsys.geometry.model.segment.LineSegmentDoubleGF)3 List (java.util.List)3 Lists (com.revolsys.collection.list.Lists)2 MapEx (com.revolsys.collection.map.MapEx)2 TriangulatedIrregularNetwork (com.revolsys.elevation.tin.TriangulatedIrregularNetwork)2 ScaledIntegerTriangulatedIrregularNetwork (com.revolsys.elevation.tin.compactbinary.ScaledIntegerTriangulatedIrregularNetwork)2 AsciiTin (com.revolsys.elevation.tin.tin.AsciiTin)2 GeometryFactoryProxy (com.revolsys.geometry.model.GeometryFactoryProxy)2 LineString (com.revolsys.geometry.model.LineString)2 BoundingBoxDoubleXY (com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)2