"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Rendering
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.PolylineEdgeArgs = exports.SilhouetteEdgeArgs = exports.EdgeArgs = exports.MeshEdges = exports.MeshEdge = exports.MeshPolylineList = exports.MeshPolyline = exports.PolylineTypeFlags = void 0;
// cSpell:ignore vals
/** Describes the semantics of a [PolylineArgs]($frontend).
 * @public
 */
var PolylineTypeFlags;
(function (PolylineTypeFlags) {
    /** Just an ordinary polyline with no special semantics. */
    PolylineTypeFlags[PolylineTypeFlags["Normal"] = 0] = "Normal";
    /** A polyline used to define the edges of a planar region. */
    PolylineTypeFlags[PolylineTypeFlags["Edge"] = 1] = "Edge";
    /** Like [[Edge]], but the edges are only displayed in [[RenderMode.Wireframe]] when the surface's fill is not displayed.
     * [[FillFlags]] controls whether the fill is displayed.
     */
    PolylineTypeFlags[PolylineTypeFlags["Outline"] = 2] = "Outline";
})(PolylineTypeFlags || (exports.PolylineTypeFlags = PolylineTypeFlags = {}));
/** @internal */
class MeshPolyline {
    constructor(indices = []) {
        this.indices = indices.slice();
    }
    addIndex(index) {
        const { indices } = this;
        if (indices.length === 0 || indices[indices.length - 1] !== index)
            indices.push(index);
    }
    clear() { this.indices.length = 0; }
}
exports.MeshPolyline = MeshPolyline;
/** @internal */
class MeshPolylineList extends Array {
    constructor(...args) {
        super(...args);
    }
}
exports.MeshPolylineList = MeshPolylineList;
/** @internal */
class MeshEdge {
    constructor(index0, index1) {
        this.indices = [0, 0];
        if (undefined === index0 || undefined === index1)
            return;
        if (index0 < index1) {
            this.indices[0] = index0;
            this.indices[1] = index1;
        }
        else {
            this.indices[0] = index1;
            this.indices[1] = index0;
        }
    }
    compareTo(other) {
        let diff = this.indices[0] - other.indices[0];
        if (0 === diff)
            diff = this.indices[1] - other.indices[1];
        return diff;
    }
}
exports.MeshEdge = MeshEdge;
/** @internal */
class MeshEdges {
    constructor() {
        this.visible = [];
        this.silhouette = [];
        this.polylines = new MeshPolylineList();
        this.silhouetteNormals = [];
    }
}
exports.MeshEdges = MeshEdges;
/** @internal */
class EdgeArgs {
    init(meshEdges) {
        this.clear();
        if (undefined !== meshEdges && 0 < meshEdges.visible.length)
            this.edges = meshEdges.visible;
        return this.isValid;
    }
    clear() { this.edges = undefined; }
    get isValid() { return 0 < this.numEdges; }
    get numEdges() { return undefined !== this.edges ? this.edges.length : 0; }
}
exports.EdgeArgs = EdgeArgs;
/** @internal */
class SilhouetteEdgeArgs extends EdgeArgs {
    init(meshEdges) {
        this.clear();
        if (undefined !== meshEdges && 0 < meshEdges.silhouette.length) {
            this.edges = meshEdges.silhouette;
            this.normals = meshEdges.silhouetteNormals;
        }
        return this.isValid;
    }
    clear() {
        this.normals = undefined;
        super.clear();
    }
}
exports.SilhouetteEdgeArgs = SilhouetteEdgeArgs;
/** @internal */
class PolylineEdgeArgs {
    constructor(lines) { this.init(lines); }
    init(lines) {
        this.lines = undefined !== lines && 0 < lines.length ? lines : undefined;
        return this.isValid;
    }
    get numLines() { return undefined !== this.lines ? this.lines.length : 0; }
    get isValid() { return this.numLines > 0; }
    clear() { this.lines = undefined; }
}
exports.PolylineEdgeArgs = PolylineEdgeArgs;
//# sourceMappingURL=Render.js.map