import { CurvePrimitive } from "../CurvePrimitive"; import { AnyChain, AnyCurve } from "../CurveTypes"; import { LineString3d } from "../LineString3d"; import { StrokeOptions } from "../StrokeOptions"; /** * Manage a growing array of arrays of curve primitives that are to be joined "head to tail" in paths. * * The caller makes a sequence of calls to announce individual primitives. * * This collector (unlike the simpler [[ChainCollectorContext]]) expects to have inputs arriving in random order, leaving multiple open chains in play at any time. * * When all curves have been announced, the call to `grabResult` restructures the various active chains into Paths (and optionally, Loops). * * Chain formation is dependent upon input fragment order, as a greedy algorithm is employed. * * Usage pattern is * * initialization: `context = new MultiChainCollector(gapTol, planeTol)` * * many times: * * `context.captureCurve(anyCurve)` * * `context.captureCurvePrimitive(primitive)` * * end: `result = context.grabResult(makeLoopIfClosed)` * @internal */ export declare class MultiChainCollector { /** Accumulated chains. */ private _chains; /** Largest gap distance to close. */ private _gapTolerance; /** Planarity tolerance, used to determine whether to return a Path or Loop in `grabResult(true)`. If undefined, always Path. */ private _planeTolerance; private static _staticPointA; private static _staticPointB; private _xyzWork0?; private _xyzWork1?; /** Initialize with an empty array of chains. * @param gapTolerance distance tolerance for calling endpoints identical * @param planeTolerance distance tolerance for considering a closed chain to be planar. If undefined, only create Path. If defined, create Loops for closed chains within this tolerance of a plane. */ constructor(gapTolerance?: number, planeTolerance?: number); /** * Find a chain (with index _other than_ exceptChainIndex) that starts or ends at xyz * @param xyz endpoint to check * @param exceptChainIndex index of chain to ignore. Send -1 to consider all chains. */ private findAnyChainToConnect; /** * Insert a single curve primitive into the active chains. * * The primitive is captured (not cloned) * * The primitive may be reversed in place * @param candidate curve to add to the context */ captureCurvePrimitive(candidate: CurvePrimitive): void; /** * Insert any curve into the collection. * * This recurses into Path, Loop, BagOfCurves etc * * All primitives are captured, and may be reversed in place. * @param candidate curve to add to the context */ captureCurve(candidate: AnyCurve): void; /** If allowed by the geometry type, move an endpoint. */ private simpleEndPointMove; /** * Try to move the end of curve0 and/or the start of curve1 to a common point. * * All z-coordinates are ignored. * @param curve0 first curve, assumed to end close to the start of curve1 * @param curve1 second curve, assumed to start close to the end of curve0 * @returns whether curve start/end point(s) moved */ private moveHeadOrTail; /** Announce a curve primitive * * If a "nearby" connection is possible, insert the candidate in the chain and force endpoint match. * * Otherwise start a new chain. */ private attachPrimitiveToAnyChain; /** * Merge two entries in the chain array. * * Move each primitive from chainB to the end of chainA. * * Clear chainB. * * Move the final chain to chainB index. * * Decrement the array length. * @param chainIndexA index of chainA * @param chainIndexB index of chainB */ private mergeChainsForwardForward; /** Reverse the curve chain in place. */ private reverseChain; /** See if the head or tail of chainIndex matches any existing chain. If so, merge the two chains. */ private searchAndMergeChainIndex; /** * Convert an array of curve primitives into the simplest possible strongly typed curve structure. * @param curves input array, assembled correctly into a single contiguous path, captured by returned object * @param makeLoopIfClosed whether to return a Loop from physically closed coplanar curves, otherwise Path * @return Loop or Path if multiple curves; the primitive if only one curve; undefined if no curves */ private promoteArrayToCurves; /** Stroke the curve chain to a line string, de-duplicate the points. */ private chainToLineString3d; /** Return the collected results, structured as the simplest possible type. */ grabResult(makeLoopIfClosed?: boolean): AnyChain | undefined; /** * Return chains as individual calls to announceChain. * * Does not use planeTolerance. */ announceChainsAsLineString3d(announceChain: (ls: LineString3d) => void, options?: StrokeOptions): void; } //# sourceMappingURL=MultiChainCollector.d.ts.map