@faicad/faijs-sketch 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/LICENSE +28 -0
  2. package/NOTICE +28 -0
  3. package/dist/bspline.d.ts +58 -0
  4. package/dist/bspline.d.ts.map +1 -0
  5. package/dist/bspline.js +93 -0
  6. package/dist/bspline.js.map +1 -0
  7. package/dist/canonical.d.ts +205 -0
  8. package/dist/canonical.d.ts.map +1 -0
  9. package/dist/canonical.js +12 -0
  10. package/dist/canonical.js.map +1 -0
  11. package/dist/contour.d.ts +43 -0
  12. package/dist/contour.d.ts.map +1 -0
  13. package/dist/contour.js +132 -0
  14. package/dist/contour.js.map +1 -0
  15. package/dist/faces.d.ts +28 -0
  16. package/dist/faces.d.ts.map +1 -0
  17. package/dist/faces.js +46 -0
  18. package/dist/faces.js.map +1 -0
  19. package/dist/fcstd-types.d.ts +177 -0
  20. package/dist/fcstd-types.d.ts.map +1 -0
  21. package/dist/fcstd-types.js +67 -0
  22. package/dist/fcstd-types.js.map +1 -0
  23. package/dist/index.d.ts +36 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +28 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/namespace.d.ts +51 -0
  28. package/dist/namespace.d.ts.map +1 -0
  29. package/dist/namespace.js +67 -0
  30. package/dist/namespace.js.map +1 -0
  31. package/dist/node.d.ts +14 -0
  32. package/dist/node.d.ts.map +1 -0
  33. package/dist/node.js +34 -0
  34. package/dist/node.js.map +1 -0
  35. package/dist/op.d.ts +67 -0
  36. package/dist/op.d.ts.map +1 -0
  37. package/dist/op.js +104 -0
  38. package/dist/op.js.map +1 -0
  39. package/dist/planegcs-backend.d.ts +46 -0
  40. package/dist/planegcs-backend.d.ts.map +1 -0
  41. package/dist/planegcs-backend.js +696 -0
  42. package/dist/planegcs-backend.js.map +1 -0
  43. package/dist/project.d.ts +115 -0
  44. package/dist/project.d.ts.map +1 -0
  45. package/dist/project.js +329 -0
  46. package/dist/project.js.map +1 -0
  47. package/dist/solve.d.ts +21 -0
  48. package/dist/solve.d.ts.map +1 -0
  49. package/dist/solve.js +102 -0
  50. package/dist/solve.js.map +1 -0
  51. package/dist/solver.d.ts +63 -0
  52. package/dist/solver.d.ts.map +1 -0
  53. package/dist/solver.js +28 -0
  54. package/dist/solver.js.map +1 -0
  55. package/dist/verify.d.ts +53 -0
  56. package/dist/verify.d.ts.map +1 -0
  57. package/dist/verify.js +71 -0
  58. package/dist/verify.js.map +1 -0
  59. package/package.json +65 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planegcs-backend.js","sourceRoot":"","sources":["../src/planegcs-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EAAE,EAAE,EAAe,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AASzD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAA8B;IACvE,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,QAAQ,CAAC;IACrD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,MAAe,CAAC,CAAC;IACxD,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAKD,MAAM,CAAC,GAAG,CAAC,KAAa,EAAE,GAAW,EAAS,EAAE,CAAC,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;AAEpE;;;;GAIG;AACH,MAAM,OAAO,cAAc;IACL;IAApB,YAAoB,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,CAAC,CAAC;oBACtG,CAAC;;wBAAM,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBACnB,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;mFAE+E;IACvE,SAAS,CAAC,GAAU;QAC1B,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,GAAG,CAA2C,CAAC;QACjG,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC;QAC/E,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5B,CAAC;IAEO,gBAAgB,CAAC,QAAgB;QACvC,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,QAAQ,EAAE,CAAoC,CAAC;QACrG,OAAO,OAAO,CAAC,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9D,CAAC;CACF","sourcesContent":["/**\n * M3.2/M3.3/M3.4 — planegcs WASM backend for the SketchSolver interface.\n *\n * M3.3: geometry → GCS primitives, including the implicit fixed RtPnt/HAxis/\n * VAxis (geoId -1/-2, plan §5.4). External geometry (geoId <= -3) is rejected\n * upstream (D4: whole sketch downgrades to L2).\n * M3.4: constraints → GCS primitives for the P0 set (plan §7 M3.4).\n * M3.5 helper: solved params are pulled back and geometry rebuilt, so the\n * caller can compare against on-disk coordinates (D2).\n */\nimport { make_gcs_wrapper, Algorithm } from '@salusoft89/planegcs';\nimport type { GcsWrapper } from '@salusoft89/planegcs';\nimport { ok, type Result } from '@faicad/faijs/api/result';\nimport type { FcstdSketchGeom, FcstdSketchCon } from './fcstd-types.js';\nimport { ConstraintType, PointPos } from './fcstd-types.js';\nimport type { FcstdSolveOutcome, SketchSolver } from './solver.js';\nimport { SUPPORTED_CONSTRAINT_TYPES } from './solver.js';\n/** Options for instantiating the planegcs WASM solver. */\nexport interface PlanegcsSolverOptions {\n /** Absolute filesystem path to `planegcs.wasm` (Node hosts). */\n wasmPath?: string\n /** Raw wasm bytes (browser/worker hosts, injected via HostPorts.assets). */\n wasmBytes?: Uint8Array | ArrayBuffer\n}\n\n/**\n * Instantiate the planegcs WASM solver.\n *\n * Environment-agnostic: the host supplies the wasm source. Node hosts use\n * `createNodePlanegcsSolver()` from `@faicad/faijs-sketch/node`; browser hosts\n * pass bytes resolved through `HostPorts.assets`.\n *\n * @param options - wasm path (Node) or bytes (browser).\n * @returns a `SketchSolver` backed by the planegcs WASM module.\n */\nexport async function createPlanegcsSolver(options: PlanegcsSolverOptions): Promise<SketchSolver> {\n const source = options.wasmBytes ?? options.wasmPath;\n if (!source) {\n throw new Error('E_SKETCHC_NO_WASM: createPlanegcsSolver needs wasmPath or wasmBytes');\n }\n const wrapper = await make_gcs_wrapper(source as never);\n return new PlanegcsSolver(wrapper);\n}\n\n/** Internal identity for a GCS point owned by a geometry element. */\ntype PtKey = string;\n\nconst P = (geoId: number, pos: number): PtKey => `g${geoId}p${pos}`;\n\n/**\n * planegcs WASM implementation of the `SketchSolver` interface (M3.2–M3.4):\n * pushes geometry/constraints into the GCS, solves, and pulls the solved\n * parameters back into `FcstdSketchGeom` values.\n */\nexport class PlanegcsSolver implements SketchSolver {\n constructor(private wrapper: GcsWrapper) {}\n\n async solve(\n geoms: FcstdSketchGeom[],\n constraints: FcstdSketchCon[],\n external?: import('./solver.js').ExternalFixedSeg[],\n ): Promise<Result<FcstdSolveOutcome, never>> {\n const externalMap = new Map<number, import('./solver.js').ExternalFixedSeg>(\n (external ?? []).map((e) => [e.geoId, e]),\n );\n // a constraint referencing an unresolvable external geoId is dropped\n const unresolvableExternal = new Set<number>();\n for (const c of constraints) {\n for (const r of c.refs) {\n if (r.geoId <= -3 && r.geoId > -2000 && !externalMap.has(r.geoId)) {\n unresolvableExternal.add(c.index);\n }\n }\n }\n const usableConstraints = constraints.filter((c) => !unresolvableExternal.has(c.index));\n\n // P3-2 (2026-09-24): constraint types that do NOT affect the solved\n // geometry are dropped-and-recorded instead of failing the whole sketch\n // (previously any of these baked the sketch as unsupported-constraint):\n // - 15 InternalAlignment: alignment bookkeeping between element pairs;\n // the aligned geometry itself is already in <Geometry> — the alignment\n // constraint adds no independent DoF removal for our solving purpose.\n // - 17 Block: freezes a geometry's current position — the stored\n // geometry IS that position, so dropping it changes nothing.\n // - 19 Weight: B-Spline control-point weight — we do not solve splines.\n const ignorable = constraints.filter(\n (c) => c.type === 15 || c.type === 17 || c.type === 19,\n ).map((c) => c.index);\n const ignorableSet = new Set(ignorable);\n\n const unsupported = usableConstraints.find(\n (c) => !SUPPORTED_CONSTRAINT_TYPES.has(c.type) && !ignorableSet.has(c.index),\n );\n if (unsupported) {\n return ok({\n geoms,\n converged: false,\n reason: 'unsupported-constraint',\n problemConstraints: [unsupported.index],\n droppedConstraints: [...unresolvableExternal, ...ignorable],\n });\n }\n\n const w = this.wrapper;\n w.clear_data();\n\n // --- M3.3: implicit fixed frame (root point + H/V axes) ---\n w.push_primitive({ type: 'point', id: P(-1, 1), x: 0, y: 0, fixed: true });\n // GOTCHA (probe-sym-min.ts / probe-l1-ablation.ts): FreeCAD models HAxis/\n // VAxis as real Line entries in Geoms (geoId -1/-2), so constraints may\n // reference axis points (pos 1/2) or the axis edge (pos 0) — e.g.\n // DistanceX(line-point, VAxis) fixes an x coordinate. planegcs has no\n // implicit axes, so we materialize both axes as fixed point+line pairs\n // and register them in `lines` (below) so all constraint shapes see them.\n w.push_primitive({ type: 'point', id: P(-1, 2), x: 1, y: 0, fixed: true });\n w.push_primitive({ type: 'point', id: P(-2, 1), x: 0, y: 0, fixed: true });\n w.push_primitive({ type: 'point', id: P(-2, 2), x: 0, y: 1, fixed: true });\n w.push_primitive({ type: 'line', id: 'L-1', p1_id: P(-1, 1), p2_id: P(-1, 2) });\n w.push_primitive({ type: 'line', id: 'L-2', p1_id: P(-2, 1), p2_id: P(-2, 2) });\n\n // --- M6.3: external fixed geometry (geoId -3, -4, ... in link order) ---\n const externalLines = new Map<number, { p1: PtKey; p2: PtKey }>();\n for (const ext of external ?? []) {\n if (ext.polyline.length === 2) {\n // straight segment: two fixed endpoints + fixed line\n const p1 = P(ext.geoId, 1);\n const p2 = P(ext.geoId, 2);\n w.push_primitive({ type: 'point', id: p1, x: ext.polyline[0]![0], y: ext.polyline[0]![1], fixed: true });\n w.push_primitive({ type: 'point', id: p2, x: ext.polyline[1]![0], y: ext.polyline[1]![1], fixed: true });\n w.push_primitive({ type: 'line', id: `X${ext.geoId}`, p1_id: p1, p2_id: p2 });\n externalLines.set(ext.geoId, { p1, p2 });\n } else {\n // multi-point polyline: pin sampled points as fixed point targets\n ext.polyline.forEach((pt, i) => {\n w.push_primitive({\n type: 'point', id: P(ext.geoId, i + 1), x: pt[0], y: pt[1], fixed: true,\n });\n });\n }\n }\n\n // --- M3.3: geometry → primitives ---\n // Track which point keys exist as standalone points vs derived from lines.\n const lines = new Map<number, { p1: PtKey; p2: PtKey }>();\n const arcs = new Map<number, { center: PtKey; start: PtKey; end: PtKey }>();\n const circles = new Map<number, { center: PtKey }>();\n const ellipses = new Map<number, { center: PtKey; focus1: PtKey }>();\n const standalone = new Map<number, PtKey>();\n // implicit axes are first-class lines for constraint resolution (see\n // the GOTCHA block above): geoId -1 = HAxis, -2 = VAxis\n lines.set(-1, { p1: P(-1, 1), p2: P(-1, 2) });\n lines.set(-2, { p1: P(-2, 1), p2: P(-2, 2) });\n\n // pass 1: standalone points that are constraint anchors\n const anchorNeedsStandalone = new Set<string>();\n for (const c of constraints) {\n for (const r of c.refs) {\n if (r.geoId >= 0 && r.pos !== PointPos.none) anchorNeedsStandalone.add(P(r.geoId, r.pos));\n }\n }\n for (const g of geoms) {\n switch (g.kind) {\n case 'point': {\n const id = P(g.index, 1);\n standalone.set(g.index, id);\n w.push_primitive({ type: 'point', id, x: g.x, y: g.y, fixed: false });\n break;\n }\n default:\n break;\n }\n }\n // pass 2: curves; create endpoint points for lines/arcs, center points\n for (const g of geoms) {\n switch (g.kind) {\n case 'line': {\n const p1 = anchorNeedsStandalone.has(P(g.index, 1)) ? P(g.index, 1) : P(g.index, 1);\n const p2 = P(g.index, 2);\n // create endpoint points as real GCS points, then a line over them\n for (const [id, x, y] of [\n [p1, g.x1, g.y1],\n [p2, g.x2, g.y2],\n ] as const) {\n w.push_primitive({ type: 'point', id, x, y, fixed: false });\n }\n w.push_primitive({ type: 'line', id: `L${g.index}`, p1_id: p1, p2_id: p2 });\n lines.set(g.index, { p1, p2 });\n break;\n }\n case 'circle': {\n const c = P(g.index, 3);\n w.push_primitive({ type: 'point', id: c, x: g.cx, y: g.cy, fixed: false });\n w.push_primitive({ type: 'circle', id: `C${g.index}`, c_id: c, radius: g.radius });\n circles.set(g.index, { center: c });\n break;\n }\n case 'arc': {\n const c = P(g.index, 3);\n const s = P(g.index, 1);\n const e = P(g.index, 2);\n for (const [id, x, y] of [\n [c, g.cx, g.cy],\n [s, g.x1, g.y1],\n [e, g.x2, g.y2],\n ] as const) {\n w.push_primitive({ type: 'point', id, x, y, fixed: false });\n }\n w.push_primitive({\n type: 'arc', id: `A${g.index}`, c_id: c, start_id: s, end_id: e,\n start_angle: g.startAngle, end_angle: g.endAngle, radius: g.radius,\n });\n arcs.set(g.index, { center: c, start: s, end: e });\n break;\n }\n case 'ellipse': {\n const c = P(g.index, 3);\n const f1 = P(g.index, 1);\n for (const [id, x, y] of [\n [c, g.cx, g.cy],\n [f1, g.fx1, g.fy1],\n ] as const) {\n w.push_primitive({ type: 'point', id, x, y, fixed: false });\n }\n w.push_primitive({\n type: 'ellipse', id: `E${g.index}`, c_id: c, focus1_id: f1, radmin: g.minorRadius,\n });\n ellipses.set(g.index, { center: c, focus1: f1 });\n break;\n }\n case 'bspline': {\n // P4: the spline itself is not pushed to GCS (planegcs has no b-spline\n // primitive); its exact endpoints participate as a line proxy so\n // coincident/dimension constraints on the curve ends still solve.\n // Interior shape is preserved at contour extraction (de Boor sampling).\n const p1 = P(g.index, 1);\n const p2 = P(g.index, 2);\n for (const [id, x, y] of [\n [p1, g.x1, g.y1],\n [p2, g.x2, g.y2],\n ] as const) {\n w.push_primitive({ type: 'point', id, x, y, fixed: false });\n }\n w.push_primitive({ type: 'line', id: `L${g.index}`, p1_id: p1, p2_id: p2 });\n lines.set(g.index, { p1, p2 });\n break;\n }\n case 'point':\n break; // handled in pass 1\n }\n }\n\n // --- M3.4: constraints → primitives ---\n // A constraint whose GCS shape cannot be pushed is dropped and recorded\n // (D3: no silent loss — surfaced via droppedConstraints).\n const droppedConstraints: number[] = [...unresolvableExternal, ...ignorable];\n for (const c of usableConstraints) {\n // P3-2: ignorable types (15/17/19) were recorded above; never pushed.\n if (ignorableSet.has(c.index)) continue;\n let prims: Record<string, unknown>[];\n try {\n prims = this.constraintToPrimitives(c, { lines, arcs, circles, ellipses, standalone, externalLines });\n } catch {\n droppedConstraints.push(c.index);\n continue;\n }\n try {\n for (const p of prims) w.push_primitive(p as never);\n } catch {\n droppedConstraints.push(c.index);\n continue;\n }\n }\n\n // --- solve (D2: initial values = on-disk coordinates) ---\n const status = w.solve(Algorithm.LevenbergMarquardt);\n const conflicting = w.has_gcs_conflicting_constraints();\n const redundant = w.has_gcs_redundant_constraints();\n\n if (conflicting) {\n const problemConstraints = w.get_gcs_conflicting_constraints()\n .map((s) => Number(s.replace(/^c/, '')))\n .filter((n) => Number.isFinite(n));\n return ok({\n geoms,\n converged: false,\n reason: 'conflicting',\n problemConstraints,\n droppedConstraints,\n });\n }\n\n if (redundant) {\n // D3: redundant constraints are dropped internally by planegcs's\n // redundant-solving mode; the best-effort solution is still valid.\n w.apply_solution();\n const solved = this.pullBack(geoms, { lines, arcs, circles, ellipses, standalone });\n const problemConstraints = w.get_gcs_redundant_constraints()\n .map((s) => Number(s.replace(/^c/, '')))\n .filter((n) => Number.isFinite(n));\n return ok({\n geoms: solved,\n converged: true,\n reason: 'redundant',\n problemConstraints,\n droppedConstraints: [...droppedConstraints, ...problemConstraints],\n });\n }\n\n if (status !== 0) {\n return ok({\n geoms,\n converged: false,\n reason: 'failed',\n problemConstraints: [],\n droppedConstraints,\n });\n }\n\n w.apply_solution();\n\n // --- pull back solved coordinates and rebuild geometry ---\n const solved = this.pullBack(geoms, { lines, arcs, circles, ellipses, standalone });\n return ok({ geoms: solved, converged: true, problemConstraints: [], droppedConstraints });\n }\n\n /**\n * Remaining degrees of freedom after a successful solve (-1 if unavailable).\n *\n * @returns the DoF count, or -1 if the backend does not report it.\n */\n getDof(): number {\n try {\n const v = this.wrapper.gcs.dof();\n return typeof v === 'number' && Number.isFinite(v) ? v : -1;\n } catch {\n return -1;\n }\n }\n\n private constraintToPrimitives(\n c: FcstdSketchCon,\n ctx: {\n lines: Map<number, { p1: PtKey; p2: PtKey }>;\n arcs: Map<number, { center: PtKey; start: PtKey; end: PtKey }>;\n circles: Map<number, { center: PtKey }>;\n ellipses: Map<number, { center: PtKey; focus1: PtKey }>;\n standalone: Map<number, PtKey>;\n externalLines: Map<number, { p1: PtKey; p2: PtKey }>;\n },\n ): Record<string, unknown>[] {\n const out: Record<string, unknown>[] = [];\n const id = `c${c.index}`;\n const r = c.refs;\n // guards: old-format fallback may yield < 2 refs for pair constraints\n if (r.length < 1) return out;\n const pt = (ref: { geoId: number; pos: number } | undefined): PtKey | undefined => {\n if (!ref) return undefined;\n if (ref.geoId === -1) return P(-1, 1); // root point\n if (ref.geoId === -2) return P(-2, ref.pos === 0 ? 1 : ref.pos); // VAxis point\n if (ref.geoId <= -3 && ref.geoId > -2000) {\n // M6.3 external geometry: endpoint/point refs onto fixed segments\n const ext = ctx.externalLines.get(ref.geoId);\n if (!ext) return undefined;\n if (ref.pos === 1) return ext.p1;\n if (ref.pos === 2) return ext.p2;\n return undefined; // pos=0 (edge itself) handled by line-typed paths\n }\n if (ref.geoId >= 0) return P(ref.geoId, ref.pos);\n return undefined;\n };\n\n switch (c.type) {\n case ConstraintType.Coincident: {\n const p1 = pt(r[0]!);\n const p2 = pt(r[1]!);\n if (p1 && p2) out.push({ type: 'p2p_coincident', id, p1_id: p1, p2_id: p2 });\n break;\n }\n case ConstraintType.Horizontal: {\n // Horizontal with pos=0 refs is the HAxis case: line horizontal\n if (r[0]!.pos === PointPos.none || r.length >= 1 && r[0]!.pos !== PointPos.mid) {\n if (r.length === 1) {\n // horizontal via axis: geoId is the line itself\n const line = ctx.lines.get(r[0]!.geoId);\n if (line) out.push({ type: 'horizontal_l', id, l_id: line ? `L${r[0]!.geoId}` : '' });\n } else {\n const p1 = pt(r[0]!);\n const p2 = pt(r[1]!);\n if (p1 && p2) out.push({ type: 'horizontal_pp', id, p1_id: p1, p2_id: p2 });\n }\n }\n break;\n }\n case ConstraintType.Vertical: {\n if (r.length === 1) {\n const gid = `L${r[0]!.geoId}`;\n if (ctx.lines.has(r[0]!.geoId)) out.push({ type: 'vertical_l', id, l_id: gid });\n } else {\n const p1 = pt(r[0]!);\n const p2 = pt(r[1]!);\n if (p1 && p2) out.push({ type: 'vertical_pp', id, p1_id: p1, p2_id: p2 });\n }\n break;\n }\n case ConstraintType.Parallel: {\n if (r.length === 2 && ctx.lines.has(r[0]!.geoId) && ctx.lines.has(r[1]!.geoId)) {\n out.push({\n type: 'parallel', id,\n l1_id: `L${r[0]!.geoId}`, l2_id: `L${r[1]!.geoId}`,\n internalalignment: 0,\n });\n }\n break;\n }\n case ConstraintType.Perpendicular: {\n if (r.length === 2 && ctx.lines.has(r[0]!.geoId) && ctx.lines.has(r[1]!.geoId)) {\n out.push({ type: 'perpendicular_ll', id, l1_id: `L${r[0]!.geoId}`, l2_id: `L${r[1]!.geoId}` });\n }\n break;\n }\n case ConstraintType.Distance: {\n // p2p / p2l / p2c / c2c variants by ref shapes.\n // GOTCHA (probe-l1-ablation.ts): a second ref that is an AXIS EDGE\n // (geoId -1/-2, pos=0) is a point-to-LINE distance against the axis\n // (FreeCAD Sketch.cpp addDistanceConstraint(point, line)) — e.g.\n // Distance(p, HAxis) = |y|. Resolving the axis edge to the root point\n // and emitting p2p_distance instead drags the point onto a circle\n // around the origin (taperedballnose collapse, delta 2.3e1).\n const p1 = pt(r[0]!);\n const axisEdgeDist = r.length >= 2 && r[1]!.pos === PointPos.none && (r[1]!.geoId === -1 || r[1]!.geoId === -2);\n if (axisEdgeDist && p1) {\n out.push({ type: 'p2l_distance', id, p_id: p1, l_id: `L${r[1]!.geoId}`, distance: c.value });\n } else if (p1 && r[1] && r[1].pos === PointPos.none && ctx.lines.has(r[1].geoId)) {\n out.push({ type: 'p2l_distance', id, p_id: p1, l_id: `L${r[1]!.geoId}`, distance: c.value });\n } else if (p1 && r[1]) {\n const p2 = pt(r[1]);\n if (p2) out.push({ type: 'p2p_distance', id, p1_id: p1, p2_id: p2, distance: c.value });\n }\n break;\n }\n case ConstraintType.DistanceX: {\n // planegcs 'difference' semantics: param2 - param1 = difference\n // (verified empirically). FCStd DistanceX value = second.x - first.x.\n // GOTCHA (probe-l1-ablation.ts, Sketch.cpp:2053): when the second ref\n // is an AXIS EDGE (geoId -1/-2, pos=0) FreeCAD treats it as GeoUndef —\n // an ABSOLUTE coordinate constraint (coordinate_x), not a difference\n // against the axis point. Mapping it to 'difference' forces x = -value\n // and produced the taperedballnose wrong solution (delta 2.3e1).\n const axisEdge = r.length >= 2 && r[1]!.pos === PointPos.none && (r[1]!.geoId === -1 || r[1]!.geoId === -2);\n const firstIsPoint = r[0]!.pos !== PointPos.none || r[0]!.geoId < 0;\n if (axisEdge && firstIsPoint) {\n const p = pt(r[0]!);\n if (p) out.push({ type: 'coordinate_x', id, p_id: p, x: c.value });\n break;\n }\n const p1 = pt(r[0]!);\n const p2 = pt(r[1]!);\n if (p1 && p2) {\n out.push({\n type: 'difference',\n id,\n param1: { o_id: p1, prop: 'x' },\n param2: { o_id: p2, prop: 'x' },\n difference: c.value,\n });\n }\n break;\n }\n case ConstraintType.DistanceY: {\n // symmetric case to DistanceX: axis-edge second ref → absolute y\n const axisEdge = r.length >= 2 && r[1]!.pos === PointPos.none && (r[1]!.geoId === -1 || r[1]!.geoId === -2);\n const firstIsPoint = r[0]!.pos !== PointPos.none || r[0]!.geoId < 0;\n if (axisEdge && firstIsPoint) {\n const p = pt(r[0]!);\n if (p) out.push({ type: 'coordinate_y', id, p_id: p, y: c.value });\n break;\n }\n const p1 = pt(r[0]!);\n const p2 = pt(r[1]!);\n if (p1 && p2) {\n out.push({\n type: 'difference',\n id,\n param1: { o_id: p1, prop: 'y' },\n param2: { o_id: p2, prop: 'y' },\n difference: c.value,\n });\n }\n break;\n }\n case ConstraintType.Angle: {\n // FreeCAD Sketch.cpp case Angle — 4 shapes by ref count/pos:\n // ① Third != GeoUndef → angle-via-point (not needed by corpus P0 set;\n // dropped explicitly below if encountered)\n // ② SecondPos != none → l2l_angle_pppp (lines with explicit start points:\n // pos==start keeps direction, pos==end swaps the point pair)\n // ③ Second set, both pos none → l2l_angle_ll (line-level)\n // ④ only First → p2p_angle on the line's own points (orientation)\n // refs may carry a Third = -2000 (GeoUndef sentinel) — filter it.\n const refs = r.filter((x) => x.geoId !== -2000);\n if (refs.length >= 3) {\n // ① via-point angle: not in the P0 mapping set — record as dropped\n break;\n }\n if (refs.length === 2) {\n const [a, b] = refs as [{ geoId: number; pos: number }, { geoId: number; pos: number }];\n const lineA = ctx.lines.has(a.geoId);\n const lineB = ctx.lines.has(b.geoId);\n if (lineA && lineB && a.pos !== PointPos.none && b.pos !== PointPos.none) {\n // ② explicit start points; pos=end reverses that line's direction\n const a1 = a.pos === PointPos.start ? P(a.geoId, 1) : P(a.geoId, 2);\n const a2 = a.pos === PointPos.start ? P(a.geoId, 2) : P(a.geoId, 1);\n const b1 = b.pos === PointPos.start ? P(b.geoId, 1) : P(b.geoId, 2);\n const b2 = b.pos === PointPos.start ? P(b.geoId, 2) : P(b.geoId, 1);\n out.push({ type: 'l2l_angle_pppp', id, l1p1_id: a1, l1p2_id: a2, l2p1_id: b1, l2p2_id: b2, angle: c.value });\n } else if (lineA && lineB) {\n // ③ line-level angle\n out.push({\n type: 'l2l_angle_ll', id,\n l1_id: `L${a.geoId}`, l2_id: `L${b.geoId}`,\n angle: c.value,\n internalalignment: 0,\n });\n }\n } else if (refs.length === 1 && ctx.lines.has(refs[0]!.geoId)) {\n // ④ orientation angle of a single line (p2p_angle on its points)\n out.push({ type: 'p2p_angle', id, p1_id: P(refs[0]!.geoId, 1), p2_id: P(refs[0]!.geoId, 2), angle: c.value });\n }\n break;\n }\n case ConstraintType.Radius: {\n if (ctx.circles.has(r[0]!.geoId)) {\n out.push({ type: 'circle_radius', id, c_id: `C${r[0]!.geoId}`, radius: c.value });\n } else if (ctx.arcs.has(r[0]!.geoId)) {\n out.push({ type: 'arc_radius', id, a_id: `A${r[0]!.geoId}`, radius: c.value });\n }\n break;\n }\n case ConstraintType.Diameter: {\n if (ctx.circles.has(r[0]!.geoId)) {\n out.push({ type: 'circle_diameter', id, c_id: `C${r[0]!.geoId}`, diameter: c.value });\n } else if (ctx.arcs.has(r[0]!.geoId)) {\n out.push({ type: 'arc_diameter', id, a_id: `A${r[0]!.geoId}`, diameter: c.value });\n }\n break;\n }\n case ConstraintType.Equal: {\n // equal_length for line pairs; equal_radii for circle/arc pairs\n if (r.length === 2) {\n const g0 = r[0]!.geoId;\n const g1 = r[1]!.geoId;\n if (ctx.lines.has(g0) && ctx.lines.has(g1)) {\n out.push({ type: 'equal_length', id, l1_id: `L${g0}`, l2_id: `L${g1}` });\n } else if ((ctx.circles.has(g0) || ctx.arcs.has(g0)) && (ctx.circles.has(g1) || ctx.arcs.has(g1))) {\n // arcs use their own primitive id (A{n}); circles use C{n}\n const id0 = ctx.circles.has(g0) ? `C${g0}` : `A${g0}`;\n const id1 = ctx.circles.has(g1) ? `C${g1}` : `A${g1}`;\n out.push({ type: 'equal_radius_cc', id, c1_id: id0, c2_id: id1 });\n } else if (ctx.ellipses.has(g0) && ctx.ellipses.has(g1)) {\n out.push({ type: 'equal_radii_ee', id, e1_id: `E${g0}`, e2_id: `E${g1}` });\n }\n }\n break;\n }\n case ConstraintType.PointOnObject: {\n const p = pt(r[0]!);\n if (p && r[1]!.pos === PointPos.none) {\n const onGeoId = r[1]!.geoId;\n if (ctx.lines.has(onGeoId)) {\n out.push({ type: 'point_on_line_pl', id, p_id: p, l_id: `L${onGeoId}` });\n } else if (ctx.externalLines.has(onGeoId)) {\n // M6.3: point-on-external-edge → point_on_line against the fixed line\n out.push({ type: 'point_on_line_pl', id, p_id: p, l_id: `X${onGeoId}` });\n } else if (ctx.circles.has(onGeoId)) {\n out.push({ type: 'point_on_circle', id, p_id: p, c_id: `C${onGeoId}` });\n } else if (ctx.arcs.has(onGeoId)) {\n out.push({ type: 'point_on_arc', id, p_id: p, a_id: `A${onGeoId}` });\n }\n }\n break;\n }\n case ConstraintType.Symmetric: {\n // Symmetric(p1, p2, line) or Symmetric(p1, p2, p3)\n const p1 = pt(r[0]!);\n const p2 = pt(r[1]!);\n if (p1 && p2) {\n if (r.length >= 3 && r[2]!.pos === PointPos.none && ctx.lines.has(r[2]!.geoId)) {\n out.push({ type: 'p2p_symmetric_ppl', id, p1_id: p1, p2_id: p2, l_id: `L${r[2]!.geoId}` });\n } else {\n const p3 = pt(r[2]!);\n if (p3) out.push({ type: 'p2p_symmetric_ppp', id, p1_id: p1, p2_id: p2, p_id: p3 });\n }\n }\n break;\n }\n case ConstraintType.Tangent: {\n // line-circle / circle-circle / line-arc / arc-arc (edge-level, pos=0)\n const a = r[0]!;\n const b = r[1]!;\n if (!a || !b) break;\n const lineA = ctx.lines.has(a.geoId);\n const circA = ctx.circles.has(a.geoId);\n const arcA = ctx.arcs.has(a.geoId);\n const lineB = ctx.lines.has(b.geoId);\n const circB = ctx.circles.has(b.geoId);\n const arcB = ctx.arcs.has(b.geoId);\n if (lineA && circB) out.push({ type: 'tangent_lc', id, l_id: `L${a.geoId}`, c_id: `C${b.geoId}`, internalalignment: 0 });\n else if (circA && lineB) out.push({ type: 'tangent_lc', id, l_id: `L${b.geoId}`, c_id: `C${a.geoId}`, internalalignment: 0 });\n else if (circA && circB) out.push({ type: 'tangent_cc', id, c1_id: `C${a.geoId}`, c2_id: `C${b.geoId}`, internalalignment: 0 });\n else if (lineA && arcB) out.push({ type: 'tangent_la', id, l_id: `L${a.geoId}`, a_id: `A${b.geoId}`, internalalignment: 0 });\n else if (arcA && lineB) out.push({ type: 'tangent_la', id, l_id: `L${b.geoId}`, a_id: `A${a.geoId}`, internalalignment: 0 });\n else if (arcA && arcB) out.push({ type: 'tangent_aa', id, a1_id: `A${a.geoId}`, a2_id: `A${b.geoId}`, internalalignment: 0 });\n break;\n }\n default:\n break; // unsupported types never reach here (guard in solve())\n }\n return out;\n }\n\n private pullBack(\n geoms: FcstdSketchGeom[],\n ctx: {\n lines: Map<number, { p1: PtKey; p2: PtKey }>;\n arcs: Map<number, { center: PtKey; start: PtKey; end: PtKey }>;\n circles: Map<number, { center: PtKey }>;\n ellipses: Map<number, { center: PtKey; focus1: PtKey }>;\n standalone: Map<number, PtKey>;\n },\n ): FcstdSketchGeom[] {\n // After apply_solution, re-derive geometry from the wrapper's primitive\n // state via pull through the wrapper's sketch index.\n const out: FcstdSketchGeom[] = [];\n for (const g of geoms) {\n switch (g.kind) {\n case 'point': {\n const key = ctx.standalone.get(g.index);\n const pt = key ? this.readPoint(key) : undefined;\n out.push(pt ? { ...g, x: pt.x, y: pt.y } : g);\n break;\n }\n case 'line': {\n const l = ctx.lines.get(g.index)!;\n const p1 = this.readPoint(l.p1);\n const p2 = this.readPoint(l.p2);\n out.push(p1 && p2 ? { ...g, x1: p1.x, y1: p1.y, x2: p2.x, y2: p2.y } : g);\n break;\n }\n case 'circle': {\n const cc = ctx.circles.get(g.index)!.center;\n const c = this.readPoint(cc);\n const rad = this.readCircleRadius(g.index);\n out.push(c && rad !== undefined ? { ...g, cx: c.x, cy: c.y, radius: rad } : g);\n break;\n }\n case 'arc': {\n const a = ctx.arcs.get(g.index)!;\n const c = this.readPoint(a.center);\n const s = this.readPoint(a.start);\n const e = this.readPoint(a.end);\n if (c && s && e) {\n const r = Math.hypot(s.x - c.x, s.y - c.y);\n const startAngle = Math.atan2(s.y - c.y, s.x - c.x);\n const endAngle = Math.atan2(e.y - c.y, e.x - c.x);\n out.push({ ...g, cx: c.x, cy: c.y, radius: r, startAngle, endAngle, x1: s.x, y1: s.y, x2: e.x, y2: e.y });\n } else out.push(g);\n break;\n }\n case 'bspline': {\n // P4: spline endpoints ride the line proxy; pull their solved coords.\n const l = ctx.lines.get(g.index)!;\n const p1 = this.readPoint(l.p1);\n const p2 = this.readPoint(l.p2);\n out.push(p1 && p2 ? { ...g, x1: p1.x, y1: p1.y, x2: p2.x, y2: p2.y } : g);\n break;\n }\n case 'ellipse': {\n const el = ctx.ellipses.get(g.index)!;\n const c = this.readPoint(el.center);\n const f1 = this.readPoint(el.focus1);\n if (c && f1) {\n const major = Math.hypot(f1.x - c.x, f1.y - c.y) * 1;\n const angleXU = Math.atan2(f1.y - c.y, f1.x - c.x);\n // minor radius is a parameter on the ellipse primitive; approximate\n // pull via ratio is not exposed — keep stored minor (M3 scope).\n out.push({ ...g, cx: c.x, cy: c.y, majorRadius: g.majorRadius * (major / g.majorRadius), angleXU });\n } else out.push(g);\n break;\n }\n }\n }\n return out;\n }\n\n /** Read a point's solved coordinates from the sketch index.\n * apply_solution() already pulled every primitive's solved values back into\n * sketch_index (gcs_wrapper.js:104-108), so get_primitive is authoritative. */\n private readPoint(key: PtKey): { x: number; y: number } | undefined {\n const p = this.wrapper.sketch_index.get_primitive(key) as { x?: number; y?: number } | undefined;\n if (!p || typeof p.x !== 'number' || typeof p.y !== 'number') return undefined;\n return { x: p.x, y: p.y };\n }\n\n private readCircleRadius(geoIndex: number): number | undefined {\n const c = this.wrapper.sketch_index.get_primitive(`C${geoIndex}`) as { radius?: number } | undefined;\n return typeof c?.radius === 'number' ? c.radius : undefined;\n }\n}\n"]}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * project — single-point conversion between the canonical sketch model and the
3
+ * two downstream projection dialects (§4.5).
4
+ *
5
+ * canonical ⇄ FCStd (`fcstd-types`, integer ConstraintType + PointPos)
6
+ * canonical ⇄ CadQuery (tag + string constraint names, 0..1 positions)
7
+ *
8
+ * One implementation, two projections: the FCStd side feeds the planegcs solve
9
+ * pipeline; the CadQuery side feeds `cq-compat-sketch`. Constraints with no
10
+ * counterpart in a target dialect raise an explicit `E_SKETCHC_*` — never a
11
+ * silent downgrade.
12
+ */
13
+ import { type FcstdGeoRef, type FcstdSketchGeom, type FcstdSketchCon } from './fcstd-types.js';
14
+ import type { At, Ref, SketchConstraint, SketchConstraintKind, SketchGeom } from './canonical.js';
15
+ /** Projection error with a stable `E_SKETCHC_*` code. */
16
+ export declare class SketchProjectionError extends Error {
17
+ readonly code: string;
18
+ constructor(code: string, message: string);
19
+ }
20
+ /**
21
+ * Map a canonical `At` to an FCStd `PointPos`. Throws `E_SKETCHC_UNMAPPED` when there is no counterpart.
22
+ *
23
+ * @param at - the canonical position.
24
+ * @returns the FCStd `PointPos` integer.
25
+ */
26
+ export declare function atToFreeCad(at: At | undefined): number;
27
+ /**
28
+ * Map an FCStd `PointPos` to a canonical `At` (`mid` FCStd means the centre).
29
+ *
30
+ * @param pos - the FCStd `PointPos` integer.
31
+ * @returns the canonical position, or `undefined` for `none`.
32
+ */
33
+ export declare function atFromFreeCad(pos: number): At | undefined;
34
+ /**
35
+ * Map a canonical `At` to a CadQuery 0..1 parameter (`null` = the arc-centre `None` argument).
36
+ *
37
+ * @param at - the canonical position.
38
+ * @returns the CadQuery 0..1 parameter, or `null` for centre.
39
+ */
40
+ export declare function atToCadQuery(at: At | undefined): number | null;
41
+ /**
42
+ * Map a CadQuery 0..1 parameter to a canonical `At`.
43
+ *
44
+ * @param v - the CadQuery parameter, or `null`/`undefined` for centre.
45
+ * @returns the canonical position, or `undefined` for `null`/`undefined`.
46
+ */
47
+ export declare function atFromCadQuery(v: number | null | undefined): At | undefined;
48
+ /**
49
+ * Build the tag → index lookup for a geometry list in one pass.
50
+ *
51
+ * @param geoms - canonical geometry list.
52
+ * @returns tag → geometry index.
53
+ */
54
+ export declare function buildTagIndex(geoms: SketchGeom[]): Map<string, number>;
55
+ /**
56
+ * Resolve a canonical `Ref` to an FCStd `(geoId, pos)` pair.
57
+ *
58
+ * @param ref - the canonical reference (tag or index + at).
59
+ * @param tagIndex - tag → index map (from {@link buildTagIndex}).
60
+ * @param geoms - the geometry array (for bounds checking of index refs).
61
+ * @returns the FCStd `(geoId, pos)` pair.
62
+ * @throws SketchProjectionError `E_SKETCHC_BAD_REF` for unknown tag or out-of-range index.
63
+ */
64
+ export declare function refToFreeCad(ref: Ref, tagIndex: Map<string, number>, geoms: SketchGeom[]): FcstdGeoRef;
65
+ /**
66
+ * Project canonical geometry to the FCStd shape consumed by the solver.
67
+ *
68
+ * @param geoms - canonical geometry.
69
+ * @returns FCStd geometry records (same order/index).
70
+ * @throws SketchProjectionError `E_SKETCHC_UNSUPPORTED_GEOM` for reserved kinds.
71
+ */
72
+ export declare function toFreeCadGeoms(geoms: SketchGeom[]): FcstdSketchGeom[];
73
+ /**
74
+ * Project FCStd geometry back to the canonical model (reserved kinds are reported).
75
+ *
76
+ * @param geoms - FCStd geometry records from the solver.
77
+ * @returns canonical geometry (same order/index).
78
+ */
79
+ export declare function fromFreeCadGeoms(geoms: FcstdSketchGeom[]): SketchGeom[];
80
+ /** Result of projecting canonical constraints to FCStd. */
81
+ export interface ProjectedConstraints {
82
+ /** FCStd constraints (index matches the canonical constraint order for kept items). */
83
+ constraints: FcstdSketchCon[];
84
+ /** canonical constraint indices mapped to a deliberate no-op (fixed). */
85
+ noops: number[];
86
+ }
87
+ /**
88
+ * Project canonical constraints to the FCStd shape the solver consumes.
89
+ *
90
+ * @param constraints - canonical constraints.
91
+ * @param geoms - canonical geometry (for tag/index resolution).
92
+ * @returns FCStd constraints plus the no-op (`fixed`) indices.
93
+ */
94
+ export declare function toFreeCadConstraints(constraints: SketchConstraint[], geoms: SketchGeom[]): ProjectedConstraints;
95
+ /** CadQuery constraint names for the canonical kinds it supports (the other 8). */
96
+ export declare const CONSTRAINT_KIND_TO_CADQUERY: Partial<Record<SketchConstraintKind, string>>;
97
+ /** CadQuery constraint name → canonical kind. */
98
+ export declare const CADQUERY_TO_CONSTRAINT_KIND: Record<string, SketchConstraintKind>;
99
+ /**
100
+ * Map a canonical constraint kind to its CadQuery name.
101
+ *
102
+ * @param kind - canonical constraint kind.
103
+ * @returns the CadQuery constraint name.
104
+ * @throws SketchProjectionError `E_SKETCHC_UNSUPPORTED_BY_CQ` when CQ has no counterpart.
105
+ */
106
+ export declare function constraintKindToCadQuery(kind: SketchConstraintKind): string;
107
+ /**
108
+ * Map a CadQuery constraint name to its canonical kind.
109
+ *
110
+ * @param name - CadQuery constraint name.
111
+ * @returns the canonical kind.
112
+ * @throws SketchProjectionError `E_SKETCHC_UNSUPPORTED_CONSTRAINT` for unknown names.
113
+ */
114
+ export declare function constraintKindFromCadQuery(name: string): SketchConstraintKind;
115
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAY,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAExG,OAAO,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEjG,yDAAyD;AACzD,qBAAa,qBAAsB,SAAQ,KAAK;aAClB,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAI1D;AAID;;;;;GAKG;AACH,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iD;AACjD,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAE5E,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM,CAM3E;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,CAM7E"}
@@ -0,0 +1,329 @@
1
+ /**
2
+ * project — single-point conversion between the canonical sketch model and the
3
+ * two downstream projection dialects (§4.5).
4
+ *
5
+ * canonical ⇄ FCStd (`fcstd-types`, integer ConstraintType + PointPos)
6
+ * canonical ⇄ CadQuery (tag + string constraint names, 0..1 positions)
7
+ *
8
+ * One implementation, two projections: the FCStd side feeds the planegcs solve
9
+ * pipeline; the CadQuery side feeds `cq-compat-sketch`. Constraints with no
10
+ * counterpart in a target dialect raise an explicit `E_SKETCHC_*` — never a
11
+ * silent downgrade.
12
+ */
13
+ import { PointPos } from './fcstd-types.js';
14
+ import { ConstraintType } from './fcstd-types.js';
15
+ /** Projection error with a stable `E_SKETCHC_*` code. */
16
+ export class SketchProjectionError extends Error {
17
+ code;
18
+ constructor(code, message) {
19
+ super(`${code}: ${message}`);
20
+ this.code = code;
21
+ this.name = 'SketchProjectionError';
22
+ }
23
+ }
24
+ // ── at / Ref resolution ──
25
+ /**
26
+ * Map a canonical `At` to an FCStd `PointPos`. Throws `E_SKETCHC_UNMAPPED` when there is no counterpart.
27
+ *
28
+ * @param at - the canonical position.
29
+ * @returns the FCStd `PointPos` integer.
30
+ */
31
+ export function atToFreeCad(at) {
32
+ if (at === undefined)
33
+ return PointPos.none;
34
+ if (at === 'start')
35
+ return PointPos.start;
36
+ if (at === 'end')
37
+ return PointPos.end;
38
+ if (at === 'center')
39
+ return PointPos.mid;
40
+ if (at === 'mid') {
41
+ throw new SketchProjectionError('E_SKETCHC_UNMAPPED', 'at "mid" (arc/line midpoint) has no FCStd PointPos');
42
+ }
43
+ if (typeof at === 'number') {
44
+ if (at === 0)
45
+ return PointPos.start;
46
+ if (at === 1)
47
+ return PointPos.end;
48
+ throw new SketchProjectionError('E_SKETCHC_UNMAPPED', `parametric at ${at} has no FCStd PointPos`);
49
+ }
50
+ throw new SketchProjectionError('E_SKETCHC_UNMAPPED', `unsupported at ${String(at)}`);
51
+ }
52
+ /**
53
+ * Map an FCStd `PointPos` to a canonical `At` (`mid` FCStd means the centre).
54
+ *
55
+ * @param pos - the FCStd `PointPos` integer.
56
+ * @returns the canonical position, or `undefined` for `none`.
57
+ */
58
+ export function atFromFreeCad(pos) {
59
+ switch (pos) {
60
+ case PointPos.none: return undefined;
61
+ case PointPos.start: return 'start';
62
+ case PointPos.end: return 'end';
63
+ case PointPos.mid: return 'center';
64
+ default: return undefined;
65
+ }
66
+ }
67
+ /**
68
+ * Map a canonical `At` to a CadQuery 0..1 parameter (`null` = the arc-centre `None` argument).
69
+ *
70
+ * @param at - the canonical position.
71
+ * @returns the CadQuery 0..1 parameter, or `null` for centre.
72
+ */
73
+ export function atToCadQuery(at) {
74
+ if (at === undefined)
75
+ return null;
76
+ if (at === 'start')
77
+ return 0;
78
+ if (at === 'end')
79
+ return 1;
80
+ if (at === 'mid')
81
+ return 0.5;
82
+ if (at === 'center')
83
+ return null;
84
+ return at;
85
+ }
86
+ /**
87
+ * Map a CadQuery 0..1 parameter to a canonical `At`.
88
+ *
89
+ * @param v - the CadQuery parameter, or `null`/`undefined` for centre.
90
+ * @returns the canonical position, or `undefined` for `null`/`undefined`.
91
+ */
92
+ export function atFromCadQuery(v) {
93
+ if (v === null || v === undefined)
94
+ return undefined;
95
+ if (v === 0)
96
+ return 'start';
97
+ if (v === 1)
98
+ return 'end';
99
+ if (v === 0.5)
100
+ return 'mid';
101
+ return v;
102
+ }
103
+ /**
104
+ * Build the tag → index lookup for a geometry list in one pass.
105
+ *
106
+ * @param geoms - canonical geometry list.
107
+ * @returns tag → geometry index.
108
+ */
109
+ export function buildTagIndex(geoms) {
110
+ const index = new Map();
111
+ geoms.forEach((g, i) => {
112
+ if (g.tag !== undefined)
113
+ index.set(g.tag, i);
114
+ });
115
+ return index;
116
+ }
117
+ /**
118
+ * Resolve a canonical `Ref` to an FCStd `(geoId, pos)` pair.
119
+ *
120
+ * @param ref - the canonical reference (tag or index + at).
121
+ * @param tagIndex - tag → index map (from {@link buildTagIndex}).
122
+ * @param geoms - the geometry array (for bounds checking of index refs).
123
+ * @returns the FCStd `(geoId, pos)` pair.
124
+ * @throws SketchProjectionError `E_SKETCHC_BAD_REF` for unknown tag or out-of-range index.
125
+ */
126
+ export function refToFreeCad(ref, tagIndex, geoms) {
127
+ let geoId;
128
+ if ('tag' in ref) {
129
+ const found = tagIndex.get(ref.tag);
130
+ if (found === undefined) {
131
+ throw new SketchProjectionError('E_SKETCHC_BAD_REF', `unknown tag "${ref.tag}"`);
132
+ }
133
+ geoId = found;
134
+ }
135
+ else {
136
+ if (!Number.isInteger(ref.index) || ref.index < 0 || ref.index >= geoms.length) {
137
+ throw new SketchProjectionError('E_SKETCHC_BAD_REF', `index ${ref.index} out of range [0, ${geoms.length})`);
138
+ }
139
+ geoId = ref.index;
140
+ }
141
+ return { geoId, pos: atToFreeCad(ref.at) };
142
+ }
143
+ // ── geometry projection ──
144
+ /**
145
+ * Project canonical geometry to the FCStd shape consumed by the solver.
146
+ *
147
+ * @param geoms - canonical geometry.
148
+ * @returns FCStd geometry records (same order/index).
149
+ * @throws SketchProjectionError `E_SKETCHC_UNSUPPORTED_GEOM` for reserved kinds.
150
+ */
151
+ export function toFreeCadGeoms(geoms) {
152
+ return geoms.map((g, index) => {
153
+ switch (g.kind) {
154
+ case 'line':
155
+ return { kind: 'line', index, x1: g.x1, y1: g.y1, z1: 0, x2: g.x2, y2: g.y2, z2: 0 };
156
+ case 'circle':
157
+ return { kind: 'circle', index, cx: g.cx, cy: g.cy, cz: 0, radius: g.r };
158
+ case 'arc': {
159
+ // Pass the canonical signed span (a0, a1) through unchanged. planegcs builds
160
+ // the arc from the pinned start/end endpoints *and* the signed start/end
161
+ // angles, so a CW arc (a1 < a0) is drawn as the short clockwise arc.
162
+ // Normalising a1 into a CCW span would instead produce the long arc through
163
+ // those same endpoints. Arc orientation is carried back to the caller via
164
+ // solveSketch (input ccw preserved), not recovered here.
165
+ const a0 = g.a0;
166
+ const a1 = g.a1;
167
+ return {
168
+ kind: 'arc', index, cx: g.cx, cy: g.cy, cz: 0, radius: g.r,
169
+ startAngle: a0, endAngle: a1,
170
+ x1: g.cx + g.r * Math.cos(a0), y1: g.cy + g.r * Math.sin(a0), z1: 0,
171
+ x2: g.cx + g.r * Math.cos(a1), y2: g.cy + g.r * Math.sin(a1), z2: 0,
172
+ };
173
+ }
174
+ case 'point':
175
+ case 'ellipse':
176
+ case 'bspline':
177
+ throw new SketchProjectionError('E_SKETCHC_UNSUPPORTED_GEOM', `geometry kind "${g.kind}" is not supported in the first release`);
178
+ }
179
+ });
180
+ }
181
+ /**
182
+ * Project FCStd geometry back to the canonical model (reserved kinds are reported).
183
+ *
184
+ * @param geoms - FCStd geometry records from the solver.
185
+ * @returns canonical geometry (same order/index).
186
+ */
187
+ export function fromFreeCadGeoms(geoms) {
188
+ return geoms.map((g) => {
189
+ switch (g.kind) {
190
+ case 'line':
191
+ return { kind: 'line', x1: g.x1, y1: g.y1, x2: g.x2, y2: g.y2 };
192
+ case 'circle':
193
+ return { kind: 'circle', cx: g.cx, cy: g.cy, r: g.radius };
194
+ case 'arc': {
195
+ const ccw = normalizeArcCcw(g.startAngle, g.endAngle);
196
+ return { kind: 'arc', cx: g.cx, cy: g.cy, r: g.radius, a0: g.startAngle, a1: g.endAngle, ccw };
197
+ }
198
+ case 'point':
199
+ return { kind: 'point', x: g.x, y: g.y };
200
+ case 'ellipse':
201
+ return { kind: 'ellipse', cx: g.cx, cy: g.cy, rx: g.majorRadius, ry: g.minorRadius, angle: g.angleXU };
202
+ case 'bspline':
203
+ return { kind: 'bspline', poles: g.poles, knots: g.knots, degree: g.degree, periodic: g.periodic };
204
+ }
205
+ });
206
+ }
207
+ /** True when the arc span is counter-clockwise as stored. */
208
+ function normalizeArcCcw(startAngle, endAngle) {
209
+ let sweep = endAngle - startAngle;
210
+ while (sweep <= 0)
211
+ sweep += 2 * Math.PI;
212
+ while (sweep > 2 * Math.PI)
213
+ sweep -= 2 * Math.PI;
214
+ return sweep > 0;
215
+ }
216
+ function mapConstraint(c, tagIndex, geoms) {
217
+ const ref = (r) => refToFreeCad(r, tagIndex, geoms);
218
+ switch (c.kind) {
219
+ case 'fixed':
220
+ // FCStd has no explicit fixed constraint — the implicit fixed frame
221
+ // (RtPnt + H/V axes) absorbs the rigid-body DoF (§4.5).
222
+ return 'noop';
223
+ case 'coincident':
224
+ return { type: ConstraintType.Coincident, refs: [ref(c.a), ref(c.b)] };
225
+ case 'horizontal':
226
+ return { type: ConstraintType.Horizontal, refs: [ref(c.of)] };
227
+ case 'vertical':
228
+ return { type: ConstraintType.Vertical, refs: [ref(c.of)] };
229
+ case 'parallel':
230
+ return { type: ConstraintType.Parallel, refs: [ref(c.a), ref(c.b)] };
231
+ case 'perpendicular':
232
+ return { type: ConstraintType.Perpendicular, refs: [ref(c.a), ref(c.b)] };
233
+ case 'tangent':
234
+ return { type: ConstraintType.Tangent, refs: [ref(c.a), ref(c.b)] };
235
+ case 'distance':
236
+ return { type: ConstraintType.Distance, refs: [ref(c.a), ref(c.b)], value: c.value };
237
+ case 'distanceX':
238
+ return { type: ConstraintType.DistanceX, refs: [ref(c.a), ref(c.b)], value: c.value };
239
+ case 'distanceY':
240
+ return { type: ConstraintType.DistanceY, refs: [ref(c.a), ref(c.b)], value: c.value };
241
+ case 'length': {
242
+ // Length is expressed as a point-to-point Distance over the element ends.
243
+ const base = ref(c.of);
244
+ const start = { geoId: base.geoId, pos: PointPos.start };
245
+ const end = { geoId: base.geoId, pos: PointPos.end };
246
+ return { type: ConstraintType.Distance, refs: [start, end], value: c.value };
247
+ }
248
+ case 'angle':
249
+ return { type: ConstraintType.Angle, refs: [ref(c.a), ref(c.b)], value: c.value };
250
+ case 'orientation':
251
+ throw new SketchProjectionError('E_SKETCHC_UNMAPPED', 'constraint "orientation" has no FCStd counterpart');
252
+ case 'radius':
253
+ return { type: ConstraintType.Radius, refs: [ref(c.of)], value: c.value };
254
+ case 'diameter':
255
+ return { type: ConstraintType.Diameter, refs: [ref(c.of)], value: c.value };
256
+ case 'arcAngle':
257
+ throw new SketchProjectionError('E_SKETCHC_UNMAPPED', 'constraint "arcAngle" has no FCStd counterpart');
258
+ case 'equal':
259
+ return { type: ConstraintType.Equal, refs: [ref(c.a), ref(c.b)] };
260
+ case 'pointOnObject':
261
+ return { type: ConstraintType.PointOnObject, refs: [ref(c.p), ref(c.on)] };
262
+ case 'symmetric':
263
+ return { type: ConstraintType.Symmetric, refs: [ref(c.p1), ref(c.p2), ref(c.about)] };
264
+ }
265
+ }
266
+ /**
267
+ * Project canonical constraints to the FCStd shape the solver consumes.
268
+ *
269
+ * @param constraints - canonical constraints.
270
+ * @param geoms - canonical geometry (for tag/index resolution).
271
+ * @returns FCStd constraints plus the no-op (`fixed`) indices.
272
+ */
273
+ export function toFreeCadConstraints(constraints, geoms) {
274
+ const tagIndex = buildTagIndex(geoms);
275
+ const out = [];
276
+ const noops = [];
277
+ constraints.forEach((c, index) => {
278
+ const mapped = mapConstraint(c, tagIndex, geoms);
279
+ if (mapped === 'noop') {
280
+ noops.push(index);
281
+ return;
282
+ }
283
+ out.push({ index, type: mapped.type, refs: mapped.refs, value: mapped.value ?? 0, isDriving: true, name: '' });
284
+ });
285
+ return { constraints: out, noops };
286
+ }
287
+ // ── CadQuery projection (constraint type names) ──
288
+ /** CadQuery constraint names for the canonical kinds it supports (the other 8). */
289
+ export const CONSTRAINT_KIND_TO_CADQUERY = {
290
+ fixed: 'FixedPoint',
291
+ coincident: 'Coincident',
292
+ angle: 'Angle',
293
+ length: 'Length',
294
+ distance: 'Distance',
295
+ radius: 'Radius',
296
+ orientation: 'Orientation',
297
+ arcAngle: 'ArcAngle',
298
+ };
299
+ /** CadQuery constraint name → canonical kind. */
300
+ export const CADQUERY_TO_CONSTRAINT_KIND = Object.fromEntries(Object.entries(CONSTRAINT_KIND_TO_CADQUERY).map(([kind, name]) => [name, kind]));
301
+ /**
302
+ * Map a canonical constraint kind to its CadQuery name.
303
+ *
304
+ * @param kind - canonical constraint kind.
305
+ * @returns the CadQuery constraint name.
306
+ * @throws SketchProjectionError `E_SKETCHC_UNSUPPORTED_BY_CQ` when CQ has no counterpart.
307
+ */
308
+ export function constraintKindToCadQuery(kind) {
309
+ const name = CONSTRAINT_KIND_TO_CADQUERY[kind];
310
+ if (!name) {
311
+ throw new SketchProjectionError('E_SKETCHC_UNSUPPORTED_BY_CQ', `constraint "${kind}" is not supported by CadQuery`);
312
+ }
313
+ return name;
314
+ }
315
+ /**
316
+ * Map a CadQuery constraint name to its canonical kind.
317
+ *
318
+ * @param name - CadQuery constraint name.
319
+ * @returns the canonical kind.
320
+ * @throws SketchProjectionError `E_SKETCHC_UNSUPPORTED_CONSTRAINT` for unknown names.
321
+ */
322
+ export function constraintKindFromCadQuery(name) {
323
+ const kind = CADQUERY_TO_CONSTRAINT_KIND[name];
324
+ if (!kind) {
325
+ throw new SketchProjectionError('E_SKETCHC_UNSUPPORTED_CONSTRAINT', `unknown CadQuery constraint "${name}"`);
326
+ }
327
+ return kind;
328
+ }
329
+ //# sourceMappingURL=project.js.map