use of com.revolsys.elevation.tin.IntArrayScaleTriangulatedIrregularNetwork in project com.revolsys.open by revolsys.
the class ScaledIntegerTriangulatedIrregularNetworkReader method newTriangulatedIrregularNetwork.
public TriangulatedIrregularNetwork newTriangulatedIrregularNetwork() {
open();
int capacity = 10;
int[] triangleXCoordinates = new int[capacity];
int[] triangleYCoordinates = new int[capacity];
int[] triangleZCoordinates = new int[capacity];
int coordinateIndex = 0;
boolean hasMore = true;
while (hasMore) {
try {
if (coordinateIndex >= capacity) {
final int minCapacity = coordinateIndex + 1;
capacity = capacity + (capacity >> 1);
if (capacity - minCapacity < 0) {
capacity = minCapacity;
}
if (capacity - MAX_ARRAY_SIZE > 0) {
if (minCapacity < 0) {
throw new OutOfMemoryError();
} else if (minCapacity > MAX_ARRAY_SIZE) {
capacity = Integer.MAX_VALUE;
} else {
capacity = MAX_ARRAY_SIZE;
}
}
triangleXCoordinates = Arrays.copyOf(triangleXCoordinates, capacity);
triangleYCoordinates = Arrays.copyOf(triangleYCoordinates, capacity);
triangleZCoordinates = Arrays.copyOf(triangleZCoordinates, capacity);
}
triangleXCoordinates[coordinateIndex] = this.in.getInt();
triangleYCoordinates[coordinateIndex] = this.in.getInt();
triangleZCoordinates[coordinateIndex] = this.in.getInt();
coordinateIndex++;
} catch (final WrappedException e) {
if (Exceptions.isException(e, EOFException.class) && coordinateIndex % 3 == 0) {
hasMore = false;
} else {
throw e;
}
}
}
triangleXCoordinates = Arrays.copyOf(triangleXCoordinates, coordinateIndex);
triangleYCoordinates = Arrays.copyOf(triangleYCoordinates, coordinateIndex);
triangleZCoordinates = Arrays.copyOf(triangleZCoordinates, coordinateIndex);
final int triangleCount = coordinateIndex / 3;
final IntArrayScaleTriangulatedIrregularNetwork tin = new IntArrayScaleTriangulatedIrregularNetwork(this.geometryFactory, this.boundingBox, triangleCount, triangleXCoordinates, triangleYCoordinates, triangleZCoordinates);
tin.setProperties(getProperties());
return tin;
}
use of com.revolsys.elevation.tin.IntArrayScaleTriangulatedIrregularNetwork 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);
}
use of com.revolsys.elevation.tin.IntArrayScaleTriangulatedIrregularNetwork in project com.revolsys.open by revolsys.
the class IntQuadEdgeDelaunayTinBuilder method newTriangulatedIrregularNetwork.
public TriangulatedIrregularNetwork newTriangulatedIrregularNetwork() {
buildTin();
final BoundingBox boundingBox = getBoundingBox();
final AtomicInteger triangleCounter = new AtomicInteger();
forEachTriangleInt((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];
forEachTriangleInt(new TriangleConsumerInt() {
private int coordinateIndex = 0;
@Override
public void accept(final int x1, final int y1, final int z1, final int x2, final int y2, final int z2, final int x3, final int y3, final int z3) {
triangleXCoordinates[this.coordinateIndex] = x1;
triangleYCoordinates[this.coordinateIndex] = y1;
triangleZCoordinates[this.coordinateIndex++] = z1;
triangleXCoordinates[this.coordinateIndex] = x2;
triangleYCoordinates[this.coordinateIndex] = y2;
triangleZCoordinates[this.coordinateIndex++] = z2;
triangleXCoordinates[this.coordinateIndex] = x3;
triangleYCoordinates[this.coordinateIndex] = y3;
triangleZCoordinates[this.coordinateIndex++] = z3;
}
});
return new IntArrayScaleTriangulatedIrregularNetwork(this.geometryFactory, boundingBox, triangleCount, triangleXCoordinates, triangleYCoordinates, triangleZCoordinates);
}
Aggregations