brepjs 18.124.0 → 18.124.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.
- package/dist/2d.cjs +10 -8
- package/dist/2d.js +10 -8
- package/dist/{adjacencyFns-BJ6jcQ-N.cjs → adjacencyFns-CpKlADYt.cjs} +3 -3
- package/dist/{adjacencyFns-CnehwLNj.js → adjacencyFns-DECdcer5.js} +3 -3
- package/dist/{blueprint-BGWbpQ-w.js → blueprint-CaY00-X2.js} +16 -11
- package/dist/{blueprint-BSfG0Uik.cjs → blueprint-CpJLcUJV.cjs} +14 -10
- package/dist/{blueprintFns-C0-nGqlW.cjs → blueprintFns-B5nFaJI0.cjs} +2 -2
- package/dist/{blueprintFns-Bt1hKlL7.js → blueprintFns-vgwEIgI0.js} +2 -2
- package/dist/{blueprintSketcher-Bd5ZS9p6.cjs → blueprintSketcher-4e0yYtCY.cjs} +19 -11
- package/dist/{blueprintSketcher-BTGRoQ_G.js → blueprintSketcher-BjBjj2cK.js} +19 -11
- package/dist/{boolean2D-Cr6oLsbf.cjs → boolean2D-7heWA1co.cjs} +12 -8
- package/dist/{boolean2D-zZ9-qR5a.js → boolean2D-Bk-VrRyQ.js} +14 -9
- package/dist/brepjs.cjs +121 -81
- package/dist/brepjs.js +132 -85
- package/dist/{cameraFns-j2I9G3L_.cjs → cameraFns-CGwrxgqB.cjs} +5 -4
- package/dist/{cameraFns-CGMawqfi.js → cameraFns-DKEilV2v.js} +5 -4
- package/dist/core.cjs +2 -2
- package/dist/core.js +2 -2
- package/dist/{cornerFinder-CaXBdZz9.js → cornerFinder-C4s6pVZ-.js} +1 -1
- package/dist/{cornerFinder-CPwSLgpM.cjs → cornerFinder-zEgIFMnk.cjs} +1 -1
- package/dist/{curveFns-BBLaLG1U.cjs → curveFns-BZZYHVow.cjs} +8 -5
- package/dist/{curveFns-BoHbhtqX.js → curveFns-RczIU30U.js} +8 -5
- package/dist/{drawFns-DOkSdo8E.cjs → drawFns-BcXzWFfn.cjs} +59 -30
- package/dist/{drawFns-BrRbAeYB.js → drawFns-BjT3RaeQ.js} +59 -30
- package/dist/{faceFns-UozswcwP.cjs → faceFns-C4xNv2zn.cjs} +4 -3
- package/dist/{faceFns-Ce7Fq6j5.js → faceFns-fvp_zfuI.js} +6 -4
- package/dist/{healingFns-Dn0EFSHm.js → healingFns-AE5182Ds.js} +38 -21
- package/dist/{healingFns-mKogaVOk.cjs → healingFns-SxSiVPQa.cjs} +38 -21
- package/dist/{helpers-DuTAcGVX.cjs → helpers-CHYzwQMk.cjs} +6 -6
- package/dist/{helpers-CZsK8STz.js → helpers-CyLQ07aD.js} +6 -6
- package/dist/{importFns-Ch2YwieP.cjs → importFns-90S7P_7P.cjs} +5 -6
- package/dist/{importFns-CE4byS-8.js → importFns-DdXOAX6k.js} +5 -6
- package/dist/io.cjs +2 -2
- package/dist/io.js +2 -2
- package/dist/kernel/occtWasm/occtWasmAdapter.cjs +1 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.js +1 -1
- package/dist/{loftFns-BYiUcAxk.cjs → loftFns-B3mbh5RA.cjs} +15 -9
- package/dist/{loftFns-DQVg8qxM.js → loftFns-CyY4qfvC.js} +15 -9
- package/dist/{measureFns-BbLLBg5q.js → measureFns-B1uLQugf.js} +3 -3
- package/dist/{measureFns-Cao9gY1L.cjs → measureFns-Cx2XJVVC.cjs} +3 -3
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-CnYIUU9b.cjs → meshFns-2ZxW-X9I.cjs} +3 -3
- package/dist/{meshFns-B6NveFwc.js → meshFns-DrO3d03M.js} +3 -3
- package/dist/{occtWasmAdapter-BQKQXF63.js → occtWasmAdapter-BEe---7w.js} +3 -1
- package/dist/{occtWasmAdapter-Aubfbks6.cjs → occtWasmAdapter-DEpy64ji.cjs} +3 -1
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/{originTrackingFns-uz38yuMp.cjs → originTrackingFns-D3rUK08B.cjs} +2 -2
- package/dist/{originTrackingFns-DXcggmgf.js → originTrackingFns-DIAwMSih.js} +2 -2
- package/dist/{primitiveFns-CmmTWOkO.js → primitiveFns-CDPqVTcc.js} +7 -5
- package/dist/{primitiveFns-DmEPf6av.cjs → primitiveFns-c7wqS-K2.cjs} +7 -5
- package/dist/projection.cjs +1 -1
- package/dist/projection.js +1 -1
- package/dist/query.cjs +2 -2
- package/dist/query.js +2 -2
- package/dist/{refResolveFns-CnPEaqHw.cjs → refResolveFns-Cm8ZHPl5.cjs} +10 -8
- package/dist/{refResolveFns-DqY7Cd00.js → refResolveFns-o3-Gdnjn.js} +10 -8
- package/dist/{rolldown-runtime-DakpK96I.cjs → rolldown-runtime-C0BPl7ul.cjs} +1 -1
- package/dist/{shapeFns-BLZ1dDSz.cjs → shapeFns-CJ6mph9b.cjs} +2 -2
- package/dist/{shapeFns-mYczuWOy.js → shapeFns-DEpbxB9Z.js} +2 -2
- package/dist/shapeRef.cjs +1 -1
- package/dist/shapeRef.js +1 -1
- package/dist/{shapeTypes-bHlssytH.js → shapeTypes-BHRboc_x.js} +235 -20
- package/dist/{shapeTypes-DZKuRt24.cjs → shapeTypes-D5Y41q7x.cjs} +219 -12
- package/dist/sketching.cjs +3 -3
- package/dist/sketching.js +3 -3
- package/dist/{solidBuilders-5tA9O1SM.cjs → solidBuilders-CsUkRC69.cjs} +14 -9
- package/dist/{solidBuilders-9s-j-ZiW.js → solidBuilders-DQQ0re9T.js} +14 -9
- package/dist/{surfaceBuilders-0x7j0ibk.cjs → surfaceBuilders-BXNZydNl.cjs} +7 -5
- package/dist/{surfaceBuilders-B7UnwkQz.js → surfaceBuilders-C8k0K7DR.js} +7 -5
- package/dist/text.cjs +2 -2
- package/dist/text.js +2 -2
- package/dist/{textBlueprints-DE3M-E9o.js → textBlueprints-BAyLXffK.js} +36 -21
- package/dist/{textBlueprints-BPbIpA4-.cjs → textBlueprints-t8MdWfki.cjs} +37 -22
- package/dist/{textMetrics-D3Bly1w4.js → textMetrics-CefI-bMN.js} +3 -2
- package/dist/{textMetrics-rRuWxQG_.cjs → textMetrics-DUEI9s5M.cjs} +3 -2
- package/dist/{threadFns-BAjFNk2_.js → threadFns-Bau5Sqad.js} +17 -12
- package/dist/{threadFns-BMT6ziG_.cjs → threadFns-OVYAleOH.cjs} +17 -12
- package/dist/topology.cjs +9 -9
- package/dist/topology.js +9 -9
- package/dist/{topologyQueryFns-DVhWxBwT.js → topologyQueryFns-QvPyCF-7.js} +1 -1
- package/dist/{topologyQueryFns-DZUpJz2p.cjs → topologyQueryFns-gah07J7-.cjs} +1 -1
- package/dist/{validityTypes-19mfqWVv.js → validityTypes-DokbYKzd.js} +1 -1
- package/dist/{validityTypes-CCnRq3A9.cjs → validityTypes-Dx-04qO0.cjs} +1 -1
- package/package.json +7 -7
package/dist/2d.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
2
|
+
const require_shapeTypes = require("./shapeTypes-D5Y41q7x.cjs");
|
|
3
3
|
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
4
|
-
const require_topologyQueryFns = require("./topologyQueryFns-
|
|
5
|
-
const require_blueprintSketcher = require("./blueprintSketcher-
|
|
6
|
-
const require_blueprint = require("./blueprint-
|
|
7
|
-
const require_boolean2D = require("./boolean2D-
|
|
8
|
-
const require_blueprintFns = require("./blueprintFns-
|
|
4
|
+
const require_topologyQueryFns = require("./topologyQueryFns-gah07J7-.cjs");
|
|
5
|
+
const require_blueprintSketcher = require("./blueprintSketcher-4e0yYtCY.cjs");
|
|
6
|
+
const require_blueprint = require("./blueprint-CpJLcUJV.cjs");
|
|
7
|
+
const require_boolean2D = require("./boolean2D-7heWA1co.cjs");
|
|
8
|
+
const require_blueprintFns = require("./blueprintFns-B5nFaJI0.cjs");
|
|
9
9
|
//#region src/core/curve2dHandle.ts
|
|
10
10
|
/**
|
|
11
11
|
* Wrap a raw kernel 2D curve handle with brand + disposal tracking.
|
|
@@ -14,7 +14,8 @@ const require_blueprintFns = require("./blueprintFns-C0-nGqlW.cjs");
|
|
|
14
14
|
* `FinalizationRegistry` safety net, and double-dispose guards.
|
|
15
15
|
*/
|
|
16
16
|
function createCurve2DHandle(rawHandle) {
|
|
17
|
-
const
|
|
17
|
+
const deletable = typeof rawHandle.delete === "function" ? rawHandle : { delete() {} };
|
|
18
|
+
const inner = require_shapeTypes.createKernelHandle(deletable);
|
|
18
19
|
return {
|
|
19
20
|
get raw() {
|
|
20
21
|
if (inner.disposed) throw new Error("Curve2DHandle has been disposed");
|
|
@@ -198,7 +199,8 @@ function distanceBetweenCurves2d(c1, c2, bounds1, bounds2) {
|
|
|
198
199
|
*/
|
|
199
200
|
function liftCurve2dToPlane(curve, plane) {
|
|
200
201
|
return require_topologyQueryFns.kernelCallRaw(() => {
|
|
201
|
-
|
|
202
|
+
const raw = require_shapeTypes.getKernel2D().liftCurve2dToPlane(curve.raw, [...plane.origin], [...plane.zDir], [...plane.xDir]);
|
|
203
|
+
return require_shapeTypes.createEdge(raw);
|
|
202
204
|
}, CURVE2D_BRIDGE_FAILED, "Failed to lift 2D curve to plane");
|
|
203
205
|
}
|
|
204
206
|
/** Extract the 2D parametric curve of a 3D edge on a face. */
|
package/dist/2d.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { P as createKernelHandle, c as createEdge, q as getKernel2D } from "./shapeTypes-
|
|
1
|
+
import { P as createKernelHandle, c as createEdge, q as getKernel2D } from "./shapeTypes-BHRboc_x.js";
|
|
2
2
|
import { E as ok, d as validationError, g as err, t as BrepErrorCode } from "./errors-MHLiNE-C.js";
|
|
3
|
-
import { T as kernelCallRaw } from "./topologyQueryFns-
|
|
4
|
-
import { a as Blueprints, i as CompoundBlueprint, r as organiseBlueprints } from "./blueprintSketcher-
|
|
5
|
-
import { _ as Curve2D, b as BoundingBox2d, t as Blueprint } from "./blueprint-
|
|
6
|
-
import { a as fuseBlueprints, c as roundedRectangleBlueprint, i as cutBlueprints, n as fuse2D, o as intersectBlueprints, r as intersect2D, s as polysidesBlueprint, t as cut2D } from "./boolean2D-
|
|
7
|
-
import { S as reverseCurve, _ as curve2dIsOnCurve, a as isInside2D, b as curve2dSplitAt, c as scale2D, d as stretch2D, f as toSVGPathD, g as curve2dFirstPoint, h as curve2dDistanceFrom, i as getOrientation2D, l as sketchOnFace2D, m as curve2dBoundingBox, o as mirror2D, p as translate2D, r as getBounds2D, s as rotate2D, t as createBlueprint, u as sketchOnPlane2D, v as curve2dLastPoint, x as curve2dTangentAt, y as curve2dParameter } from "./blueprintFns-
|
|
3
|
+
import { T as kernelCallRaw } from "./topologyQueryFns-QvPyCF-7.js";
|
|
4
|
+
import { a as Blueprints, i as CompoundBlueprint, r as organiseBlueprints } from "./blueprintSketcher-BjBjj2cK.js";
|
|
5
|
+
import { _ as Curve2D, b as BoundingBox2d, t as Blueprint } from "./blueprint-CaY00-X2.js";
|
|
6
|
+
import { a as fuseBlueprints, c as roundedRectangleBlueprint, i as cutBlueprints, n as fuse2D, o as intersectBlueprints, r as intersect2D, s as polysidesBlueprint, t as cut2D } from "./boolean2D-Bk-VrRyQ.js";
|
|
7
|
+
import { S as reverseCurve, _ as curve2dIsOnCurve, a as isInside2D, b as curve2dSplitAt, c as scale2D, d as stretch2D, f as toSVGPathD, g as curve2dFirstPoint, h as curve2dDistanceFrom, i as getOrientation2D, l as sketchOnFace2D, m as curve2dBoundingBox, o as mirror2D, p as translate2D, r as getBounds2D, s as rotate2D, t as createBlueprint, u as sketchOnPlane2D, v as curve2dLastPoint, x as curve2dTangentAt, y as curve2dParameter } from "./blueprintFns-vgwEIgI0.js";
|
|
8
8
|
//#region src/core/curve2dHandle.ts
|
|
9
9
|
/**
|
|
10
10
|
* Wrap a raw kernel 2D curve handle with brand + disposal tracking.
|
|
@@ -13,7 +13,8 @@ import { S as reverseCurve, _ as curve2dIsOnCurve, a as isInside2D, b as curve2d
|
|
|
13
13
|
* `FinalizationRegistry` safety net, and double-dispose guards.
|
|
14
14
|
*/
|
|
15
15
|
function createCurve2DHandle(rawHandle) {
|
|
16
|
-
const
|
|
16
|
+
const deletable = typeof rawHandle.delete === "function" ? rawHandle : { delete() {} };
|
|
17
|
+
const inner = createKernelHandle(deletable);
|
|
17
18
|
return {
|
|
18
19
|
get raw() {
|
|
19
20
|
if (inner.disposed) throw new Error("Curve2DHandle has been disposed");
|
|
@@ -197,7 +198,8 @@ function distanceBetweenCurves2d(c1, c2, bounds1, bounds2) {
|
|
|
197
198
|
*/
|
|
198
199
|
function liftCurve2dToPlane(curve, plane) {
|
|
199
200
|
return kernelCallRaw(() => {
|
|
200
|
-
|
|
201
|
+
const raw = getKernel2D().liftCurve2dToPlane(curve.raw, [...plane.origin], [...plane.zDir], [...plane.xDir]);
|
|
202
|
+
return createEdge(raw);
|
|
201
203
|
}, CURVE2D_BRIDGE_FAILED, "Failed to lift 2D curve to plane");
|
|
202
204
|
}
|
|
203
205
|
/** Extract the 2D parametric curve of a 3D edge on a face. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
2
|
-
const require_occtWasmAdapter = require("./occtWasmAdapter-
|
|
3
|
-
const require_topologyQueryFns = require("./topologyQueryFns-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-D5Y41q7x.cjs");
|
|
2
|
+
const require_occtWasmAdapter = require("./occtWasmAdapter-DEpy64ji.cjs");
|
|
3
|
+
const require_topologyQueryFns = require("./topologyQueryFns-gah07J7-.cjs");
|
|
4
4
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
5
5
|
//#region src/topology/adjacencyFns.ts
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { G as getActiveKernelId, K as getKernel, r as castResultShapeWithKnownType, t as borrowShapeWithKnownType } from "./shapeTypes-
|
|
2
|
-
import { O as isUnsupportedKernelOperationError } from "./occtWasmAdapter-
|
|
3
|
-
import { c as getFaces, f as getVertices, l as getOrCreateCache, s as getEdges } from "./topologyQueryFns-
|
|
1
|
+
import { G as getActiveKernelId, K as getKernel, r as castResultShapeWithKnownType, t as borrowShapeWithKnownType } from "./shapeTypes-BHRboc_x.js";
|
|
2
|
+
import { O as isUnsupportedKernelOperationError } from "./occtWasmAdapter-BEe---7w.js";
|
|
3
|
+
import { c as getFaces, f as getVertices, l as getOrCreateCache, s as getEdges } from "./topologyQueryFns-QvPyCF-7.js";
|
|
4
4
|
import { n as HASH_CODE_MAX } from "./constants-ITRzCnCp.js";
|
|
5
5
|
//#region src/topology/adjacencyFns.ts
|
|
6
6
|
/**
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { K as getKernel, L as registerForCleanup, c as createEdge, p as createWire, q as getKernel2D, z as unregisterFromCleanup } from "./shapeTypes-
|
|
1
|
+
import { K as getKernel, L as registerForCleanup, c as createEdge, p as createWire, q as getKernel2D, z as unregisterFromCleanup } from "./shapeTypes-BHRboc_x.js";
|
|
2
2
|
import { i as wasmIndex, n as bug } from "./bug-BdOHwn_e.js";
|
|
3
3
|
import { E as ok, P as unwrap, d as validationError, g as err, n as computationError } from "./errors-MHLiNE-C.js";
|
|
4
4
|
import { r as RAD2DEG, t as DEG2RAD } from "./constants-ITRzCnCp.js";
|
|
5
5
|
import { r as toVec3 } from "./types-D24Y27N0.js";
|
|
6
6
|
import { r as makePlane } from "./planeOps-CQahLrCx.js";
|
|
7
|
-
import { _ as cast, h as uvCoordinates, i as faceGeomType, m as uvBounds, r as faceCenter } from "./faceFns-
|
|
8
|
-
import { p as getOrientation } from "./curveFns-
|
|
7
|
+
import { _ as cast, h as uvCoordinates, i as faceGeomType, m as uvBounds, r as faceCenter } from "./faceFns-fvp_zfuI.js";
|
|
8
|
+
import { p as getOrientation } from "./curveFns-RczIU30U.js";
|
|
9
9
|
import { n as getAtOrThrow, r as lastOrThrow, t as firstOrThrow } from "./arrayAccess-DrUGPADn.js";
|
|
10
|
-
import { r as makeFace } from "./surfaceBuilders-
|
|
11
|
-
import { _ as samePoint, b as subtract2d, c as add2d, f as distance2d, p as normalize2d$1, t as getSingleFace, v as scalarMultiply2d } from "./helpers-
|
|
10
|
+
import { r as makeFace } from "./surfaceBuilders-C8k0K7DR.js";
|
|
11
|
+
import { _ as samePoint, b as subtract2d, c as add2d, f as distance2d, p as normalize2d$1, t as getSingleFace, v as scalarMultiply2d } from "./helpers-CyLQ07aD.js";
|
|
12
12
|
//#region src/2d/lib/definitions.ts
|
|
13
13
|
/** Type guard that checks whether a value is a `Point2D`. */
|
|
14
14
|
function isPoint2D(point) {
|
|
@@ -504,13 +504,14 @@ var make2dBezierCurve = (startPoint, controls, endPoint) => {
|
|
|
504
504
|
function make2dInerpolatedBSplineCurve(points, { tolerance = .001, smoothing = null, degMax = 3, degMin = 1 } = {}) {
|
|
505
505
|
try {
|
|
506
506
|
const pts = points.map((p) => [p[0], p[1]]);
|
|
507
|
-
|
|
507
|
+
const handle = getKernel().makeBSpline2d(pts, {
|
|
508
508
|
tolerance,
|
|
509
509
|
smoothing,
|
|
510
510
|
degMax,
|
|
511
511
|
degMin,
|
|
512
512
|
continuity: "C2"
|
|
513
|
-
})
|
|
513
|
+
});
|
|
514
|
+
return ok(new Curve2D(handle));
|
|
514
515
|
} catch (e) {
|
|
515
516
|
return err(computationError("BSPLINE_2D_FAILED", "B-spline approximation failed", e));
|
|
516
517
|
}
|
|
@@ -523,7 +524,8 @@ function make2dInerpolatedBSplineCurve(points, { tolerance = .001, smoothing = n
|
|
|
523
524
|
var make2dArcFromCenter = (startPoint, endPoint, center, longArc = false) => {
|
|
524
525
|
const midChord = scalarMultiply2d(add2d(startPoint, endPoint), .5);
|
|
525
526
|
const orientedRadius = distance2d(center, startPoint) * (longArc ? -1 : 1);
|
|
526
|
-
|
|
527
|
+
const midChordDir = normalize2d(subtract2d(midChord, center));
|
|
528
|
+
return make2dThreePointArc(startPoint, add2d(scalarMultiply2d(midChordDir, orientedRadius), center), endPoint);
|
|
527
529
|
};
|
|
528
530
|
//#endregion
|
|
529
531
|
//#region src/2d/lib/svgPath.ts
|
|
@@ -916,8 +918,10 @@ var Blueprint = class Blueprint {
|
|
|
916
918
|
* @returns A new Face bounded by the blueprint's profile.
|
|
917
919
|
*/
|
|
918
920
|
subFace(face, origin) {
|
|
919
|
-
const
|
|
920
|
-
|
|
921
|
+
const originPoint = origin || [...faceCenter(face)];
|
|
922
|
+
const originVec3 = toVec3(originPoint);
|
|
923
|
+
const sketch = this.translate(uvCoordinates(face, originVec3)).sketchOnFace(face, "original");
|
|
924
|
+
return unwrap(makeFace(sketch.wire));
|
|
921
925
|
}
|
|
922
926
|
/**
|
|
923
927
|
* Cut a prism-shaped hole through a solid along a face using this blueprint.
|
|
@@ -933,7 +937,8 @@ var Blueprint = class Blueprint {
|
|
|
933
937
|
punchHole(shape, face, { height = null, origin = null, draftAngle = 0 } = {}) {
|
|
934
938
|
const foundFace = unwrap(getSingleFace(face, shape));
|
|
935
939
|
const hole = this.subFace(foundFace, origin);
|
|
936
|
-
|
|
940
|
+
const result = getKernel().draftPrism(shape.wrapped, hole.wrapped, foundFace.wrapped, height, draftAngle, false);
|
|
941
|
+
return unwrap(cast(result));
|
|
937
942
|
}
|
|
938
943
|
/** Convert the blueprint to an SVG path `d` attribute string. */
|
|
939
944
|
toSVGPathD() {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-D5Y41q7x.cjs");
|
|
2
2
|
const require_bug = require("./bug-O02CsAmt.cjs");
|
|
3
3
|
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
4
4
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
5
5
|
const require_types = require("./types-KjA8tY4Y.cjs");
|
|
6
6
|
const require_planeOps = require("./planeOps-VlFxtvzY.cjs");
|
|
7
|
-
const require_faceFns = require("./faceFns-
|
|
8
|
-
const require_curveFns = require("./curveFns-
|
|
7
|
+
const require_faceFns = require("./faceFns-C4xNv2zn.cjs");
|
|
8
|
+
const require_curveFns = require("./curveFns-BZZYHVow.cjs");
|
|
9
9
|
const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
|
|
10
|
-
const require_surfaceBuilders = require("./surfaceBuilders-
|
|
11
|
-
const require_helpers = require("./helpers-
|
|
10
|
+
const require_surfaceBuilders = require("./surfaceBuilders-BXNZydNl.cjs");
|
|
11
|
+
const require_helpers = require("./helpers-CHYzwQMk.cjs");
|
|
12
12
|
//#region src/2d/lib/definitions.ts
|
|
13
13
|
/** Type guard that checks whether a value is a `Point2D`. */
|
|
14
14
|
function isPoint2D(point) {
|
|
@@ -504,13 +504,14 @@ var make2dBezierCurve = (startPoint, controls, endPoint) => {
|
|
|
504
504
|
function make2dInerpolatedBSplineCurve(points, { tolerance = .001, smoothing = null, degMax = 3, degMin = 1 } = {}) {
|
|
505
505
|
try {
|
|
506
506
|
const pts = points.map((p) => [p[0], p[1]]);
|
|
507
|
-
|
|
507
|
+
const handle = require_shapeTypes.getKernel().makeBSpline2d(pts, {
|
|
508
508
|
tolerance,
|
|
509
509
|
smoothing,
|
|
510
510
|
degMax,
|
|
511
511
|
degMin,
|
|
512
512
|
continuity: "C2"
|
|
513
|
-
})
|
|
513
|
+
});
|
|
514
|
+
return require_errors.ok(new Curve2D(handle));
|
|
514
515
|
} catch (e) {
|
|
515
516
|
return require_errors.err(require_errors.computationError("BSPLINE_2D_FAILED", "B-spline approximation failed", e));
|
|
516
517
|
}
|
|
@@ -917,8 +918,10 @@ var Blueprint = class Blueprint {
|
|
|
917
918
|
* @returns A new Face bounded by the blueprint's profile.
|
|
918
919
|
*/
|
|
919
920
|
subFace(face, origin) {
|
|
920
|
-
const
|
|
921
|
-
|
|
921
|
+
const originPoint = origin || [...require_faceFns.faceCenter(face)];
|
|
922
|
+
const originVec3 = require_types.toVec3(originPoint);
|
|
923
|
+
const sketch = this.translate(require_faceFns.uvCoordinates(face, originVec3)).sketchOnFace(face, "original");
|
|
924
|
+
return require_errors.unwrap(require_surfaceBuilders.makeFace(sketch.wire));
|
|
922
925
|
}
|
|
923
926
|
/**
|
|
924
927
|
* Cut a prism-shaped hole through a solid along a face using this blueprint.
|
|
@@ -934,7 +937,8 @@ var Blueprint = class Blueprint {
|
|
|
934
937
|
punchHole(shape, face, { height = null, origin = null, draftAngle = 0 } = {}) {
|
|
935
938
|
const foundFace = require_errors.unwrap(require_helpers.getSingleFace(face, shape));
|
|
936
939
|
const hole = this.subFace(foundFace, origin);
|
|
937
|
-
|
|
940
|
+
const result = require_shapeTypes.getKernel().draftPrism(shape.wrapped, hole.wrapped, foundFace.wrapped, height, draftAngle, false);
|
|
941
|
+
return require_errors.unwrap(require_faceFns.cast(result));
|
|
938
942
|
}
|
|
939
943
|
/** Convert the blueprint to an SVG path `d` attribute string. */
|
|
940
944
|
toSVGPathD() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
2
|
-
const require_blueprintSketcher = require("./blueprintSketcher-
|
|
3
|
-
const require_blueprint = require("./blueprint-
|
|
2
|
+
const require_blueprintSketcher = require("./blueprintSketcher-4e0yYtCY.cjs");
|
|
3
|
+
const require_blueprint = require("./blueprint-CpJLcUJV.cjs");
|
|
4
4
|
//#region src/2d/lib/curve2dFns.ts
|
|
5
5
|
/**
|
|
6
6
|
* Return a reversed copy of the curve (non-mutating).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { E as ok, d as validationError, g as err, t as BrepErrorCode } from "./errors-MHLiNE-C.js";
|
|
2
|
-
import { i as CompoundBlueprint } from "./blueprintSketcher-
|
|
3
|
-
import { t as Blueprint } from "./blueprint-
|
|
2
|
+
import { i as CompoundBlueprint } from "./blueprintSketcher-BjBjj2cK.js";
|
|
3
|
+
import { t as Blueprint } from "./blueprint-CaY00-X2.js";
|
|
4
4
|
//#region src/2d/lib/curve2dFns.ts
|
|
5
5
|
/**
|
|
6
6
|
* Return a reversed copy of the curve (non-mutating).
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-D5Y41q7x.cjs");
|
|
2
2
|
const require_bug = require("./bug-O02CsAmt.cjs");
|
|
3
3
|
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
4
4
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
5
5
|
const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
|
|
6
|
-
const require_helpers = require("./helpers-
|
|
7
|
-
const require_blueprint = require("./blueprint-
|
|
6
|
+
const require_helpers = require("./helpers-CHYzwQMk.cjs");
|
|
7
|
+
const require_blueprint = require("./blueprint-CpJLcUJV.cjs");
|
|
8
8
|
//#region node_modules/flatqueue/index.js
|
|
9
9
|
/**
|
|
10
10
|
* @typedef {Float64ArrayConstructor | Float32ArrayConstructor |
|
|
@@ -198,7 +198,7 @@ var Flatbush = class Flatbush {
|
|
|
198
198
|
this.minY = Infinity;
|
|
199
199
|
this.maxX = -Infinity;
|
|
200
200
|
this.maxY = -Infinity;
|
|
201
|
-
new Uint8Array(data, 0, 2).set([251,
|
|
201
|
+
new Uint8Array(data, 0, 2).set([251, 48 + arrayTypeIndex]);
|
|
202
202
|
new Uint16Array(data, 2, 1)[0] = nodeSize;
|
|
203
203
|
new Uint32Array(data, 4, 1)[0] = numItems;
|
|
204
204
|
}
|
|
@@ -252,7 +252,9 @@ var Flatbush = class Flatbush {
|
|
|
252
252
|
const itemMinY = boxes[pos++];
|
|
253
253
|
const itemMaxX = boxes[pos++];
|
|
254
254
|
const itemMaxY = boxes[pos++];
|
|
255
|
-
|
|
255
|
+
const x = sx * ((itemMinX + itemMaxX) / 2 - minX) | 0;
|
|
256
|
+
const y = sy * ((itemMinY + itemMaxY) / 2 - minY) | 0;
|
|
257
|
+
hilbertValues[i] = hilbert(x, y);
|
|
256
258
|
}
|
|
257
259
|
sort(hilbertValues, boxes, indices, 0, numItems - 1, nodeSize);
|
|
258
260
|
let pos = numItems * 4;
|
|
@@ -557,7 +559,8 @@ var intersectCurves = (first, second, precision = 1e-9) => {
|
|
|
557
559
|
}
|
|
558
560
|
const isDegenerate = (c) => {
|
|
559
561
|
if (!require_helpers.samePoint(c.firstPoint, c.lastPoint, precision)) return false;
|
|
560
|
-
|
|
562
|
+
const mid = c.value((c.firstParameter + c.lastParameter) / 2);
|
|
563
|
+
return require_helpers.samePoint(mid, c.firstPoint, precision);
|
|
561
564
|
};
|
|
562
565
|
const segmentsAsPoints = commonSegments.filter(isDegenerate).map((c) => c.firstPoint);
|
|
563
566
|
if (segmentsAsPoints.length) {
|
|
@@ -642,7 +645,8 @@ var make2dOffset = (curve, offset) => {
|
|
|
642
645
|
lastPoint: offsetViaCenter(curve.lastPoint)
|
|
643
646
|
};
|
|
644
647
|
}
|
|
645
|
-
const
|
|
648
|
+
const circleHandle = kernel.makeCircle2d(cx, cy, newRadius, isDirect);
|
|
649
|
+
const fullCircle = new require_blueprint.Curve2D(circleHandle);
|
|
646
650
|
let trimmedHandle;
|
|
647
651
|
try {
|
|
648
652
|
trimmedHandle = kernel.trimCurve2d(fullCircle.wrapped, curve.firstParameter, curve.lastParameter);
|
|
@@ -655,7 +659,8 @@ var make2dOffset = (curve, offset) => {
|
|
|
655
659
|
const { firstPoint, lastPoint } = offsetEndPoints(curve.firstPoint, curve.lastPoint, offset);
|
|
656
660
|
return require_blueprint.make2dSegmentCurve(firstPoint, lastPoint);
|
|
657
661
|
}
|
|
658
|
-
const
|
|
662
|
+
const offsetHandle = kernel.offsetCurve2d(curve.wrapped, offset);
|
|
663
|
+
const offsetCurve = new require_blueprint.Curve2D(offsetHandle);
|
|
659
664
|
const approximation = require_blueprint.approximateAsBSpline(offsetCurve);
|
|
660
665
|
offsetCurve.delete();
|
|
661
666
|
if (require_errors.unwrap(selfIntersections(approximation)).length) {
|
|
@@ -811,7 +816,9 @@ function chamferCurves(firstCurve, secondCurve, radius) {
|
|
|
811
816
|
* round end-mill of the given radius can fully reach the corner.
|
|
812
817
|
*/
|
|
813
818
|
function dogboneFilletCurves(firstCurve, secondCurve, radius) {
|
|
814
|
-
const
|
|
819
|
+
const tgt1 = require_blueprint.normalize2d(firstCurve.tangentAt(1));
|
|
820
|
+
const tgt2 = require_blueprint.normalize2d(secondCurve.tangentAt(0));
|
|
821
|
+
const sinAngle = require_helpers.crossProduct2d(tgt1, tgt2);
|
|
815
822
|
const a = Math.asin(sinAngle);
|
|
816
823
|
if (Math.abs(sinAngle) < 1e-10) return [firstCurve, secondCurve];
|
|
817
824
|
const orientationCorrection = sinAngle > 0 ? -1 : 1;
|
|
@@ -968,10 +975,11 @@ var Blueprints = class Blueprints {
|
|
|
968
975
|
}
|
|
969
976
|
/** Render a complete SVG document string for all child blueprints. */
|
|
970
977
|
toSVG(margin = 1) {
|
|
971
|
-
|
|
978
|
+
const elements = this.blueprints.map((bp) => {
|
|
972
979
|
if (bp instanceof require_blueprint.Blueprint) return bp.toSVGPath();
|
|
973
980
|
else return bp.toSVGGroup();
|
|
974
|
-
})
|
|
981
|
+
});
|
|
982
|
+
return require_blueprint.asSVG(elements.join("\n "), this.boundingBox, margin);
|
|
975
983
|
}
|
|
976
984
|
};
|
|
977
985
|
//#endregion
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { K as getKernel, q as getKernel2D } from "./shapeTypes-
|
|
1
|
+
import { K as getKernel, q as getKernel2D } from "./shapeTypes-BHRboc_x.js";
|
|
2
2
|
import { i as wasmIndex, n as bug } from "./bug-BdOHwn_e.js";
|
|
3
3
|
import { E as ok, P as unwrap, g as err, n as computationError, s as safeIndex, x as isOk } from "./errors-MHLiNE-C.js";
|
|
4
4
|
import { r as RAD2DEG, t as DEG2RAD } from "./constants-ITRzCnCp.js";
|
|
5
5
|
import { t as firstOrThrow } from "./arrayAccess-DrUGPADn.js";
|
|
6
|
-
import { _ as samePoint, b as subtract2d, c as add2d, d as crossProduct2d, f as distance2d, g as rotate2d, h as polarToCartesian, m as polarAngle2d, u as cartesianToPolar, v as scalarMultiply2d } from "./helpers-
|
|
7
|
-
import { S as isPoint2D, _ as Curve2D, b as BoundingBox2d, c as make2dCircle, f as make2dSegmentCurve, h as approximateAsBSpline, m as make2dThreePointArc, n as asSVG, o as make2dArcFromCenter, p as make2dTangentArc, r as viewbox, s as make2dBezierCurve, t as Blueprint, u as make2dEllipseArc, y as normalize2d } from "./blueprint-
|
|
6
|
+
import { _ as samePoint, b as subtract2d, c as add2d, d as crossProduct2d, f as distance2d, g as rotate2d, h as polarToCartesian, m as polarAngle2d, u as cartesianToPolar, v as scalarMultiply2d } from "./helpers-CyLQ07aD.js";
|
|
7
|
+
import { S as isPoint2D, _ as Curve2D, b as BoundingBox2d, c as make2dCircle, f as make2dSegmentCurve, h as approximateAsBSpline, m as make2dThreePointArc, n as asSVG, o as make2dArcFromCenter, p as make2dTangentArc, r as viewbox, s as make2dBezierCurve, t as Blueprint, u as make2dEllipseArc, y as normalize2d } from "./blueprint-CaY00-X2.js";
|
|
8
8
|
//#region node_modules/flatqueue/index.js
|
|
9
9
|
/**
|
|
10
10
|
* @typedef {Float64ArrayConstructor | Float32ArrayConstructor |
|
|
@@ -198,7 +198,7 @@ var Flatbush = class Flatbush {
|
|
|
198
198
|
this.minY = Infinity;
|
|
199
199
|
this.maxX = -Infinity;
|
|
200
200
|
this.maxY = -Infinity;
|
|
201
|
-
new Uint8Array(data, 0, 2).set([251,
|
|
201
|
+
new Uint8Array(data, 0, 2).set([251, 48 + arrayTypeIndex]);
|
|
202
202
|
new Uint16Array(data, 2, 1)[0] = nodeSize;
|
|
203
203
|
new Uint32Array(data, 4, 1)[0] = numItems;
|
|
204
204
|
}
|
|
@@ -252,7 +252,9 @@ var Flatbush = class Flatbush {
|
|
|
252
252
|
const itemMinY = boxes[pos++];
|
|
253
253
|
const itemMaxX = boxes[pos++];
|
|
254
254
|
const itemMaxY = boxes[pos++];
|
|
255
|
-
|
|
255
|
+
const x = sx * ((itemMinX + itemMaxX) / 2 - minX) | 0;
|
|
256
|
+
const y = sy * ((itemMinY + itemMaxY) / 2 - minY) | 0;
|
|
257
|
+
hilbertValues[i] = hilbert(x, y);
|
|
256
258
|
}
|
|
257
259
|
sort(hilbertValues, boxes, indices, 0, numItems - 1, nodeSize);
|
|
258
260
|
let pos = numItems * 4;
|
|
@@ -557,7 +559,8 @@ var intersectCurves = (first, second, precision = 1e-9) => {
|
|
|
557
559
|
}
|
|
558
560
|
const isDegenerate = (c) => {
|
|
559
561
|
if (!samePoint(c.firstPoint, c.lastPoint, precision)) return false;
|
|
560
|
-
|
|
562
|
+
const mid = c.value((c.firstParameter + c.lastParameter) / 2);
|
|
563
|
+
return samePoint(mid, c.firstPoint, precision);
|
|
561
564
|
};
|
|
562
565
|
const segmentsAsPoints = commonSegments.filter(isDegenerate).map((c) => c.firstPoint);
|
|
563
566
|
if (segmentsAsPoints.length) {
|
|
@@ -642,7 +645,8 @@ var make2dOffset = (curve, offset) => {
|
|
|
642
645
|
lastPoint: offsetViaCenter(curve.lastPoint)
|
|
643
646
|
};
|
|
644
647
|
}
|
|
645
|
-
const
|
|
648
|
+
const circleHandle = kernel.makeCircle2d(cx, cy, newRadius, isDirect);
|
|
649
|
+
const fullCircle = new Curve2D(circleHandle);
|
|
646
650
|
let trimmedHandle;
|
|
647
651
|
try {
|
|
648
652
|
trimmedHandle = kernel.trimCurve2d(fullCircle.wrapped, curve.firstParameter, curve.lastParameter);
|
|
@@ -655,7 +659,8 @@ var make2dOffset = (curve, offset) => {
|
|
|
655
659
|
const { firstPoint, lastPoint } = offsetEndPoints(curve.firstPoint, curve.lastPoint, offset);
|
|
656
660
|
return make2dSegmentCurve(firstPoint, lastPoint);
|
|
657
661
|
}
|
|
658
|
-
const
|
|
662
|
+
const offsetHandle = kernel.offsetCurve2d(curve.wrapped, offset);
|
|
663
|
+
const offsetCurve = new Curve2D(offsetHandle);
|
|
659
664
|
const approximation = approximateAsBSpline(offsetCurve);
|
|
660
665
|
offsetCurve.delete();
|
|
661
666
|
if (unwrap(selfIntersections(approximation)).length) {
|
|
@@ -811,7 +816,9 @@ function chamferCurves(firstCurve, secondCurve, radius) {
|
|
|
811
816
|
* round end-mill of the given radius can fully reach the corner.
|
|
812
817
|
*/
|
|
813
818
|
function dogboneFilletCurves(firstCurve, secondCurve, radius) {
|
|
814
|
-
const
|
|
819
|
+
const tgt1 = normalize2d(firstCurve.tangentAt(1));
|
|
820
|
+
const tgt2 = normalize2d(secondCurve.tangentAt(0));
|
|
821
|
+
const sinAngle = crossProduct2d(tgt1, tgt2);
|
|
815
822
|
const a = Math.asin(sinAngle);
|
|
816
823
|
if (Math.abs(sinAngle) < 1e-10) return [firstCurve, secondCurve];
|
|
817
824
|
const orientationCorrection = sinAngle > 0 ? -1 : 1;
|
|
@@ -968,10 +975,11 @@ var Blueprints = class Blueprints {
|
|
|
968
975
|
}
|
|
969
976
|
/** Render a complete SVG document string for all child blueprints. */
|
|
970
977
|
toSVG(margin = 1) {
|
|
971
|
-
|
|
978
|
+
const elements = this.blueprints.map((bp) => {
|
|
972
979
|
if (bp instanceof Blueprint) return bp.toSVGPath();
|
|
973
980
|
else return bp.toSVGGroup();
|
|
974
|
-
})
|
|
981
|
+
});
|
|
982
|
+
return asSVG(elements.join("\n "), this.boundingBox, margin);
|
|
975
983
|
}
|
|
976
984
|
};
|
|
977
985
|
//#endregion
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_bug = require("./bug-O02CsAmt.cjs");
|
|
2
2
|
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
3
3
|
const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
|
|
4
|
-
const require_surfaceBuilders = require("./surfaceBuilders-
|
|
5
|
-
const require_blueprintSketcher = require("./blueprintSketcher-
|
|
6
|
-
const require_helpers = require("./helpers-
|
|
7
|
-
const require_blueprint = require("./blueprint-
|
|
4
|
+
const require_surfaceBuilders = require("./surfaceBuilders-BXNZydNl.cjs");
|
|
5
|
+
const require_blueprintSketcher = require("./blueprintSketcher-4e0yYtCY.cjs");
|
|
6
|
+
const require_helpers = require("./helpers-CHYzwQMk.cjs");
|
|
7
|
+
const require_blueprint = require("./blueprint-CpJLcUJV.cjs");
|
|
8
8
|
//#region src/2d/blueprints/cannedBlueprints.ts
|
|
9
9
|
/**
|
|
10
10
|
* Create a regular polygon blueprint inscribed in a circle of the given radius.
|
|
@@ -66,8 +66,10 @@ var roundedRectangleBlueprint = (width, height, r = 0) => {
|
|
|
66
66
|
const symmetricRadius = rx === ry;
|
|
67
67
|
const sk = new require_blueprintSketcher.BlueprintSketcher([Math.min(0, -(width / 2 - rx)), -height / 2]);
|
|
68
68
|
const addFillet = (xDist, yDist) => {
|
|
69
|
-
if (withRadius)
|
|
70
|
-
|
|
69
|
+
if (withRadius) {
|
|
70
|
+
if (symmetricRadius) sk.tangentArc(xDist, yDist);
|
|
71
|
+
else sk.ellipse(xDist, yDist, rx, ry, 0, false, true);
|
|
72
|
+
}
|
|
71
73
|
};
|
|
72
74
|
if (rx < width / 2) sk.hLine(width - 2 * rx);
|
|
73
75
|
addFillet(rx, ry);
|
|
@@ -268,7 +270,8 @@ function findAllIntersections(first, second) {
|
|
|
268
270
|
const [[xMin, yMin], [xMax, yMax]] = thisCurve.boundingBox.bounds;
|
|
269
271
|
const candidates = secondIndex.search(xMin, yMin, xMax, yMax);
|
|
270
272
|
for (const secondIdx of candidates) {
|
|
271
|
-
const
|
|
273
|
+
const otherCurve = require_bug.wasmIndex(second.curves, secondIdx);
|
|
274
|
+
const { intersections, commonSegments, commonSegmentsPoints } = require_errors.unwrap(require_blueprintSketcher.intersectCurves(thisCurve, otherCurve, require_helpers.PRECISION_INTERSECTION / 100));
|
|
272
275
|
allIntersections.push(...intersections);
|
|
273
276
|
firstCurvePoints[firstIdx]?.push(...intersections);
|
|
274
277
|
secondCurvePoints[secondIdx]?.push(...intersections);
|
|
@@ -404,7 +407,8 @@ function mergeCollinearSegments(curves) {
|
|
|
404
407
|
function splitPaths(curves) {
|
|
405
408
|
const startPoints = curves.map((c) => c.firstPoint);
|
|
406
409
|
const shiftedEndPoints = curves.map((c) => c.lastPoint);
|
|
407
|
-
const
|
|
410
|
+
const endPoints = shiftedEndPoints.slice(-1).concat(shiftedEndPoints.slice(0, -1));
|
|
411
|
+
const discontinuities = require_surfaceBuilders.zip([startPoints, endPoints]).map(([startPoint, endPoint], index) => {
|
|
408
412
|
if (startPoint === void 0 || endPoint === void 0) return null;
|
|
409
413
|
return samePoint(startPoint, endPoint) ? null : index;
|
|
410
414
|
}).filter((f) => f !== null);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { i as wasmIndex, n as bug } from "./bug-BdOHwn_e.js";
|
|
2
2
|
import { P as unwrap, s as safeIndex } from "./errors-MHLiNE-C.js";
|
|
3
3
|
import { r as lastOrThrow } from "./arrayAccess-DrUGPADn.js";
|
|
4
|
-
import { v as zip } from "./surfaceBuilders-
|
|
5
|
-
import { a as Blueprints, i as CompoundBlueprint, l as intersectCurves, r as organiseBlueprints, t as BlueprintSketcher, u as Flatbush } from "./blueprintSketcher-
|
|
6
|
-
import { _ as samePoint$1, b as subtract2d, d as crossProduct2d, o as PRECISION_INTERSECTION } from "./helpers-
|
|
7
|
-
import { f as make2dSegmentCurve, t as Blueprint, x as removeDuplicatePoints } from "./blueprint-
|
|
4
|
+
import { v as zip } from "./surfaceBuilders-C8k0K7DR.js";
|
|
5
|
+
import { a as Blueprints, i as CompoundBlueprint, l as intersectCurves, r as organiseBlueprints, t as BlueprintSketcher, u as Flatbush } from "./blueprintSketcher-BjBjj2cK.js";
|
|
6
|
+
import { _ as samePoint$1, b as subtract2d, d as crossProduct2d, o as PRECISION_INTERSECTION } from "./helpers-CyLQ07aD.js";
|
|
7
|
+
import { f as make2dSegmentCurve, t as Blueprint, x as removeDuplicatePoints } from "./blueprint-CaY00-X2.js";
|
|
8
8
|
//#region src/2d/blueprints/cannedBlueprints.ts
|
|
9
9
|
/**
|
|
10
10
|
* Create a regular polygon blueprint inscribed in a circle of the given radius.
|
|
@@ -66,8 +66,10 @@ var roundedRectangleBlueprint = (width, height, r = 0) => {
|
|
|
66
66
|
const symmetricRadius = rx === ry;
|
|
67
67
|
const sk = new BlueprintSketcher([Math.min(0, -(width / 2 - rx)), -height / 2]);
|
|
68
68
|
const addFillet = (xDist, yDist) => {
|
|
69
|
-
if (withRadius)
|
|
70
|
-
|
|
69
|
+
if (withRadius) {
|
|
70
|
+
if (symmetricRadius) sk.tangentArc(xDist, yDist);
|
|
71
|
+
else sk.ellipse(xDist, yDist, rx, ry, 0, false, true);
|
|
72
|
+
}
|
|
71
73
|
};
|
|
72
74
|
if (rx < width / 2) sk.hLine(width - 2 * rx);
|
|
73
75
|
addFillet(rx, ry);
|
|
@@ -268,7 +270,8 @@ function findAllIntersections(first, second) {
|
|
|
268
270
|
const [[xMin, yMin], [xMax, yMax]] = thisCurve.boundingBox.bounds;
|
|
269
271
|
const candidates = secondIndex.search(xMin, yMin, xMax, yMax);
|
|
270
272
|
for (const secondIdx of candidates) {
|
|
271
|
-
const
|
|
273
|
+
const otherCurve = wasmIndex(second.curves, secondIdx);
|
|
274
|
+
const { intersections, commonSegments, commonSegmentsPoints } = unwrap(intersectCurves(thisCurve, otherCurve, PRECISION_INTERSECTION / 100));
|
|
272
275
|
allIntersections.push(...intersections);
|
|
273
276
|
firstCurvePoints[firstIdx]?.push(...intersections);
|
|
274
277
|
secondCurvePoints[secondIdx]?.push(...intersections);
|
|
@@ -404,7 +407,8 @@ function mergeCollinearSegments(curves) {
|
|
|
404
407
|
function splitPaths(curves) {
|
|
405
408
|
const startPoints = curves.map((c) => c.firstPoint);
|
|
406
409
|
const shiftedEndPoints = curves.map((c) => c.lastPoint);
|
|
407
|
-
const
|
|
410
|
+
const endPoints = shiftedEndPoints.slice(-1).concat(shiftedEndPoints.slice(0, -1));
|
|
411
|
+
const discontinuities = zip([startPoints, endPoints]).map(([startPoint, endPoint], index) => {
|
|
408
412
|
if (startPoint === void 0 || endPoint === void 0) return null;
|
|
409
413
|
return samePoint(startPoint, endPoint) ? null : index;
|
|
410
414
|
}).filter((f) => f !== null);
|
|
@@ -787,7 +791,8 @@ var cut2D = (first, second) => {
|
|
|
787
791
|
const wrapper = safeIndex(first.blueprints, 0, "cut2D");
|
|
788
792
|
if (second instanceof Blueprint && !second.intersects(wrapper)) {
|
|
789
793
|
if (!wrapper.isInside(second.firstPoint)) return first.clone();
|
|
790
|
-
|
|
794
|
+
const cuts = fuse2D(second, new Blueprints(first.blueprints.slice(1)));
|
|
795
|
+
return organiseBlueprints([wrapper, ...allBlueprints(cuts)]);
|
|
791
796
|
} else {
|
|
792
797
|
let out = cut2D(wrapper, second);
|
|
793
798
|
first.blueprints.slice(1).forEach((bp) => {
|