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
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
- const occtBoundary = require("./occtBoundary-du8_ex-p.cjs");
2
+ const occtBoundary = require("./occtBoundary-6kQSl3cF.cjs");
3
3
  const vecOps = require("./vecOps-CjRL1jau.cjs");
4
- const shapeTypes = require("./shapeTypes-DKhwEnUM.cjs");
5
- const cast = require("./cast-DkB0GKmQ.cjs");
4
+ const shapeTypes = require("./shapeTypes-BJ3Hmskg.cjs");
5
+ const cast = require("./cast-DIiyxDLo.cjs");
6
6
  const errors = require("./errors-DK1VAdP4.cjs");
7
- const loft = require("./loft-BzWFokmC.cjs");
8
- const shapeFns = require("./shapeFns-BvOndshS.cjs");
9
- const booleanFns = require("./booleanFns-BBSVKhL2.cjs");
7
+ const loft = require("./loft-DJXwxV_L.cjs");
8
+ const shapeFns = require("./shapeFns-cN4qGpbO.cjs");
9
+ const booleanFns = require("./booleanFns-BxW-N3rP.cjs");
10
10
  function uuidv() {
11
11
  return (String([1e7]) + String(-1e3) + String(-4e3) + String(-8e3) + String(-1e11)).replace(
12
12
  /[018]/g,
@@ -150,6 +150,15 @@ function revolve(face, center = [0, 0, 0], direction = [0, 0, 1], angle = 360) {
150
150
  return errors.ok(result);
151
151
  }
152
152
  function sweep(wire, spine, config = {}, shellMode = false) {
153
+ if (config.mode === "simple" && !shellMode) {
154
+ const kernel = occtBoundary.getKernel();
155
+ const resultOc = kernel.simplePipe(wire.wrapped, spine.wrapped);
156
+ const shape2 = shapeTypes.castShape(resultOc);
157
+ if (!shapeTypes.isShape3D(shape2)) {
158
+ return errors.err(errors.typeCastError("SWEEP_NOT_3D", "Simple pipe did not produce a 3D shape"));
159
+ }
160
+ return errors.ok(shape2);
161
+ }
153
162
  const oc = occtBoundary.getKernel().oc;
154
163
  const r = shapeTypes.gcWithScope();
155
164
  const {
@@ -159,10 +168,24 @@ function sweep(wire, spine, config = {}, shellMode = false) {
159
168
  transitionMode = "right",
160
169
  withContact,
161
170
  support,
162
- forceProfileSpineOthogonality
171
+ forceProfileSpineOthogonality,
172
+ tolerance,
173
+ boundTolerance,
174
+ angularTolerance,
175
+ maxDegree,
176
+ maxSegments
163
177
  } = config;
164
178
  const withCorrection = transitionMode === "round" ? true : !!forceProfileSpineOthogonality;
165
179
  const builder = r(new oc.BRepOffsetAPI_MakePipeShell(spine.wrapped));
180
+ if (tolerance !== void 0) {
181
+ builder.SetTolerance(tolerance, boundTolerance ?? tolerance, angularTolerance ?? 1e-7);
182
+ }
183
+ if (maxDegree !== void 0) {
184
+ builder.SetMaxDegree(maxDegree);
185
+ }
186
+ if (maxSegments !== void 0) {
187
+ builder.SetMaxSegments(maxSegments);
188
+ }
166
189
  {
167
190
  const mode = {
168
191
  transformed: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_Transformed,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const operations = require("./operations-BP1wVDw0.cjs");
4
- const loft = require("./loft-BzWFokmC.cjs");
3
+ const operations = require("./operations-Do-WZGXc.cjs");
4
+ const loft = require("./loft-DJXwxV_L.cjs");
5
5
  exports.addChild = operations.addChild;
6
6
  exports.addStep = operations.addStep;
7
7
  exports.circularPattern = operations.circularPattern;
@@ -1,9 +1,9 @@
1
- import { a, b, c, d, f, g, h, i, j, k, m, n, o, p, l, q, t, u, v, w, x, y, z, A, s, B, C, D, E } from "./operations-C1rWoba2.js";
2
- import { b as b2, g as g2, l as l2, r } from "./loft-CtG5nMq5.js";
1
+ import { a, b, c, d, f, g, h, i, j, k, m, n, o, p, l, q, t, u, v, w, x, y, z, A, s, B, C, D, E } from "./operations-CrQlFDHc.js";
2
+ import { i as i2, j as j2, l as l2, r } from "./loft-Bk9EM0gZ.js";
3
3
  export {
4
4
  a as addChild,
5
5
  b as addStep,
6
- b2 as basicFaceExtrusion,
6
+ i2 as basicFaceExtrusion,
7
7
  c as circularPattern,
8
8
  d as collectShapes,
9
9
  f as complexExtrude,
@@ -15,7 +15,7 @@ export {
15
15
  m as exportAssemblySTEP,
16
16
  n as findNode,
17
17
  o as findStep,
18
- g2 as genericSweep,
18
+ j2 as genericSweep,
19
19
  p as getHistoryShape,
20
20
  l as linearPattern,
21
21
  l2 as loft,
@@ -0,0 +1,48 @@
1
+ import { Point2D } from '../2d/lib/definitions.js';
2
+ import { Curve2D } from '../2d/lib/Curve2D.js';
3
+ /**
4
+ * Minimal Blueprint interface for corner extraction.
5
+ *
6
+ * The full Blueprint class lives in the sketching layer; this interface
7
+ * keeps the query layer decoupled from it so that corner finding does
8
+ * not pull in Layer 3 dependencies.
9
+ */
10
+ export interface BlueprintLike {
11
+ /** Ordered sequence of curves forming the profile. */
12
+ curves: Curve2D[];
13
+ }
14
+ /** A junction between two consecutive curves in a 2D profile. */
15
+ export type Corner = {
16
+ /** The curve arriving at the corner point. */
17
+ firstCurve: Curve2D;
18
+ /** The curve departing from the corner point. */
19
+ secondCurve: Curve2D;
20
+ /** The shared endpoint where the two curves meet. */
21
+ point: Point2D;
22
+ };
23
+ export interface CornerFilter {
24
+ readonly shouldKeep: (corner: Corner) => boolean;
25
+ }
26
+ export interface CornerFinderFn extends CornerFilter {
27
+ /** Add a custom predicate filter. Returns new finder. */
28
+ readonly when: (predicate: (corner: Corner) => boolean) => CornerFinderFn;
29
+ /** Filter to corners whose point matches one from the list. */
30
+ readonly inList: (points: Point2D[]) => CornerFinderFn;
31
+ /** Filter to corners at a specific distance from a point. */
32
+ readonly atDistance: (distance: number, point?: Point2D) => CornerFinderFn;
33
+ /** Filter to corners at an exact point. */
34
+ readonly atPoint: (point: Point2D) => CornerFinderFn;
35
+ /** Filter to corners within an axis-aligned bounding box. */
36
+ readonly inBox: (corner1: Point2D, corner2: Point2D) => CornerFinderFn;
37
+ /** Filter to corners with a specific interior angle (in degrees). */
38
+ readonly ofAngle: (angle: number) => CornerFinderFn;
39
+ /** Invert a filter. Returns new finder. */
40
+ readonly not: (fn: (f: CornerFinderFn) => CornerFinderFn) => CornerFinderFn;
41
+ /** Combine filters with OR. Returns new finder. */
42
+ readonly either: (fns: ((f: CornerFinderFn) => CornerFinderFn)[]) => CornerFinderFn;
43
+ /** Find matching corners from a blueprint. */
44
+ readonly find: (blueprint: BlueprintLike) => Corner[];
45
+ }
46
+ /** Create an immutable corner finder for 2D blueprint corners. */
47
+ export declare function cornerFinder(): CornerFinderFn;
48
+ //# sourceMappingURL=cornerFinder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cornerFinder.d.ts","sourceRoot":"","sources":["../../src/query/cornerFinder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAoBpD;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,sDAAsD;IACtD,MAAM,EAAE,OAAO,EAAE,CAAC;CACnB;AAED,iEAAiE;AACjE,MAAM,MAAM,MAAM,GAAG;IACnB,8CAA8C;IAC9C,UAAU,EAAE,OAAO,CAAC;IACpB,iDAAiD;IACjD,WAAW,EAAE,OAAO,CAAC;IACrB,qDAAqD;IACrD,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;CAClD;AAED,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD,yDAAyD;IACzD,QAAQ,CAAC,IAAI,EAAE,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,KAAK,cAAc,CAAC;IAC1E,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,cAAc,CAAC;IACvD,6DAA6D;IAC7D,QAAQ,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,cAAc,CAAC;IAC3E,2CAA2C;IAC3C,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,cAAc,CAAC;IACrD,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK,cAAc,CAAC;IACvE,qEAAqE;IACrE,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,cAAc,CAAC;IACpD,2CAA2C;IAC3C,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,cAAc,KAAK,cAAc,CAAC;IAC5E,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,KAAK,cAAc,CAAC,EAAE,KAAK,cAAc,CAAC;IACpF,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,CAAC,SAAS,EAAE,aAAa,KAAK,MAAM,EAAE,CAAC;CACvD;AAwED,kEAAkE;AAClE,wBAAgB,YAAY,IAAI,cAAc,CAE7C"}
@@ -0,0 +1,6 @@
1
+ import { Vec3 } from '../core/types.js';
2
+ /** A named axis or an explicit 3D vector. */
3
+ export type DirectionInput = 'X' | 'Y' | 'Z' | Vec3;
4
+ /** Resolve a named axis or passthrough a vector. */
5
+ export declare function resolveDir(dir: DirectionInput): Vec3;
6
+ //# sourceMappingURL=directionUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directionUtils.d.ts","sourceRoot":"","sources":["../../src/query/directionUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAY7C,6CAA6C;AAC7C,MAAM,MAAM,cAAc,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;AAEpD,oDAAoD;AACpD,wBAAgB,UAAU,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAGpD"}
@@ -0,0 +1,15 @@
1
+ import { Vec3 } from '../core/types.js';
2
+ import { Edge } from '../core/shapeTypes.js';
3
+ import { CurveType } from '../core/definitionMaps.js';
4
+ import { ShapeFinder } from './finderCore.js';
5
+ import { DirectionInput } from './directionUtils.js';
6
+ export interface EdgeFinderFn extends ShapeFinder<Edge> {
7
+ readonly inDirection: (dir?: DirectionInput, angle?: number) => EdgeFinderFn;
8
+ readonly ofLength: (length: number, tolerance?: number) => EdgeFinderFn;
9
+ readonly ofCurveType: (curveType: CurveType) => EdgeFinderFn;
10
+ readonly parallelTo: (dir?: DirectionInput) => EdgeFinderFn;
11
+ readonly atDistance: (distance: number, point?: Vec3) => EdgeFinderFn;
12
+ }
13
+ /** Create an immutable edge finder. */
14
+ export declare function edgeFinder(): EdgeFinderFn;
15
+ //# sourceMappingURL=edgeFinder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edgeFinder.d.ts","sourceRoot":"","sources":["../../src/query/edgeFinder.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAMlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,KAAK,WAAW,EAAqC,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAE,KAAK,cAAc,EAAc,MAAM,qBAAqB,CAAC;AAOtE,MAAM,WAAW,YAAa,SAAQ,WAAW,CAAC,IAAI,CAAC;IACrD,QAAQ,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC;IAC7E,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC;IACxE,QAAQ,CAAC,WAAW,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,YAAY,CAAC;IAC7D,QAAQ,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE,cAAc,KAAK,YAAY,CAAC;IAC5D,QAAQ,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,IAAI,KAAK,YAAY,CAAC;CACvE;AAiDD,uCAAuC;AACvC,wBAAgB,UAAU,IAAI,YAAY,CAEzC"}
@@ -0,0 +1,15 @@
1
+ import { Vec3 } from '../core/types.js';
2
+ import { Face } from '../core/shapeTypes.js';
3
+ import { SurfaceType } from '../topology/faceFns.js';
4
+ import { ShapeFinder } from './finderCore.js';
5
+ import { DirectionInput } from './directionUtils.js';
6
+ export interface FaceFinderFn extends ShapeFinder<Face> {
7
+ readonly inDirection: (dir?: DirectionInput, angle?: number) => FaceFinderFn;
8
+ readonly parallelTo: (dir?: DirectionInput) => FaceFinderFn;
9
+ readonly ofSurfaceType: (surfaceType: SurfaceType) => FaceFinderFn;
10
+ readonly ofArea: (area: number, tolerance?: number) => FaceFinderFn;
11
+ readonly atDistance: (distance: number, point?: Vec3) => FaceFinderFn;
12
+ }
13
+ /** Create an immutable face finder. */
14
+ export declare function faceFinder(): FaceFinderFn;
15
+ //# sourceMappingURL=faceFinder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"faceFinder.d.ts","sourceRoot":"","sources":["../../src/query/faceFinder.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAGlD,OAAO,EAA4C,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGpG,OAAO,EAAE,KAAK,WAAW,EAAqC,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAE,KAAK,cAAc,EAAc,MAAM,qBAAqB,CAAC;AAOtE,MAAM,WAAW,YAAa,SAAQ,WAAW,CAAC,IAAI,CAAC;IACrD,QAAQ,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC;IAC7E,QAAQ,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE,cAAc,KAAK,YAAY,CAAC;IAC5D,QAAQ,CAAC,aAAa,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,YAAY,CAAC;IACnE,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC;IACpE,QAAQ,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,IAAI,KAAK,YAAY,CAAC;CACvE;AA0CD,uCAAuC;AACvC,wBAAgB,UAAU,IAAI,YAAY,CAEzC"}
@@ -0,0 +1,35 @@
1
+ import { AnyShape } from '../core/shapeTypes.js';
2
+ import { Result } from '../core/result.js';
3
+ export type Predicate<T> = (element: T) => boolean;
4
+ export type TopoKind = 'edge' | 'face' | 'wire' | 'vertex';
5
+ export interface ShapeFinder<T extends AnyShape> {
6
+ /** Add a custom predicate filter. Returns new finder. */
7
+ readonly when: (predicate: Predicate<T>) => ShapeFinder<T>;
8
+ /** Filter to elements in a list. Returns new finder. */
9
+ readonly inList: (elements: T[]) => ShapeFinder<T>;
10
+ /** Invert a filter. Returns new finder. */
11
+ readonly not: (builderFn: (f: ShapeFinder<T>) => ShapeFinder<T>) => ShapeFinder<T>;
12
+ /** Combine filters with OR. Returns new finder. */
13
+ readonly either: (fns: ((f: ShapeFinder<T>) => ShapeFinder<T>)[]) => ShapeFinder<T>;
14
+ /** Find all matching elements from a shape. */
15
+ readonly findAll: (shape: AnyShape) => T[];
16
+ /** Find exactly one matching element. Returns error if 0 or more than 1 match. */
17
+ readonly findUnique: (shape: AnyShape) => Result<T>;
18
+ /** Check if an element passes all filters. */
19
+ readonly shouldKeep: (element: T) => boolean;
20
+ readonly _filters: ReadonlyArray<Predicate<T>>;
21
+ readonly _topoKind: TopoKind;
22
+ }
23
+ /**
24
+ * Build a typed finder that extends `ShapeFinder<T>` with domain-specific
25
+ * filter methods. The `rebuild` callback re-creates the full typed finder
26
+ * whenever a new filter is added, eliminating the per-finder boilerplate
27
+ * for `when`, `inList`, `not`, `either`, etc.
28
+ *
29
+ * @param topoKind - topology iteration target
30
+ * @param filters - accumulated predicates (immutable list)
31
+ * @param rebuild - reconstruct the typed finder from a new filter list
32
+ * @param extend - attach domain-specific methods onto the base finder
33
+ */
34
+ export declare function createTypedFinder<T extends AnyShape, F extends ShapeFinder<T>>(topoKind: TopoKind, filters: ReadonlyArray<Predicate<T>>, rebuild: (newFilters: ReadonlyArray<Predicate<T>>) => F, extend: (base: ShapeFinder<T>, withFilter: (pred: Predicate<T>) => F) => Omit<F, keyof ShapeFinder<T>>): F;
35
+ //# sourceMappingURL=finderCore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"finderCore.d.ts","sourceRoot":"","sources":["../../src/query/finderCore.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,KAAK,MAAM,EAAmB,MAAM,mBAAmB,CAAC;AASjE,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,OAAO,CAAC;AAMnD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AAM3D,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,QAAQ;IAC7C,yDAAyD;IACzD,QAAQ,CAAC,IAAI,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,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CACN,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EACpB,UAAU,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAClC,IAAI,CAAC,CAAC,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,CAAC,GACjC,CAAC,CAsEH"}
@@ -1,110 +1,25 @@
1
- import { Vec3 } from '../core/types.js';
2
- import { AnyShape, Edge, Face, Wire, Vertex } from '../core/shapeTypes.js';
3
- import { Point2D } from '../2d/lib/definitions.js';
4
- import { Curve2D } from '../2d/lib/Curve2D.js';
5
- import { SurfaceType } from '../topology/faceFns.js';
6
- import { CurveType } from '../core/definitionMaps.js';
7
- import { Result } from '../core/result.js';
8
- type Predicate<T> = (element: T) => boolean;
9
- export interface ShapeFinder<T extends AnyShape> {
10
- /** Add a custom predicate filter. Returns new finder. */
11
- readonly when: (predicate: Predicate<T>) => ShapeFinder<T>;
12
- /** Filter to elements in a list. Returns new finder. */
13
- readonly inList: (elements: T[]) => ShapeFinder<T>;
14
- /** Invert a filter. Returns new finder. */
15
- readonly not: (builderFn: (f: ShapeFinder<T>) => ShapeFinder<T>) => ShapeFinder<T>;
16
- /** Combine filters with OR. Returns new finder. */
17
- readonly either: (fns: ((f: ShapeFinder<T>) => ShapeFinder<T>)[]) => ShapeFinder<T>;
18
- /** Find all matching elements from a shape. */
19
- readonly findAll: (shape: AnyShape) => T[];
20
- /** Find exactly one matching element. Returns error if 0 or more than 1 match. */
21
- readonly findUnique: (shape: AnyShape) => Result<T>;
22
- /** Check if an element passes all filters. */
23
- readonly shouldKeep: (element: T) => boolean;
24
- readonly _filters: ReadonlyArray<Predicate<T>>;
25
- readonly _topoKind: 'edge' | 'face' | 'wire' | 'vertex';
26
- }
27
- export interface EdgeFinderFn extends ShapeFinder<Edge> {
28
- readonly inDirection: (dir?: 'X' | 'Y' | 'Z' | Vec3, angle?: number) => EdgeFinderFn;
29
- readonly ofLength: (length: number, tolerance?: number) => EdgeFinderFn;
30
- readonly ofCurveType: (curveType: CurveType) => EdgeFinderFn;
31
- readonly parallelTo: (dir?: 'X' | 'Y' | 'Z' | Vec3) => EdgeFinderFn;
32
- readonly atDistance: (distance: number, point?: Vec3) => EdgeFinderFn;
33
- }
34
- /** Create an immutable edge finder. */
35
- export declare function edgeFinder(): EdgeFinderFn;
36
- export interface FaceFinderFn extends ShapeFinder<Face> {
37
- readonly inDirection: (dir?: 'X' | 'Y' | 'Z' | Vec3, angle?: number) => FaceFinderFn;
38
- readonly parallelTo: (dir?: 'X' | 'Y' | 'Z' | Vec3) => FaceFinderFn;
39
- readonly ofSurfaceType: (surfaceType: SurfaceType) => FaceFinderFn;
40
- readonly ofArea: (area: number, tolerance?: number) => FaceFinderFn;
41
- readonly atDistance: (distance: number, point?: Vec3) => FaceFinderFn;
42
- }
43
- /** Create an immutable face finder. */
44
- export declare function faceFinder(): FaceFinderFn;
45
- export interface WireFinderFn extends ShapeFinder<Wire> {
46
- readonly isClosed: () => WireFinderFn;
47
- readonly isOpen: () => WireFinderFn;
48
- readonly ofEdgeCount: (count: number) => WireFinderFn;
49
- }
50
- /** Create an immutable wire finder. */
51
- export declare function wireFinder(): WireFinderFn;
52
- export interface VertexFinderFn extends ShapeFinder<Vertex> {
53
- /** Filter vertices nearest to a reference point. Returns a new finder that keeps only the closest vertex. */
54
- readonly nearestTo: (point: Vec3) => VertexFinderFn;
55
- /** Filter vertices at an exact position (within tolerance). */
56
- readonly atPosition: (point: Vec3, tolerance?: number) => VertexFinderFn;
57
- /** Filter vertices within an axis-aligned bounding box. */
58
- readonly withinBox: (min: Vec3, max: Vec3) => VertexFinderFn;
59
- /** Filter vertices at a given distance from a point. */
60
- readonly atDistance: (distance: number, point?: Vec3, tolerance?: number) => VertexFinderFn;
61
- }
62
- /** Create an immutable vertex finder. */
63
- export declare function vertexFinder(): VertexFinderFn;
64
1
  /**
65
- * Minimal Blueprint interface for corner extraction.
2
+ * Functional, immutable finder filter-based shape querying with branded types.
3
+ * Each filter method returns a NEW finder (immutable builder pattern).
66
4
  *
67
- * The full Blueprint class lives in the sketching layer; this interface
68
- * keeps the query layer decoupled from it so that corner finding does
69
- * not pull in Layer 3 dependencies.
5
+ * Usage:
6
+ * const edges = edgeFinder()
7
+ * .inDirection('Z')
8
+ * .ofLength(10, 0.01)
9
+ * .findAll(shape);
10
+ *
11
+ * This barrel re-exports everything from the individual finder modules
12
+ * so that existing imports from `'./finderFns.js'` continue to work.
70
13
  */
71
- export interface BlueprintLike {
72
- /** Ordered sequence of curves forming the profile. */
73
- curves: Curve2D[];
74
- }
75
- /** A junction between two consecutive curves in a 2D profile. */
76
- export type Corner = {
77
- /** The curve arriving at the corner point. */
78
- firstCurve: Curve2D;
79
- /** The curve departing from the corner point. */
80
- secondCurve: Curve2D;
81
- /** The shared endpoint where the two curves meet. */
82
- point: Point2D;
83
- };
84
- export interface CornerFilter {
85
- readonly shouldKeep: (corner: Corner) => boolean;
86
- }
87
- export interface CornerFinderFn extends CornerFilter {
88
- /** Add a custom predicate filter. Returns new finder. */
89
- readonly when: (predicate: (corner: Corner) => boolean) => CornerFinderFn;
90
- /** Filter to corners whose point matches one from the list. */
91
- readonly inList: (points: Point2D[]) => CornerFinderFn;
92
- /** Filter to corners at a specific distance from a point. */
93
- readonly atDistance: (distance: number, point?: Point2D) => CornerFinderFn;
94
- /** Filter to corners at an exact point. */
95
- readonly atPoint: (point: Point2D) => CornerFinderFn;
96
- /** Filter to corners within an axis-aligned bounding box. */
97
- readonly inBox: (corner1: Point2D, corner2: Point2D) => CornerFinderFn;
98
- /** Filter to corners with a specific interior angle (in degrees). */
99
- readonly ofAngle: (angle: number) => CornerFinderFn;
100
- /** Invert a filter. Returns new finder. */
101
- readonly not: (fn: (f: CornerFinderFn) => CornerFinderFn) => CornerFinderFn;
102
- /** Combine filters with OR. Returns new finder. */
103
- readonly either: (fns: ((f: CornerFinderFn) => CornerFinderFn)[]) => CornerFinderFn;
104
- /** Find matching corners from a blueprint. */
105
- readonly find: (blueprint: BlueprintLike) => Corner[];
106
- }
107
- /** Create an immutable corner finder for 2D blueprint corners. */
108
- export declare function cornerFinder(): CornerFinderFn;
109
- export {};
14
+ export type { ShapeFinder, Predicate, TopoKind } from './finderCore.js';
15
+ export { edgeFinder } from './edgeFinder.js';
16
+ export type { EdgeFinderFn } from './edgeFinder.js';
17
+ export { faceFinder } from './faceFinder.js';
18
+ export type { FaceFinderFn } from './faceFinder.js';
19
+ export { wireFinder } from './wireFinder.js';
20
+ export type { WireFinderFn } from './wireFinder.js';
21
+ export { vertexFinder } from './vertexFinder.js';
22
+ export type { VertexFinderFn } from './vertexFinder.js';
23
+ export { cornerFinder } from './cornerFinder.js';
24
+ export type { CornerFinderFn, CornerFilter, Corner, BlueprintLike } from './cornerFinder.js';
110
25
  //# sourceMappingURL=finderFns.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"finderFns.d.ts","sourceRoot":"","sources":["../../src/query/finderFns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAK7C,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAKpD,OAAO,EAA4C,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGpG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,KAAK,MAAM,EAAmB,MAAM,mBAAmB,CAAC;AAOjE,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,OAAO,CAAC;AAM5C,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,QAAQ;IAC7C,yDAAyD;IACzD,QAAQ,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;AAC7C,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { Vec3 } from '../core/types.js';
2
+ import { AnyShape } from '../core/shapeTypes.js';
3
+ import { Predicate } from './finderCore.js';
4
+ /**
5
+ * Create a predicate that checks whether a shape element's minimum distance
6
+ * from `point` equals `distance` (within `tolerance`).
7
+ *
8
+ * Uses OCCT's `BRepExtrema_DistShapeShape` and works for any shape type.
9
+ */
10
+ export declare function distanceFromPointFilter<T extends AnyShape>(distance: number, point: Vec3, tolerance: number): Predicate<T>;
11
+ //# sourceMappingURL=shapeDistanceFilter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shapeDistanceFilter.d.ts","sourceRoot":"","sources":["../../src/query/shapeDistanceFilter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAItD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,QAAQ,EACxD,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,IAAI,EACX,SAAS,EAAE,MAAM,GAChB,SAAS,CAAC,CAAC,CAAC,CAmBd"}
@@ -0,0 +1,16 @@
1
+ import { Vec3 } from '../core/types.js';
2
+ import { Vertex } from '../core/shapeTypes.js';
3
+ import { ShapeFinder } from './finderCore.js';
4
+ export interface VertexFinderFn extends ShapeFinder<Vertex> {
5
+ /** Filter vertices nearest to a reference point. Returns a new finder that keeps only the closest vertex. */
6
+ readonly nearestTo: (point: Vec3) => VertexFinderFn;
7
+ /** Filter vertices at an exact position (within tolerance). */
8
+ readonly atPosition: (point: Vec3, tolerance?: number) => VertexFinderFn;
9
+ /** Filter vertices within an axis-aligned bounding box. */
10
+ readonly withinBox: (min: Vec3, max: Vec3) => VertexFinderFn;
11
+ /** Filter vertices at a given distance from a point. */
12
+ readonly atDistance: (distance: number, point?: Vec3, tolerance?: number) => VertexFinderFn;
13
+ }
14
+ /** Create an immutable vertex finder. */
15
+ export declare function vertexFinder(): VertexFinderFn;
16
+ //# sourceMappingURL=vertexFinder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vertexFinder.d.ts","sourceRoot":"","sources":["../../src/query/vertexFinder.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAY,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAK9D,OAAO,EAAE,KAAK,WAAW,EAAqC,MAAM,iBAAiB,CAAC;AAMtF,MAAM,WAAW,cAAe,SAAQ,WAAW,CAAC,MAAM,CAAC;IACzD,6GAA6G;IAC7G,QAAQ,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,cAAc,CAAC;IACpD,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,cAAc,CAAC;IACzE,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,KAAK,cAAc,CAAC;IAC7D,wDAAwD;IACxD,QAAQ,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,cAAc,CAAC;CAC7F;AAuFD,yCAAyC;AACzC,wBAAgB,YAAY,IAAI,cAAc,CAE7C"}
@@ -0,0 +1,10 @@
1
+ import { Wire } from '../core/shapeTypes.js';
2
+ import { ShapeFinder } from './finderCore.js';
3
+ export interface WireFinderFn extends ShapeFinder<Wire> {
4
+ readonly isClosed: () => WireFinderFn;
5
+ readonly isOpen: () => WireFinderFn;
6
+ readonly ofEdgeCount: (count: number) => WireFinderFn;
7
+ }
8
+ /** Create an immutable wire finder. */
9
+ export declare function wireFinder(): WireFinderFn;
10
+ //# sourceMappingURL=wireFinder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wireFinder.d.ts","sourceRoot":"","sources":["../../src/query/wireFinder.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAGlD,OAAO,EAAE,KAAK,WAAW,EAAqC,MAAM,iBAAiB,CAAC;AAMtF,MAAM,WAAW,YAAa,SAAQ,WAAW,CAAC,IAAI,CAAC;IACrD,QAAQ,CAAC,QAAQ,EAAE,MAAM,YAAY,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,YAAY,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,YAAY,CAAC;CACvD;AA4BD,uCAAuC;AACvC,wBAAgB,UAAU,IAAI,YAAY,CAEzC"}
package/dist/query.cjs CHANGED
@@ -1,7 +1,44 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const query = require("./query-hMSmOWJP.cjs");
4
- exports.cornerFinder = query.cornerFinder;
5
- exports.edgeFinder = query.edgeFinder;
6
- exports.faceFinder = query.faceFinder;
7
- exports.getSingleFace = query.getSingleFace;
3
+ const helpers = require("./helpers-Ck8GJ58k.cjs");
4
+ const cornerFinder = require("./cornerFinder-BndBNtJE.cjs");
5
+ const occtBoundary = require("./occtBoundary-6kQSl3cF.cjs");
6
+ const shapeTypes = require("./shapeTypes-BJ3Hmskg.cjs");
7
+ const vecOps = require("./vecOps-CjRL1jau.cjs");
8
+ const curveFns = require("./curveFns-BrJDkaWi.cjs");
9
+ function edgeDirectionFilter(dir, angle) {
10
+ const d = vecOps.vecNormalize(helpers.resolveDir(dir));
11
+ return (edge) => {
12
+ const oc = occtBoundary.getKernel().oc;
13
+ const r = shapeTypes.gcWithScope();
14
+ const adaptor = r(new oc.BRepAdaptor_Curve_2(edge.wrapped));
15
+ const tmpPnt = r(new oc.gp_Pnt_1());
16
+ const tmpVec = r(new oc.gp_Vec_1());
17
+ const mid = (Number(adaptor.FirstParameter()) + Number(adaptor.LastParameter())) / 2;
18
+ adaptor.D1(mid, tmpPnt, tmpVec);
19
+ const tangent = vecOps.vecNormalize([tmpVec.X(), tmpVec.Y(), tmpVec.Z()]);
20
+ const ang = Math.acos(Math.min(1, Math.abs(vecOps.vecDot(tangent, d))));
21
+ return Math.abs(ang - vecOps.DEG2RAD * angle) < 1e-6;
22
+ };
23
+ }
24
+ function buildEdgeFinder(filters) {
25
+ return helpers.createTypedFinder(
26
+ "edge",
27
+ filters,
28
+ buildEdgeFinder,
29
+ (_base, withFilter) => ({
30
+ inDirection: (dir = "Z", angle = 0) => withFilter(edgeDirectionFilter(dir, angle)),
31
+ ofLength: (length, tolerance = 1e-3) => withFilter((edge) => Math.abs(curveFns.curveLength(edge) - length) < tolerance),
32
+ ofCurveType: (curveType) => withFilter((edge) => curveFns.getCurveType(edge) === curveType),
33
+ parallelTo: (dir = "Z") => buildEdgeFinder(filters).inDirection(dir, 0),
34
+ atDistance: (distance, point = [0, 0, 0]) => withFilter(helpers.distanceFromPointFilter(distance, point, 1e-6))
35
+ })
36
+ );
37
+ }
38
+ function edgeFinder() {
39
+ return buildEdgeFinder([]);
40
+ }
41
+ exports.faceFinder = helpers.faceFinder;
42
+ exports.getSingleFace = helpers.getSingleFace;
43
+ exports.cornerFinder = cornerFinder.cornerFinder;
44
+ exports.edgeFinder = edgeFinder;
package/dist/query.js CHANGED
@@ -1,7 +1,45 @@
1
- import { c, e, f, g } from "./query-V6nV-VfL.js";
1
+ import { c as createTypedFinder, o as distanceFromPointFilter, q as resolveDir } from "./helpers-jku2V1DY.js";
2
+ import { f, g } from "./helpers-jku2V1DY.js";
3
+ import { c } from "./cornerFinder-DzGzfiqb.js";
4
+ import { g as getKernel } from "./occtBoundary-CqXvDhZY.js";
5
+ import { p as gcWithScope } from "./shapeTypes-C9sUsmEW.js";
6
+ import { j as vecNormalize, d as vecDot, D as DEG2RAD } from "./vecOps-ZDdZWbwT.js";
7
+ import { l as getCurveType, f as curveLength } from "./curveFns-BshHA9Ys.js";
8
+ function edgeDirectionFilter(dir, angle) {
9
+ const d = vecNormalize(resolveDir(dir));
10
+ return (edge) => {
11
+ const oc = getKernel().oc;
12
+ const r = gcWithScope();
13
+ const adaptor = r(new oc.BRepAdaptor_Curve_2(edge.wrapped));
14
+ const tmpPnt = r(new oc.gp_Pnt_1());
15
+ const tmpVec = r(new oc.gp_Vec_1());
16
+ const mid = (Number(adaptor.FirstParameter()) + Number(adaptor.LastParameter())) / 2;
17
+ adaptor.D1(mid, tmpPnt, tmpVec);
18
+ const tangent = vecNormalize([tmpVec.X(), tmpVec.Y(), tmpVec.Z()]);
19
+ const ang = Math.acos(Math.min(1, Math.abs(vecDot(tangent, d))));
20
+ return Math.abs(ang - DEG2RAD * angle) < 1e-6;
21
+ };
22
+ }
23
+ function buildEdgeFinder(filters) {
24
+ return createTypedFinder(
25
+ "edge",
26
+ filters,
27
+ buildEdgeFinder,
28
+ (_base, withFilter) => ({
29
+ inDirection: (dir = "Z", angle = 0) => withFilter(edgeDirectionFilter(dir, angle)),
30
+ ofLength: (length, tolerance = 1e-3) => withFilter((edge) => Math.abs(curveLength(edge) - length) < tolerance),
31
+ ofCurveType: (curveType) => withFilter((edge) => getCurveType(edge) === curveType),
32
+ parallelTo: (dir = "Z") => buildEdgeFinder(filters).inDirection(dir, 0),
33
+ atDistance: (distance, point = [0, 0, 0]) => withFilter(distanceFromPointFilter(distance, point, 1e-6))
34
+ })
35
+ );
36
+ }
37
+ function edgeFinder() {
38
+ return buildEdgeFinder([]);
39
+ }
2
40
  export {
3
41
  c as cornerFinder,
4
- e as edgeFinder,
42
+ edgeFinder,
5
43
  f as faceFinder,
6
44
  g as getSingleFace
7
45
  };
@@ -1,7 +1,7 @@
1
- import { g as getKernel, b as toOcVec, m as makeOcAx1, c as makeOcAx2, d as toOcPnt } from "./occtBoundary-CwegMzqc.js";
2
- import { c as castShape, g as getShapeKind } from "./shapeTypes-BlSElW8z.js";
1
+ import { g as getKernel, c as toOcVec, e as makeOcAx1, m as makeOcAx2, b as toOcPnt } from "./occtBoundary-CqXvDhZY.js";
2
+ import { c as castShape, g as getShapeKind, p as gcWithScope } from "./shapeTypes-C9sUsmEW.js";
3
3
  import { H as HASH_CODE_MAX, D as DEG2RAD } from "./vecOps-ZDdZWbwT.js";
4
- import { i as iterTopo, d as downcast } from "./cast-DQaUibmm.js";
4
+ import { i as iterTopo, d as downcast } from "./cast-C4Ff_1Qe.js";
5
5
  import { u as unwrap } from "./errors-wGhcJMpB.js";
6
6
  function clone(shape) {
7
7
  return castShape(unwrap(downcast(shape.wrapped)));
@@ -24,11 +24,10 @@ function isEqualShape(a, b) {
24
24
  }
25
25
  function simplify(shape) {
26
26
  const oc = getKernel().oc;
27
- const upgrader = new oc.ShapeUpgrade_UnifySameDomain_2(shape.wrapped, true, true, false);
27
+ const r = gcWithScope();
28
+ const upgrader = r(new oc.ShapeUpgrade_UnifySameDomain_2(shape.wrapped, true, true, false));
28
29
  upgrader.Build();
29
- const result = castShape(upgrader.Shape());
30
- upgrader.delete();
31
- return result;
30
+ return castShape(upgrader.Shape());
32
31
  }
33
32
  function translate(shape, v) {
34
33
  const oc = getKernel().oc;
@@ -179,20 +178,20 @@ function vertexPosition(vertex) {
179
178
  return result;
180
179
  }
181
180
  export {
182
- simplify as a,
183
- toBREP as b,
181
+ getEdges as a,
182
+ isEmpty as b,
184
183
  clone as c,
185
184
  describe as d,
186
- getBounds as e,
187
- getFaces as f,
188
- getEdges as g,
189
- getVertices as h,
190
- isEmpty as i,
191
- getWires as j,
192
- getHashCode as k,
193
- isEqualShape as l,
185
+ simplify as e,
186
+ toBREP as f,
187
+ getHashCode as g,
188
+ getBounds as h,
189
+ isSameShape as i,
190
+ getFaces as j,
191
+ getVertices as k,
192
+ getWires as l,
194
193
  mirror as m,
195
- isSameShape as n,
194
+ isEqualShape as n,
196
195
  iterEdges as o,
197
196
  iterFaces as p,
198
197
  iterVertices as q,