import { BSplineWrapMode } from "../bspline/KnotVector"; /** * The `SerializationHelpers` namespace has helper classes for serializing and deserializing geometry, such as B-spline curves and surfaces. * @public */ export declare namespace SerializationHelpers { /** Interface for data common to B-spline curves and surfaces. */ interface BSplineParams { /** The number of control points, aka poles. */ numPoles: number; /** B-spline order, one more than the degree. */ order: number; /** Whether the B-spline is to be considered closed. */ closed?: boolean; /** Full knot vector. */ knots: number[] | Float64Array; /** Wrap mode, for data roundtrip. */ wrapMode?: BSplineWrapMode; } /** Interface for B-spline curve data. */ interface BSplineCurveData { /** Control points, aka poles. */ poles: number[][] | Float64Array; /** The number of coordinates per pole. This is the inner dimension of the poles number array. Possible values: 3, 4. Dimension 4 means the curve is rational, with poles of homogeneous form [wx,wy,wz,w]. */ dim: number; /** Weights for a rational curve that is specified by parallel arrays of poles and weights. If defined, dim is expected to be 3, and poles are of homogeneous form [wx,wy,wz]. */ weights?: number[] | Float64Array; /** Knots and other B-spline data. */ params: BSplineParams; } /** Interface for B-spline surface data. */ interface BSplineSurfaceData { /** Control points, aka poles in row-major order. */ poles: number[][][] | Float64Array; /** The number of coordinates per pole. This is the inner dimension of the poles number array. Possible values: 3, 4. Dimension 4 means the surface is rational, with poles of homogeneous form [wx,wy,wz,w]. */ dim: number; /** Weights for a rational surface that is specified by parallel arrays of poles and weights. If defined, dim is expected to be 3, and poles are of homogeneous form [wx,wy,wz]. */ weights?: number[][] | Float64Array; /** Knots and other B-spline data with respect to the surface u parameter. uParams.numPoles = # columns (middle dimension) of the poles array. */ uParams: BSplineParams; /** Knots and other B-spline data with respect to the surface v parameter. vParams.numPoles = # rows (outer dimension) of the poles array. */ vParams: BSplineParams; } /** Interface of options for import/export. */ interface BSplineDataOptions { /** Type of output pole/weight arrays. true: structured number array; false: Float64Array; undefined: either. */ jsonPoles?: boolean; /** Type of output knot arrays. true: number array; false: Float64Array; undefined: either. */ jsonKnots?: boolean; /** Extraneous knot handling during Import: true: remove them; false | undefined: leave them. Has no effect during Export, which always outputs the extraneous knots. */ removeExtraKnots?: boolean; } /** Constructor for BSplineCurveData that populates the required data. Inputs are captured, not copied. */ function createBSplineCurveData(poles: number[][] | Float64Array, dim: number, knots: number[] | Float64Array, numPoles: number, order: number): BSplineCurveData; /** Constructor for BSplineSurfaceData that populates the required data. Inputs are captured, not copied. */ function createBSplineSurfaceData(poles: number[][][] | Float64Array, dim: number, uKnots: number[] | Float64Array, uNumPoles: number, uOrder: number, vKnots: number[] | Float64Array, vNumPoles: number, vOrder: number): BSplineSurfaceData; /** Clone B-spline curve data */ function cloneBSplineCurveData(source: BSplineCurveData): BSplineCurveData; /** Clone B-spline surface data */ function cloneBSplineSurfaceData(source: BSplineSurfaceData): BSplineSurfaceData; /** * Process 1-based blocked indices into 0-based indices. * @param sourceIndices signed, 1-based, 0-terminated/padded source indices, blocking specified by `numPerBlock` * @param numPerBlock index blocking: fixed blocks of size numPerBlock > 1, possibly 0-padded; otherwise, variable-sized blocks terminated by 0 * @param announceZeroBasedIndex callback to receive a 0-based index and optional flag indicating whether the sign of the source index is positive * @param terminateBlock optional callback called after each index block has been announced */ function announceZeroBasedIndicesFromSignedOneBasedIndices(sourceIndices: Int32Array, numPerBlock: number, announceZeroBasedIndex: (i0: number, flag?: boolean) => any, terminateBlock?: () => any): void; /** * Process 0-based indices with blocking specified by another index array. * @param sourceIndices 0-based source indices. This array is compressed (has no blocking). * @param blockingIndices 1-based source indices, blocking specified by `numPerBlock`. Assumed to have length equal to its zero count plus `sourceIndices.length`. * @param numPerBlock index blocking: fixed blocks of size numPerBlock > 1, possibly 0-padded; otherwise, variable-sized blocks terminated by 0 * @param announceZeroBasedIndex callback to receive a 0-based index * @param terminateBlock optional callback called after each index block has been announced */ function announceZeroBasedIndicesWithExternalBlocking(sourceIndices: Int32Array, blockingIndices: Int32Array, numPerBlock: number, announceZeroBasedIndex: (i0: number) => any, terminateBlock?: () => any): void; /** Special values for persistent zero-based edge mate indices. */ enum EdgeMateIndex { /** Separates face loops. */ BlockSeparator = -1, /** Indicates no edge mate. */ NoEdgeMate = -2 } /** * Compress a 0-based blocked index array by removing block separators/pads and remapping each index. * * The entries of `sourceIndices` are reflexive indices, i.e., they index `sourceIndices`. * * The remapped index `j` must refer to the same block location in the compressed array to which the * original index `i >= 0` refers in `sourceIndices`; therefore `j` is obtained from `i` by subtracting the * number of block separators/pads preceding `sourceIndices[i]`. * @param sourceIndices array of blocked indices to process. Each entry is a 0-based reflexive index, `nullValue`, or `blockSeparator`. * @param numPerBlock index blocking for sourceIndices: padded block size > 2 or variable-sized terminated blocks. * @param blockSeparator negative value that terminates/pads blocks in sourceIndices, e.g. -1. This value is not announced. * @param nullValue negative value that represents "no index" in sourceIndices, e.g., -2. This value is announced as "undefined". * @param announceRemappedIndex callback to receive a remapped index. * @returns true if and only if the mapping was successful. */ function announceCompressedZeroBasedReflexiveIndices(sourceIndices: Int32Array, numPerBlock: number, blockSeparator: number, nullValue: number, announceRemappedIndex: (i: number | undefined) => any): boolean; /** * Uncompress a 0-based index array by inserting block separators and remapping each index. * * Defined entries of `sourceIndices` are reflexive indices, i.e., they index `sourceIndices`. * * The remapped index `j` must refer to the same block location in the uncompressed array to which the * original defined index `i` refers in `sourceIndices`; therefore `j` is obtained from `i` by adding the * number of full blocks preceding `sourceIndices[i]`. * @param sourceIndices array of compressed indices to process. Each entry is a 0-based reflexive index, or `undefined`. * @param sourceStarts sourceStarts[k] is the first index of the k_th block in `sourceIndices`; its last entry is the * length of `sourceIndices`. * @param blockSeparator negative value that represents an announced block terminator, e.g. -1. * @param nullValue negative value to announce for an undefined source index, e.g., -2. * @param announceRemappedIndex callback to receive a remapped index. * @returns true if and only if the mapping was successful. */ function announceUncompressedZeroBasedReflexiveIndices(sourceIndices: Array, sourceStarts: ReadonlyArray, blockSeparator: number, nullValue: number, announceRemappedIndex: (i: number) => any): boolean; /** Helper class for preparing geometry data for import. */ class Import { /** copy knots, with options to control destination type and extraneous knot removal */ private static copyKnots; /** * Recognize the special legacy periodic B-spline data of mode BSplineWrapMode.OpenByRemovingKnots, and return the corresponding modern open clamped knots. * * Note that the B-spline poles corresponding to the converted knots remain unchanged, but it is assumed that first and last poles are equal. * * Example: the legacy 7-point quadratic circle periodic knots {-1/3 0 0 0 1/3 1/3 2/3 2/3 1 1 1 4/3} are converted to open knots {0 0 1/3 1/3 2/3 2/3 1 1}. * * General form of knot vector (k = order, d = k-1 = degree, p = numPoles): * * * legacy input: {k/2 periodically extended knots} {start knot multiplicity k} {p-k interior knots} {end knot multiplicity k} {d/2 periodically extended knots} * * * converted output: {start knot multiplicity d} {p-k interior knots} {end knot multiplicity d} * @param knots classic knot vector to test * @param numPoles number of poles * @param order B-spline order * @param options for output type, extraneous knot removal * @returns open knots if legacy periodic B-spline input data is recognized; otherwise, undefined * @see Export.closeLegacyPeriodicKnots */ private static openLegacyPeriodicKnots; /** Prepare imported B-spline curve data for eventual conversion to BSplineCurve3d | BSplineCurve3dH: * * Opens legacy "fake" periodic data by expanding knots * * Opens true periodic data by expanding poles and weights * @param data updated in place. If poles/weights/knots are updated, their respective arrays are reallocated. * @param options output specifications * @returns whether data was successfully prepared */ static prepareBSplineCurveData(data: BSplineCurveData, options?: BSplineDataOptions): boolean; /** Prepare imported B-spline surface data for eventual conversion to BSplineSurface3d | BSplineSurface3dH: * * Opens legacy "fake" periodic data by expanding knots * * Opens true periodic data by expanding poles and weights * @param data updated in place. If poles/weights/knots are updated, their respective arrays are reallocated. * @param options output specifications * @returns whether data was successfully prepared */ static prepareBSplineSurfaceData(data: BSplineSurfaceData, options?: BSplineDataOptions): boolean; } /** Helper class for preparing geometry data for export. */ class Export { /** * Restore special legacy periodic B-spline knots opened via BSplineWrapMode.OpenByRemovingKnots logic. * @param knots modern knot vector: {start knot multiplicity d} {p-k interior knots} {end knot multiplicity d} * @param order B-spline order * @param options for output type * @param wrapMode wrap mode of the knots * @returns legacy periodic knots (with classic extraneous start/end knot) if wrapMode recognized; otherwise, undefined * @see Import.openLegacyPeriodicKnots */ private static closeLegacyPeriodicKnots; /** * Prepare data from a B-spline curve for export. * * adds classic extraneous knot at start and end of knot vector * * re-closes periodic data based on BSplineWrapMode * @param data updated in place. If poles/weights/knots are updated, their respective arrays are reallocated. * @param options output specifications * @returns whether data was successfully prepared */ static prepareBSplineCurveData(data: BSplineCurveData, options?: BSplineDataOptions): boolean; /** * Prepare data from a B-spline surface for export. * * adds classic extraneous knot at start and end of knot vectors * * re-closes periodic data based on BSplineWrapMode * @param data updated in place. If poles/weights/knots are updated, their respective arrays are reallocated. * @param options output specifications * @returns whether data was successfully prepared */ static prepareBSplineSurfaceData(data: BSplineSurfaceData, options?: BSplineDataOptions): boolean; } } //# sourceMappingURL=SerializationHelpers.d.ts.map