/** @packageDocumentation * @module Curve */ import { BSpline2dNd } from "../bspline/BSplineSurface"; import { GeometryHandler } from "../geometry3d/GeometryHandler"; import { Range3d } from "../geometry3d/Range"; import { Transform } from "../geometry3d/Transform"; import { Polyface } from "../polyface/Polyface"; import { SolidPrimitive } from "../solid/SolidPrimitive"; import { CoordinateXYZ } from "./CoordinateXYZ"; import { CurveCollection } from "./CurveCollection"; import { CurvePrimitive } from "./CurvePrimitive"; import { PointString3d } from "./PointString3d"; /** * Describes the category of a [[GeometryQuery]], enabling type-switching like: * ```ts * function processGeometryQuery(q: GeometryQuery): void { * if ("solid" === q.geometryCategory) * alert("Solid type = " + q.solidPrimitiveType); // compiler knows q is an instance of SolidPrimitive * // ...etc... * ``` * * Each string maps to a particular subclass of [[GeometryQuery]]: * - "polyface" => [[Polyface]] * - "curvePrimitive" => [[CurvePrimitive]] * - "curveCollection" => [[CurveCollection]] * - "solid" => [[SolidPrimitive]] * - "point" => [[CoordinateXYZ]] * - "pointCollection" => [[PointString3d]] * - "bsurf" => [[BSpline2dNd]] (which is an intermediate class shared by [[BSplineSurface3d]] and [[BSplineSurface3dH]]) * * @see [[AnyGeometryQuery]] * @public */ export type GeometryQueryCategory = "polyface" | "curvePrimitive" | "curveCollection" | "solid" | "point" | "pointCollection" | "bsurf"; /** * Union type for subclasses of [[GeometryQuery]]. Specific subclasses can be discriminated at compile- or run-time * using [[GeometryQuery.geometryCategory]]. * @public */ export type AnyGeometryQuery = Polyface | CurvePrimitive | CurveCollection | SolidPrimitive | CoordinateXYZ | PointString3d | BSpline2dNd; /** * Options bundle for [[GeometryQuery.computeScaledTolerance]] and [[GeometryQuery.scaleToleranceForGeometry]]. * @public */ export interface ScaledToleranceOptions { /** Optional transform to apply to geometry before computing its size. */ transform?: Transform; /** Relative tolerance by which to scale the computed geometry size. Default is [[Geometry.smallMetricDistance]]. */ relativeTolerance?: number; /** Smallest tolerance to return. Default is [[Geometry.smallMetricDistanceSquared]]. */ minimumTolerance?: number; /** Whether to ignore z-coordinates when computing the geometry size. */ xyOnly?: boolean; } /** * Queries to be supported by Curve, Surface, and Solid objects. * * `GeometryQuery` is an abstract base class with (abstract) methods for querying curve, solid primitive, mesh, * and bspline surfaces. * @public */ export declare abstract class GeometryQuery { /** Type discriminator. */ abstract readonly geometryCategory: GeometryQueryCategory; /** Return the range of the entire GeometryQuery tree. */ range(transform?: Transform, result?: Range3d): Range3d; /** Extend `rangeToExtend` by the range of this geometry multiplied by the `transform`. */ abstract extendRange(rangeToExtend: Range3d, transform?: Transform): void; /** * Attempt to transform in place. * * Curve types always succeed. * * Other geometry types may fail if the transform is not invertible. * * Subclasses are free to ignore certain effects of the transform in lieu of failing. */ abstract tryTransformInPlace(transform: Transform): boolean; /** Try to move the geometry by dx,dy,dz. */ tryTranslateInPlace(dx: number, dy?: number, dz?: number): boolean; /** * Return a transformed clone. * @see [[tryTransformInPlace]] for discussion of transform success. */ abstract cloneTransformed(transform: Transform): GeometryQuery | undefined; /** Return a clone */ abstract clone(): GeometryQuery; /** * Return GeometryQuery children for recursive queries. * * leaf classes do not need to implement. */ get children(): GeometryQuery[] | undefined; /** Test `if (other instanceof this.Type)`. REQUIRED IN ALL CONCRETE CLASSES. */ abstract isSameGeometryClass(other: GeometryQuery): boolean; /** * Test for exact structure and nearly identical geometry. * * Leaf classes must implement. * * Base class implementation recurses through children. * * Base implementation is complete for classes with children and no properties. * * Classes with both children and properties must implement for properties, call super for children. */ isAlmostEqual(other: GeometryQuery): boolean; /** * Apply instance method [[isAlmostEqual]] if both are defined. * * Both undefined returns true. * * Single defined returns false. */ static areAlmostEqual(a: GeometryQuery | undefined, b: GeometryQuery | undefined): boolean; /** * Double Dispatch call pattern. * * User code implements a `GeometryHandler` with specialized methods to handle `LineSegment3d`, `Arc3d`, etc as * relevant to its use case. * * Each such `GeometryQuery` class implements this method as a one-line method containing the appropriate call * such as `handler.handleLineSegment3d())` * * This allows each type-specific method to be called without a switch or `instanceof` test. * @param handler handler to be called by the particular geometry class */ abstract dispatchToGeometryHandler(handler: GeometryHandler): any; /** * Compute a distance tolerance appropriate for comparing the coordinates of `geom`. * * The formula is `absTol = minTol + relTol * geomSize`, where `geomSize` is the largest absolute coordinate of * the geometry range. * * Scaling tolerances by geometry size helps account for the decreased floating point resolution between large * coordinates. While using such scaled tolerances can enable more tolerance-sensitive constructions to succeed on * far-flung geometries, on extremely small geometries at extremely large coordinate magnitudes, geometric * constructions are generally more accurate when applied to the geometry temporarily translated to the origin. * @param geom geometry to measure * @param options bundle of options * @returns the computed absolute tolerance * @see [[scaleToleranceForGeometry]] */ static computeScaledTolerance(geom: GeometryQuery | GeometryQuery[], options?: ScaledToleranceOptions): number; /** * Scale the given distance tolerance as appropriate for comparing the coordinates of `geom`. * * Scaling tolerances by geometry size helps account for the decreased floating point resolution between large * coordinates. While using such scaled tolerances can enable more tolerance-sensitive constructions to succeed on * far-flung geometries, on extremely small geometries at extremely large coordinate magnitudes, geometric * constructions are generally more accurate when applied to the geometry temporarily translated to the origin. * @param geom geometry to measure * @param distanceTolerance positive input distance tolerance to examine * @param options bundle of options (`minimumTolerance` and `relativeTolerance` are ignored) * @return a distance tolerance >= `distanceTolerance` * @see [[computeScaledTolerance]] */ static scaleToleranceForGeometry(geom: GeometryQuery | GeometryQuery[], distanceTolerance: number, options?: ScaledToleranceOptions): number; } //# sourceMappingURL=GeometryQuery.d.ts.map