"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloneWithExpandedLineStrings = void 0;
const LineSegment3d_1 = require("../LineSegment3d");
const LineString3d_1 = require("../LineString3d");
const CloneCurvesContext_1 = require("./CloneCurvesContext");
/**
 * Algorithmic class for cloning with linestrings expanded to line segments
 * @internal
 */
class CloneWithExpandedLineStrings extends CloneCurvesContext_1.CloneCurvesContext {
    constructor() {
        // we have no transform ....
        super(undefined);
    }
    // We know we have no transform !!!
    doClone(primitive) {
        if (primitive instanceof LineString3d_1.LineString3d && primitive.numPoints() > 1) {
            const packedPoints = primitive.packedPoints;
            const n = packedPoints.length;
            const segments = [];
            for (let i = 0; i + 1 < n; i++) {
                segments.push(LineSegment3d_1.LineSegment3d.createCapture(packedPoints.getPoint3dAtUncheckedPointIndex(i), packedPoints.getPoint3dAtUncheckedPointIndex(i + 1)));
            }
            return segments;
        }
        return primitive.clone();
    }
    static clone(target) {
        const context = new CloneWithExpandedLineStrings();
        target.announceToCurveProcessor(context);
        return context._result;
    }
}
exports.CloneWithExpandedLineStrings = CloneWithExpandedLineStrings;
//# sourceMappingURL=CloneWithExpandedLineStrings.js.map