import type { Curve } from 'flo-boolean'; /** @internal */ interface Debug { /** Generated by debug object for later inspection */ elems: Elems; timing: Timing; /** * These functions are meant to be used in the console, e.g. in the * console try typing d.fs.twoProng.traceConvergence(0); */ fs: {}; directives: Directives; } /** * Elements generated during `findMats` for later inspection (only available * if debug has been enabled via `enableDebugForMat(true)`). * * The arrays are reset at the start of each `findMats` call and accumulate * over all MATs found in that call, one entry per boundary bezier curve in the * order the curves are encountered. */ interface Elems { /** The loose (axis-aligned) bounding box of each boundary bezier curve */ readonly looseBoundingBoxes: number[][][]; /** The tight (rotated) bounding box of each boundary bezier curve */ readonly tightBoundingBoxes: number[][][]; /** The bounding hull of each boundary bezier curve */ readonly boundingHulls: number[][][]; /** The curves whose end point forms a quite sharp corner with the next curve */ readonly sharpCorners: Curve[]; /** The curves whose end point forms a quite dull corner with the next curve */ readonly dullCorners: Curve[]; } /** @internal */ interface Timing { holeClosers: number; oneAnd2Prongs: number; threeProngs: number; sats: number; simplifyMat: number; } /** @internal */ interface Directives { stopAfterHoleClosers: boolean, stopAfterHoleClosersNum: number, stopAfterTwoProngs: boolean, stopAfterTwoProngsNum: number, stopAfterThreeProngs: boolean, stopAfterThreeProngsNum: number, } /** Returns a fresh (empty) set of debug `Elems`. */ function createEmptyElems(): Elems { return { looseBoundingBoxes: [], tightBoundingBoxes: [], boundingHulls: [], sharpCorners: [], dullCorners: [] }; } function enableDebugForMat(debugOn: boolean) { if (!debugOn) { (globalThis as any)._debug_ = undefined; return; } let debug: Debug = (globalThis as any)._debug_; debug = { ...debug, elems: { ...debug?.elems, ...createEmptyElems() }, timing: { ...debug?.timing, holeClosers: 0, oneAnd2Prongs: 0, threeProngs: 0, sats: 0, simplifyMat: 0 }, fs: { ...debug?.fs }, directives: { //...debug?.directives, ...debug?.directives, stopAfterHoleClosers: false, stopAfterHoleClosersNum: undefined!, stopAfterTwoProngs: false, stopAfterTwoProngsNum: undefined!, stopAfterThreeProngs: false, stopAfterThreeProngsNum: undefined!, } }; (globalThis as any)._debug_ = debug; } export type { Debug, Elems, Timing, Directives } export { enableDebugForMat, createEmptyElems }