brepjs 8.0.1 → 8.0.3

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 (131) hide show
  1. package/dist/2d/blueprints/booleanHelpers.d.ts +32 -0
  2. package/dist/2d/blueprints/booleanHelpers.d.ts.map +1 -0
  3. package/dist/2d/blueprints/booleanOperations.d.ts +5 -3
  4. package/dist/2d/blueprints/booleanOperations.d.ts.map +1 -1
  5. package/dist/2d/blueprints/intersectionSegments.d.ts +12 -0
  6. package/dist/2d/blueprints/intersectionSegments.d.ts.map +1 -0
  7. package/dist/2d/blueprints/segmentAssembly.d.ts +31 -0
  8. package/dist/2d/blueprints/segmentAssembly.d.ts.map +1 -0
  9. package/dist/2d.cjs +2 -2
  10. package/dist/2d.js +8 -8
  11. package/dist/{Blueprint-D3JfGJTz.js → Blueprint-DnAO3gr5.js} +116 -30
  12. package/dist/{Blueprint-CVctc41Z.cjs → Blueprint-FxmMji4s.cjs} +110 -24
  13. package/dist/{boolean2D-hOw5Qay5.js → boolean2D-BnZKKBWU.js} +391 -310
  14. package/dist/{boolean2D-BdZATaHs.cjs → boolean2D-BrjHZfWn.cjs} +426 -345
  15. package/dist/{booleanFns-CqehfzcK.js → booleanFns-Ct3wDnhc.js} +14 -18
  16. package/dist/{booleanFns-BBSVKhL2.cjs → booleanFns-ND7sZvhu.cjs} +12 -16
  17. package/dist/brepjs.cjs +171 -101
  18. package/dist/brepjs.js +315 -244
  19. package/dist/{cast-DQaUibmm.js → cast-BEg1mN7n.js} +2 -2
  20. package/dist/{cast-DkB0GKmQ.cjs → cast-CqDc8oFW.cjs} +2 -2
  21. package/dist/core/disposal.d.ts +1 -1
  22. package/dist/core/disposal.d.ts.map +1 -1
  23. package/dist/core.cjs +3 -3
  24. package/dist/core.js +3 -3
  25. package/dist/cornerFinder-89obDwGi.js +59 -0
  26. package/dist/cornerFinder-BKsCkrXd.cjs +58 -0
  27. package/dist/curveBuilders-BjtdNw1B.cjs +196 -0
  28. package/dist/curveBuilders-U26XDfxg.js +197 -0
  29. package/dist/curveFns-BoG_iA07.cjs +375 -0
  30. package/dist/curveFns-Cg99XKe2.js +376 -0
  31. package/dist/{drawFns-CUyx50gi.cjs → drawFns-C-MCkYj6.cjs} +60 -62
  32. package/dist/{drawFns-921SkhDL.js → drawFns-DJV-nOox.js} +12 -14
  33. package/dist/{faceFns-DHu-2JpA.js → faceFns-CyokaCDr.js} +3 -3
  34. package/dist/{faceFns-BwK7FP7N.cjs → faceFns-DcSCjDG0.cjs} +3 -3
  35. package/dist/helpers--iZxPeJg.cjs +203 -0
  36. package/dist/helpers-CRx_ks-u.js +204 -0
  37. package/dist/io.cjs +4 -4
  38. package/dist/io.js +4 -4
  39. package/dist/kernel/curveOps.d.ts.map +1 -1
  40. package/dist/kernel/meshOps.d.ts.map +1 -1
  41. package/dist/kernel/modifierOps.d.ts.map +1 -1
  42. package/dist/kernel/occtAdapter.d.ts +1 -0
  43. package/dist/kernel/occtAdapter.d.ts.map +1 -1
  44. package/dist/kernel/sweepOps.d.ts +8 -0
  45. package/dist/kernel/sweepOps.d.ts.map +1 -1
  46. package/dist/kernel/types.d.ts +1 -0
  47. package/dist/kernel/types.d.ts.map +1 -1
  48. package/dist/loft-8asn63t4.cjs +372 -0
  49. package/dist/loft-jIkZRqHm.js +373 -0
  50. package/dist/{measurement-C5JGCuUP.js → measurement-DWv8kK6J.js} +3 -3
  51. package/dist/{measurement-fxm_pW7x.cjs → measurement-lRLwaoqD.cjs} +3 -3
  52. package/dist/measurement.cjs +1 -1
  53. package/dist/measurement.js +1 -1
  54. package/dist/{meshFns-BhrZGi6w.cjs → meshFns-DWuLC3fk.cjs} +29 -9
  55. package/dist/{meshFns-AqAjTTVl.js → meshFns-DgAIL1B-.js} +29 -9
  56. package/dist/{occtBoundary-du8_ex-p.cjs → occtBoundary-DHtzU4tz.cjs} +93 -61
  57. package/dist/{occtBoundary-CwegMzqc.js → occtBoundary-DYsksDtE.js} +98 -66
  58. package/dist/operations/extrude.d.ts.map +1 -1
  59. package/dist/operations/extrudeFns.d.ts.map +1 -1
  60. package/dist/operations/extrudeUtils.d.ts +17 -0
  61. package/dist/operations/extrudeUtils.d.ts.map +1 -1
  62. package/dist/operations/patternFns.d.ts.map +1 -1
  63. package/dist/{operations-C1rWoba2.js → operations-B8FHVC22.js} +54 -9
  64. package/dist/{operations-BP1wVDw0.cjs → operations-CCFPvtd-.cjs} +54 -9
  65. package/dist/operations.cjs +2 -2
  66. package/dist/operations.js +4 -4
  67. package/dist/query/cornerFinder.d.ts +48 -0
  68. package/dist/query/cornerFinder.d.ts.map +1 -0
  69. package/dist/query/directionUtils.d.ts +6 -0
  70. package/dist/query/directionUtils.d.ts.map +1 -0
  71. package/dist/query/edgeFinder.d.ts +15 -0
  72. package/dist/query/edgeFinder.d.ts.map +1 -0
  73. package/dist/query/faceFinder.d.ts +15 -0
  74. package/dist/query/faceFinder.d.ts.map +1 -0
  75. package/dist/query/finderCore.d.ts +35 -0
  76. package/dist/query/finderCore.d.ts.map +1 -0
  77. package/dist/query/finderFns.d.ts +21 -106
  78. package/dist/query/finderFns.d.ts.map +1 -1
  79. package/dist/query/shapeDistanceFilter.d.ts +11 -0
  80. package/dist/query/shapeDistanceFilter.d.ts.map +1 -0
  81. package/dist/query/vertexFinder.d.ts +16 -0
  82. package/dist/query/vertexFinder.d.ts.map +1 -0
  83. package/dist/query/wireFinder.d.ts +10 -0
  84. package/dist/query/wireFinder.d.ts.map +1 -0
  85. package/dist/query.cjs +42 -5
  86. package/dist/query.js +40 -2
  87. package/dist/{shapeTypes-DKhwEnUM.cjs → shapeTypes-b_lhwQB7.cjs} +24 -20
  88. package/dist/{shapeTypes-BlSElW8z.js → shapeTypes-i7VwMRwc.js} +32 -28
  89. package/dist/sketching/Sketcher.d.ts.map +1 -1
  90. package/dist/sketching/Sketcher2d.d.ts +12 -4
  91. package/dist/sketching/Sketcher2d.d.ts.map +1 -1
  92. package/dist/sketching/ellipseUtils.d.ts +29 -0
  93. package/dist/sketching/ellipseUtils.d.ts.map +1 -0
  94. package/dist/sketching.cjs +2 -2
  95. package/dist/sketching.js +2 -2
  96. package/dist/topology/booleanFns.d.ts.map +1 -1
  97. package/dist/topology/curveBuilders.d.ts +75 -0
  98. package/dist/topology/curveBuilders.d.ts.map +1 -0
  99. package/dist/topology/curveFns.d.ts.map +1 -1
  100. package/dist/topology/meshFns.d.ts.map +1 -1
  101. package/dist/topology/primitiveFns.d.ts.map +1 -1
  102. package/dist/topology/shapeFns.d.ts.map +1 -1
  103. package/dist/topology/shapeHelpers.d.ts +6 -173
  104. package/dist/topology/shapeHelpers.d.ts.map +1 -1
  105. package/dist/topology/shapeUtils.d.ts +13 -0
  106. package/dist/topology/shapeUtils.d.ts.map +1 -0
  107. package/dist/topology/solidBuilders.d.ts +70 -0
  108. package/dist/topology/solidBuilders.d.ts.map +1 -0
  109. package/dist/topology/surfaceBuilders.d.ts +35 -0
  110. package/dist/topology/surfaceBuilders.d.ts.map +1 -0
  111. package/dist/topology/wrapperFns.d.ts +1 -0
  112. package/dist/topology/wrapperFns.d.ts.map +1 -1
  113. package/dist/{topology-tFzqSrGH.js → topology-Bh-aPIxA.js} +7 -8
  114. package/dist/{topology-CIooytHH.cjs → topology-ByOn_z3E.cjs} +12 -13
  115. package/dist/topology.cjs +33 -34
  116. package/dist/topology.js +54 -55
  117. package/dist/{vectors-CBuaMeZv.js → vectors-DWLjb9-P.js} +1 -1
  118. package/dist/{vectors-ChWEZPwy.cjs → vectors-aQBZK0Sb.cjs} +1 -1
  119. package/dist/vectors.cjs +2 -2
  120. package/dist/vectors.js +2 -2
  121. package/package.json +1 -1
  122. package/dist/curveFns-BilyYL_s.cjs +0 -190
  123. package/dist/curveFns-CdVE4da7.js +0 -191
  124. package/dist/loft-BzWFokmC.cjs +0 -178
  125. package/dist/loft-CtG5nMq5.js +0 -179
  126. package/dist/query-V6nV-VfL.js +0 -396
  127. package/dist/query-hMSmOWJP.cjs +0 -395
  128. package/dist/shapeFns-BrF97sKt.js +0 -204
  129. package/dist/shapeFns-BvOndshS.cjs +0 -203
  130. package/dist/shapeHelpers-B2SXz1p4.cjs +0 -488
  131. package/dist/shapeHelpers-BcoZf2N9.js +0 -489
@@ -0,0 +1,32 @@
1
+ import { Point2D, Curve2D } from '../lib/index.js';
2
+ export declare const samePoint: (x: Point2D, y: Point2D) => boolean;
3
+ /**
4
+ * Hash a point for Set/Map lookup using precision rounding.
5
+ * Must match PRECISION_INTERSECTION (1e-9) to avoid hash collisions for
6
+ * nearly-equal points.
7
+ */
8
+ export declare function hashPoint(p: Point2D): string;
9
+ /**
10
+ * Hash a segment by both orientations for bidirectional lookup.
11
+ * The smaller hash comes first so that (A,B) and (B,A) produce the same key.
12
+ */
13
+ export declare function hashSegment(first: Point2D, last: Point2D): string;
14
+ export type Segment = Curve2D[];
15
+ export type IntersectionSegment = [Segment, Segment | 'same'];
16
+ export declare function startOfSegment(s: Segment): Point2D;
17
+ export declare function endOfSegment(s: Segment): Point2D;
18
+ export declare function reverseSegment(segment: Segment): Segment;
19
+ export declare function reverseSegments(segments: Segment[]): Segment[];
20
+ export declare function curveMidPoint(curve: Curve2D): Point2D;
21
+ /**
22
+ * Rotate the curves array so that it starts at the curve whose firstPoint
23
+ * matches the given point.
24
+ */
25
+ export declare function rotateToStartAt(curves: Curve2D[], point: Point2D): Curve2D[];
26
+ /**
27
+ * Rotate the curves array so that it starts at the curve matching the given
28
+ * segment. If the segment is oriented the other way, the curves are reversed
29
+ * first.
30
+ */
31
+ export declare function rotateToStartAtSegment(curves: Curve2D[], segment: Curve2D): Curve2D[];
32
+ //# sourceMappingURL=booleanHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"booleanHelpers.d.ts","sourceRoot":"","sources":["../../../src/2d/blueprints/booleanHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAQxD,eAAO,MAAM,SAAS,GAAI,GAAG,OAAO,EAAE,GAAG,OAAO,KAAG,OACH,CAAC;AAMjD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAE5C;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAIjE;AAMD,MAAM,MAAM,OAAO,GAAG,OAAO,EAAE,CAAC;AAChC,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC;AAE9D,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAMlD;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAMhD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAMxD;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAE9D;AAMD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAGrD;AAsDD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,EAAE,CAG5E;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,CAwBrF"}
@@ -1,5 +1,7 @@
1
1
  import { default as Blueprint } from './Blueprint.js';
2
2
  import { default as Blueprints } from './Blueprints.js';
3
+ export type { Segment, IntersectionSegment } from './booleanHelpers.js';
4
+ export { blueprintsIntersectionSegments } from './intersectionSegments.js';
3
5
  /**
4
6
  * Compute the boolean union of two simple blueprints.
5
7
  *
@@ -14,7 +16,7 @@ import { default as Blueprints } from './Blueprints.js';
14
16
  * @remarks Both blueprints must be closed. For compound or multi-blueprint
15
17
  * inputs, use {@link fuse2D} instead.
16
18
  */
17
- export declare const fuseBlueprints: (first: Blueprint, second: Blueprint) => null | Blueprint | Blueprints;
19
+ export declare function fuseBlueprints(first: Blueprint, second: Blueprint): null | Blueprint | Blueprints;
18
20
  /**
19
21
  * Compute the boolean difference of two simple blueprints (first minus second).
20
22
  *
@@ -28,7 +30,7 @@ export declare const fuseBlueprints: (first: Blueprint, second: Blueprint) => nu
28
30
  *
29
31
  * @remarks Both blueprints must be closed. For compound inputs use {@link cut2D}.
30
32
  */
31
- export declare const cutBlueprints: (first: Blueprint, second: Blueprint) => null | Blueprint | Blueprints;
33
+ export declare function cutBlueprints(first: Blueprint, second: Blueprint): null | Blueprint | Blueprints;
32
34
  /**
33
35
  * Compute the boolean intersection of two simple blueprints.
34
36
  *
@@ -41,5 +43,5 @@ export declare const cutBlueprints: (first: Blueprint, second: Blueprint) => nul
41
43
  *
42
44
  * @remarks Both blueprints must be closed. For compound inputs use {@link intersect2D}.
43
45
  */
44
- export declare const intersectBlueprints: (first: Blueprint, second: Blueprint) => null | Blueprint | Blueprints;
46
+ export declare function intersectBlueprints(first: Blueprint, second: Blueprint): null | Blueprint | Blueprints;
45
47
  //# sourceMappingURL=booleanOperations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"booleanOperations.d.ts","sourceRoot":"","sources":["../../../src/2d/blueprints/booleanOperations.ts"],"names":[],"mappings":"AAWA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,UAAU,MAAM,iBAAiB,CAAC;AA4ezC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,SAAS,EAChB,QAAQ,SAAS,KAChB,IAAI,GAAG,SAAS,GAAG,UAqBrB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO,SAAS,EAChB,QAAQ,SAAS,KAChB,IAAI,GAAG,SAAS,GAAG,UAqBrB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAO,SAAS,EAChB,QAAQ,SAAS,KAChB,IAAI,GAAG,SAAS,GAAG,UAqBrB,CAAC"}
1
+ {"version":3,"file":"booleanOperations.d.ts","sourceRoot":"","sources":["../../../src/2d/blueprints/booleanOperations.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAKzC,YAAY,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAM3E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,GAAG,UAAU,CAqBjG;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,GAAG,UAAU,CAqBhG;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,SAAS,GAChB,IAAI,GAAG,SAAS,GAAG,UAAU,CAqB/B"}
@@ -0,0 +1,12 @@
1
+ import { default as Blueprint } from './Blueprint.js';
2
+ import { IntersectionSegment } from './booleanHelpers.js';
3
+ /**
4
+ * Given two closed blueprints, find their intersection points, split each
5
+ * blueprint's curves at those points, and pair up the resulting segments.
6
+ *
7
+ * Returns an array of paired segments (one from each blueprint) that share
8
+ * the same start/end intersection points, or `null` if the blueprints do not
9
+ * intersect.
10
+ */
11
+ export declare function blueprintsIntersectionSegments(first: Blueprint, second: Blueprint): IntersectionSegment[] | null;
12
+ //# sourceMappingURL=intersectionSegments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intersectionSegments.d.ts","sourceRoot":"","sources":["../../../src/2d/blueprints/intersectionSegments.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAY5C,OAAO,KAAK,EAAW,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAgKxE;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,SAAS,GAChB,mBAAmB,EAAE,GAAG,IAAI,CAwE9B"}
@@ -0,0 +1,31 @@
1
+ import { Curve2D } from '../lib/index.js';
2
+ import { default as Blueprint } from './Blueprint.js';
3
+ import { default as Blueprints } from './Blueprints.js';
4
+ /**
5
+ * Split an array of curves into separate continuous paths. A discontinuity
6
+ * occurs where one curve's lastPoint does not match the next curve's
7
+ * firstPoint.
8
+ */
9
+ export declare function splitPaths(curves: Curve2D[]): Curve2D[][];
10
+ interface NoIntersectionResult {
11
+ readonly identical: false;
12
+ readonly firstCurveInSecond: boolean;
13
+ readonly secondCurveInFirst: boolean;
14
+ }
15
+ interface IdenticalResult {
16
+ readonly identical: true;
17
+ }
18
+ export type BooleanOperationResult = Blueprint | Blueprints | null | IdenticalResult | NoIntersectionResult;
19
+ interface BooleanOperationConfig {
20
+ readonly firstInside: 'keep' | 'remove';
21
+ readonly secondInside: 'keep' | 'remove';
22
+ }
23
+ /**
24
+ * Core boolean operation between two simple (non-compound) blueprints.
25
+ *
26
+ * Segments both blueprints at their intersection points, then selects which
27
+ * segments to keep based on the `firstInside`/`secondInside` configuration.
28
+ */
29
+ export declare function booleanOperation(first: Blueprint, second: Blueprint, config: BooleanOperationConfig): BooleanOperationResult;
30
+ export {};
31
+ //# sourceMappingURL=segmentAssembly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segmentAssembly.d.ts","sourceRoot":"","sources":["../../../src/2d/blueprints/segmentAssembly.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAU9C;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,EAAE,CA6BzD;AAMD,UAAU,oBAAoB;IAC5B,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC;IAC1B,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;IACrC,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;CACtC;AAED,UAAU,eAAe;IACvB,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;CAC1B;AAED,MAAM,MAAM,sBAAsB,GAC9B,SAAS,GACT,UAAU,GACV,IAAI,GACJ,eAAe,GACf,oBAAoB,CAAC;AAMzB,UAAU,sBAAsB;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,CAAC;CAC1C;AAmGD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,sBAAsB,GAC7B,sBAAsB,CAoDxB"}
package/dist/2d.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const Blueprint = require("./Blueprint-CVctc41Z.cjs");
4
- const boolean2D = require("./boolean2D-BdZATaHs.cjs");
3
+ const Blueprint = require("./Blueprint-FxmMji4s.cjs");
4
+ const boolean2D = require("./boolean2D-BrjHZfWn.cjs");
5
5
  function reverseCurve(curve) {
6
6
  const cloned = curve.clone();
7
7
  cloned.reverse();
package/dist/2d.js CHANGED
@@ -1,6 +1,6 @@
1
- import { B as Blueprint } from "./Blueprint-D3JfGJTz.js";
2
- import { a, C, b } from "./Blueprint-D3JfGJTz.js";
3
- import { b as b2, C as C2, c, d, f, e, i, g, o, p, r } from "./boolean2D-hOw5Qay5.js";
1
+ import { B as Blueprint } from "./Blueprint-DnAO3gr5.js";
2
+ import { e, C, f } from "./Blueprint-DnAO3gr5.js";
3
+ import { b, C as C2, c, d, f as f2, e as e2, i, g, o, p, r } from "./boolean2D-BnZKKBWU.js";
4
4
  function reverseCurve(curve) {
5
5
  const cloned = curve.clone();
6
6
  cloned.reverse();
@@ -68,11 +68,11 @@ function sketch2DOnFace(bp, face, scaleMode) {
68
68
  }
69
69
  export {
70
70
  Blueprint,
71
- b2 as Blueprints,
72
- a as BoundingBox2d,
71
+ b as Blueprints,
72
+ e as BoundingBox2d,
73
73
  C2 as CompoundBlueprint,
74
74
  C as Curve2D,
75
- b as axis2d,
75
+ f as axis2d,
76
76
  createBlueprint,
77
77
  curve2dBoundingBox,
78
78
  curve2dDistanceFrom,
@@ -84,8 +84,8 @@ export {
84
84
  curve2dTangentAt,
85
85
  c as cut2D,
86
86
  d as cutBlueprints,
87
- f as fuse2D,
88
- e as fuseBlueprints,
87
+ f2 as fuse2D,
88
+ e2 as fuseBlueprints,
89
89
  getBounds2D,
90
90
  getOrientation2D,
91
91
  i as intersect2D,
@@ -1,13 +1,13 @@
1
- import { r as resolvePlane } from "./vectors-CBuaMeZv.js";
2
- import { g as getKernel, a as toVec3, c as makeOcAx2 } from "./occtBoundary-CwegMzqc.js";
3
- import { o as localGC, y as registerForCleanup, z as unregisterFromCleanup, n as gcWithScope, t as createEdge, s as createWire } from "./shapeTypes-BlSElW8z.js";
4
- import { u as uvBounds, a as faceGeomType, f as faceCenter, h as uvCoordinates } from "./faceFns-DHu-2JpA.js";
5
- import { j as findCurveType, m as getOrientation } from "./curveFns-CdVE4da7.js";
6
- import { u as unwrap, l as ok, e as err, b as computationError, x as validationError } from "./errors-wGhcJMpB.js";
7
- import { z as zip, o as makeFace } from "./shapeHelpers-BcoZf2N9.js";
8
- import { i as distance2d, s as samePoint, h as scalarMultiply2d, b as add2d, n as normalize2d, a as subtract2d, g as getSingleFace } from "./query-V6nV-VfL.js";
9
- import { c as cast } from "./cast-DQaUibmm.js";
1
+ import { r as resolvePlane } from "./vectors-DWLjb9-P.js";
2
+ import { g as getKernel, a as toVec3, m as makeOcAx2 } from "./occtBoundary-DYsksDtE.js";
3
+ import { t as localGC, u as createFace, e as isFace, y as registerForCleanup, z as unregisterFromCleanup, p as gcWithScope, o as createEdge, n as createWire } from "./shapeTypes-i7VwMRwc.js";
4
+ import { u as uvBounds, a as faceGeomType, f as faceCenter, h as uvCoordinates } from "./faceFns-CyokaCDr.js";
5
+ import { a as getEdges, A as findCurveType, D as getOrientation } from "./curveFns-Cg99XKe2.js";
6
+ import { e as err, o as occtError, l as ok, a as andThen, x as validationError, u as unwrap, b as computationError } from "./errors-wGhcJMpB.js";
7
+ import { d as distance2d, s as samePoint, k as scalarMultiply2d, i as add2d, n as normalize2d, h as subtract2d, g as getSingleFace } from "./helpers-CRx_ks-u.js";
8
+ import { c as cast } from "./cast-BEg1mN7n.js";
10
9
  import { R as RAD2DEG, D as DEG2RAD } from "./vecOps-ZDdZWbwT.js";
10
+ import { m as makeLine, a as assembleWire$1 } from "./curveBuilders-U26XDfxg.js";
11
11
  import { bug } from "./result.js";
12
12
  function makePlane(plane, origin) {
13
13
  if (plane && typeof plane !== "string") {
@@ -44,6 +44,86 @@ function mirror(shape, inputPlane, origin) {
44
44
  gc();
45
45
  return newShape;
46
46
  }
47
+ function range(len) {
48
+ return Array.from(Array(len).keys());
49
+ }
50
+ function zip(arrays) {
51
+ const minLength = Math.min(...arrays.map((arr) => arr.length));
52
+ return range(minLength).map((i) => arrays.map((arr) => arr[i]));
53
+ }
54
+ function makeFace(wire, holes) {
55
+ const oc = getKernel().oc;
56
+ const faceBuilder = new oc.BRepBuilderAPI_MakeFace_15(wire.wrapped, false);
57
+ holes?.forEach((hole) => {
58
+ faceBuilder.Add(hole.wrapped);
59
+ });
60
+ if (!faceBuilder.IsDone()) {
61
+ faceBuilder.delete();
62
+ return err(
63
+ occtError("FACE_BUILD_FAILED", "Failed to build the face. Your wire might be non planar.")
64
+ );
65
+ }
66
+ const face = faceBuilder.Face();
67
+ faceBuilder.delete();
68
+ return ok(createFace(face));
69
+ }
70
+ function makeNewFaceWithinFace(originFace, wire) {
71
+ const oc = getKernel().oc;
72
+ const [r, gc] = localGC();
73
+ const surface = r(oc.BRep_Tool.Surface_2(originFace.wrapped));
74
+ const faceBuilder = r(new oc.BRepBuilderAPI_MakeFace_21(surface, wire.wrapped, true));
75
+ const face = faceBuilder.Face();
76
+ gc();
77
+ return createFace(face);
78
+ }
79
+ function makeNonPlanarFace(wire) {
80
+ const oc = getKernel().oc;
81
+ const [r, gc] = localGC();
82
+ const faceBuilder = r(
83
+ new oc.BRepOffsetAPI_MakeFilling(3, 15, 2, false, 1e-5, 1e-4, 0.01, 0.1, 8, 9)
84
+ );
85
+ getEdges(wire).forEach((edge) => {
86
+ faceBuilder.Add_1(
87
+ edge.wrapped,
88
+ oc.GeomAbs_Shape.GeomAbs_C0,
89
+ true
90
+ );
91
+ });
92
+ const progress = r(new oc.Message_ProgressRange_1());
93
+ faceBuilder.Build(progress);
94
+ return andThen(cast(faceBuilder.Shape()), (newFace) => {
95
+ gc();
96
+ if (!isFace(newFace)) {
97
+ return err(occtError("FACE_BUILD_FAILED", "Failed to create a face"));
98
+ }
99
+ return ok(newFace);
100
+ });
101
+ }
102
+ function addHolesInFace(face, holes) {
103
+ const oc = getKernel().oc;
104
+ const [r, gc] = localGC();
105
+ const faceMaker = r(new oc.BRepBuilderAPI_MakeFace_2(face.wrapped));
106
+ holes.forEach((wire) => {
107
+ faceMaker.Add(wire.wrapped);
108
+ });
109
+ const builtFace = r(faceMaker.Face());
110
+ const fixer = r(new oc.ShapeFix_Face_2(builtFace));
111
+ fixer.FixOrientation_1();
112
+ const newFace = fixer.Face();
113
+ gc();
114
+ return createFace(newFace);
115
+ }
116
+ function makePolygon(points) {
117
+ if (points.length < 3)
118
+ return err(
119
+ validationError("POLYGON_MIN_POINTS", "You need at least 3 points to make a polygon")
120
+ );
121
+ const edges = zip([points, [...points.slice(1), points[0]]]).map(
122
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- zip returns untyped pairs
123
+ ([p1, p2]) => makeLine(p1, p2)
124
+ );
125
+ return andThen(assembleWire$1(edges), (wire) => makeFace(wire));
126
+ }
47
127
  function isPoint2D(point) {
48
128
  return Array.isArray(point) && point.length === 2 && typeof point[0] === "number" && typeof point[1] === "number";
49
129
  }
@@ -1158,27 +1238,33 @@ class Blueprint {
1158
1238
  }
1159
1239
  }
1160
1240
  export {
1241
+ removeDuplicatePoints as A,
1161
1242
  Blueprint as B,
1162
1243
  Curve2D as C,
1163
- BoundingBox2d as a,
1164
- axis2d as b,
1165
- make2dSegmentCurve as c,
1166
- approximateAsBSpline as d,
1167
- make2dCircle as e,
1168
- make2dThreePointArc as f,
1169
- make2dArcFromCenter as g,
1170
- asSVG as h,
1171
- isPoint2D as i,
1172
- make2dTangentArc as j,
1173
- make2dEllipseArc as k,
1174
- make2dBezierCurve as l,
1175
- makePlane as m,
1176
- mirror as n,
1177
- approximateAsSvgCompatibleCurve as o,
1178
- edgeToCurve as p,
1179
- make2dInerpolatedBSplineCurve as q,
1180
- removeDuplicatePoints as r,
1181
- make2dEllipse as s,
1182
- deserializeCurve2D as t,
1183
- viewbox as v
1244
+ addHolesInFace as a,
1245
+ makeNonPlanarFace as b,
1246
+ makePolygon as c,
1247
+ makeNewFaceWithinFace as d,
1248
+ BoundingBox2d as e,
1249
+ axis2d as f,
1250
+ makePlane as g,
1251
+ mirror as h,
1252
+ make2dSegmentCurve as i,
1253
+ make2dArcFromCenter as j,
1254
+ approximateAsSvgCompatibleCurve as k,
1255
+ edgeToCurve as l,
1256
+ makeFace as m,
1257
+ make2dInerpolatedBSplineCurve as n,
1258
+ make2dCircle as o,
1259
+ make2dEllipse as p,
1260
+ deserializeCurve2D as q,
1261
+ approximateAsBSpline as r,
1262
+ isPoint2D as s,
1263
+ make2dThreePointArc as t,
1264
+ asSVG as u,
1265
+ viewbox as v,
1266
+ make2dEllipseArc as w,
1267
+ make2dTangentArc as x,
1268
+ make2dBezierCurve as y,
1269
+ zip as z
1184
1270
  };
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
- const vectors = require("./vectors-ChWEZPwy.cjs");
3
- const occtBoundary = require("./occtBoundary-du8_ex-p.cjs");
4
- const shapeTypes = require("./shapeTypes-DKhwEnUM.cjs");
5
- const faceFns = require("./faceFns-BwK7FP7N.cjs");
6
- const curveFns = require("./curveFns-BilyYL_s.cjs");
2
+ const vectors = require("./vectors-aQBZK0Sb.cjs");
3
+ const occtBoundary = require("./occtBoundary-DHtzU4tz.cjs");
4
+ const shapeTypes = require("./shapeTypes-b_lhwQB7.cjs");
5
+ const faceFns = require("./faceFns-DcSCjDG0.cjs");
6
+ const curveFns = require("./curveFns-BoG_iA07.cjs");
7
7
  const errors = require("./errors-DK1VAdP4.cjs");
8
- const shapeHelpers = require("./shapeHelpers-B2SXz1p4.cjs");
9
- const query = require("./query-hMSmOWJP.cjs");
10
- const cast = require("./cast-DkB0GKmQ.cjs");
8
+ const helpers = require("./helpers--iZxPeJg.cjs");
9
+ const cast = require("./cast-CqDc8oFW.cjs");
11
10
  const vecOps = require("./vecOps-CjRL1jau.cjs");
11
+ const curveBuilders = require("./curveBuilders-BjtdNw1B.cjs");
12
12
  const result = require("./result.cjs");
13
13
  function makePlane(plane, origin) {
14
14
  if (plane && typeof plane !== "string") {
@@ -45,6 +45,86 @@ function mirror(shape, inputPlane, origin) {
45
45
  gc();
46
46
  return newShape;
47
47
  }
48
+ function range(len) {
49
+ return Array.from(Array(len).keys());
50
+ }
51
+ function zip(arrays) {
52
+ const minLength = Math.min(...arrays.map((arr) => arr.length));
53
+ return range(minLength).map((i) => arrays.map((arr) => arr[i]));
54
+ }
55
+ function makeFace(wire, holes) {
56
+ const oc = occtBoundary.getKernel().oc;
57
+ const faceBuilder = new oc.BRepBuilderAPI_MakeFace_15(wire.wrapped, false);
58
+ holes?.forEach((hole) => {
59
+ faceBuilder.Add(hole.wrapped);
60
+ });
61
+ if (!faceBuilder.IsDone()) {
62
+ faceBuilder.delete();
63
+ return errors.err(
64
+ errors.occtError("FACE_BUILD_FAILED", "Failed to build the face. Your wire might be non planar.")
65
+ );
66
+ }
67
+ const face = faceBuilder.Face();
68
+ faceBuilder.delete();
69
+ return errors.ok(shapeTypes.createFace(face));
70
+ }
71
+ function makeNewFaceWithinFace(originFace, wire) {
72
+ const oc = occtBoundary.getKernel().oc;
73
+ const [r, gc] = shapeTypes.localGC();
74
+ const surface = r(oc.BRep_Tool.Surface_2(originFace.wrapped));
75
+ const faceBuilder = r(new oc.BRepBuilderAPI_MakeFace_21(surface, wire.wrapped, true));
76
+ const face = faceBuilder.Face();
77
+ gc();
78
+ return shapeTypes.createFace(face);
79
+ }
80
+ function makeNonPlanarFace(wire) {
81
+ const oc = occtBoundary.getKernel().oc;
82
+ const [r, gc] = shapeTypes.localGC();
83
+ const faceBuilder = r(
84
+ new oc.BRepOffsetAPI_MakeFilling(3, 15, 2, false, 1e-5, 1e-4, 0.01, 0.1, 8, 9)
85
+ );
86
+ curveFns.getEdges(wire).forEach((edge) => {
87
+ faceBuilder.Add_1(
88
+ edge.wrapped,
89
+ oc.GeomAbs_Shape.GeomAbs_C0,
90
+ true
91
+ );
92
+ });
93
+ const progress = r(new oc.Message_ProgressRange_1());
94
+ faceBuilder.Build(progress);
95
+ return errors.andThen(cast.cast(faceBuilder.Shape()), (newFace) => {
96
+ gc();
97
+ if (!shapeTypes.isFace(newFace)) {
98
+ return errors.err(errors.occtError("FACE_BUILD_FAILED", "Failed to create a face"));
99
+ }
100
+ return errors.ok(newFace);
101
+ });
102
+ }
103
+ function addHolesInFace(face, holes) {
104
+ const oc = occtBoundary.getKernel().oc;
105
+ const [r, gc] = shapeTypes.localGC();
106
+ const faceMaker = r(new oc.BRepBuilderAPI_MakeFace_2(face.wrapped));
107
+ holes.forEach((wire) => {
108
+ faceMaker.Add(wire.wrapped);
109
+ });
110
+ const builtFace = r(faceMaker.Face());
111
+ const fixer = r(new oc.ShapeFix_Face_2(builtFace));
112
+ fixer.FixOrientation_1();
113
+ const newFace = fixer.Face();
114
+ gc();
115
+ return shapeTypes.createFace(newFace);
116
+ }
117
+ function makePolygon(points) {
118
+ if (points.length < 3)
119
+ return errors.err(
120
+ errors.validationError("POLYGON_MIN_POINTS", "You need at least 3 points to make a polygon")
121
+ );
122
+ const edges = zip([points, [...points.slice(1), points[0]]]).map(
123
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- zip returns untyped pairs
124
+ ([p1, p2]) => curveBuilders.makeLine(p1, p2)
125
+ );
126
+ return errors.andThen(curveBuilders.assembleWire(edges), (wire) => makeFace(wire));
127
+ }
48
128
  function isPoint2D(point) {
49
129
  return Array.isArray(point) && point.length === 2 && typeof point[0] === "number" && typeof point[1] === "number";
50
130
  }
@@ -291,8 +371,8 @@ class Curve2D {
291
371
  }
292
372
  return Math.min(
293
373
  curveToPoint,
294
- query.distance2d(point, this.firstPoint),
295
- query.distance2d(point, this.lastPoint)
374
+ helpers.distance2d(point, this.firstPoint),
375
+ helpers.distance2d(point, this.lastPoint)
296
376
  );
297
377
  }
298
378
  distanceFromCurve(curve) {
@@ -348,8 +428,8 @@ class Curve2D {
348
428
  lowerDistance = projector.LowerDistance();
349
429
  lowerDistanceParameter = projector.LowerDistanceParameter();
350
430
  } catch {
351
- if (query.samePoint(point, this.firstPoint, precision)) return errors.ok(this.firstParameter);
352
- if (query.samePoint(point, this.lastPoint, precision)) return errors.ok(this.lastParameter);
431
+ if (helpers.samePoint(point, this.firstPoint, precision)) return errors.ok(this.firstParameter);
432
+ if (helpers.samePoint(point, this.lastPoint, precision)) return errors.ok(this.lastParameter);
353
433
  return errors.err(errors.computationError("PARAMETER_NOT_FOUND", "Failed to find parameter"));
354
434
  }
355
435
  if (lowerDistance > precision) {
@@ -412,7 +492,7 @@ class Curve2D {
412
492
  )
413
493
  parameters = parameters.slice(0, -1);
414
494
  if (!parameters.length) return [this];
415
- return shapeHelpers.zip([
495
+ return zip([
416
496
  [firstParam, ...parameters],
417
497
  [...parameters, lastParam]
418
498
  ]).map(([first, last]) => {
@@ -489,7 +569,7 @@ function approximateAsSvgCompatibleCurve(curves, options = {
489
569
  return curves.flatMap((curve) => {
490
570
  const adaptor = r(curve.adaptor());
491
571
  const curveType = errors.unwrap(curveFns.findCurveType(adaptor.GetType()));
492
- if (curveType === "ELLIPSE" || curveType === "CIRCLE" && query.samePoint(curve.firstPoint, curve.lastPoint)) {
572
+ if (curveType === "ELLIPSE" || curveType === "CIRCLE" && helpers.samePoint(curve.firstPoint, curve.lastPoint)) {
493
573
  return curve.splitAt([0.5]);
494
574
  }
495
575
  if (["LINE", "ELLIPSE", "CIRCLE"].includes(curveType)) {
@@ -520,7 +600,7 @@ const make2dSegmentCurve = (startPoint, endPoint) => {
520
600
  const [r, gc] = shapeTypes.localGC();
521
601
  const segment = r(new oc.GCE2d_MakeSegment_1(r(pnt(startPoint)), r(pnt(endPoint)))).Value();
522
602
  const curve = new Curve2D(segment);
523
- if (!query.samePoint(curve.firstPoint, startPoint)) {
603
+ if (!helpers.samePoint(curve.firstPoint, startPoint)) {
524
604
  curve.reverse();
525
605
  }
526
606
  gc();
@@ -534,7 +614,7 @@ const make2dThreePointArc = (startPoint, midPoint, endPoint) => {
534
614
  ).Value();
535
615
  gc();
536
616
  const curve = new Curve2D(segment);
537
- if (!query.samePoint(curve.firstPoint, startPoint)) {
617
+ if (!helpers.samePoint(curve.firstPoint, startPoint)) {
538
618
  curve.wrapped.get().SetTrim(curve.lastParameter, curve.firstParameter, true, true);
539
619
  }
540
620
  return curve;
@@ -547,7 +627,7 @@ const make2dTangentArc = (startPoint, tangent, endPoint) => {
547
627
  ).Value();
548
628
  gc();
549
629
  const curve = new Curve2D(segment);
550
- if (!query.samePoint(curve.firstPoint, startPoint)) {
630
+ if (!helpers.samePoint(curve.firstPoint, startPoint)) {
551
631
  curve.wrapped.get().SetTrim(curve.lastParameter, curve.firstParameter, true, true);
552
632
  }
553
633
  return curve;
@@ -630,12 +710,12 @@ function make2dInerpolatedBSplineCurve(points, {
630
710
  return errors.ok(new Curve2D(splineBuilder.Curve()));
631
711
  }
632
712
  const make2dArcFromCenter = (startPoint, endPoint, center, longArc = false) => {
633
- const midChord = query.scalarMultiply2d(query.add2d(startPoint, endPoint), 0.5);
634
- const orientedRadius = query.distance2d(center, startPoint) * (longArc ? -1 : 1);
635
- const midChordDir = query.normalize2d(query.subtract2d(midChord, center));
713
+ const midChord = helpers.scalarMultiply2d(helpers.add2d(startPoint, endPoint), 0.5);
714
+ const orientedRadius = helpers.distance2d(center, startPoint) * (longArc ? -1 : 1);
715
+ const midChordDir = helpers.normalize2d(helpers.subtract2d(midChord, center));
636
716
  return make2dThreePointArc(
637
717
  startPoint,
638
- query.add2d(query.scalarMultiply2d(midChordDir, orientedRadius), center),
718
+ helpers.add2d(helpers.scalarMultiply2d(midChordDir, orientedRadius), center),
639
719
  endPoint
640
720
  );
641
721
  };
@@ -1021,7 +1101,7 @@ class Blueprint {
1021
1101
  const originPoint = origin || [...faceFns.faceCenter(face)];
1022
1102
  const originVec3 = occtBoundary.toVec3(originPoint);
1023
1103
  const sketch = this.translate(faceFns.uvCoordinates(face, originVec3)).sketchOnFace(face, "original");
1024
- return errors.unwrap(shapeHelpers.makeFace(sketch.wire));
1104
+ return errors.unwrap(makeFace(sketch.wire));
1025
1105
  }
1026
1106
  /**
1027
1107
  * Cut a prism-shaped hole through a solid along a face using this blueprint.
@@ -1041,7 +1121,7 @@ class Blueprint {
1041
1121
  } = {}) {
1042
1122
  const oc = occtBoundary.getKernel().oc;
1043
1123
  const gc = shapeTypes.gcWithScope();
1044
- const foundFace = errors.unwrap(query.getSingleFace(face, shape));
1124
+ const foundFace = errors.unwrap(helpers.getSingleFace(face, shape));
1045
1125
  const hole = this.subFace(foundFace, origin);
1046
1126
  const maker = gc(
1047
1127
  new oc.BRepFeat_MakeDPrism_1(
@@ -1133,7 +1213,7 @@ class Blueprint {
1133
1213
  }
1134
1214
  /** Check whether the first and last points coincide (the profile is closed). */
1135
1215
  isClosed() {
1136
- return query.samePoint(this.firstPoint, this.lastPoint);
1216
+ return helpers.samePoint(this.firstPoint, this.lastPoint);
1137
1217
  }
1138
1218
  /**
1139
1219
  * Test whether this blueprint's curves intersect with another blueprint's curves.
@@ -1161,6 +1241,7 @@ class Blueprint {
1161
1241
  exports.Blueprint = Blueprint;
1162
1242
  exports.BoundingBox2d = BoundingBox2d;
1163
1243
  exports.Curve2D = Curve2D;
1244
+ exports.addHolesInFace = addHolesInFace;
1164
1245
  exports.approximateAsBSpline = approximateAsBSpline;
1165
1246
  exports.approximateAsSvgCompatibleCurve = approximateAsSvgCompatibleCurve;
1166
1247
  exports.asSVG = asSVG;
@@ -1177,7 +1258,12 @@ exports.make2dInerpolatedBSplineCurve = make2dInerpolatedBSplineCurve;
1177
1258
  exports.make2dSegmentCurve = make2dSegmentCurve;
1178
1259
  exports.make2dTangentArc = make2dTangentArc;
1179
1260
  exports.make2dThreePointArc = make2dThreePointArc;
1261
+ exports.makeFace = makeFace;
1262
+ exports.makeNewFaceWithinFace = makeNewFaceWithinFace;
1263
+ exports.makeNonPlanarFace = makeNonPlanarFace;
1180
1264
  exports.makePlane = makePlane;
1265
+ exports.makePolygon = makePolygon;
1181
1266
  exports.mirror = mirror;
1182
1267
  exports.removeDuplicatePoints = removeDuplicatePoints;
1183
1268
  exports.viewbox = viewbox;
1269
+ exports.zip = zip;