UNPKG

ducjs

Version:

The duc 2D CAD file format is a cornerstone of our advanced design system, conceived to cater to professionals seeking precision and efficiency in their design work.

54 lines (53 loc) 3.04 kB
import { HANDLE_TYPE } from "../../flatbuffers/duc"; import type { PrecisionValue, RawValue, Scope } from "../../types"; import type { DucLine, DucLinearElement, DucLinearLikeElement, DucPoint, DucTextElementWithContainer, ElementsMap, NonDeleted } from "../../types/elements"; import { Bounds, GeometricPoint } from "../../types/geometryTypes"; import type { ValueOf } from "../../types/utility-types"; import { ElementAbsoluteCoords } from "../bounds"; export type HandleType = ValueOf<typeof HANDLE_TYPE> | null; export type HandleInfo = { pointIndex: number; handleType: HandleInfo; lineIndex: number; handle: DucPoint; }; /** * Merges overlapping points using the line-based system * Returns updated points and lines arrays */ export declare const mergeOverlappingPoints: (points: DucPoint[], lines: DucLine[], threshold?: RawValue) => { points: DucPoint[]; lines: DucLine[]; }; /** * Normalizes line points so that the start point is at [0,0]. This is * expected in various parts of the codebase. Also returns new x/y to account * for the potential normalization. */ export declare const getNormalizedPoints: (element: DucLinearElement | { points: DucPoint[]; lines: DucLine[]; x: PrecisionValue; y: PrecisionValue; scope: Scope; }, currentScope: Scope) => { points: DucPoint[]; lines: DucLine[]; x: PrecisionValue; y: PrecisionValue; }; /** scene coords */ export declare const getPointsGlobalCoordinates: (element: DucLinearLikeElement, elementsMap: ElementsMap, currentScope: Scope) => DucPoint[]; /** scene coords */ export declare const getPointGlobalCoordinates: (element: DucLinearLikeElement, point: GeometricPoint, elementsMap: ElementsMap, currentScope: Scope) => GeometricPoint; export declare const getBoundTextElementPosition: (element: DucLinearLikeElement, boundTextElement: DucTextElementWithContainer, elementsMap: ElementsMap, currentScope: Scope) => GeometricPoint | null; export declare const getLinearElementAbsoluteCoords: (element: DucLinearElement, elementsMap: ElementsMap, includeBoundText: boolean | undefined, currentScope: Scope, returnUnrotatedBoundsOnly?: boolean) => ElementAbsoluteCoords; export declare const getMinMaxXYWithBoundText: (element: DucLinearElement, elementsMap: ElementsMap, elementBounds: Bounds, boundTextElement: DucTextElementWithContainer, currentScope: Scope) => ElementAbsoluteCoords; export declare const getSegmentMidPoint: (element: NonDeleted<DucLinearLikeElement>, startPoint: GeometricPoint, endPoint: GeometricPoint, endPointIndex: number, elementsMap: ElementsMap, currentScope: Scope) => GeometricPoint; /** * Validates if the given line indices form a closed path in the element * @param element The linear element containing the points and lines * @param lineIndices Array of line indices to check * @returns true if the line indices form a valid closed path, false otherwise */ export declare const validateClosedPath: (element: NonDeleted<DucLinearElement>, lineIndices: number[]) => boolean;