import { GeometryHandler } from "../geometry3d/GeometryHandler"; import { GrowableXYZArray } from "../geometry3d/GrowableXYZArray"; import { Plane3dByOriginAndUnitNormal } from "../geometry3d/Plane3dByOriginAndUnitNormal"; import { Point3d, Vector3d } from "../geometry3d/Point3dVector3d"; import { Range1d, Range3d } from "../geometry3d/Range"; import { Ray3d } from "../geometry3d/Ray3d"; import { Transform } from "../geometry3d/Transform"; import { VariantCurveExtendParameter } from "./CurveExtendMode"; import { CurveLocationDetail } from "./CurveLocationDetail"; import { CurvePrimitive, TangentOptions } from "./CurvePrimitive"; import { AnyCurve, type AnyRegion } from "./CurveTypes"; import { GeometryQuery } from "./GeometryQuery"; import { StrokeOptions } from "./StrokeOptions"; import type { RecursiveCurveProcessor } from "./CurveProcessor"; import type { Path } from "./Path"; import type { Loop } from "./Loop"; /** Note: CurveChain and BagOfCurves classes are located in this file to prevent circular dependency. */ /** * Describes the concrete type of a [[CurveCollection]]. Each type name maps to a specific subclass and can be * used in conditional statements for type-switching. * - "loop" => [[Loop]] * - "path" => [[Path]] * - "unionRegion" => [[UnionRegion]] * - "parityRegion" => [[ParityRegion]] * - "bagOfCurves" => [[BagOfCurves]] * @public */ export type CurveCollectionType = "loop" | "path" | "unionRegion" | "parityRegion" | "bagOfCurves"; /** * A `CurveCollection` is an abstract (non-instantiable) class for various sets of curves with particular structures: * - [[CurveChain]] - a non-instantiable intermediate class for a sequence of [[CurvePrimitive]] joining head-to-tail. * The two instantiable forms of `CurveChain` are: * - [[Path]] - a chain of curves. Does not have to be closed or planar. A closed `Path` is not treated as bounding a surface. * - [[Loop]] - a closed and planar chain of curves. A `Loop` is treated as bounding a planar area. * - [[ParityRegion]] - a collection of coplanar `Loop`, with "in/out" classification by parity rules. * - [[UnionRegion]] - a collection of coplanar `Loop` and/or `ParityRegion`, with "in/out" classification by union rules. * - [[BagOfCurves]] - a collection of [[AnyCurve]] with no implied structure. * * @see [Curve Collections]($docs/learning/geometry/CurveCollection.md) learning article. * @public */ export declare abstract class CurveCollection extends GeometryQuery { /** String name for schema properties */ readonly geometryCategory = "curveCollection"; /** Type discriminator. */ abstract readonly curveCollectionType: CurveCollectionType; /** Return the curve children. */ abstract get children(): AnyCurve[]; /** Return the sum of the lengths of all contained curves. */ sumLengths(): number; private computeClosestPoint; /** * Return the closest point on the contained curves. * @param spacePoint point in space. * @param extend extend applicable only to [[Path]] and [[BagOfCurves]]. Default value `false`. * @param result (optional) pre-allocated detail to populate and return. * @returns details of the closest point. */ closestPoint(spacePoint: Point3d, extend?: VariantCurveExtendParameter, result?: CurveLocationDetail): CurveLocationDetail | undefined; /** * Return the closest point on the contained curves as viewed in the xy-plane (ignoring z). * @param spacePoint point in space. * @param extend (optional) extend applicable only to [[Path]] and [[BagOfCurves]]. Default value `false`. * @param result (optional) pre-allocated detail to populate and return. * @returns details of the closest point. */ closestPointXY(spacePoint: Point3d, extend?: VariantCurveExtendParameter, result?: CurveLocationDetail): CurveLocationDetail | undefined; /** * Announce all points `P` on the contained curves such that the line containing `spacePoint` and `P` is tangent to * the contained curves in the view defined by `options.vectorToEye`. * * Strictly speaking, each tangent line lies in the plane through `P` whose normal is the cross product of the curve * tangent at `P` and `options.vectorToEye`. This is equivalent to tangency as seen in a view plane perpendicular to * `options.vectorToEye`. * @param spacePoint point in space. * @param announceTangent callback to announce each computed tangent. The received [[CurveLocationDetail]] is reused * internally, so it should be cloned in the callback if it needs to be saved. * @param options (optional) options for computing tangents. See [[TangentOptions]] for defaults. */ emitTangents(spacePoint: Point3d, announceTangent: (tangent: CurveLocationDetail) => any, options?: TangentOptions): void; /** * Return all points `P` on the contained curves such that the line containing `spacePoint` and `P` is tangent to the * contained curves in the view defined by `options.vectorToEye`. * * See [[emitTangents]] for the definition of tangency employed. * @param spacePoint point in space. * @param options (optional) options for computing tangents. See [[TangentOptions]] for defaults. * @returns an array of details of all tangent points or undefined if no tangent was found. */ allTangents(spacePoint: Point3d, options?: TangentOptions): CurveLocationDetail[] | undefined; /** * Return the point `P` on the contained curves such that the line containing `spacePoint` and `P` is tangent to the * contained curves in the view defined by `options.vectorToEye`, and `P` is closest to `options.hintPoint` in this view. * * See [[emitTangents]] for the definition of tangency employed. * @param spacePoint point in space. * @param options (optional) options for computing tangents. See [[TangentOptions]] for defaults. * @returns the detail of the closest tangent point or undefined if no tangent was found. */ closestTangent(spacePoint: Point3d, options?: TangentOptions): CurveLocationDetail | undefined; /** Reverse the collection's data so that each child curve's fractional stroking moves in the opposite direction. */ reverseInPlace(): void; /** Call [[reverseInPlace]] and return the instance. */ reverse(): this; /** * Return the max gap between adjacent primitives in Path and Loop collections. * * In a Path, gaps are computed between consecutive primitives. * * In a Loop, gaps are computed between consecutive primitives and between last and first. * * Gaps are NOT computed between consecutive CurvePrimitives in "unstructured" collections. The type is * "unstructured" so gaps should not be semantically meaningful. */ maxGap(): number; /** Return true if the curve collection has any primitives other than LineSegment3d and LineString3d */ checkForNonLinearPrimitives(): boolean; /** Apply transform recursively to children */ tryTransformInPlace(transform: Transform): boolean; /** Return a deep copy. */ clone(): CurveCollection; /** Create a deep copy of transformed curves. */ cloneTransformed(transform: Transform): CurveCollection; /** Create a deep copy with all linestrings broken down into multiple LineSegment3d. */ cloneWithExpandedLineStrings(): CurveCollection; /** * Push all CurvePrimitives contained in the instance onto the `results` array. * * This method is recursive. For example, if the CurveCollection contains a Loop, all CurvePrimitives * of the Loop are pushed onto `results`. */ private collectCurvePrimitivesGo; /** * Return an array containing all CurvePrimitives in the instance. * * This method is recursive. For example, if the CurveCollection contains a Loop, all CurvePrimitives of * the Loop are pushed onto the returned array. * @param collectorArray optional array to receive primitives. If present, new primitives are ADDED (without * clearing the array). * @param smallestPossiblePrimitives if false, CurvePrimitiveWithDistanceIndex returns only itself. If true, * it recurses to its (otherwise hidden) children. */ collectCurvePrimitives(collectorArray?: CurvePrimitive[], smallestPossiblePrimitives?: boolean, explodeLineStrings?: boolean): CurvePrimitive[]; /** * Return true for planar region types: * * `Loop` * * `ParityRegion` * * `UnionRegion` * @see isAnyRegion */ get isAnyRegionType(): boolean; /** Type guard for AnyRegion */ isAnyRegion(): this is AnyRegion; /** * Return true for a `Path`, i.e. a chain of curves joined head-to-tail. * * This is NOT a test for (lack of) physical closure. * @see [[isPath]], [[CurveChain.isPhysicallyClosedCurve]] */ get isOpenPath(): boolean; /** * Type guard for Path. * * This is NOT a test for (lack of) physical closure. * @see [[CurveChain.isPhysicallyClosedCurve]] */ isPath(): this is Path; /** * Return true for a single-loop planar region type, i.e. `Loop`. * * This is NOT a test for physical closure. * @see [[isLoop]], [[CurveChain.isPhysicallyClosedCurve]] */ get isClosedPath(): boolean; /** * Type guard for Loop. * * This is NOT a test for physical closure. * @see [[CurveChain.isPhysicallyClosedCurve]] */ isLoop(): this is Loop; /** Return a CurveCollection with the same structure but all curves replaced by strokes. */ abstract cloneStroked(options?: StrokeOptions): CurveCollection; /** Support method for ICurvePrimitive ... one line call to specific announce method . . */ abstract announceToCurveProcessor(processor: RecursiveCurveProcessor): void; /** Clone an empty collection. */ abstract cloneEmptyPeer(): CurveCollection; /** * Return the boundary type of a corresponding MicroStation CurveVector. * * Derived class must implement. */ abstract dgnBoundaryType(): number; /** * Try to add a child. * @param child child to add. * @return true if child is an acceptable type for this collection. */ abstract tryAddChild(child: AnyCurve | undefined): boolean; /** Return a child identified by by index */ abstract getChild(i: number): AnyCurve | undefined; /** * Extend (increase) the given range as needed to encompass all curves in the curve collection. * @param rangeToExtend the given range. * @param transform if supplied, the range is extended with transformed curves. */ extendRange(rangeToExtend: Range3d, transform?: Transform): void; /** * Find any CurvePrimitive in the source and evaluate it at the given fraction. * * The first CurvePrimitive found is evaluated. Any other CurvePrimitives are ignored. * @param source containing `CurvePrimitive` or `CurveCollection` * @param fraction fraction to use in `curve.fractionToPoint(fraction)` */ static createCurveLocationDetailOnAnyCurvePrimitive(source: GeometryQuery | undefined, fraction?: number): CurveLocationDetail | undefined; /** * Project instance geometry (via dispatch) onto the given ray, and return the extreme fractional parameters * of projection. * @param ray ray onto which the instance is projected. A `Vector3d` is treated as a `Ray3d` with zero origin. * @param lowHigh optional receiver for output * @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is the * end of the ray. */ projectedParameterRange(ray: Vector3d | Ray3d, lowHigh?: Range1d): Range1d | undefined; /** Return the immediate parent of the input curve in the instance, or undefined if it is not a descendant. */ findParentOfDescendant(descendant: AnyCurve): CurveCollection | undefined; /** * Ask if the curves of the collection are within tolerance of the input plane. * @returns whether the collection is nonempty and its curves lie within tolerance of the plane. */ isInPlane(plane: Plane3dByOriginAndUnitNormal): boolean; } /** * Shared base class for use by both open and closed paths. * * A `CurveChain` contains only CurvePrimitives. No other paths, loops, or regions allowed. * * The specific derived classes are `Path` and `Loop`. * * `CurveChain` is an intermediate class. It is not instantiable on its own. * * The related class `CurveChainWithDistanceIndex` is a `CurvePrimitive` whose API presents well-defined mappings * from fraction to xyz over the entire chain, but in fact does all the calculations over multiple primitives. * @see [Curve Collections]($docs/learning/geometry/CurveCollection.md) learning article. * @public */ export declare abstract class CurveChain extends CurveCollection { /** The curve primitives in the chain. */ protected _curves: CurvePrimitive[]; /** Constructor */ protected constructor(); /** Return the array of `CurvePrimitive` */ get children(): CurvePrimitive[]; /** Return the start point of the curve chain (start point of the first child). */ startPoint(result?: Point3d): Point3d | undefined; /** Return the end point of the curve chain (end point of the last child). */ endPoint(result?: Point3d): Point3d | undefined; /** * Whether the chain start and end points are defined and within tolerance. * * Does not check for planarity or degeneracy. * @param tolerance optional distance tolerance (default is [[Geometry.smallMetricDistance]]) * @param xyOnly if true, ignore z coordinate (default is `false`) */ isPhysicallyClosedCurve(tolerance?: number, xyOnly?: boolean): boolean; /** * Return the start point and derivative of the first child of the curve chain. * * For queries interior to the chain, use [[CurveChainWithDistanceIndex.fractionToPointAndDerivative]]. */ startPointAndDerivative(result?: Ray3d): Ray3d | undefined; /** * Return the end point and derivative of the last child of the curve chain. * * For queries interior to the chain, use [[CurveChainWithDistanceIndex.fractionToPointAndDerivative]]. */ endPointAndDerivative(result?: Ray3d): Ray3d | undefined; /** * Return the curve primitive at the given `index`, optionally using `modulo` to map `index` to the cyclic indexing. * * In particular, `-1` is the final curve. * @param index cyclic index * @param cyclic whether to employ modulo operator for wrap-around indexing. Default is `true`. */ cyclicCurvePrimitive(index: number, cyclic?: boolean): CurvePrimitive | undefined; /** * Stroke the chain into a simple xyz array. * @param options tolerance parameters controlling the stroking. */ getPackedStrokes(options?: StrokeOptions): GrowableXYZArray | undefined; /** Return a structural clone, with CurvePrimitive objects stroked. */ abstract cloneStroked(options?: StrokeOptions): CurveChain; /** Return a deep copy. */ clone(): CurveChain; /** Create a deep copy of transformed curves. */ cloneTransformed(transform: Transform): CurveChain; /** Create a deep copy with all linestrings broken down into multiple LineSegment3d. */ cloneWithExpandedLineStrings(): CurveChain; /** * Add a child curve. * @param child curve to add to the chain. The curve is captured by this instance. * @return whether the child was added */ tryAddChild(child: AnyCurve | undefined): boolean; /** Return a child by index */ getChild(i: number): CurvePrimitive | undefined; /** Invoke `curve.extendRange(range, transform)` for each child */ extendRange(range: Range3d, transform?: Transform): void; /** * Reverse each child curve (in place). * Reverse the order of the children array. */ reverseChildrenInPlace(): void; /** Same as [[reverseChildrenInPlace]]. */ reverseInPlace(): void; /** * Return the index where target is found in the array of children. * @param alsoSearchProxies whether to also check proxy curves of the children */ childIndex(target: CurvePrimitive | undefined, alsoSearchProxies?: boolean): number | undefined; /** Evaluate an indexed curve at a fraction. Return as a CurveLocationDetail that indicates the primitive. */ primitiveIndexAndFractionToCurveLocationDetailPointAndDerivative(index: number, fraction: number, cyclic?: boolean, result?: CurveLocationDetail): CurveLocationDetail | undefined; } /** * * A `BagOfCurves` object is a collection of `AnyCurve` objects. * * A `BagOfCurves` has no implied properties such as being planar. * @public */ export declare class BagOfCurves extends CurveCollection { /** String name for schema properties */ readonly curveCollectionType = "bagOfCurves"; /** Test if `other` is an instance of `BagOfCurves` */ isSameGeometryClass(other: GeometryQuery): boolean; /** * Array of children. * * No restrictions on type. */ protected _children: AnyCurve[]; /** Construct an empty `BagOfCurves` */ constructor(); /** Return the (reference to) array of children */ get children(): AnyCurve[]; /** Create with given curves. */ static create(...data: AnyCurve[]): BagOfCurves; /** Return the boundary type (0) of a corresponding MicroStation CurveVector */ dgnBoundaryType(): number; /** Invoke `processor.announceBagOfCurves(this, indexInParent);` */ announceToCurveProcessor(processor: RecursiveCurveProcessor, indexInParent?: number): void; /** Clone all children in stroked form. */ cloneStroked(options?: StrokeOptions): BagOfCurves; /** Return an empty `BagOfCurves` */ cloneEmptyPeer(): BagOfCurves; /** Return a deep copy. */ clone(): BagOfCurves; /** Create a deep copy of transformed curves. */ cloneTransformed(transform: Transform): BagOfCurves; /** Create a deep copy with all linestrings broken down into multiple LineSegment3d. */ cloneWithExpandedLineStrings(): BagOfCurves; /** Add a child */ tryAddChild(child: AnyCurve | undefined): boolean; /** Get a child by index */ getChild(i: number): AnyCurve | undefined; /** Second step of double dispatch: call `handler.handleBagOfCurves(this)` */ dispatchToGeometryHandler(handler: GeometryHandler): any; } //# sourceMappingURL=CurveCollection.d.ts.map