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.
- package/dist/2d/blueprints/booleanHelpers.d.ts +32 -0
- package/dist/2d/blueprints/booleanHelpers.d.ts.map +1 -0
- package/dist/2d/blueprints/booleanOperations.d.ts +5 -3
- package/dist/2d/blueprints/booleanOperations.d.ts.map +1 -1
- package/dist/2d/blueprints/intersectionSegments.d.ts +12 -0
- package/dist/2d/blueprints/intersectionSegments.d.ts.map +1 -0
- package/dist/2d/blueprints/segmentAssembly.d.ts +31 -0
- package/dist/2d/blueprints/segmentAssembly.d.ts.map +1 -0
- package/dist/2d.cjs +2 -2
- package/dist/2d.js +8 -8
- package/dist/{Blueprint-D3JfGJTz.js → Blueprint-DnAO3gr5.js} +116 -30
- package/dist/{Blueprint-CVctc41Z.cjs → Blueprint-FxmMji4s.cjs} +110 -24
- package/dist/{boolean2D-hOw5Qay5.js → boolean2D-BnZKKBWU.js} +391 -310
- package/dist/{boolean2D-BdZATaHs.cjs → boolean2D-BrjHZfWn.cjs} +426 -345
- package/dist/{booleanFns-CqehfzcK.js → booleanFns-Ct3wDnhc.js} +14 -18
- package/dist/{booleanFns-BBSVKhL2.cjs → booleanFns-ND7sZvhu.cjs} +12 -16
- package/dist/brepjs.cjs +171 -101
- package/dist/brepjs.js +315 -244
- package/dist/{cast-DQaUibmm.js → cast-BEg1mN7n.js} +2 -2
- package/dist/{cast-DkB0GKmQ.cjs → cast-CqDc8oFW.cjs} +2 -2
- package/dist/core/disposal.d.ts +1 -1
- package/dist/core/disposal.d.ts.map +1 -1
- package/dist/core.cjs +3 -3
- package/dist/core.js +3 -3
- package/dist/cornerFinder-89obDwGi.js +59 -0
- package/dist/cornerFinder-BKsCkrXd.cjs +58 -0
- package/dist/curveBuilders-BjtdNw1B.cjs +196 -0
- package/dist/curveBuilders-U26XDfxg.js +197 -0
- package/dist/curveFns-BoG_iA07.cjs +375 -0
- package/dist/curveFns-Cg99XKe2.js +376 -0
- package/dist/{drawFns-CUyx50gi.cjs → drawFns-C-MCkYj6.cjs} +60 -62
- package/dist/{drawFns-921SkhDL.js → drawFns-DJV-nOox.js} +12 -14
- package/dist/{faceFns-DHu-2JpA.js → faceFns-CyokaCDr.js} +3 -3
- package/dist/{faceFns-BwK7FP7N.cjs → faceFns-DcSCjDG0.cjs} +3 -3
- package/dist/helpers--iZxPeJg.cjs +203 -0
- package/dist/helpers-CRx_ks-u.js +204 -0
- package/dist/io.cjs +4 -4
- package/dist/io.js +4 -4
- package/dist/kernel/curveOps.d.ts.map +1 -1
- package/dist/kernel/meshOps.d.ts.map +1 -1
- package/dist/kernel/modifierOps.d.ts.map +1 -1
- package/dist/kernel/occtAdapter.d.ts +1 -0
- package/dist/kernel/occtAdapter.d.ts.map +1 -1
- package/dist/kernel/sweepOps.d.ts +8 -0
- package/dist/kernel/sweepOps.d.ts.map +1 -1
- package/dist/kernel/types.d.ts +1 -0
- package/dist/kernel/types.d.ts.map +1 -1
- package/dist/loft-8asn63t4.cjs +372 -0
- package/dist/loft-jIkZRqHm.js +373 -0
- package/dist/{measurement-C5JGCuUP.js → measurement-DWv8kK6J.js} +3 -3
- package/dist/{measurement-fxm_pW7x.cjs → measurement-lRLwaoqD.cjs} +3 -3
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-BhrZGi6w.cjs → meshFns-DWuLC3fk.cjs} +29 -9
- package/dist/{meshFns-AqAjTTVl.js → meshFns-DgAIL1B-.js} +29 -9
- package/dist/{occtBoundary-du8_ex-p.cjs → occtBoundary-DHtzU4tz.cjs} +93 -61
- package/dist/{occtBoundary-CwegMzqc.js → occtBoundary-DYsksDtE.js} +98 -66
- package/dist/operations/extrude.d.ts.map +1 -1
- package/dist/operations/extrudeFns.d.ts.map +1 -1
- package/dist/operations/extrudeUtils.d.ts +17 -0
- package/dist/operations/extrudeUtils.d.ts.map +1 -1
- package/dist/operations/patternFns.d.ts.map +1 -1
- package/dist/{operations-C1rWoba2.js → operations-B8FHVC22.js} +54 -9
- package/dist/{operations-BP1wVDw0.cjs → operations-CCFPvtd-.cjs} +54 -9
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +4 -4
- package/dist/query/cornerFinder.d.ts +48 -0
- package/dist/query/cornerFinder.d.ts.map +1 -0
- package/dist/query/directionUtils.d.ts +6 -0
- package/dist/query/directionUtils.d.ts.map +1 -0
- package/dist/query/edgeFinder.d.ts +15 -0
- package/dist/query/edgeFinder.d.ts.map +1 -0
- package/dist/query/faceFinder.d.ts +15 -0
- package/dist/query/faceFinder.d.ts.map +1 -0
- package/dist/query/finderCore.d.ts +35 -0
- package/dist/query/finderCore.d.ts.map +1 -0
- package/dist/query/finderFns.d.ts +21 -106
- package/dist/query/finderFns.d.ts.map +1 -1
- package/dist/query/shapeDistanceFilter.d.ts +11 -0
- package/dist/query/shapeDistanceFilter.d.ts.map +1 -0
- package/dist/query/vertexFinder.d.ts +16 -0
- package/dist/query/vertexFinder.d.ts.map +1 -0
- package/dist/query/wireFinder.d.ts +10 -0
- package/dist/query/wireFinder.d.ts.map +1 -0
- package/dist/query.cjs +42 -5
- package/dist/query.js +40 -2
- package/dist/{shapeTypes-DKhwEnUM.cjs → shapeTypes-b_lhwQB7.cjs} +24 -20
- package/dist/{shapeTypes-BlSElW8z.js → shapeTypes-i7VwMRwc.js} +32 -28
- package/dist/sketching/Sketcher.d.ts.map +1 -1
- package/dist/sketching/Sketcher2d.d.ts +12 -4
- package/dist/sketching/Sketcher2d.d.ts.map +1 -1
- package/dist/sketching/ellipseUtils.d.ts +29 -0
- package/dist/sketching/ellipseUtils.d.ts.map +1 -0
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/topology/booleanFns.d.ts.map +1 -1
- package/dist/topology/curveBuilders.d.ts +75 -0
- package/dist/topology/curveBuilders.d.ts.map +1 -0
- package/dist/topology/curveFns.d.ts.map +1 -1
- package/dist/topology/meshFns.d.ts.map +1 -1
- package/dist/topology/primitiveFns.d.ts.map +1 -1
- package/dist/topology/shapeFns.d.ts.map +1 -1
- package/dist/topology/shapeHelpers.d.ts +6 -173
- package/dist/topology/shapeHelpers.d.ts.map +1 -1
- package/dist/topology/shapeUtils.d.ts +13 -0
- package/dist/topology/shapeUtils.d.ts.map +1 -0
- package/dist/topology/solidBuilders.d.ts +70 -0
- package/dist/topology/solidBuilders.d.ts.map +1 -0
- package/dist/topology/surfaceBuilders.d.ts +35 -0
- package/dist/topology/surfaceBuilders.d.ts.map +1 -0
- package/dist/topology/wrapperFns.d.ts +1 -0
- package/dist/topology/wrapperFns.d.ts.map +1 -1
- package/dist/{topology-tFzqSrGH.js → topology-Bh-aPIxA.js} +7 -8
- package/dist/{topology-CIooytHH.cjs → topology-ByOn_z3E.cjs} +12 -13
- package/dist/topology.cjs +33 -34
- package/dist/topology.js +54 -55
- package/dist/{vectors-CBuaMeZv.js → vectors-DWLjb9-P.js} +1 -1
- package/dist/{vectors-ChWEZPwy.cjs → vectors-aQBZK0Sb.cjs} +1 -1
- package/dist/vectors.cjs +2 -2
- package/dist/vectors.js +2 -2
- package/package.json +1 -1
- package/dist/curveFns-BilyYL_s.cjs +0 -190
- package/dist/curveFns-CdVE4da7.js +0 -191
- package/dist/loft-BzWFokmC.cjs +0 -178
- package/dist/loft-CtG5nMq5.js +0 -179
- package/dist/query-V6nV-VfL.js +0 -396
- package/dist/query-hMSmOWJP.cjs +0 -395
- package/dist/shapeFns-BrF97sKt.js +0 -204
- package/dist/shapeFns-BvOndshS.cjs +0 -203
- package/dist/shapeHelpers-B2SXz1p4.cjs +0 -488
- package/dist/shapeHelpers-BcoZf2N9.js +0 -489
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const occtBoundary = require("./occtBoundary-
|
|
2
|
+
const occtBoundary = require("./occtBoundary-DHtzU4tz.cjs");
|
|
3
3
|
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
4
|
-
const shapeTypes = require("./shapeTypes-
|
|
5
|
-
const cast = require("./cast-
|
|
4
|
+
const shapeTypes = require("./shapeTypes-b_lhwQB7.cjs");
|
|
5
|
+
const cast = require("./cast-CqDc8oFW.cjs");
|
|
6
6
|
const errors = require("./errors-DK1VAdP4.cjs");
|
|
7
|
-
const loft = require("./loft-
|
|
8
|
-
const
|
|
9
|
-
const booleanFns = require("./booleanFns-BBSVKhL2.cjs");
|
|
7
|
+
const loft = require("./loft-8asn63t4.cjs");
|
|
8
|
+
const booleanFns = require("./booleanFns-ND7sZvhu.cjs");
|
|
10
9
|
function uuidv() {
|
|
11
10
|
return (String([1e7]) + String(-1e3) + String(-4e3) + String(-8e3) + String(-1e11)).replace(
|
|
12
11
|
/[018]/g,
|
|
@@ -150,6 +149,15 @@ function revolve(face, center = [0, 0, 0], direction = [0, 0, 1], angle = 360) {
|
|
|
150
149
|
return errors.ok(result);
|
|
151
150
|
}
|
|
152
151
|
function sweep(wire, spine, config = {}, shellMode = false) {
|
|
152
|
+
if (config.mode === "simple" && !shellMode) {
|
|
153
|
+
const kernel = occtBoundary.getKernel();
|
|
154
|
+
const resultOc = kernel.simplePipe(wire.wrapped, spine.wrapped);
|
|
155
|
+
const shape2 = shapeTypes.castShape(resultOc);
|
|
156
|
+
if (!shapeTypes.isShape3D(shape2)) {
|
|
157
|
+
return errors.err(errors.typeCastError("SWEEP_NOT_3D", "Simple pipe did not produce a 3D shape"));
|
|
158
|
+
}
|
|
159
|
+
return errors.ok(shape2);
|
|
160
|
+
}
|
|
153
161
|
const oc = occtBoundary.getKernel().oc;
|
|
154
162
|
const r = shapeTypes.gcWithScope();
|
|
155
163
|
const {
|
|
@@ -159,10 +167,24 @@ function sweep(wire, spine, config = {}, shellMode = false) {
|
|
|
159
167
|
transitionMode = "right",
|
|
160
168
|
withContact,
|
|
161
169
|
support,
|
|
162
|
-
forceProfileSpineOthogonality
|
|
170
|
+
forceProfileSpineOthogonality,
|
|
171
|
+
tolerance,
|
|
172
|
+
boundTolerance,
|
|
173
|
+
angularTolerance,
|
|
174
|
+
maxDegree,
|
|
175
|
+
maxSegments
|
|
163
176
|
} = config;
|
|
164
177
|
const withCorrection = transitionMode === "round" ? true : !!forceProfileSpineOthogonality;
|
|
165
178
|
const builder = r(new oc.BRepOffsetAPI_MakePipeShell(spine.wrapped));
|
|
179
|
+
if (tolerance !== void 0) {
|
|
180
|
+
builder.SetTolerance(tolerance, boundTolerance ?? tolerance, angularTolerance ?? 1e-7);
|
|
181
|
+
}
|
|
182
|
+
if (maxDegree !== void 0) {
|
|
183
|
+
builder.SetMaxDegree(maxDegree);
|
|
184
|
+
}
|
|
185
|
+
if (maxSegments !== void 0) {
|
|
186
|
+
builder.SetMaxSegments(maxSegments);
|
|
187
|
+
}
|
|
166
188
|
{
|
|
167
189
|
const mode = {
|
|
168
190
|
transformed: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_Transformed,
|
|
@@ -288,10 +310,20 @@ function linearPattern(shape, direction, count, spacing, options) {
|
|
|
288
310
|
return errors.err(errors.validationError("PATTERN_ZERO_DIRECTION", "Pattern direction cannot be zero"));
|
|
289
311
|
const dir = vecOps.vecNormalize(direction);
|
|
290
312
|
const copies = [shape];
|
|
313
|
+
const oc = occtBoundary.getKernel().oc;
|
|
314
|
+
const trsf = new oc.gp_Trsf_1();
|
|
315
|
+
const vec = new oc.gp_Vec_4(0, 0, 0);
|
|
291
316
|
for (let i = 1; i < count; i++) {
|
|
292
317
|
const offset = vecOps.vecScale(dir, spacing * i);
|
|
293
|
-
|
|
318
|
+
vec.SetCoord_2(offset[0], offset[1], offset[2]);
|
|
319
|
+
trsf.SetTranslation_1(vec);
|
|
320
|
+
const transformer = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, trsf, true);
|
|
321
|
+
const result = transformer.ModifiedShape(shape.wrapped);
|
|
322
|
+
transformer.delete();
|
|
323
|
+
copies.push(shapeTypes.castShape(result));
|
|
294
324
|
}
|
|
325
|
+
trsf.delete();
|
|
326
|
+
vec.delete();
|
|
295
327
|
return booleanFns.fuseAll(copies, options);
|
|
296
328
|
}
|
|
297
329
|
function circularPattern(shape, axis, count, fullAngle = 360, center = [0, 0, 0], options) {
|
|
@@ -302,9 +334,22 @@ function circularPattern(shape, axis, count, fullAngle = 360, center = [0, 0, 0]
|
|
|
302
334
|
return errors.err(errors.validationError("PATTERN_ZERO_AXIS", "Pattern axis cannot be zero"));
|
|
303
335
|
const angleStep = fullAngle / count;
|
|
304
336
|
const copies = [shape];
|
|
337
|
+
const oc = occtBoundary.getKernel().oc;
|
|
338
|
+
const trsf = new oc.gp_Trsf_1();
|
|
339
|
+
const origin = new oc.gp_Pnt_3(center[0], center[1], center[2]);
|
|
340
|
+
const dir = new oc.gp_Dir_4(axis[0], axis[1], axis[2]);
|
|
341
|
+
const ax1 = new oc.gp_Ax1_2(origin, dir);
|
|
305
342
|
for (let i = 1; i < count; i++) {
|
|
306
|
-
|
|
343
|
+
trsf.SetRotation_1(ax1, angleStep * i * Math.PI / 180);
|
|
344
|
+
const transformer = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, trsf, true);
|
|
345
|
+
const result = transformer.ModifiedShape(shape.wrapped);
|
|
346
|
+
transformer.delete();
|
|
347
|
+
copies.push(shapeTypes.castShape(result));
|
|
307
348
|
}
|
|
349
|
+
trsf.delete();
|
|
350
|
+
ax1.delete();
|
|
351
|
+
origin.delete();
|
|
352
|
+
dir.delete();
|
|
308
353
|
return booleanFns.fuseAll(copies, options);
|
|
309
354
|
}
|
|
310
355
|
function createAssemblyNode(name, options = {}) {
|
package/dist/operations.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const operations = require("./operations-
|
|
4
|
-
const loft = require("./loft-
|
|
3
|
+
const operations = require("./operations-CCFPvtd-.cjs");
|
|
4
|
+
const loft = require("./loft-8asn63t4.cjs");
|
|
5
5
|
exports.addChild = operations.addChild;
|
|
6
6
|
exports.addStep = operations.addStep;
|
|
7
7
|
exports.circularPattern = operations.circularPattern;
|
package/dist/operations.js
CHANGED
|
@@ -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-
|
|
2
|
-
import {
|
|
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-B8FHVC22.js";
|
|
2
|
+
import { i as i2, j as j2, l as l2, r } from "./loft-jIkZRqHm.js";
|
|
3
3
|
export {
|
|
4
4
|
a as addChild,
|
|
5
5
|
b as addStep,
|
|
6
|
-
|
|
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
|
-
|
|
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,CAAC,CAAC,CAAC;IAC3D,wDAAwD;IACxD,QAAQ,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC;IACnD,2CAA2C;IAC3C,QAAQ,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC;IACnF,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC;IACpF,+CAA+C;IAC/C,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,CAAC,EAAE,CAAC;IAC3C,kFAAkF;IAClF,QAAQ,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC;IACpD,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,OAAO,CAAC;IAG7C,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/C,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC;CAC9B;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,EAC5E,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EACpC,OAAO,EAAE,CAAC,UAAU,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EACvD,MAAM,EAAE,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
|
-
*
|
|
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
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
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
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
|
1
|
+
{"version":3,"file":"finderFns.d.ts","sourceRoot":"","sources":["../../src/query/finderFns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGxE,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,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
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const helpers = require("./helpers--iZxPeJg.cjs");
|
|
4
|
+
const cornerFinder = require("./cornerFinder-BKsCkrXd.cjs");
|
|
5
|
+
const occtBoundary = require("./occtBoundary-DHtzU4tz.cjs");
|
|
6
|
+
const shapeTypes = require("./shapeTypes-b_lhwQB7.cjs");
|
|
7
|
+
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
8
|
+
const curveFns = require("./curveFns-BoG_iA07.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
|
|
1
|
+
import { c as createTypedFinder, o as distanceFromPointFilter, q as resolveDir } from "./helpers-CRx_ks-u.js";
|
|
2
|
+
import { f, g } from "./helpers-CRx_ks-u.js";
|
|
3
|
+
import { c } from "./cornerFinder-89obDwGi.js";
|
|
4
|
+
import { g as getKernel } from "./occtBoundary-DYsksDtE.js";
|
|
5
|
+
import { p as gcWithScope } from "./shapeTypes-i7VwMRwc.js";
|
|
6
|
+
import { j as vecNormalize, d as vecDot, D as DEG2RAD } from "./vecOps-ZDdZWbwT.js";
|
|
7
|
+
import { C as getCurveType, q as curveLength } from "./curveFns-Cg99XKe2.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
|
-
|
|
42
|
+
edgeFinder,
|
|
5
43
|
f as faceFinder,
|
|
6
44
|
g as getSingleFace
|
|
7
45
|
};
|