brepjs 8.0.0 → 8.0.2

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 (124) 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-B9fhnpFp.js} +117 -30
  12. package/dist/{Blueprint-CVctc41Z.cjs → Blueprint-VGbo3izk.cjs} +111 -24
  13. package/dist/{boolean2D-BdZATaHs.cjs → boolean2D-B1XrGVgx.cjs} +426 -345
  14. package/dist/{boolean2D-hOw5Qay5.js → boolean2D-_WiqPxWZ.js} +391 -310
  15. package/dist/{booleanFns-BBSVKhL2.cjs → booleanFns-BxW-N3rP.cjs} +12 -16
  16. package/dist/{booleanFns-CqehfzcK.js → booleanFns-CkccZ7UL.js} +14 -18
  17. package/dist/brepjs.cjs +133 -62
  18. package/dist/brepjs.js +290 -217
  19. package/dist/{cast-DQaUibmm.js → cast-C4Ff_1Qe.js} +2 -2
  20. package/dist/{cast-DkB0GKmQ.cjs → cast-DIiyxDLo.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-BndBNtJE.cjs +58 -0
  26. package/dist/cornerFinder-DzGzfiqb.js +59 -0
  27. package/dist/curveBuilders-BUoFO1UG.cjs +196 -0
  28. package/dist/curveBuilders-CBlIWlbU.js +197 -0
  29. package/dist/{curveFns-BilyYL_s.cjs → curveFns-BrJDkaWi.cjs} +31 -44
  30. package/dist/{curveFns-CdVE4da7.js → curveFns-BshHA9Ys.js} +31 -44
  31. package/dist/{drawFns-921SkhDL.js → drawFns-Btmlh_Oz.js} +13 -14
  32. package/dist/{drawFns-CUyx50gi.cjs → drawFns-D2eDcf4k.cjs} +58 -59
  33. package/dist/{faceFns-DHu-2JpA.js → faceFns-DDzCECn3.js} +3 -3
  34. package/dist/{faceFns-BwK7FP7N.cjs → faceFns-NDRFeekj.cjs} +3 -3
  35. package/dist/helpers-Ck8GJ58k.cjs +203 -0
  36. package/dist/helpers-jku2V1DY.js +204 -0
  37. package/dist/io.cjs +4 -4
  38. package/dist/io.js +4 -4
  39. package/dist/kernel/occtAdapter.d.ts +1 -0
  40. package/dist/kernel/occtAdapter.d.ts.map +1 -1
  41. package/dist/kernel/sweepOps.d.ts +8 -0
  42. package/dist/kernel/sweepOps.d.ts.map +1 -1
  43. package/dist/kernel/types.d.ts +1 -0
  44. package/dist/kernel/types.d.ts.map +1 -1
  45. package/dist/loft-Bk9EM0gZ.js +373 -0
  46. package/dist/loft-DJXwxV_L.cjs +372 -0
  47. package/dist/{measurement-C5JGCuUP.js → measurement-DlXaTzKc.js} +3 -3
  48. package/dist/{measurement-fxm_pW7x.cjs → measurement-LcGh4wV0.cjs} +3 -3
  49. package/dist/measurement.cjs +1 -1
  50. package/dist/measurement.js +1 -1
  51. package/dist/{meshFns-AqAjTTVl.js → meshFns-Djzdn-CS.js} +1 -1
  52. package/dist/{meshFns-BhrZGi6w.cjs → meshFns-c8lDKfYy.cjs} +1 -1
  53. package/dist/{occtBoundary-du8_ex-p.cjs → occtBoundary-6kQSl3cF.cjs} +21 -0
  54. package/dist/{occtBoundary-CwegMzqc.js → occtBoundary-CqXvDhZY.js} +26 -5
  55. package/dist/operations/extrude.d.ts.map +1 -1
  56. package/dist/operations/extrudeFns.d.ts.map +1 -1
  57. package/dist/operations/extrudeUtils.d.ts +17 -0
  58. package/dist/operations/extrudeUtils.d.ts.map +1 -1
  59. package/dist/{operations-C1rWoba2.js → operations-CrQlFDHc.js} +30 -7
  60. package/dist/{operations-BP1wVDw0.cjs → operations-Do-WZGXc.cjs} +30 -7
  61. package/dist/operations.cjs +2 -2
  62. package/dist/operations.js +4 -4
  63. package/dist/query/cornerFinder.d.ts +48 -0
  64. package/dist/query/cornerFinder.d.ts.map +1 -0
  65. package/dist/query/directionUtils.d.ts +6 -0
  66. package/dist/query/directionUtils.d.ts.map +1 -0
  67. package/dist/query/edgeFinder.d.ts +15 -0
  68. package/dist/query/edgeFinder.d.ts.map +1 -0
  69. package/dist/query/faceFinder.d.ts +15 -0
  70. package/dist/query/faceFinder.d.ts.map +1 -0
  71. package/dist/query/finderCore.d.ts +35 -0
  72. package/dist/query/finderCore.d.ts.map +1 -0
  73. package/dist/query/finderFns.d.ts +21 -106
  74. package/dist/query/finderFns.d.ts.map +1 -1
  75. package/dist/query/shapeDistanceFilter.d.ts +11 -0
  76. package/dist/query/shapeDistanceFilter.d.ts.map +1 -0
  77. package/dist/query/vertexFinder.d.ts +16 -0
  78. package/dist/query/vertexFinder.d.ts.map +1 -0
  79. package/dist/query/wireFinder.d.ts +10 -0
  80. package/dist/query/wireFinder.d.ts.map +1 -0
  81. package/dist/query.cjs +42 -5
  82. package/dist/query.js +40 -2
  83. package/dist/{shapeFns-BrF97sKt.js → shapeFns-DQtpzndX.js} +17 -18
  84. package/dist/{shapeFns-BvOndshS.cjs → shapeFns-cN4qGpbO.cjs} +6 -7
  85. package/dist/{shapeTypes-DKhwEnUM.cjs → shapeTypes-BJ3Hmskg.cjs} +24 -20
  86. package/dist/{shapeTypes-BlSElW8z.js → shapeTypes-C9sUsmEW.js} +32 -28
  87. package/dist/sketching/Sketcher.d.ts.map +1 -1
  88. package/dist/sketching/Sketcher2d.d.ts +12 -4
  89. package/dist/sketching/Sketcher2d.d.ts.map +1 -1
  90. package/dist/sketching/ellipseUtils.d.ts +29 -0
  91. package/dist/sketching/ellipseUtils.d.ts.map +1 -0
  92. package/dist/sketching.cjs +2 -2
  93. package/dist/sketching.js +2 -2
  94. package/dist/topology/booleanFns.d.ts.map +1 -1
  95. package/dist/topology/curveBuilders.d.ts +75 -0
  96. package/dist/topology/curveBuilders.d.ts.map +1 -0
  97. package/dist/topology/curveFns.d.ts.map +1 -1
  98. package/dist/topology/primitiveFns.d.ts.map +1 -1
  99. package/dist/topology/shapeFns.d.ts.map +1 -1
  100. package/dist/topology/shapeHelpers.d.ts +6 -173
  101. package/dist/topology/shapeHelpers.d.ts.map +1 -1
  102. package/dist/topology/shapeUtils.d.ts +13 -0
  103. package/dist/topology/shapeUtils.d.ts.map +1 -0
  104. package/dist/topology/solidBuilders.d.ts +70 -0
  105. package/dist/topology/solidBuilders.d.ts.map +1 -0
  106. package/dist/topology/surfaceBuilders.d.ts +35 -0
  107. package/dist/topology/surfaceBuilders.d.ts.map +1 -0
  108. package/dist/topology/wrapperFns.d.ts +1 -0
  109. package/dist/topology/wrapperFns.d.ts.map +1 -1
  110. package/dist/{topology-tFzqSrGH.js → topology-CtfUZwLR.js} +8 -8
  111. package/dist/{topology-CIooytHH.cjs → topology-DXq8dLsi.cjs} +8 -8
  112. package/dist/topology.cjs +7 -7
  113. package/dist/topology.js +31 -31
  114. package/dist/{vectors-CBuaMeZv.js → vectors-BVgXsYWl.js} +1 -1
  115. package/dist/{vectors-ChWEZPwy.cjs → vectors-DK2hEKcI.cjs} +1 -1
  116. package/dist/vectors.cjs +2 -2
  117. package/dist/vectors.js +2 -2
  118. package/package.json +1 -1
  119. package/dist/loft-BzWFokmC.cjs +0 -178
  120. package/dist/loft-CtG5nMq5.js +0 -179
  121. package/dist/query-V6nV-VfL.js +0 -396
  122. package/dist/query-hMSmOWJP.cjs +0 -395
  123. package/dist/shapeHelpers-B2SXz1p4.cjs +0 -488
  124. 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-VGbo3izk.cjs");
4
+ const boolean2D = require("./boolean2D-B1XrGVgx.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-B9fhnpFp.js";
2
+ import { e, C, f } from "./Blueprint-B9fhnpFp.js";
3
+ import { b, C as C2, c, d, f as f2, e as e2, i, g, o, p, r } from "./boolean2D-_WiqPxWZ.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,14 @@
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-BVgXsYWl.js";
2
+ import { g as getKernel, a as toVec3, m as makeOcAx2 } from "./occtBoundary-CqXvDhZY.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-C9sUsmEW.js";
4
+ import { u as uvBounds, a as faceGeomType, f as faceCenter, h as uvCoordinates } from "./faceFns-DDzCECn3.js";
5
+ import { j as findCurveType, m as getOrientation } from "./curveFns-BshHA9Ys.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-jku2V1DY.js";
8
+ import { c as cast } from "./cast-C4Ff_1Qe.js";
10
9
  import { R as RAD2DEG, D as DEG2RAD } from "./vecOps-ZDdZWbwT.js";
10
+ import { a as getEdges } from "./shapeFns-DQtpzndX.js";
11
+ import { m as makeLine, a as assembleWire$1 } from "./curveBuilders-CBlIWlbU.js";
11
12
  import { bug } from "./result.js";
12
13
  function makePlane(plane, origin) {
13
14
  if (plane && typeof plane !== "string") {
@@ -44,6 +45,86 @@ function mirror(shape, inputPlane, origin) {
44
45
  gc();
45
46
  return newShape;
46
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 = 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 err(
64
+ 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 ok(createFace(face));
70
+ }
71
+ function makeNewFaceWithinFace(originFace, wire) {
72
+ const oc = getKernel().oc;
73
+ const [r, gc] = 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 createFace(face);
79
+ }
80
+ function makeNonPlanarFace(wire) {
81
+ const oc = getKernel().oc;
82
+ const [r, gc] = 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
+ 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 andThen(cast(faceBuilder.Shape()), (newFace) => {
96
+ gc();
97
+ if (!isFace(newFace)) {
98
+ return err(occtError("FACE_BUILD_FAILED", "Failed to create a face"));
99
+ }
100
+ return ok(newFace);
101
+ });
102
+ }
103
+ function addHolesInFace(face, holes) {
104
+ const oc = getKernel().oc;
105
+ const [r, gc] = 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 createFace(newFace);
116
+ }
117
+ function makePolygon(points) {
118
+ if (points.length < 3)
119
+ return err(
120
+ 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]) => makeLine(p1, p2)
125
+ );
126
+ return andThen(assembleWire$1(edges), (wire) => makeFace(wire));
127
+ }
47
128
  function isPoint2D(point) {
48
129
  return Array.isArray(point) && point.length === 2 && typeof point[0] === "number" && typeof point[1] === "number";
49
130
  }
@@ -1158,27 +1239,33 @@ class Blueprint {
1158
1239
  }
1159
1240
  }
1160
1241
  export {
1242
+ removeDuplicatePoints as A,
1161
1243
  Blueprint as B,
1162
1244
  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
1245
+ addHolesInFace as a,
1246
+ makeNonPlanarFace as b,
1247
+ makePolygon as c,
1248
+ makeNewFaceWithinFace as d,
1249
+ BoundingBox2d as e,
1250
+ axis2d as f,
1251
+ makePlane as g,
1252
+ mirror as h,
1253
+ make2dSegmentCurve as i,
1254
+ make2dArcFromCenter as j,
1255
+ approximateAsSvgCompatibleCurve as k,
1256
+ edgeToCurve as l,
1257
+ makeFace as m,
1258
+ make2dInerpolatedBSplineCurve as n,
1259
+ make2dCircle as o,
1260
+ make2dEllipse as p,
1261
+ deserializeCurve2D as q,
1262
+ approximateAsBSpline as r,
1263
+ isPoint2D as s,
1264
+ make2dThreePointArc as t,
1265
+ asSVG as u,
1266
+ viewbox as v,
1267
+ make2dEllipseArc as w,
1268
+ make2dTangentArc as x,
1269
+ make2dBezierCurve as y,
1270
+ zip as z
1184
1271
  };
@@ -1,14 +1,15 @@
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-DK2hEKcI.cjs");
3
+ const occtBoundary = require("./occtBoundary-6kQSl3cF.cjs");
4
+ const shapeTypes = require("./shapeTypes-BJ3Hmskg.cjs");
5
+ const faceFns = require("./faceFns-NDRFeekj.cjs");
6
+ const curveFns = require("./curveFns-BrJDkaWi.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-Ck8GJ58k.cjs");
9
+ const cast = require("./cast-DIiyxDLo.cjs");
11
10
  const vecOps = require("./vecOps-CjRL1jau.cjs");
11
+ const shapeFns = require("./shapeFns-cN4qGpbO.cjs");
12
+ const curveBuilders = require("./curveBuilders-BUoFO1UG.cjs");
12
13
  const result = require("./result.cjs");
13
14
  function makePlane(plane, origin) {
14
15
  if (plane && typeof plane !== "string") {
@@ -45,6 +46,86 @@ function mirror(shape, inputPlane, origin) {
45
46
  gc();
46
47
  return newShape;
47
48
  }
49
+ function range(len) {
50
+ return Array.from(Array(len).keys());
51
+ }
52
+ function zip(arrays) {
53
+ const minLength = Math.min(...arrays.map((arr) => arr.length));
54
+ return range(minLength).map((i) => arrays.map((arr) => arr[i]));
55
+ }
56
+ function makeFace(wire, holes) {
57
+ const oc = occtBoundary.getKernel().oc;
58
+ const faceBuilder = new oc.BRepBuilderAPI_MakeFace_15(wire.wrapped, false);
59
+ holes?.forEach((hole) => {
60
+ faceBuilder.Add(hole.wrapped);
61
+ });
62
+ if (!faceBuilder.IsDone()) {
63
+ faceBuilder.delete();
64
+ return errors.err(
65
+ errors.occtError("FACE_BUILD_FAILED", "Failed to build the face. Your wire might be non planar.")
66
+ );
67
+ }
68
+ const face = faceBuilder.Face();
69
+ faceBuilder.delete();
70
+ return errors.ok(shapeTypes.createFace(face));
71
+ }
72
+ function makeNewFaceWithinFace(originFace, wire) {
73
+ const oc = occtBoundary.getKernel().oc;
74
+ const [r, gc] = shapeTypes.localGC();
75
+ const surface = r(oc.BRep_Tool.Surface_2(originFace.wrapped));
76
+ const faceBuilder = r(new oc.BRepBuilderAPI_MakeFace_21(surface, wire.wrapped, true));
77
+ const face = faceBuilder.Face();
78
+ gc();
79
+ return shapeTypes.createFace(face);
80
+ }
81
+ function makeNonPlanarFace(wire) {
82
+ const oc = occtBoundary.getKernel().oc;
83
+ const [r, gc] = shapeTypes.localGC();
84
+ const faceBuilder = r(
85
+ new oc.BRepOffsetAPI_MakeFilling(3, 15, 2, false, 1e-5, 1e-4, 0.01, 0.1, 8, 9)
86
+ );
87
+ shapeFns.getEdges(wire).forEach((edge) => {
88
+ faceBuilder.Add_1(
89
+ edge.wrapped,
90
+ oc.GeomAbs_Shape.GeomAbs_C0,
91
+ true
92
+ );
93
+ });
94
+ const progress = r(new oc.Message_ProgressRange_1());
95
+ faceBuilder.Build(progress);
96
+ return errors.andThen(cast.cast(faceBuilder.Shape()), (newFace) => {
97
+ gc();
98
+ if (!shapeTypes.isFace(newFace)) {
99
+ return errors.err(errors.occtError("FACE_BUILD_FAILED", "Failed to create a face"));
100
+ }
101
+ return errors.ok(newFace);
102
+ });
103
+ }
104
+ function addHolesInFace(face, holes) {
105
+ const oc = occtBoundary.getKernel().oc;
106
+ const [r, gc] = shapeTypes.localGC();
107
+ const faceMaker = r(new oc.BRepBuilderAPI_MakeFace_2(face.wrapped));
108
+ holes.forEach((wire) => {
109
+ faceMaker.Add(wire.wrapped);
110
+ });
111
+ const builtFace = r(faceMaker.Face());
112
+ const fixer = r(new oc.ShapeFix_Face_2(builtFace));
113
+ fixer.FixOrientation_1();
114
+ const newFace = fixer.Face();
115
+ gc();
116
+ return shapeTypes.createFace(newFace);
117
+ }
118
+ function makePolygon(points) {
119
+ if (points.length < 3)
120
+ return errors.err(
121
+ errors.validationError("POLYGON_MIN_POINTS", "You need at least 3 points to make a polygon")
122
+ );
123
+ const edges = zip([points, [...points.slice(1), points[0]]]).map(
124
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- zip returns untyped pairs
125
+ ([p1, p2]) => curveBuilders.makeLine(p1, p2)
126
+ );
127
+ return errors.andThen(curveBuilders.assembleWire(edges), (wire) => makeFace(wire));
128
+ }
48
129
  function isPoint2D(point) {
49
130
  return Array.isArray(point) && point.length === 2 && typeof point[0] === "number" && typeof point[1] === "number";
50
131
  }
@@ -291,8 +372,8 @@ class Curve2D {
291
372
  }
292
373
  return Math.min(
293
374
  curveToPoint,
294
- query.distance2d(point, this.firstPoint),
295
- query.distance2d(point, this.lastPoint)
375
+ helpers.distance2d(point, this.firstPoint),
376
+ helpers.distance2d(point, this.lastPoint)
296
377
  );
297
378
  }
298
379
  distanceFromCurve(curve) {
@@ -348,8 +429,8 @@ class Curve2D {
348
429
  lowerDistance = projector.LowerDistance();
349
430
  lowerDistanceParameter = projector.LowerDistanceParameter();
350
431
  } 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);
432
+ if (helpers.samePoint(point, this.firstPoint, precision)) return errors.ok(this.firstParameter);
433
+ if (helpers.samePoint(point, this.lastPoint, precision)) return errors.ok(this.lastParameter);
353
434
  return errors.err(errors.computationError("PARAMETER_NOT_FOUND", "Failed to find parameter"));
354
435
  }
355
436
  if (lowerDistance > precision) {
@@ -412,7 +493,7 @@ class Curve2D {
412
493
  )
413
494
  parameters = parameters.slice(0, -1);
414
495
  if (!parameters.length) return [this];
415
- return shapeHelpers.zip([
496
+ return zip([
416
497
  [firstParam, ...parameters],
417
498
  [...parameters, lastParam]
418
499
  ]).map(([first, last]) => {
@@ -489,7 +570,7 @@ function approximateAsSvgCompatibleCurve(curves, options = {
489
570
  return curves.flatMap((curve) => {
490
571
  const adaptor = r(curve.adaptor());
491
572
  const curveType = errors.unwrap(curveFns.findCurveType(adaptor.GetType()));
492
- if (curveType === "ELLIPSE" || curveType === "CIRCLE" && query.samePoint(curve.firstPoint, curve.lastPoint)) {
573
+ if (curveType === "ELLIPSE" || curveType === "CIRCLE" && helpers.samePoint(curve.firstPoint, curve.lastPoint)) {
493
574
  return curve.splitAt([0.5]);
494
575
  }
495
576
  if (["LINE", "ELLIPSE", "CIRCLE"].includes(curveType)) {
@@ -520,7 +601,7 @@ const make2dSegmentCurve = (startPoint, endPoint) => {
520
601
  const [r, gc] = shapeTypes.localGC();
521
602
  const segment = r(new oc.GCE2d_MakeSegment_1(r(pnt(startPoint)), r(pnt(endPoint)))).Value();
522
603
  const curve = new Curve2D(segment);
523
- if (!query.samePoint(curve.firstPoint, startPoint)) {
604
+ if (!helpers.samePoint(curve.firstPoint, startPoint)) {
524
605
  curve.reverse();
525
606
  }
526
607
  gc();
@@ -534,7 +615,7 @@ const make2dThreePointArc = (startPoint, midPoint, endPoint) => {
534
615
  ).Value();
535
616
  gc();
536
617
  const curve = new Curve2D(segment);
537
- if (!query.samePoint(curve.firstPoint, startPoint)) {
618
+ if (!helpers.samePoint(curve.firstPoint, startPoint)) {
538
619
  curve.wrapped.get().SetTrim(curve.lastParameter, curve.firstParameter, true, true);
539
620
  }
540
621
  return curve;
@@ -547,7 +628,7 @@ const make2dTangentArc = (startPoint, tangent, endPoint) => {
547
628
  ).Value();
548
629
  gc();
549
630
  const curve = new Curve2D(segment);
550
- if (!query.samePoint(curve.firstPoint, startPoint)) {
631
+ if (!helpers.samePoint(curve.firstPoint, startPoint)) {
551
632
  curve.wrapped.get().SetTrim(curve.lastParameter, curve.firstParameter, true, true);
552
633
  }
553
634
  return curve;
@@ -630,12 +711,12 @@ function make2dInerpolatedBSplineCurve(points, {
630
711
  return errors.ok(new Curve2D(splineBuilder.Curve()));
631
712
  }
632
713
  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));
714
+ const midChord = helpers.scalarMultiply2d(helpers.add2d(startPoint, endPoint), 0.5);
715
+ const orientedRadius = helpers.distance2d(center, startPoint) * (longArc ? -1 : 1);
716
+ const midChordDir = helpers.normalize2d(helpers.subtract2d(midChord, center));
636
717
  return make2dThreePointArc(
637
718
  startPoint,
638
- query.add2d(query.scalarMultiply2d(midChordDir, orientedRadius), center),
719
+ helpers.add2d(helpers.scalarMultiply2d(midChordDir, orientedRadius), center),
639
720
  endPoint
640
721
  );
641
722
  };
@@ -1021,7 +1102,7 @@ class Blueprint {
1021
1102
  const originPoint = origin || [...faceFns.faceCenter(face)];
1022
1103
  const originVec3 = occtBoundary.toVec3(originPoint);
1023
1104
  const sketch = this.translate(faceFns.uvCoordinates(face, originVec3)).sketchOnFace(face, "original");
1024
- return errors.unwrap(shapeHelpers.makeFace(sketch.wire));
1105
+ return errors.unwrap(makeFace(sketch.wire));
1025
1106
  }
1026
1107
  /**
1027
1108
  * Cut a prism-shaped hole through a solid along a face using this blueprint.
@@ -1041,7 +1122,7 @@ class Blueprint {
1041
1122
  } = {}) {
1042
1123
  const oc = occtBoundary.getKernel().oc;
1043
1124
  const gc = shapeTypes.gcWithScope();
1044
- const foundFace = errors.unwrap(query.getSingleFace(face, shape));
1125
+ const foundFace = errors.unwrap(helpers.getSingleFace(face, shape));
1045
1126
  const hole = this.subFace(foundFace, origin);
1046
1127
  const maker = gc(
1047
1128
  new oc.BRepFeat_MakeDPrism_1(
@@ -1133,7 +1214,7 @@ class Blueprint {
1133
1214
  }
1134
1215
  /** Check whether the first and last points coincide (the profile is closed). */
1135
1216
  isClosed() {
1136
- return query.samePoint(this.firstPoint, this.lastPoint);
1217
+ return helpers.samePoint(this.firstPoint, this.lastPoint);
1137
1218
  }
1138
1219
  /**
1139
1220
  * Test whether this blueprint's curves intersect with another blueprint's curves.
@@ -1161,6 +1242,7 @@ class Blueprint {
1161
1242
  exports.Blueprint = Blueprint;
1162
1243
  exports.BoundingBox2d = BoundingBox2d;
1163
1244
  exports.Curve2D = Curve2D;
1245
+ exports.addHolesInFace = addHolesInFace;
1164
1246
  exports.approximateAsBSpline = approximateAsBSpline;
1165
1247
  exports.approximateAsSvgCompatibleCurve = approximateAsSvgCompatibleCurve;
1166
1248
  exports.asSVG = asSVG;
@@ -1177,7 +1259,12 @@ exports.make2dInerpolatedBSplineCurve = make2dInerpolatedBSplineCurve;
1177
1259
  exports.make2dSegmentCurve = make2dSegmentCurve;
1178
1260
  exports.make2dTangentArc = make2dTangentArc;
1179
1261
  exports.make2dThreePointArc = make2dThreePointArc;
1262
+ exports.makeFace = makeFace;
1263
+ exports.makeNewFaceWithinFace = makeNewFaceWithinFace;
1264
+ exports.makeNonPlanarFace = makeNonPlanarFace;
1180
1265
  exports.makePlane = makePlane;
1266
+ exports.makePolygon = makePolygon;
1181
1267
  exports.mirror = mirror;
1182
1268
  exports.removeDuplicatePoints = removeDuplicatePoints;
1183
1269
  exports.viewbox = viewbox;
1270
+ exports.zip = zip;