use of com.revolsys.elevation.tin.TriangleConsumer in project com.revolsys.open by revolsys.
the class QuadEdgeDelaunayTinBuilder method newTriangulatedIrregularNetwork.
@Override
public final TriangulatedIrregularNetwork newTriangulatedIrregularNetwork() {
buildTin();
final BoundingBox boundingBox = getBoundingBox();
final AtomicInteger triangleCounter = new AtomicInteger();
forEachTriangle((x1, y1, z1, x2, y2, z2, x3, y3, z3) -> {
triangleCounter.incrementAndGet();
});
final int triangleCount = triangleCounter.get();
final int[] triangleXCoordinates = new int[triangleCount * 3];
final int[] triangleYCoordinates = new int[triangleCount * 3];
final int[] triangleZCoordinates = new int[triangleCount * 3];
forEachTriangle(new TriangleConsumer() {
private int coordinateIndex = 0;
@Override
public void accept(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 double scaleX = QuadEdgeDelaunayTinBuilder.this.scaleX;
final double scaleY = QuadEdgeDelaunayTinBuilder.this.scaleY;
final double scaleZ = QuadEdgeDelaunayTinBuilder.this.scaleZ;
triangleXCoordinates[this.coordinateIndex] = (int) Math.round(x1 * scaleX);
triangleYCoordinates[this.coordinateIndex] = (int) Math.round(y1 * scaleY);
triangleZCoordinates[this.coordinateIndex++] = (int) Math.round(z1 * scaleZ);
triangleXCoordinates[this.coordinateIndex] = (int) Math.round(x2 * scaleX);
triangleYCoordinates[this.coordinateIndex] = (int) Math.round(y2 * scaleY);
triangleZCoordinates[this.coordinateIndex++] = (int) Math.round(z2 * scaleZ);
triangleXCoordinates[this.coordinateIndex] = (int) Math.round(x3 * scaleX);
triangleYCoordinates[this.coordinateIndex] = (int) Math.round(y3 * scaleY);
triangleZCoordinates[this.coordinateIndex++] = (int) Math.round(z3 * scaleZ);
}
});
return new IntArrayScaleTriangulatedIrregularNetwork(this.geometryFactory, boundingBox, triangleCount, triangleXCoordinates, triangleYCoordinates, triangleZCoordinates);
}
Aggregations