import { AcDbHatch, AcDbHatchStyle, AcDbObjectId, AcGeLoop2d } from '@mlightcad/data-model'; import { AcApContext } from '../../app'; import { AcEdCommand } from '../../editor'; /** * Persisted HATCH command options reused between command invocations. */ export interface HatchSettings { /** Hatch pattern name, e.g. a predefined hatch pattern or `SOLID`. */ patternName: string; /** Pattern scale factor in drawing units (must be positive). */ patternScale: number; /** Pattern angle in degrees, converted to radians when writing entity data. */ patternAngleDeg: number; /** Hatch style that controls island handling behavior. */ style: AcDbHatchStyle; /** Whether the command should operate in associative mode. */ associative: boolean; } /** * Command-line HATCH command (no dialog), inspired by AutoCAD flow. * * Current scope: * - Build hatch boundaries from selected objects. * - Support command-line option branches (pattern/scale/angle/style/associative). * - No island-detection refinement beyond loop construction. */ export declare class AcApHatchCmd extends AcEdCommand { /** * Last-used command settings shared by all `AcApHatchCmd` instances. */ private static _lastSettings; /** * Creates one HATCH command instance and marks it as write-mode only. */ constructor(); /** * Current settings used by this command instance when creating hatches. */ protected get settings(): HatchSettings; private normalizeSysVarNumber; private normalizePositiveSysVarNumber; private sysVarRadiansToDegrees; private getSysVar; private getDatabaseSysVarSettings; private getActiveSettings; private setActiveSysVar; /** * Normalizes pattern name input. * * @param value Raw user-entered pattern name. * @returns Trimmed name, or `SOLID` when input is empty. */ protected normalizePatternName(value: string): string; /** * Converts hatch style enum to command keyword string. * * @param style Hatch style enum value. * @returns Command keyword name used by keyword prompts. */ protected styleToKeyword(style: AcDbHatchStyle): "Normal" | "Outer" | "Ignore"; /** * Converts command keyword string to hatch style enum. * * @param keyword Keyword returned by prompt API. * @returns Matching hatch style enum, defaulting to `Normal`. */ protected keywordToStyle(keyword: string): AcDbHatchStyle; /** * Converts a closed polyline entity into a boundary-edge sequence. * * The function keeps arc segments by reading per-vertex bulge values. * If runtime bulge data is unavailable, vertices fall back to straight edges. * * @param entity Input polyline entity. * @returns Ordered boundary edges or empty array if not hatchable. */ private buildEdgesFromPolyline; /** * Converts a supported boundary entity into one or more boundary edges. * * Supported entities: * - `AcDbPolyline` (closed) * - `AcDbCircle` * - `AcDbArc` (closed only) * - `AcDbLine` * * @param entity Input entity from model space. * @returns Edge list consumable by loop builder. */ private buildEdgesFromEntity; /** * Builds closed loops from explicit object ids. * * @param context Active command context. * @param ids Object ids selected by the user. * @returns Closed loops ready for hatch creation. */ protected collectLoopsFromIds(context: AcApContext, ids: AcDbObjectId[]): AcGeLoop2d[]; /** * Scans model space and builds closed loops from all supported boundaries. * * This is used by pick-points mode so a seed point can be resolved against * all potential loops in the drawing. * * @param context Active command context. * @returns Closed loops derived from all hatchable entities. */ protected collectLoopsFromAllBoundaries(context: AcApContext): AcGeLoop2d[]; /** * Builds best-effort closed loops from boundary edges. * * The loop solver is retried with increasing tolerance values and the best * (largest) closed-loop result set is returned. * * @param edges Input boundary edge set. * @returns Closed loops produced by the best tolerance attempt. */ private buildLoopsFromEdges; /** * Calculates polygon signed area using the shoelace formula. * * @param points Polygon vertices. * @returns Signed area; positive/negative sign depends on winding direction. */ private signedArea; /** * Tests whether one point lies on a finite segment within a tolerance. * * @param px Test point X. * @param py Test point Y. * @param ax Segment start X. * @param ay Segment start Y. * @param bx Segment end X. * @param by Segment end Y. * @param tolerance Distance tolerance. * @returns `true` if point is on segment; otherwise `false`. */ private isPointOnSegment; /** * Determines whether a point is inside (or on boundary of) a polygon. * * Boundary points are treated as inside to keep seed-point behavior stable * near loop edges. * * @param point Test point. * @param polygon Polygon vertices. * @returns `true` when inside or on boundary. */ private isPointInPolygon; /** * Builds loop metadata and parent/child containment relationships. * * @param loops Candidate closed loops. * @returns Loop info array with area and hierarchy metadata. */ private buildLoopInfos; /** * Resolves which loops should be used for one pick-point seed. * * Strategy: * - Find the smallest containing loop as target. * - Include direct children as holes unless style is `Ignore`. * * @param point Seed point selected by user. * @param loops Candidate loops. * @returns Ordered loop set to append into one hatch entity. */ protected resolveLoopsForPickPoint(point: { x: number; y: number; }, loops: ReadonlyArray): AcGeLoop2d[]; /** * Creates and appends one hatch entity from computed loops. * * @param context Active command context. * @param loops Boundary loops to be added to the hatch. * @returns `true` when hatch entity was created; otherwise `false`. */ protected appendHatch(context: AcApContext, loops: ReadonlyArray): boolean; /** * Allows specialized hatch commands to apply additional entity properties * before the hatch is added to model space. * * @param _hatch Hatch entity being created. */ protected configureHatch(_hatch: AcDbHatch): void; /** * Prompts for pattern name and updates persisted command settings. * * @returns Promise resolved when prompt flow completes. */ protected promptPatternName(): Promise; /** * Prompts for pattern scale and updates persisted command settings. * * @returns Promise resolved when prompt flow completes. */ protected promptPatternScale(): Promise; /** * Prompts for pattern angle (degrees) and updates persisted settings. * * @returns Promise resolved when prompt flow completes. */ protected promptPatternAngle(): Promise; /** * Prompts for hatch style (`Normal` / `Outer` / `Ignore`). * * @returns Promise resolved when prompt flow completes. */ protected promptStyle(): Promise; /** * Prompts for associative mode switch (`Yes` / `No`). * * @returns Promise resolved when prompt flow completes. */ protected promptAssociative(): Promise; /** * Executes object-selection branch of HATCH. * * @param context Active command context. * @returns `true` if a hatch was created from selected objects. */ protected doSelectObjects(context: AcApContext): Promise; /** * Executes pick-points branch of HATCH. * * The user can place multiple seed points. Each accepted point attempts * one hatch creation, and pressing Enter terminates this branch. * * @param context Active command context. * @returns `true` if at least one hatch was created. */ protected doPickPoints(context: AcApContext): Promise; /** * Runs the interactive command-line HATCH workflow. * * Main loop behavior: * - Direct entity pick: hatch from picked boundary object. * - Keyword branches: pick-points, select-objects, or option editing. * - Enter/Cancel: exits command. * * @param context Active command context. * @returns Promise resolved when command ends. */ execute(context: AcApContext): Promise; } //# sourceMappingURL=AcApHatchCmd.d.ts.map