/** @packageDocumentation * @module ArraysAndInterfaces */ import { PlaneAltitudeEvaluator } from "../Geometry"; import { Matrix4d } from "../geometry4d/Matrix4d"; import { IndexedReadWriteXYZCollection, IndexedXYZCollection, MultiLineStringDataVariant } from "./IndexedXYZCollection"; import { Matrix3d } from "./Matrix3d"; import { Plane3dByOriginAndUnitNormal } from "./Plane3dByOriginAndUnitNormal"; import { Point2d } from "./Point2dVector2d"; import { Point3d, Vector3d, XYZ } from "./Point3dVector3d"; import { Range1d, Range3d } from "./Range"; import { Transform } from "./Transform"; import { XYAndZ } from "./XYZProps"; /** * `GrowableXYZArray` manages a (possibly growing) Float64Array to pack xyz coordinates. * @public */ export declare class GrowableXYZArray extends IndexedReadWriteXYZCollection { /** Array of packed xyz xyz xyz components. */ private _data; /** Number of xyz triples (not floats) in the array. */ private _xyzInUse; /** Capacity in xyz triples (not floats). */ private _xyzCapacity; /** Multiplier used by [[ensureCapacity]] to expand requested reallocation size. */ private _growthFactor; /** * Construct a new growable array. * @param numPoints initial capacity in xyz tuples. Default value is 8. * @param growthFactor used by [[ensureCapacity]] to expand requested reallocation size. Default value is 1.5. * For no expansion, use 1. * @param data optional array to serve as the point source. If `data` is supplied, `numPoints` is reinterpreted as * the initial point count, defaulting to and bounded above by the array's point capacity. If a subsequent [[push]] * would exceed the array's capacity, a new Float64Array of the same buffer type is allocated and filled. */ constructor(numPoints?: number, growthFactor?: number, data?: Float64Array); /** * Copy xyz points from source array. Does not reallocate or change active point count. * @param source array to copy from. * @param sourceCount copy the first sourceCount points; all points if undefined. * @param destOffset copy to instance array starting at this point index; zero if undefined. * @return count and offset of points copied. */ protected copyData(source: Float64Array | number[], sourceCount?: number, destOffset?: number): { count: number; offset: number; }; /** The number of points in use. When the length is increased, the array is padded with zeroes. */ get length(): number; set length(newLength: number); /** Return the number of float64 in use. */ get float64Length(): number; /** * Return the raw packed data. * * Note that the length of the returned Float64Array is a count of doubles, and includes the excess capacity */ float64Data(): Float64Array; /** * If necessary, increase the capacity to the new number of points. Current coordinates and point count (length) are * unchanged. */ ensureCapacity(pointCapacity: number, applyGrowthFactor?: boolean): void; /** * * If pointCount is less than current length, just reset current length to pointCount, effectively trimming active * points but preserving original capacity. * * If pointCount is greater than current length, reallocate to exactly pointCount, copy existing points, and * optionally pad excess with zero. * @param pointCount new number of active points in array. * @param padWithZero when increasing point count, whether to zero out new points (default false). */ resize(pointCount: number, padWithZero?: boolean): void; /** Make a copy of the (active) points in this array (the clone does NOT get excess capacity). */ clone(result?: GrowableXYZArray): GrowableXYZArray; /** * Clone the input array with each successive duplicate point removed. * * First and last points are always preserved. * @param source the source array. * @param tolerance optional distance tol for compression (default [[Geometry.smallMetricDistance]]). * @param result optional pre-allocated object to populate and return. Can be a reference to `source`, in * which case the array is compressed in place and returned. * @see [[cloneCompressed]], [[compressInPlace]], [[PolylineOps.compressShortEdges]]. */ static createCompressed(source: IndexedXYZCollection, tolerance?: number, result?: GrowableXYZArray): GrowableXYZArray; /** * Clone the instance array with each successive duplicate point removed. * * First and last points are always preserved. * @param tolerance optional distance tol for compression (default [[Geometry.smallMetricDistance]]) * @param result optional pre-allocated object to populate and return. Can be a reference to the instance array, in * which case the array is compressed in place and returned. * @see [[createCompressed]], [[compressInPlace]], [[PolylineOps.compressShortEdges]] */ cloneCompressed(tolerance?: number, result?: GrowableXYZArray): GrowableXYZArray; /** * Compress the input array by removing successive duplicate points. * * First and last points are always preserved. * @param tolerance optional distance tol for compression (default [[Geometry.smallMetricDistance]]). * @returns the instance array. * @see [[createCompressed]], [[cloneCompressed]], [[PolylineOps.compressShortEdges]]. */ compressInPlace(tolerance?: number): GrowableXYZArray; /** * Create an array by copying data from various point formats. * Valid inputs are: * * Point2d * * Point3d * * An array of 2 doubles * * An array of 3 doubles * * A GrowableXYZArray * * Any json object satisfying Point3d.isXYAndZ * * Any json object satisfying Point3d.isXAndY * * A Float64Array of doubles, interpreted as xyzxyz * * An array of any of the above * @param data source points. * @param result optional pre-allocated GrowableXYZArray to clear and fill. */ static create(data: any, result?: GrowableXYZArray): GrowableXYZArray; /** * Create a new GrowableXYZArray capturing the provided data. The data is not copied, just referenced. * @param data source data to capture. * @returns a new GrowableXYZArray object that references the provided data. */ static createCapture(data: Float64Array): GrowableXYZArray; /** Restructure MultiLineStringDataVariant as array of GrowableXYZArray. */ static createArrayOfGrowableXYZArray(data: MultiLineStringDataVariant): GrowableXYZArray[] | undefined; /** Push a point to the end of the array. */ push(toPush: XYAndZ): void; /** Push all points of an array. */ pushAll(points: Point3d[]): void; /** * Push copies of points from variant sources. * Valid inputs are: * * Point2d * * Point3d * * An array of 2 doubles * * An array of 3 doubles * * An IndexedXYZCollection * * Any json object satisfying Point3d.isXYAndZ * * Any json object satisfying Point3d.isXAndY * * A Float64Array of doubles, interpreted as xyzxyz * * An array of any of the above. */ pushFrom(p: any): void; /** * Replicate numWrap xyz values from the front of the array as new values at the end. * @param numWrap number of xyz values to replicate. */ pushWrap(numWrap: number): void; /** Append a new point with given x,y,z. */ pushXYZ(x: number, y: number, z: number): void; /** * Shift all data forward to make space for numPoints at the front. * * Leading (3*numPoints) doubles are left with prior contents. * * _xyzInUse count is increased. */ private shiftForward; /** * Prepend a new point with given x,y,z * * Remark: this copies all content forward. */ pushFrontXYZ(x: number, y: number, z: number): void; /** Prepend a new point at the front of the array. */ pushFront(toPush: XYAndZ): void; /** * Move the coordinates at fromIndex to toIndex. * * No action if either index is invalid. */ moveIndexToIndex(fromIndex: number, toIndex: number): void; /** * Remove one point from the back. * * NOTE that (in the manner of std::vector native) this is "just" removing the point -- no point is NOT returned. * * Use `back ()` to get the last x,y,z assembled into a `Point3d ` */ pop(): void; /** Clear all xyz data, but leave capacity unchanged. */ clear(): void; /** * Get a point by index, strongly typed as a Point3d. This is unchecked. Use [[getPoint3dAtCheckedPointIndex]] to * have validity test. * @param pointIndex index to access. * @param result optional result. */ getPoint3dAtUncheckedPointIndex(pointIndex: number, result?: Point3d): Point3d; /** * Get a point by index, strongly typed as a Point2d. This is unchecked. Use [[getPoint2dAtCheckedPointIndex]] to * have validity test. * @param pointIndex index to access. * @param result optional result. */ getPoint2dAtUncheckedPointIndex(pointIndex: number, result?: Point2d): Point2d; /** * Get a vector by index, strongly typed as a Vector3d. This is unchecked. Use [[getVector3dAtCheckedVectorIndex]] * to have validity test. * @param vectorIndex index to access. * @param result optional result. */ getVector3dAtUncheckedVectorIndex(vectorIndex: number, result?: Vector3d): Vector3d; /** Copy xyz into strongly typed Point3d. */ getPoint3dAtCheckedPointIndex(pointIndex: number, result?: Point3d): Point3d | undefined; /** Access x of indexed point. */ getXAtUncheckedPointIndex(pointIndex: number): number; /** Access y of indexed point. */ getYAtUncheckedPointIndex(pointIndex: number): number; /** Access z of indexed point. */ getZAtUncheckedPointIndex(pointIndex: number): number; /** Copy xy into strongly typed Point2d. */ getPoint2dAtCheckedPointIndex(pointIndex: number, result?: Point2d): Point2d | undefined; /** Copy xyz into strongly typed Vector3d. */ getVector3dAtCheckedVectorIndex(vectorIndex: number, result?: Vector3d): Vector3d | undefined; /** * Read a point from the source array, and place its coordinates at the given index within this array. * @param destIndex index of point in this array to be overwritten. * @param source source array. * @param sourceIndex point index in source array. * @returns true if destIndex and sourceIndex are both valid. */ transferFromGrowableXYZArray(destIndex: number, source: IndexedXYZCollection, sourceIndex: number): boolean; /** * Push coordinates from the source array to the end of this array. * @param source source array. * @param sourceIndex xyz index within the source. If undefined, entire source is pushed. * @returns number of points pushed. */ pushFromGrowableXYZArray(source: GrowableXYZArray, sourceIndex?: number): number; /** * Push coordinates from the source array to the end of this array. * @param source source array. * @returns number of points pushed. */ pushIndexedXYZCollection(source: IndexedXYZCollection): number; /** * Set the coordinates of a single point. * @param pointIndex index of point to set. * @param value coordinates to set. */ setAtCheckedPointIndex(pointIndex: number, value: XYAndZ): boolean; /** * Set the coordinates of a single point given as coordinates. * @param pointIndex index of point to set. * @param x x coordinate. * @param y y coordinate. * @param z z coordinate. */ setXYZAtCheckedPointIndex(pointIndex: number, x: number, y: number, z: number): boolean; /** Copy all points into a simple array of Point3. */ getPoint3dArray(): Point3d[]; /** Multiply each point by the transform, replace values. */ static multiplyTransformInPlace(transform: Transform, data: GrowableXYZArray[] | GrowableXYZArray): void; /** Multiply each point by the transform, replace values. */ multiplyTransformInPlace(transform: Transform): void; /** Reverse the order of points. */ reverseInPlace(): void; /** Multiply each xyz (as a vector) by matrix, replace values. */ multiplyMatrix3dInPlace(matrix: Matrix3d): void; /** * Multiply each xyz (as a vector) by matrix inverse transpose, renormalize the vector, replace values. * * This is the way to apply a matrix (possibly with skew and scale) to a surface normal, and have it end up * perpendicular to the transformed in-surface vectors. * * Return false if matrix is not invertible or if any normalization fails. */ multiplyAndRenormalizeMatrix3dInverseTransposeInPlace(matrix: Matrix3d): boolean; /** Multiply each xyz (as a point) by a homogeneous matrix and update as the normalized point. */ multiplyMatrix4dAndQuietRenormalizeMatrix4d(matrix: Matrix4d): void; /** Multiply each point by the transform, replace values. */ tryTransformInverseInPlace(transform: Transform): boolean; /** Extend `range` to extend by all points. */ extendRange(rangeToExtend: Range3d, transform?: Transform): void; /** Get range of points. */ getRange(transform?: Transform, result?: Range3d): Range3d; /** Initialize `range` with coordinates in this array. */ setRange(range: Range3d, transform?: Transform): void; /** Sum the lengths of segments between points. */ sumLengths(): number; /** * Multiply each x,y,z by the scale factor. * @param factor scale factor. */ scaleInPlace(factor: number): void; /** Test if all points are within tolerance of a plane. */ isCloseToPlane(plane: Plane3dByOriginAndUnitNormal, tolerance?: number): boolean; /** * * If not already closed, push a copy of the first point. * * If already closed within tolerance, force exact copy. * * Otherwise leave unchanged. */ forceClosure(tolerance?: number): void; /** Compute a point at fractional coordinate between points i and j. */ interpolate(i: number, fraction: number, j: number, result?: Point3d): Point3d | undefined; /** Compute a point at fractional coordinate between points i and j of source and push onto this array. */ pushInterpolatedFromGrowableXYZArray(source: GrowableXYZArray, i: number, fraction: number, j: number): void; /** Sum the signed areas of the projection to xy plane. */ areaXY(): number; /** Compute a vector from index origin i to indexed target j. */ vectorIndexIndex(i: number, j: number, result?: Vector3d): Vector3d | undefined; /** * Compute a vector from index origin i to indexed target j. * * This method does not check for index validity. Use [[vectorIndexIndex]] to have validity test. */ vectorUncheckedIndexIndex(i: number, j: number, result?: Vector3d): Vector3d; /** Compute a vector from origin to indexed target j. */ vectorXYAndZIndex(origin: XYAndZ, j: number, result?: Vector3d): Vector3d | undefined; /** * Compute a vector from origin to indexed target j. * * This method does not check for index validity. Use [[vectorXYAndZIndex]] to have validity test. */ vectorXYAndZUncheckedIndex(origin: XYAndZ, j: number, result?: Vector3d): Vector3d; /** Compute the cross product of vectors from from indexed origin to indexed targets. */ crossProductIndexIndexIndex(originIndex: number, targetAIndex: number, targetBIndex: number, result?: Vector3d): Vector3d | undefined; /** * Compute the cross product of vectors from from indexed origin to indexed targets. * * This method does not check for index validity. Use [[crossProductIndexIndexIndex]] to have validity test. */ crossProductUncheckedIndexIndexIndex(originIndex: number, targetAIndex: number, targetBIndex: number, result?: Vector3d): Vector3d; /** * Return the cross product of the vectors from `origin` to the point at `indexA` and to `targetB. * * This method does not check for index validity. Use [[crossProductIndexIndexXYAndZ]] to have validity test. * @param origin index of point within the array; origin of both vectors. * @param indexA index of point within the array; target of the first vector. * @param targetB target of second vector. * @param result optional caller-allocated result to fill and return. */ crossProductUncheckedIndexIndexXYAndZ(origin: number, indexA: number, targetB: XYAndZ, result?: Vector3d): Vector3d; /** Compute the dot product of pointIndex with [x,y,z]. */ evaluateUncheckedIndexDotProductXYZ(pointIndex: number, x: number, y: number, z: number): number; /** Return the altitude of the indexed point from the plane. */ evaluateUncheckedIndexPlaneAltitude(pointIndex: number, plane: PlaneAltitudeEvaluator): number; /** Compute the cross product from the point at `originIndex` to targets at indices `targetAIndex` and `targetBIndex`, and add it to `result`. */ accumulateCrossProductIndexIndexIndex(originIndex: number, targetAIndex: number, targetBIndex: number, result: Vector3d): void; /** * Compute the cross product from indexed origin t indexed targets targetAIndex and targetB index. * * Accumulate it to the result. */ accumulateScaledXYZ(index: number, scale: number, sum: Point3d): void; /** Compute the cross product of vectors from from origin to indexed targets i and j. */ crossProductXYAndZIndexIndex(origin: XYAndZ, targetAIndex: number, targetBIndex: number, result?: Vector3d): Vector3d | undefined; /** Return the distance between an array point and the input point. */ distanceIndexToPoint(i: number, spacePoint: XYAndZ): number | undefined; /** * Return distance squared between indicated points. * @param i first point index. * @param j second point index. */ distanceSquaredIndexIndex(i: number, j: number): number | undefined; /** * Return distance squared between indicated points. * * This method does not check for index validity. Use [[distanceSquaredIndexIndex]] to have validity test. * @param i first point index. * @param j second point index. */ distanceSquaredUncheckedIndexIndex(i: number, j: number): number; /** * Return distance between indicated points. * @param i first point index. * @param j second point index. */ distanceIndexIndex(i: number, j: number): number | undefined; /** * Return distance between indicated points. * * This method does not check for index validity. Use [[distanceIndexIndex]] to have validity test. * @param i first point index. * @param j second point index. */ distanceUncheckedIndexIndex(i: number, j: number): number; /** Return the distance between points in distinct arrays. */ static distanceBetweenPointsIn2Arrays(arrayA: GrowableXYZArray, i: number, arrayB: GrowableXYZArray, j: number): number | undefined; /** Test for near equality between two `GrowableXYZArray`. */ static isAlmostEqual(dataA: GrowableXYZArray | undefined, dataB: GrowableXYZArray | undefined): boolean; /** Return an array of block indices sorted per compareLexicalBlock function. */ sortIndicesLexical(): Uint32Array; /** Compare two blocks in simple lexical order. */ compareLexicalBlock(ia: number, ib: number): number; /** Access a single double at offset within a block. This has no index checking. */ component(pointIndex: number, componentIndex: number): number; /** Add points at regular steps from `other`. */ addSteppedPoints(other: GrowableXYZArray, pointIndex0: number, step: number, numAdd: number): void; /** * Find the min and max distance between corresponding indexed points. Excess points are ignored. * @param arrayA first array. * @param arrayB second array. */ static distanceRangeBetweenCorrespondingPoints(arrayA: GrowableXYZArray, arrayB: GrowableXYZArray): Range1d; /** Remove trailing point(s) within tolerance of the start point. */ static removeClosure(points: IndexedReadWriteXYZCollection, tolerance?: number): void; /** * Compute frame for a triangle formed by three (unchecked!) points identified by index. * * z direction of frame is 001. * * Transform axes from origin to targetA and targetB. * * in local coordinates (u,v,w) the xy interior of the triangle is `u>=0, v>= 0, w>= 0, u+v+w<1`. * * Return undefined if transform is not invertible, e.g. if points are in a vertical plane. */ fillLocalXYTriangleFrame(originIndex: number, targetAIndex: number, targetBIndex: number, result?: Transform): Transform | undefined; /** * Pass the (x,y,z) of each point to a function which returns a replacement for one of the 3 components. * @param componentIndex Index (0,1,2) of component to be replaced. * @param func function to be called as `func(x,y,z)`, returning a replacement value for componentIndex. */ mapComponent(componentIndex: 0 | 1 | 2, func: (x: number, y: number, z: number) => number): void; /** * Pass the (x,y,z) of each point to a function which returns a replacement for the point. * * @param func function to be called as `func(x,y,z)`, returning a replacement point. */ mapPoint(func: (x: number, y: number, z: number) => XYZ): void; } //# sourceMappingURL=GrowableXYZArray.d.ts.map