import _ from 'lodash';
import '../../../../assert/js/assert.js';
import '../../../../globals.js';
// Copyright 2023-2024, University of Colorado Boulder
/**
 * Represents an edge from a RasterCompleteEdgeChunk
 *
 * Output edge for the raster-clip algorithm
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import { alpenglow } from '../../imports.js';
import Vector2 from '../../../../dot/js/Vector2.js';
class RasterCompleteEdge {
    constructor(startPoint, endPoint) {
        this.startPoint = startPoint;
        this.endPoint = endPoint;
    }
    toString() {
        if (isNaN(this.startPoint.x)) {
            return 'RasterCompleteEdge[INDETERMINATE]';
        }
        return `RasterCompleteEdge[${this.startPoint.x},${this.startPoint.y} => ${this.endPoint.x},${this.endPoint.y}]`;
    }
    writeEncoding(encoder) {
        encoder.pushF32(this.startPoint.x);
        encoder.pushF32(this.startPoint.y);
        encoder.pushF32(this.endPoint.x);
        encoder.pushF32(this.endPoint.y);
    }
    static readEncoding(arrayBuffer, byteOffset) {
        const floatBuffer = new Float32Array(arrayBuffer, byteOffset, RasterCompleteEdge.ENCODING_BYTE_LENGTH / 4);
        return new RasterCompleteEdge(new Vector2(floatBuffer[0], floatBuffer[1]), new Vector2(floatBuffer[2], floatBuffer[3]));
    }
    static fromArrayBuffer(arrayBuffer) {
        assert && assert(arrayBuffer.byteLength % RasterCompleteEdge.ENCODING_BYTE_LENGTH === 0);
        return _.range(0, arrayBuffer.byteLength / RasterCompleteEdge.ENCODING_BYTE_LENGTH).map(i => {
            return RasterCompleteEdge.readEncoding(arrayBuffer, i * RasterCompleteEdge.ENCODING_BYTE_LENGTH);
        });
    }
}
RasterCompleteEdge.ENCODING_BYTE_LENGTH = 4 * 4;
RasterCompleteEdge.INDETERMINATE = new RasterCompleteEdge(new Vector2(NaN, NaN), new Vector2(NaN, NaN));
export default RasterCompleteEdge;
alpenglow.register('RasterCompleteEdge', RasterCompleteEdge);
//# sourceMappingURL=RasterCompleteEdge.js.map