brepjs 13.1.0 → 13.4.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 (114) hide show
  1. package/dist/2d/curve2dGeometryFns.d.ts +107 -0
  2. package/dist/2d/curve2dGeometryFns.d.ts.map +1 -0
  3. package/dist/2d.cjs +229 -3
  4. package/dist/2d.d.ts +2 -0
  5. package/dist/2d.d.ts.map +1 -1
  6. package/dist/2d.js +206 -4
  7. package/dist/{arrayAccess-Bz2OkAF_.js → arrayAccess-B5LgmXBo.js} +4 -4
  8. package/dist/{arrayAccess-FwdVX3Nh.cjs → arrayAccess-t2dlxGSK.cjs} +4 -4
  9. package/dist/{blueprint-Bpa-w3WF.js → blueprint-CB_85Lz_.js} +10 -10
  10. package/dist/{blueprint-YPV8lQqg.cjs → blueprint-CDnBM-tA.cjs} +10 -10
  11. package/dist/{blueprintFns-iQsyPfTY.cjs → blueprintFns-D4YucGaQ.cjs} +142 -3
  12. package/dist/{blueprintFns-D0RopDZS.js → blueprintFns-DVDommWB.js} +125 -4
  13. package/dist/{boolean2D-D_yuF0kT.js → boolean2D-Mzp-0g7o.js} +12 -12
  14. package/dist/{boolean2D-CMXMxTgD.cjs → boolean2D-lqfKJKUY.cjs} +12 -12
  15. package/dist/{booleanFns-omB4YLGU.js → booleanFns-B46fgObh.js} +26 -14
  16. package/dist/{booleanFns-o7EsqNGM.cjs → booleanFns-Bw8sAMgI.cjs} +26 -14
  17. package/dist/brepjs.cjs +28 -145
  18. package/dist/brepjs.js +23 -143
  19. package/dist/core/curve2dHandle.d.ts +27 -0
  20. package/dist/core/curve2dHandle.d.ts.map +1 -0
  21. package/dist/core/errors.d.ts +7 -0
  22. package/dist/core/errors.d.ts.map +1 -1
  23. package/dist/core.cjs +5 -5
  24. package/dist/core.js +5 -5
  25. package/dist/{cornerFinder-E2w1gRI3.cjs → cornerFinder-BszIcLqj.cjs} +3 -3
  26. package/dist/{cornerFinder-nn_mma6p.js → cornerFinder-aBLykolI.js} +3 -3
  27. package/dist/{curveFns-DHFAK2lD.cjs → curveFns-CZszKLQB.cjs} +2 -2
  28. package/dist/{curveFns-CzcOFFDX.js → curveFns-DY4dFcP-.js} +2 -2
  29. package/dist/{drawFns-DLPEVSbK.cjs → drawFns-BHNDF8hb.cjs} +15 -15
  30. package/dist/{drawFns-4x9wOpZ3.js → drawFns-l5CY2s-l.js} +15 -15
  31. package/dist/{errors-D7ZQfeqv.js → errors-BVOlxlIA.js} +7 -0
  32. package/dist/{errors-BDTFTJ22.cjs → errors-BlC5ZWv4.cjs} +7 -0
  33. package/dist/{extrudeFns-CqKzY5BT.cjs → extrudeFns-GpCB_Uzs.cjs} +3 -3
  34. package/dist/{extrudeFns-CDWViQSe.js → extrudeFns-b0uLn4E4.js} +3 -3
  35. package/dist/{faceFns-DSUZvptN.cjs → faceFns-BywUjlJ7.cjs} +3 -3
  36. package/dist/{faceFns-6mY9O_5h.js → faceFns-Cat-4X74.js} +3 -3
  37. package/dist/{helpers-BWZ7h12W.cjs → helpers-1iCCEElA.cjs} +7 -7
  38. package/dist/{helpers-C9PtrI6D.js → helpers-DgX1UucG.js} +7 -7
  39. package/dist/{historyFns-r1owwcvA.js → historyFns-BFwp8NLX.js} +6 -6
  40. package/dist/{historyFns-DIUNWvA3.cjs → historyFns-DqxDtXIZ.cjs} +6 -6
  41. package/dist/{importFns-xg7LSAv6.js → importFns-Cb8fcldB.js} +4 -4
  42. package/dist/{importFns-CeDf0HmX.cjs → importFns-ChXEJAvu.cjs} +4 -4
  43. package/dist/index.d.ts +5 -0
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/io.cjs +2 -2
  46. package/dist/io.js +2 -2
  47. package/dist/kernel/brepkit/booleanOps.d.ts +7 -1
  48. package/dist/kernel/brepkit/booleanOps.d.ts.map +1 -1
  49. package/dist/kernel/brepkit/brepkitAdapter.d.ts +7 -4
  50. package/dist/kernel/brepkit/brepkitAdapter.d.ts.map +1 -1
  51. package/dist/kernel/brepkit/evolutionOps.d.ts +4 -4
  52. package/dist/kernel/brepkit/evolutionOps.d.ts.map +1 -1
  53. package/dist/kernel/interfaces/booleanOps.d.ts +3 -1
  54. package/dist/kernel/interfaces/booleanOps.d.ts.map +1 -1
  55. package/dist/kernel/interfaces/curveOps.d.ts +3 -1
  56. package/dist/kernel/interfaces/curveOps.d.ts.map +1 -1
  57. package/dist/kernel/interfaces/evolutionOps.d.ts +4 -4
  58. package/dist/kernel/interfaces/evolutionOps.d.ts.map +1 -1
  59. package/dist/kernel/interfaces/surfaceOps.d.ts +3 -1
  60. package/dist/kernel/interfaces/surfaceOps.d.ts.map +1 -1
  61. package/dist/kernel/occt/booleanOps.d.ts +7 -1
  62. package/dist/kernel/occt/booleanOps.d.ts.map +1 -1
  63. package/dist/kernel/occt/defaultAdapter.d.ts +7 -4
  64. package/dist/kernel/occt/defaultAdapter.d.ts.map +1 -1
  65. package/dist/kernel/occt/evolutionOps.d.ts +2 -2
  66. package/dist/kernel/occt/evolutionOps.d.ts.map +1 -1
  67. package/dist/kernel/occt/historyOps.d.ts +4 -4
  68. package/dist/kernel/occt/historyOps.d.ts.map +1 -1
  69. package/dist/kernel/occt/nurbsQueryOps.d.ts +12 -0
  70. package/dist/kernel/occt/nurbsQueryOps.d.ts.map +1 -0
  71. package/dist/kernel/occt/wasmTypes/occtBuilders.d.ts +4 -0
  72. package/dist/kernel/occt/wasmTypes/occtBuilders.d.ts.map +1 -1
  73. package/dist/kernel/types.d.ts +56 -0
  74. package/dist/kernel/types.d.ts.map +1 -1
  75. package/dist/{measureFns-Dp2Znpf_.cjs → measureFns-Bx-kl7_g.cjs} +3 -3
  76. package/dist/{measureFns-B7pm7ulJ.js → measureFns-D3rAp1X1.js} +3 -3
  77. package/dist/measurement.cjs +1 -1
  78. package/dist/measurement.js +1 -1
  79. package/dist/{meshFns-1ARDwoZ4.js → meshFns-BPi0bhm9.js} +3 -3
  80. package/dist/{meshFns-DHS9gepE.cjs → meshFns-D3KAZ_ma.cjs} +3 -3
  81. package/dist/operations.cjs +2 -2
  82. package/dist/operations.js +2 -2
  83. package/dist/{planeOps-DA5DmML2.cjs → planeOps-BqLav0Ir.cjs} +3 -3
  84. package/dist/{planeOps-D4THn1al.js → planeOps-D88tfyJs.js} +3 -3
  85. package/dist/{primitiveFns-DtAy6t6n.cjs → primitiveFns-BGh9A9jR.cjs} +67 -7
  86. package/dist/{primitiveFns-CfCgkRwY.js → primitiveFns-CnZkW6Bi.js} +50 -8
  87. package/dist/query.cjs +2 -2
  88. package/dist/query.js +2 -2
  89. package/dist/result.cjs +1 -1
  90. package/dist/result.js +1 -1
  91. package/dist/{shapeTypes-Du2qyM2n.cjs → shapeTypes-8eK48l-X.cjs} +258 -9
  92. package/dist/{shapeTypes-Beo7ikOL.js → shapeTypes-Di6GlhPk.js} +258 -9
  93. package/dist/sketching.cjs +2 -2
  94. package/dist/sketching.js +2 -2
  95. package/dist/{solidBuilders-BePRwqfJ.cjs → solidBuilders-D9KYP9sL.cjs} +3 -3
  96. package/dist/{solidBuilders-8CBjeBfT.js → solidBuilders-ctO_wFrm.js} +3 -3
  97. package/dist/{surfaceBuilders-BC0MvMK1.js → surfaceBuilders-BaqeZa0x.js} +3 -3
  98. package/dist/{surfaceBuilders-BCiMuuGV.cjs → surfaceBuilders-CZzipftq.cjs} +3 -3
  99. package/dist/topology/booleanDiagnosticFns.d.ts +18 -0
  100. package/dist/topology/booleanDiagnosticFns.d.ts.map +1 -0
  101. package/dist/topology/booleanFns.d.ts.map +1 -1
  102. package/dist/topology/nurbsFns.d.ts +13 -0
  103. package/dist/topology/nurbsFns.d.ts.map +1 -0
  104. package/dist/topology.cjs +9 -6
  105. package/dist/topology.d.ts +2 -0
  106. package/dist/topology.d.ts.map +1 -1
  107. package/dist/topology.js +7 -7
  108. package/dist/vectors.cjs +3 -3
  109. package/dist/vectors.js +3 -3
  110. package/package.json +1 -1
  111. /package/dist/{types-Bb4KK_iG.js → types-BWBlwp6w.js} +0 -0
  112. /package/dist/{types-BD-VVaWB.cjs → types-BjDcsS7l.cjs} +0 -0
  113. /package/dist/{vecOps-B9-MTeC8.js → vecOps-DFfUfsmc.js} +0 -0
  114. /package/dist/{vecOps-4iBMiet9.cjs → vecOps-DKGelwGL.cjs} +0 -0
@@ -0,0 +1,107 @@
1
+ import { Curve2DHandle } from '../core/curve2dHandle.js';
2
+ import { Point2D } from './lib/definitions.js';
3
+ import { Plane } from '../core/planeTypes.js';
4
+ import { Edge, Face } from '../core/shapeTypes.js';
5
+ import { Result } from '../core/result.js';
6
+ /** Create a 2D line segment between two points. */
7
+ export declare function line2d(from: Point2D, to: Point2D): Result<Curve2DHandle>;
8
+ /** Create a full 2D circle. */
9
+ export declare function circle2d(center: Point2D, radius: number, sense?: boolean): Result<Curve2DHandle>;
10
+ /** Create a 2D arc through three points. */
11
+ export declare function arc2d(p1: Point2D, mid: Point2D, p2: Point2D): Result<Curve2DHandle>;
12
+ /** Create a 2D arc from a start point, tangent direction, and end point. */
13
+ export declare function arc2dTangent(start: Point2D, tangent: Point2D, end: Point2D): Result<Curve2DHandle>;
14
+ /** Options for ellipse construction. */
15
+ export interface Ellipse2dOptions {
16
+ /** X-axis direction for the major axis (default: [1, 0]). */
17
+ readonly xDir?: Point2D;
18
+ /** Orientation sense (default: true = counter-clockwise). */
19
+ readonly sense?: boolean;
20
+ }
21
+ /** Create a full 2D ellipse. */
22
+ export declare function ellipse2d(center: Point2D, majorRadius: number, minorRadius: number, options?: Ellipse2dOptions): Result<Curve2DHandle>;
23
+ /** Create a 2D elliptical arc. */
24
+ export declare function ellipseArc2d(center: Point2D, majorRadius: number, minorRadius: number, startAngle: number, endAngle: number, options?: Ellipse2dOptions): Result<Curve2DHandle>;
25
+ /** Create a 2D Bezier curve through control points. */
26
+ export declare function bezier2d(points: Point2D[]): Result<Curve2DHandle>;
27
+ /** Options for B-spline construction. */
28
+ export interface BSpline2dOptions {
29
+ readonly degMin?: number;
30
+ readonly degMax?: number;
31
+ readonly continuity?: 'C0' | 'C1' | 'C2' | 'C3';
32
+ readonly tolerance?: number;
33
+ readonly smoothing?: [number, number, number] | null;
34
+ }
35
+ /** Create a 2D B-spline curve interpolating through points. */
36
+ export declare function bspline2d(points: Point2D[], options?: BSpline2dOptions): Result<Curve2DHandle>;
37
+ /** Translate a 2D curve by (dx, dy). Returns a new curve. */
38
+ export declare function translateCurve2d(curve: Curve2DHandle, dx: number, dy: number): Result<Curve2DHandle>;
39
+ /** Rotate a 2D curve by an angle (radians) around a center point. Returns a new curve. */
40
+ export declare function rotateCurve2d(curve: Curve2DHandle, angle: number, center?: Point2D): Result<Curve2DHandle>;
41
+ /** Scale a 2D curve by a factor around a center point. Returns a new curve. */
42
+ export declare function scaleCurve2d(curve: Curve2DHandle, factor: number, center?: Point2D): Result<Curve2DHandle>;
43
+ /** Mirror a 2D curve across a point. Returns a new curve. */
44
+ export declare function mirrorCurve2d(curve: Curve2DHandle, point: Point2D): Result<Curve2DHandle>;
45
+ /** Mirror a 2D curve across an axis defined by origin and direction. Returns a new curve. */
46
+ export declare function mirrorCurve2dAcrossAxis(curve: Curve2DHandle, origin: Point2D, direction: Point2D): Result<Curve2DHandle>;
47
+ /** Offset a 2D curve by a distance. Returns a new curve. */
48
+ export declare function offsetCurve2d(curve: Curve2DHandle, distance: number): Result<Curve2DHandle>;
49
+ /** Evaluate a point on a 2D curve at a parameter value. */
50
+ export declare function evaluateCurve2d(curve: Curve2DHandle, param: number): Result<Point2D>;
51
+ /** Evaluate point and tangent on a 2D curve at a parameter value. */
52
+ export declare function tangentCurve2d(curve: Curve2DHandle, param: number): Result<{
53
+ point: Point2D;
54
+ tangent: Point2D;
55
+ }>;
56
+ /** Get the parameter bounds of a 2D curve. */
57
+ export declare function boundsCurve2d(curve: Curve2DHandle): Result<{
58
+ first: number;
59
+ last: number;
60
+ }>;
61
+ /** Get the geometric type of a 2D curve (e.g., "Line", "Circle", "BSpline"). */
62
+ export declare function typeCurve2d(curve: Curve2DHandle): Result<string>;
63
+ /**
64
+ * Find intersection points and overlap segments between two 2D curves.
65
+ *
66
+ * Returned `segments` are individually disposable — callers must dispose
67
+ * each element when done.
68
+ *
69
+ * @param tolerance - Intersection tolerance (default: `1e-7`).
70
+ */
71
+ export declare function intersectCurves2d(c1: Curve2DHandle, c2: Curve2DHandle, tolerance?: number): Result<{
72
+ points: Point2D[];
73
+ segments: Curve2DHandle[];
74
+ }>;
75
+ /**
76
+ * Project a point onto a 2D curve, finding the closest parameter.
77
+ *
78
+ * Returns `ok(null)` when no projection exists (valid geometric outcome),
79
+ * not an error. Only kernel failures produce `err()`.
80
+ */
81
+ export declare function projectPointOnCurve2d(curve: Curve2DHandle, point: Point2D): Result<{
82
+ param: number;
83
+ distance: number;
84
+ } | null>;
85
+ /**
86
+ * Compute the minimum distance between two 2D curves.
87
+ *
88
+ * @param bounds1 - Optional parameter range for c1 (default: full curve bounds).
89
+ * @param bounds2 - Optional parameter range for c2 (default: full curve bounds).
90
+ */
91
+ export declare function distanceBetweenCurves2d(c1: Curve2DHandle, c2: Curve2DHandle, bounds1?: {
92
+ first: number;
93
+ last: number;
94
+ }, bounds2?: {
95
+ first: number;
96
+ last: number;
97
+ }): Result<number>;
98
+ /**
99
+ * Lift a 2D curve onto a 3D plane, producing a 3D edge.
100
+ *
101
+ * Decomposes the `Plane` into kernel arguments:
102
+ * `plane.origin` → `planeOrigin`, `plane.zDir` → `planeZ`, `plane.xDir` → `planeX`.
103
+ */
104
+ export declare function liftCurve2dToPlane(curve: Curve2DHandle, plane: Plane): Result<Edge>;
105
+ /** Extract the 2D parametric curve of a 3D edge on a face. */
106
+ export declare function extractCurve2dFromEdge(edge: Edge, face: Face): Result<Curve2DHandle>;
107
+ //# sourceMappingURL=curve2dGeometryFns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"curve2dGeometryFns.d.ts","sourceRoot":"","sources":["../../src/2d/curve2dGeometryFns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,K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Aa,EACpB,KAAK,EAAE,OAAO,GACb,MAAM,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAMpD;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,aAAa,EACjB,EAAE,EAAE,aAAa,EACjB,OAAO,CAAC,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EACzC,OAAO,CAAC,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACxC,MAAM,CAAC,MAAM,CAAC,CAWhB;AAMD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAcnF;AAED,8DAA8D;AAC9D,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC,aAAa,CAAC,CAMpF"}
package/dist/2d.cjs CHANGED
@@ -1,13 +1,222 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_boolean2D = require("./boolean2D-CMXMxTgD.cjs");
3
- const require_blueprint = require("./blueprint-YPV8lQqg.cjs");
4
- const require_blueprintFns = require("./blueprintFns-iQsyPfTY.cjs");
2
+ const require_shapeTypes = require("./shapeTypes-8eK48l-X.cjs");
3
+ const require_errors = require("./errors-BlC5ZWv4.cjs");
4
+ const require_blueprintFns = require("./blueprintFns-D4YucGaQ.cjs");
5
+ const require_boolean2D = require("./boolean2D-lqfKJKUY.cjs");
6
+ const require_blueprint = require("./blueprint-CDnBM-tA.cjs");
7
+ //#region src/core/curve2dHandle.ts
8
+ /**
9
+ * Wrap a raw kernel 2D curve handle with brand + disposal tracking.
10
+ *
11
+ * Uses {@link createKernelHandle} internally for stats tracking,
12
+ * `FinalizationRegistry` safety net, and double-dispose guards.
13
+ */
14
+ function createCurve2DHandle(rawHandle) {
15
+ const inner = require_shapeTypes.createKernelHandle(typeof rawHandle.delete === "function" ? rawHandle : { delete() {} });
16
+ return {
17
+ get raw() {
18
+ if (inner.disposed) throw new Error("Curve2DHandle has been disposed");
19
+ return rawHandle;
20
+ },
21
+ get disposed() {
22
+ return inner.disposed;
23
+ },
24
+ [Symbol.dispose]() {
25
+ inner[Symbol.dispose]();
26
+ }
27
+ };
28
+ }
29
+ //#endregion
30
+ //#region src/2d/curve2dGeometryFns.ts
31
+ /**
32
+ * Public functional API for 2D curve geometry.
33
+ *
34
+ * Wraps {@link Kernel2DCapability} methods with branded {@link Curve2DHandle}
35
+ * types, `Result<T>` error handling, and `Disposable` support.
36
+ *
37
+ * All functions call `getKernel2D()` internally — the kernel must be
38
+ * initialised before use.
39
+ *
40
+ * @module
41
+ */
42
+ var { CURVE2D_CONSTRUCTION_FAILED, CURVE2D_INVALID_RADIUS, CURVE2D_TRANSFORM_FAILED, CURVE2D_QUERY_FAILED, CURVE2D_INTERSECTION_FAILED, CURVE2D_BRIDGE_FAILED } = require_errors.BrepErrorCode;
43
+ /**
44
+ * Wrap a raw kernel curve handle, upcasting to Handle_Geom2d_Curve
45
+ * (required for OCCT — specific subtypes like Handle_Geom2d_TrimmedCurve
46
+ * must be upcasted before passing to generic curve operations).
47
+ */
48
+ function wrapRawHandle(raw) {
49
+ return createCurve2DHandle(require_shapeTypes.getKernel2D().wrapCurve2dHandle(raw));
50
+ }
51
+ /** Wrap a kernel call that returns a raw curve handle into Result<Curve2DHandle>. */
52
+ function curveCall(fn, code, message) {
53
+ const result = require_blueprintFns.kernelCallRaw(fn, code, message);
54
+ if (!result.ok) return result;
55
+ return require_errors.ok(wrapRawHandle(result.value));
56
+ }
57
+ /** Validate that ellipse radii are positive and that minor does not exceed major. */
58
+ function validateEllipseRadii(majorRadius, minorRadius) {
59
+ if (majorRadius <= 0 || minorRadius <= 0) return require_errors.err(require_errors.validationError(CURVE2D_INVALID_RADIUS, `Ellipse radii must be positive, got major=${majorRadius}, minor=${minorRadius}`));
60
+ if (minorRadius > majorRadius) return require_errors.err(require_errors.validationError(CURVE2D_INVALID_RADIUS, `Ellipse minor radius (${minorRadius}) must not exceed major radius (${majorRadius})`));
61
+ return null;
62
+ }
63
+ /** Create a 2D line segment between two points. */
64
+ function line2d(from, to) {
65
+ return curveCall(() => require_shapeTypes.getKernel2D().makeLine2d(from[0], from[1], to[0], to[1]), CURVE2D_CONSTRUCTION_FAILED, "Failed to create 2D line");
66
+ }
67
+ /** Create a full 2D circle. */
68
+ function circle2d(center, radius, sense) {
69
+ if (radius <= 0) return require_errors.err(require_errors.validationError(CURVE2D_INVALID_RADIUS, `Circle radius must be positive, got ${radius}`));
70
+ return curveCall(() => require_shapeTypes.getKernel2D().makeCircle2d(center[0], center[1], radius, sense), CURVE2D_CONSTRUCTION_FAILED, "Failed to create 2D circle");
71
+ }
72
+ /** Create a 2D arc through three points. */
73
+ function arc2d(p1, mid, p2) {
74
+ return curveCall(() => require_shapeTypes.getKernel2D().makeArc2dThreePoints(p1[0], p1[1], mid[0], mid[1], p2[0], p2[1]), CURVE2D_CONSTRUCTION_FAILED, "Failed to create 2D arc from 3 points");
75
+ }
76
+ /** Create a 2D arc from a start point, tangent direction, and end point. */
77
+ function arc2dTangent(start, tangent, end) {
78
+ return curveCall(() => require_shapeTypes.getKernel2D().makeArc2dTangent(start[0], start[1], tangent[0], tangent[1], end[0], end[1]), CURVE2D_CONSTRUCTION_FAILED, "Failed to create 2D tangent arc");
79
+ }
80
+ /** Create a full 2D ellipse. */
81
+ function ellipse2d(center, majorRadius, minorRadius, options) {
82
+ const radiusError = validateEllipseRadii(majorRadius, minorRadius);
83
+ if (radiusError !== null) return radiusError;
84
+ return curveCall(() => require_shapeTypes.getKernel2D().makeEllipse2d(center[0], center[1], majorRadius, minorRadius, options?.xDir?.[0], options?.xDir?.[1], options?.sense), CURVE2D_CONSTRUCTION_FAILED, "Failed to create 2D ellipse");
85
+ }
86
+ /** Create a 2D elliptical arc. */
87
+ function ellipseArc2d(center, majorRadius, minorRadius, startAngle, endAngle, options) {
88
+ const radiusError = validateEllipseRadii(majorRadius, minorRadius);
89
+ if (radiusError !== null) return radiusError;
90
+ return curveCall(() => require_shapeTypes.getKernel2D().makeEllipseArc2d(center[0], center[1], majorRadius, minorRadius, startAngle, endAngle, options?.xDir?.[0], options?.xDir?.[1], options?.sense), CURVE2D_CONSTRUCTION_FAILED, "Failed to create 2D ellipse arc");
91
+ }
92
+ /** Create a 2D Bezier curve through control points. */
93
+ function bezier2d(points) {
94
+ if (points.length < 2) return require_errors.err(require_errors.validationError(CURVE2D_CONSTRUCTION_FAILED, `Bezier curve requires at least 2 control points, got ${points.length}`));
95
+ return curveCall(() => require_shapeTypes.getKernel2D().makeBezier2d(points), CURVE2D_CONSTRUCTION_FAILED, "Failed to create 2D Bezier curve");
96
+ }
97
+ /** Create a 2D B-spline curve interpolating through points. */
98
+ function bspline2d(points, options) {
99
+ if (points.length < 2) return require_errors.err(require_errors.validationError(CURVE2D_CONSTRUCTION_FAILED, `B-spline curve requires at least 2 points, got ${points.length}`));
100
+ return curveCall(() => require_shapeTypes.getKernel2D().makeBSpline2d(points, options), CURVE2D_CONSTRUCTION_FAILED, "Failed to create 2D B-spline curve");
101
+ }
102
+ /** Translate a 2D curve by (dx, dy). Returns a new curve. */
103
+ function translateCurve2d(curve, dx, dy) {
104
+ return curveCall(() => require_shapeTypes.getKernel2D().translateCurve2d(curve.raw, dx, dy), CURVE2D_TRANSFORM_FAILED, "Failed to translate 2D curve");
105
+ }
106
+ /** Rotate a 2D curve by an angle (radians) around a center point. Returns a new curve. */
107
+ function rotateCurve2d(curve, angle, center = [0, 0]) {
108
+ return curveCall(() => require_shapeTypes.getKernel2D().rotateCurve2d(curve.raw, angle, center[0], center[1]), CURVE2D_TRANSFORM_FAILED, "Failed to rotate 2D curve");
109
+ }
110
+ /** Scale a 2D curve by a factor around a center point. Returns a new curve. */
111
+ function scaleCurve2d(curve, factor, center = [0, 0]) {
112
+ return curveCall(() => require_shapeTypes.getKernel2D().scaleCurve2d(curve.raw, factor, center[0], center[1]), CURVE2D_TRANSFORM_FAILED, "Failed to scale 2D curve");
113
+ }
114
+ /** Mirror a 2D curve across a point. Returns a new curve. */
115
+ function mirrorCurve2d(curve, point) {
116
+ return curveCall(() => require_shapeTypes.getKernel2D().mirrorCurve2dAtPoint(curve.raw, point[0], point[1]), CURVE2D_TRANSFORM_FAILED, "Failed to mirror 2D curve");
117
+ }
118
+ /** Mirror a 2D curve across an axis defined by origin and direction. Returns a new curve. */
119
+ function mirrorCurve2dAcrossAxis(curve, origin, direction) {
120
+ return curveCall(() => require_shapeTypes.getKernel2D().mirrorCurve2dAcrossAxis(curve.raw, origin[0], origin[1], direction[0], direction[1]), CURVE2D_TRANSFORM_FAILED, "Failed to mirror 2D curve across axis");
121
+ }
122
+ /** Offset a 2D curve by a distance. Returns a new curve. */
123
+ function offsetCurve2d(curve, distance) {
124
+ return curveCall(() => require_shapeTypes.getKernel2D().offsetCurve2d(curve.raw, distance), CURVE2D_TRANSFORM_FAILED, "Failed to offset 2D curve");
125
+ }
126
+ /** Evaluate a point on a 2D curve at a parameter value. */
127
+ function evaluateCurve2d(curve, param) {
128
+ return require_blueprintFns.kernelCallRaw(() => require_shapeTypes.getKernel2D().evaluateCurve2d(curve.raw, param), CURVE2D_QUERY_FAILED, "Failed to evaluate 2D curve");
129
+ }
130
+ /** Evaluate point and tangent on a 2D curve at a parameter value. */
131
+ function tangentCurve2d(curve, param) {
132
+ return require_blueprintFns.kernelCallRaw(() => require_shapeTypes.getKernel2D().evaluateCurve2dD1(curve.raw, param), CURVE2D_QUERY_FAILED, "Failed to evaluate 2D curve tangent");
133
+ }
134
+ /** Get the parameter bounds of a 2D curve. */
135
+ function boundsCurve2d(curve) {
136
+ return require_blueprintFns.kernelCallRaw(() => require_shapeTypes.getKernel2D().getCurve2dBounds(curve.raw), CURVE2D_QUERY_FAILED, "Failed to get 2D curve bounds");
137
+ }
138
+ /** Get the geometric type of a 2D curve (e.g., "Line", "Circle", "BSpline"). */
139
+ function typeCurve2d(curve) {
140
+ return require_blueprintFns.kernelCallRaw(() => require_shapeTypes.getKernel2D().getCurve2dType(curve.raw), CURVE2D_QUERY_FAILED, "Failed to get 2D curve type");
141
+ }
142
+ /**
143
+ * Find intersection points and overlap segments between two 2D curves.
144
+ *
145
+ * Returned `segments` are individually disposable — callers must dispose
146
+ * each element when done.
147
+ *
148
+ * @param tolerance - Intersection tolerance (default: `1e-7`).
149
+ */
150
+ function intersectCurves2d(c1, c2, tolerance = 1e-7) {
151
+ return require_blueprintFns.kernelCallRaw(() => {
152
+ const result = require_shapeTypes.getKernel2D().intersectCurves2d(c1.raw, c2.raw, tolerance);
153
+ const wrapped = [];
154
+ try {
155
+ for (const s of result.segments) wrapped.push(wrapRawHandle(s));
156
+ } catch (e) {
157
+ wrapped.forEach((h) => {
158
+ h[Symbol.dispose]();
159
+ });
160
+ throw e;
161
+ }
162
+ return {
163
+ points: result.points,
164
+ segments: wrapped
165
+ };
166
+ }, CURVE2D_INTERSECTION_FAILED, "Failed to intersect 2D curves");
167
+ }
168
+ /**
169
+ * Project a point onto a 2D curve, finding the closest parameter.
170
+ *
171
+ * Returns `ok(null)` when no projection exists (valid geometric outcome),
172
+ * not an error. Only kernel failures produce `err()`.
173
+ */
174
+ function projectPointOnCurve2d(curve, point) {
175
+ return require_blueprintFns.kernelCallRaw(() => require_shapeTypes.getKernel2D().projectPointOnCurve2d(curve.raw, point[0], point[1]), CURVE2D_QUERY_FAILED, "Failed to project point onto 2D curve");
176
+ }
177
+ /**
178
+ * Compute the minimum distance between two 2D curves.
179
+ *
180
+ * @param bounds1 - Optional parameter range for c1 (default: full curve bounds).
181
+ * @param bounds2 - Optional parameter range for c2 (default: full curve bounds).
182
+ */
183
+ function distanceBetweenCurves2d(c1, c2, bounds1, bounds2) {
184
+ return require_blueprintFns.kernelCallRaw(() => {
185
+ const kernel = require_shapeTypes.getKernel2D();
186
+ const b1 = bounds1 ?? kernel.getCurve2dBounds(c1.raw);
187
+ const b2 = bounds2 ?? kernel.getCurve2dBounds(c2.raw);
188
+ return kernel.distanceBetweenCurves2d(c1.raw, c2.raw, b1.first, b1.last, b2.first, b2.last);
189
+ }, CURVE2D_QUERY_FAILED, "Failed to compute distance between 2D curves");
190
+ }
191
+ /**
192
+ * Lift a 2D curve onto a 3D plane, producing a 3D edge.
193
+ *
194
+ * Decomposes the `Plane` into kernel arguments:
195
+ * `plane.origin` → `planeOrigin`, `plane.zDir` → `planeZ`, `plane.xDir` → `planeX`.
196
+ */
197
+ function liftCurve2dToPlane(curve, plane) {
198
+ return require_blueprintFns.kernelCallRaw(() => {
199
+ return require_shapeTypes.createEdge(require_shapeTypes.getKernel2D().liftCurve2dToPlane(curve.raw, [...plane.origin], [...plane.zDir], [...plane.xDir]));
200
+ }, CURVE2D_BRIDGE_FAILED, "Failed to lift 2D curve to plane");
201
+ }
202
+ /** Extract the 2D parametric curve of a 3D edge on a face. */
203
+ function extractCurve2dFromEdge(edge, face) {
204
+ return curveCall(() => require_shapeTypes.getKernel2D().extractCurve2dFromEdge(edge.wrapped, face.wrapped), CURVE2D_BRIDGE_FAILED, "Failed to extract 2D curve from edge");
205
+ }
206
+ //#endregion
5
207
  exports.Blueprint = require_blueprint.Blueprint;
6
208
  exports.Blueprints = require_boolean2D.Blueprints;
7
209
  exports.BoundingBox2d = require_blueprint.BoundingBox2d;
8
210
  exports.CompoundBlueprint = require_boolean2D.CompoundBlueprint;
9
211
  exports.Curve2D = require_blueprint.Curve2D;
212
+ exports.arc2d = arc2d;
213
+ exports.arc2dTangent = arc2dTangent;
214
+ exports.bezier2d = bezier2d;
215
+ exports.boundsCurve2d = boundsCurve2d;
216
+ exports.bspline2d = bspline2d;
217
+ exports.circle2d = circle2d;
10
218
  exports.createBlueprint = require_blueprintFns.createBlueprint;
219
+ exports.createCurve2DHandle = createCurve2DHandle;
11
220
  exports.curve2dBoundingBox = require_blueprintFns.curve2dBoundingBox;
12
221
  exports.curve2dDistanceFrom = require_blueprintFns.curve2dDistanceFrom;
13
222
  exports.curve2dFirstPoint = require_blueprintFns.curve2dFirstPoint;
@@ -18,22 +227,39 @@ exports.curve2dSplitAt = require_blueprintFns.curve2dSplitAt;
18
227
  exports.curve2dTangentAt = require_blueprintFns.curve2dTangentAt;
19
228
  exports.cut2D = require_boolean2D.cut2D;
20
229
  exports.cutBlueprints = require_boolean2D.cutBlueprints;
230
+ exports.distanceBetweenCurves2d = distanceBetweenCurves2d;
231
+ exports.ellipse2d = ellipse2d;
232
+ exports.ellipseArc2d = ellipseArc2d;
233
+ exports.evaluateCurve2d = evaluateCurve2d;
234
+ exports.extractCurve2dFromEdge = extractCurve2dFromEdge;
21
235
  exports.fuse2D = require_boolean2D.fuse2D;
22
236
  exports.fuseBlueprints = require_boolean2D.fuseBlueprints;
23
237
  exports.getBounds2D = require_blueprintFns.getBounds2D;
24
238
  exports.getOrientation2D = require_blueprintFns.getOrientation2D;
25
239
  exports.intersect2D = require_boolean2D.intersect2D;
26
240
  exports.intersectBlueprints = require_boolean2D.intersectBlueprints;
241
+ exports.intersectCurves2d = intersectCurves2d;
27
242
  exports.isInside2D = require_blueprintFns.isInside2D;
243
+ exports.liftCurve2dToPlane = liftCurve2dToPlane;
244
+ exports.line2d = line2d;
28
245
  exports.mirror2D = require_blueprintFns.mirror2D;
246
+ exports.mirrorCurve2d = mirrorCurve2d;
247
+ exports.mirrorCurve2dAcrossAxis = mirrorCurve2dAcrossAxis;
248
+ exports.offsetCurve2d = offsetCurve2d;
29
249
  exports.organiseBlueprints = require_boolean2D.organiseBlueprints;
30
250
  exports.polysidesBlueprint = require_boolean2D.polysidesBlueprint;
251
+ exports.projectPointOnCurve2d = projectPointOnCurve2d;
31
252
  exports.reverseCurve = require_blueprintFns.reverseCurve;
32
253
  exports.rotate2D = require_blueprintFns.rotate2D;
254
+ exports.rotateCurve2d = rotateCurve2d;
33
255
  exports.roundedRectangleBlueprint = require_boolean2D.roundedRectangleBlueprint;
34
256
  exports.scale2D = require_blueprintFns.scale2D;
257
+ exports.scaleCurve2d = scaleCurve2d;
35
258
  exports.sketchOnFace2D = require_blueprintFns.sketchOnFace2D;
36
259
  exports.sketchOnPlane2D = require_blueprintFns.sketchOnPlane2D;
37
260
  exports.stretch2D = require_blueprintFns.stretch2D;
261
+ exports.tangentCurve2d = tangentCurve2d;
38
262
  exports.toSVGPathD = require_blueprintFns.toSVGPathD;
39
263
  exports.translate2D = require_blueprintFns.translate2D;
264
+ exports.translateCurve2d = translateCurve2d;
265
+ exports.typeCurve2d = typeCurve2d;
package/dist/2d.d.ts CHANGED
@@ -17,7 +17,9 @@ export { createBlueprint, getBounds2D, getOrientation2D, isInside2D, toSVGPathD,
17
17
  export { fuseBlueprints, cutBlueprints, intersectBlueprints, } from './2d/blueprints/booleanOperations.js';
18
18
  export { fuse2D, cut2D, intersect2D, type Shape2D } from './2d/blueprints/boolean2D.js';
19
19
  export { reverseCurve, curve2dBoundingBox, curve2dFirstPoint, curve2dLastPoint, curve2dSplitAt, curve2dParameter, curve2dTangentAt, curve2dIsOnCurve, curve2dDistanceFrom, } from './2d/lib/curve2dFns.js';
20
+ export { line2d, circle2d, arc2d, arc2dTangent, ellipse2d, ellipseArc2d, bezier2d, bspline2d, translateCurve2d, rotateCurve2d, scaleCurve2d, mirrorCurve2d, mirrorCurve2dAcrossAxis, offsetCurve2d, evaluateCurve2d, tangentCurve2d, boundsCurve2d, typeCurve2d, intersectCurves2d, projectPointOnCurve2d, distanceBetweenCurves2d, liftCurve2dToPlane, extractCurve2dFromEdge, type Ellipse2dOptions, type BSpline2dOptions, } from './2d/curve2dGeometryFns.js';
20
21
  export { type Point2D, BoundingBox2d, Curve2D } from './2d/lib/index.js';
22
+ export { type Curve2DHandle, createCurve2DHandle } from './core/curve2dHandle.js';
21
23
  export { organiseBlueprints } from './2d/blueprints/lib.js';
22
24
  export { polysidesBlueprint, roundedRectangleBlueprint } from './2d/blueprints/cannedBlueprints.js';
23
25
  export type { ScaleMode } from './2d/curves.js';
package/dist/2d.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"2d.d.ts","sourceRoot":"","sources":["../src/2d.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAItE,OAAO,EACL,eAAe,EAEf,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,SAAS,EACT,eAAe,EACf,cAAc,GACf,MAAM,iCAAiC,CAAC;AAIzC,OAAO,EACL,cAAc,EACd,aAAa,EACb,mBAAmB,GACpB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAIxF,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAAE,KAAK,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AACpG,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"2d.d.ts","sourceRoot":"","sources":["../src/2d.ts"],"names":[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B,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AACpG,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/2d.js CHANGED
@@ -1,4 +1,206 @@
1
- import { a as fuseBlueprints, c as roundedRectangleBlueprint, g as Blueprints, h as CompoundBlueprint, i as cutBlueprints, m as organiseBlueprints, n as fuse2D, o as intersectBlueprints, r as intersect2D, s as polysidesBlueprint, t as cut2D } from "./boolean2D-D_yuF0kT.js";
2
- import { _ as Curve2D, t as Blueprint, y as BoundingBox2d } from "./blueprint-Bpa-w3WF.js";
3
- import { S as reverseCurve, _ as curve2dIsOnCurve, a as isInside2D, b as curve2dSplitAt, c as scale2D, d as stretch2D, f as toSVGPathD, g as curve2dFirstPoint, h as curve2dDistanceFrom, i as getOrientation2D, l as sketchOnFace2D, m as curve2dBoundingBox, o as mirror2D, p as translate2D, r as getBounds2D, s as rotate2D, t as createBlueprint, u as sketchOnPlane2D, v as curve2dLastPoint, x as curve2dTangentAt, y as curve2dParameter } from "./blueprintFns-D0RopDZS.js";
4
- export { Blueprint, Blueprints, BoundingBox2d, CompoundBlueprint, Curve2D, createBlueprint, curve2dBoundingBox, curve2dDistanceFrom, curve2dFirstPoint, curve2dIsOnCurve, curve2dLastPoint, curve2dParameter, curve2dSplitAt, curve2dTangentAt, cut2D, cutBlueprints, fuse2D, fuseBlueprints, getBounds2D, getOrientation2D, intersect2D, intersectBlueprints, isInside2D, mirror2D, organiseBlueprints, polysidesBlueprint, reverseCurve, rotate2D, roundedRectangleBlueprint, scale2D, sketchOnFace2D, sketchOnPlane2D, stretch2D, toSVGPathD, translate2D };
1
+ import { X as getKernel2D, a as createEdge, z as createKernelHandle } from "./shapeTypes-Di6GlhPk.js";
2
+ import { d as validationError, k as ok, t as BrepErrorCode, y as err } from "./errors-BVOlxlIA.js";
3
+ import { S as reverseCurve, _ as curve2dIsOnCurve, a as isInside2D, b as curve2dSplitAt, c as scale2D, d as stretch2D, f as toSVGPathD, g as curve2dFirstPoint, h as curve2dDistanceFrom, i as getOrientation2D, l as sketchOnFace2D, m as curve2dBoundingBox, o as mirror2D, p as translate2D, r as getBounds2D, s as rotate2D, t as createBlueprint, u as sketchOnPlane2D, v as curve2dLastPoint, w as kernelCallRaw, x as curve2dTangentAt, y as curve2dParameter } from "./blueprintFns-DVDommWB.js";
4
+ import { a as fuseBlueprints, c as roundedRectangleBlueprint, g as Blueprints, h as CompoundBlueprint, i as cutBlueprints, m as organiseBlueprints, n as fuse2D, o as intersectBlueprints, r as intersect2D, s as polysidesBlueprint, t as cut2D } from "./boolean2D-Mzp-0g7o.js";
5
+ import { _ as Curve2D, t as Blueprint, y as BoundingBox2d } from "./blueprint-CB_85Lz_.js";
6
+ //#region src/core/curve2dHandle.ts
7
+ /**
8
+ * Wrap a raw kernel 2D curve handle with brand + disposal tracking.
9
+ *
10
+ * Uses {@link createKernelHandle} internally for stats tracking,
11
+ * `FinalizationRegistry` safety net, and double-dispose guards.
12
+ */
13
+ function createCurve2DHandle(rawHandle) {
14
+ const inner = createKernelHandle(typeof rawHandle.delete === "function" ? rawHandle : { delete() {} });
15
+ return {
16
+ get raw() {
17
+ if (inner.disposed) throw new Error("Curve2DHandle has been disposed");
18
+ return rawHandle;
19
+ },
20
+ get disposed() {
21
+ return inner.disposed;
22
+ },
23
+ [Symbol.dispose]() {
24
+ inner[Symbol.dispose]();
25
+ }
26
+ };
27
+ }
28
+ //#endregion
29
+ //#region src/2d/curve2dGeometryFns.ts
30
+ /**
31
+ * Public functional API for 2D curve geometry.
32
+ *
33
+ * Wraps {@link Kernel2DCapability} methods with branded {@link Curve2DHandle}
34
+ * types, `Result<T>` error handling, and `Disposable` support.
35
+ *
36
+ * All functions call `getKernel2D()` internally — the kernel must be
37
+ * initialised before use.
38
+ *
39
+ * @module
40
+ */
41
+ var { CURVE2D_CONSTRUCTION_FAILED, CURVE2D_INVALID_RADIUS, CURVE2D_TRANSFORM_FAILED, CURVE2D_QUERY_FAILED, CURVE2D_INTERSECTION_FAILED, CURVE2D_BRIDGE_FAILED } = BrepErrorCode;
42
+ /**
43
+ * Wrap a raw kernel curve handle, upcasting to Handle_Geom2d_Curve
44
+ * (required for OCCT — specific subtypes like Handle_Geom2d_TrimmedCurve
45
+ * must be upcasted before passing to generic curve operations).
46
+ */
47
+ function wrapRawHandle(raw) {
48
+ return createCurve2DHandle(getKernel2D().wrapCurve2dHandle(raw));
49
+ }
50
+ /** Wrap a kernel call that returns a raw curve handle into Result<Curve2DHandle>. */
51
+ function curveCall(fn, code, message) {
52
+ const result = kernelCallRaw(fn, code, message);
53
+ if (!result.ok) return result;
54
+ return ok(wrapRawHandle(result.value));
55
+ }
56
+ /** Validate that ellipse radii are positive and that minor does not exceed major. */
57
+ function validateEllipseRadii(majorRadius, minorRadius) {
58
+ if (majorRadius <= 0 || minorRadius <= 0) return err(validationError(CURVE2D_INVALID_RADIUS, `Ellipse radii must be positive, got major=${majorRadius}, minor=${minorRadius}`));
59
+ if (minorRadius > majorRadius) return err(validationError(CURVE2D_INVALID_RADIUS, `Ellipse minor radius (${minorRadius}) must not exceed major radius (${majorRadius})`));
60
+ return null;
61
+ }
62
+ /** Create a 2D line segment between two points. */
63
+ function line2d(from, to) {
64
+ return curveCall(() => getKernel2D().makeLine2d(from[0], from[1], to[0], to[1]), CURVE2D_CONSTRUCTION_FAILED, "Failed to create 2D line");
65
+ }
66
+ /** Create a full 2D circle. */
67
+ function circle2d(center, radius, sense) {
68
+ if (radius <= 0) return err(validationError(CURVE2D_INVALID_RADIUS, `Circle radius must be positive, got ${radius}`));
69
+ return curveCall(() => getKernel2D().makeCircle2d(center[0], center[1], radius, sense), CURVE2D_CONSTRUCTION_FAILED, "Failed to create 2D circle");
70
+ }
71
+ /** Create a 2D arc through three points. */
72
+ function arc2d(p1, mid, p2) {
73
+ return curveCall(() => getKernel2D().makeArc2dThreePoints(p1[0], p1[1], mid[0], mid[1], p2[0], p2[1]), CURVE2D_CONSTRUCTION_FAILED, "Failed to create 2D arc from 3 points");
74
+ }
75
+ /** Create a 2D arc from a start point, tangent direction, and end point. */
76
+ function arc2dTangent(start, tangent, end) {
77
+ return curveCall(() => getKernel2D().makeArc2dTangent(start[0], start[1], tangent[0], tangent[1], end[0], end[1]), CURVE2D_CONSTRUCTION_FAILED, "Failed to create 2D tangent arc");
78
+ }
79
+ /** Create a full 2D ellipse. */
80
+ function ellipse2d(center, majorRadius, minorRadius, options) {
81
+ const radiusError = validateEllipseRadii(majorRadius, minorRadius);
82
+ if (radiusError !== null) return radiusError;
83
+ return curveCall(() => getKernel2D().makeEllipse2d(center[0], center[1], majorRadius, minorRadius, options?.xDir?.[0], options?.xDir?.[1], options?.sense), CURVE2D_CONSTRUCTION_FAILED, "Failed to create 2D ellipse");
84
+ }
85
+ /** Create a 2D elliptical arc. */
86
+ function ellipseArc2d(center, majorRadius, minorRadius, startAngle, endAngle, options) {
87
+ const radiusError = validateEllipseRadii(majorRadius, minorRadius);
88
+ if (radiusError !== null) return radiusError;
89
+ return curveCall(() => getKernel2D().makeEllipseArc2d(center[0], center[1], majorRadius, minorRadius, startAngle, endAngle, options?.xDir?.[0], options?.xDir?.[1], options?.sense), CURVE2D_CONSTRUCTION_FAILED, "Failed to create 2D ellipse arc");
90
+ }
91
+ /** Create a 2D Bezier curve through control points. */
92
+ function bezier2d(points) {
93
+ if (points.length < 2) return err(validationError(CURVE2D_CONSTRUCTION_FAILED, `Bezier curve requires at least 2 control points, got ${points.length}`));
94
+ return curveCall(() => getKernel2D().makeBezier2d(points), CURVE2D_CONSTRUCTION_FAILED, "Failed to create 2D Bezier curve");
95
+ }
96
+ /** Create a 2D B-spline curve interpolating through points. */
97
+ function bspline2d(points, options) {
98
+ if (points.length < 2) return err(validationError(CURVE2D_CONSTRUCTION_FAILED, `B-spline curve requires at least 2 points, got ${points.length}`));
99
+ return curveCall(() => getKernel2D().makeBSpline2d(points, options), CURVE2D_CONSTRUCTION_FAILED, "Failed to create 2D B-spline curve");
100
+ }
101
+ /** Translate a 2D curve by (dx, dy). Returns a new curve. */
102
+ function translateCurve2d(curve, dx, dy) {
103
+ return curveCall(() => getKernel2D().translateCurve2d(curve.raw, dx, dy), CURVE2D_TRANSFORM_FAILED, "Failed to translate 2D curve");
104
+ }
105
+ /** Rotate a 2D curve by an angle (radians) around a center point. Returns a new curve. */
106
+ function rotateCurve2d(curve, angle, center = [0, 0]) {
107
+ return curveCall(() => getKernel2D().rotateCurve2d(curve.raw, angle, center[0], center[1]), CURVE2D_TRANSFORM_FAILED, "Failed to rotate 2D curve");
108
+ }
109
+ /** Scale a 2D curve by a factor around a center point. Returns a new curve. */
110
+ function scaleCurve2d(curve, factor, center = [0, 0]) {
111
+ return curveCall(() => getKernel2D().scaleCurve2d(curve.raw, factor, center[0], center[1]), CURVE2D_TRANSFORM_FAILED, "Failed to scale 2D curve");
112
+ }
113
+ /** Mirror a 2D curve across a point. Returns a new curve. */
114
+ function mirrorCurve2d(curve, point) {
115
+ return curveCall(() => getKernel2D().mirrorCurve2dAtPoint(curve.raw, point[0], point[1]), CURVE2D_TRANSFORM_FAILED, "Failed to mirror 2D curve");
116
+ }
117
+ /** Mirror a 2D curve across an axis defined by origin and direction. Returns a new curve. */
118
+ function mirrorCurve2dAcrossAxis(curve, origin, direction) {
119
+ return curveCall(() => getKernel2D().mirrorCurve2dAcrossAxis(curve.raw, origin[0], origin[1], direction[0], direction[1]), CURVE2D_TRANSFORM_FAILED, "Failed to mirror 2D curve across axis");
120
+ }
121
+ /** Offset a 2D curve by a distance. Returns a new curve. */
122
+ function offsetCurve2d(curve, distance) {
123
+ return curveCall(() => getKernel2D().offsetCurve2d(curve.raw, distance), CURVE2D_TRANSFORM_FAILED, "Failed to offset 2D curve");
124
+ }
125
+ /** Evaluate a point on a 2D curve at a parameter value. */
126
+ function evaluateCurve2d(curve, param) {
127
+ return kernelCallRaw(() => getKernel2D().evaluateCurve2d(curve.raw, param), CURVE2D_QUERY_FAILED, "Failed to evaluate 2D curve");
128
+ }
129
+ /** Evaluate point and tangent on a 2D curve at a parameter value. */
130
+ function tangentCurve2d(curve, param) {
131
+ return kernelCallRaw(() => getKernel2D().evaluateCurve2dD1(curve.raw, param), CURVE2D_QUERY_FAILED, "Failed to evaluate 2D curve tangent");
132
+ }
133
+ /** Get the parameter bounds of a 2D curve. */
134
+ function boundsCurve2d(curve) {
135
+ return kernelCallRaw(() => getKernel2D().getCurve2dBounds(curve.raw), CURVE2D_QUERY_FAILED, "Failed to get 2D curve bounds");
136
+ }
137
+ /** Get the geometric type of a 2D curve (e.g., "Line", "Circle", "BSpline"). */
138
+ function typeCurve2d(curve) {
139
+ return kernelCallRaw(() => getKernel2D().getCurve2dType(curve.raw), CURVE2D_QUERY_FAILED, "Failed to get 2D curve type");
140
+ }
141
+ /**
142
+ * Find intersection points and overlap segments between two 2D curves.
143
+ *
144
+ * Returned `segments` are individually disposable — callers must dispose
145
+ * each element when done.
146
+ *
147
+ * @param tolerance - Intersection tolerance (default: `1e-7`).
148
+ */
149
+ function intersectCurves2d(c1, c2, tolerance = 1e-7) {
150
+ return kernelCallRaw(() => {
151
+ const result = getKernel2D().intersectCurves2d(c1.raw, c2.raw, tolerance);
152
+ const wrapped = [];
153
+ try {
154
+ for (const s of result.segments) wrapped.push(wrapRawHandle(s));
155
+ } catch (e) {
156
+ wrapped.forEach((h) => {
157
+ h[Symbol.dispose]();
158
+ });
159
+ throw e;
160
+ }
161
+ return {
162
+ points: result.points,
163
+ segments: wrapped
164
+ };
165
+ }, CURVE2D_INTERSECTION_FAILED, "Failed to intersect 2D curves");
166
+ }
167
+ /**
168
+ * Project a point onto a 2D curve, finding the closest parameter.
169
+ *
170
+ * Returns `ok(null)` when no projection exists (valid geometric outcome),
171
+ * not an error. Only kernel failures produce `err()`.
172
+ */
173
+ function projectPointOnCurve2d(curve, point) {
174
+ return kernelCallRaw(() => getKernel2D().projectPointOnCurve2d(curve.raw, point[0], point[1]), CURVE2D_QUERY_FAILED, "Failed to project point onto 2D curve");
175
+ }
176
+ /**
177
+ * Compute the minimum distance between two 2D curves.
178
+ *
179
+ * @param bounds1 - Optional parameter range for c1 (default: full curve bounds).
180
+ * @param bounds2 - Optional parameter range for c2 (default: full curve bounds).
181
+ */
182
+ function distanceBetweenCurves2d(c1, c2, bounds1, bounds2) {
183
+ return kernelCallRaw(() => {
184
+ const kernel = getKernel2D();
185
+ const b1 = bounds1 ?? kernel.getCurve2dBounds(c1.raw);
186
+ const b2 = bounds2 ?? kernel.getCurve2dBounds(c2.raw);
187
+ return kernel.distanceBetweenCurves2d(c1.raw, c2.raw, b1.first, b1.last, b2.first, b2.last);
188
+ }, CURVE2D_QUERY_FAILED, "Failed to compute distance between 2D curves");
189
+ }
190
+ /**
191
+ * Lift a 2D curve onto a 3D plane, producing a 3D edge.
192
+ *
193
+ * Decomposes the `Plane` into kernel arguments:
194
+ * `plane.origin` → `planeOrigin`, `plane.zDir` → `planeZ`, `plane.xDir` → `planeX`.
195
+ */
196
+ function liftCurve2dToPlane(curve, plane) {
197
+ return kernelCallRaw(() => {
198
+ return createEdge(getKernel2D().liftCurve2dToPlane(curve.raw, [...plane.origin], [...plane.zDir], [...plane.xDir]));
199
+ }, CURVE2D_BRIDGE_FAILED, "Failed to lift 2D curve to plane");
200
+ }
201
+ /** Extract the 2D parametric curve of a 3D edge on a face. */
202
+ function extractCurve2dFromEdge(edge, face) {
203
+ return curveCall(() => getKernel2D().extractCurve2dFromEdge(edge.wrapped, face.wrapped), CURVE2D_BRIDGE_FAILED, "Failed to extract 2D curve from edge");
204
+ }
205
+ //#endregion
206
+ export { Blueprint, Blueprints, BoundingBox2d, CompoundBlueprint, Curve2D, arc2d, arc2dTangent, bezier2d, boundsCurve2d, bspline2d, circle2d, createBlueprint, createCurve2DHandle, curve2dBoundingBox, curve2dDistanceFrom, curve2dFirstPoint, curve2dIsOnCurve, curve2dLastPoint, curve2dParameter, curve2dSplitAt, curve2dTangentAt, cut2D, cutBlueprints, distanceBetweenCurves2d, ellipse2d, ellipseArc2d, evaluateCurve2d, extractCurve2dFromEdge, fuse2D, fuseBlueprints, getBounds2D, getOrientation2D, intersect2D, intersectBlueprints, intersectCurves2d, isInside2D, liftCurve2dToPlane, line2d, mirror2D, mirrorCurve2d, mirrorCurve2dAcrossAxis, offsetCurve2d, organiseBlueprints, polysidesBlueprint, projectPointOnCurve2d, reverseCurve, rotate2D, rotateCurve2d, roundedRectangleBlueprint, scale2D, scaleCurve2d, sketchOnFace2D, sketchOnPlane2D, stretch2D, tangentCurve2d, toSVGPathD, translate2D, translateCurve2d, typeCurve2d };
@@ -1,7 +1,7 @@
1
- import { Y as getKernel, r as castShapeWithKnownType, t as castShape } from "./shapeTypes-Beo7ikOL.js";
2
- import { L as unwrap, d as validationError, k as ok, t as BrepErrorCode, y as err } from "./errors-D7ZQfeqv.js";
3
- import { _ as DEG2RAD, v as HASH_CODE_MAX } from "./vecOps-B9-MTeC8.js";
4
- import { _ as downcast } from "./faceFns-6mY9O_5h.js";
1
+ import { Y as getKernel, r as castShapeWithKnownType, t as castShape } from "./shapeTypes-Di6GlhPk.js";
2
+ import { L as unwrap, d as validationError, k as ok, t as BrepErrorCode, y as err } from "./errors-BVOlxlIA.js";
3
+ import { _ as DEG2RAD, v as HASH_CODE_MAX } from "./vecOps-DFfUfsmc.js";
4
+ import { _ as downcast } from "./faceFns-Cat-4X74.js";
5
5
  //#region src/topology/topologyQueryFns.ts
6
6
  /**
7
7
  * Topology query functions — extract sub-shapes, compute bounds, and
@@ -1,7 +1,7 @@
1
- const require_shapeTypes = require("./shapeTypes-Du2qyM2n.cjs");
2
- const require_errors = require("./errors-BDTFTJ22.cjs");
3
- const require_vecOps = require("./vecOps-4iBMiet9.cjs");
4
- const require_faceFns = require("./faceFns-DSUZvptN.cjs");
1
+ const require_shapeTypes = require("./shapeTypes-8eK48l-X.cjs");
2
+ const require_errors = require("./errors-BlC5ZWv4.cjs");
3
+ const require_vecOps = require("./vecOps-DKGelwGL.cjs");
4
+ const require_faceFns = require("./faceFns-BywUjlJ7.cjs");
5
5
  //#region src/topology/topologyQueryFns.ts
6
6
  /**
7
7
  * Topology query functions — extract sub-shapes, compute bounds, and