brepjs 8.3.0 → 8.7.4
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/lib/Curve2D.d.ts.map +1 -1
- package/dist/2d.cjs +2 -2
- package/dist/2d.js +13 -13
- package/dist/{Blueprint-a3ukJMG4.cjs → Blueprint-BcbOBF-9.cjs} +17 -102
- package/dist/{Blueprint-CdVaHDSx.js → Blueprint-Cmh8lKc4.js} +35 -120
- package/dist/{boolean2D-pvPIs21j.cjs → boolean2D-CqacqjME.cjs} +24 -25
- package/dist/{boolean2D-DzA0STqC.js → boolean2D-D94Axs3i.js} +23 -24
- package/dist/{booleanFns-BcQUqjUu.js → booleanFns-DdjtpcM6.js} +306 -12
- package/dist/{booleanFns-Cd414V3l.cjs → booleanFns-NtKxkiXn.cjs} +299 -5
- package/dist/brepjs.cjs +1782 -68
- package/dist/brepjs.js +2030 -317
- package/dist/core/errors.d.ts +25 -0
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core.cjs +4 -4
- package/dist/core.js +4 -4
- package/dist/{cornerFinder-DvPiz-VR.js → cornerFinder-BBOYfsXl.js} +1 -1
- package/dist/{cornerFinder-BdKtobgb.cjs → cornerFinder-Bqy8Lw2p.cjs} +1 -1
- package/dist/{curveFns-CyHyk29c.js → curveFns-B85Glnfo.js} +19 -17
- package/dist/{curveFns-B5EQsSwv.cjs → curveFns-BXCbASW-.cjs} +6 -4
- package/dist/{drawFns-CAAE4Z88.js → drawFns-B-gJ2WUc.js} +52 -23
- package/dist/{drawFns-Mr2pghU8.cjs → drawFns-CAmFEqd1.cjs} +68 -39
- package/dist/{errors-wGhcJMpB.js → errors-Coh_5_19.js} +35 -1
- package/dist/{errors-DK1VAdP4.cjs → errors-eRQu29oc.cjs} +35 -1
- package/dist/{faceFns-ub3CugDN.js → faceFns-CltrEfOo.js} +109 -12
- package/dist/{faceFns-D1Sqnlu6.cjs → faceFns-DcndPHWm.cjs} +103 -6
- package/dist/{helpers-CP2KrBZl.cjs → helpers-CC21GeAr.cjs} +8 -9
- package/dist/{helpers-r_e-u1JM.js → helpers-SksQIreB.js} +16 -17
- package/dist/index.d.ts +20 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/io/dxfImportFns.d.ts +17 -0
- package/dist/io/dxfImportFns.d.ts.map +1 -0
- package/dist/io/objImportFns.d.ts +19 -0
- package/dist/io/objImportFns.d.ts.map +1 -0
- package/dist/io/threemfImportFns.d.ts +19 -0
- package/dist/io/threemfImportFns.d.ts.map +1 -0
- package/dist/io.cjs +5 -5
- package/dist/io.js +5 -5
- package/dist/kernel/hullOps.d.ts +23 -0
- package/dist/kernel/hullOps.d.ts.map +1 -0
- package/dist/kernel/occtAdapter.d.ts +11 -0
- package/dist/kernel/occtAdapter.d.ts.map +1 -1
- package/dist/kernel/solverAdapter.d.ts +39 -0
- package/dist/kernel/solverAdapter.d.ts.map +1 -0
- package/dist/kernel/types.d.ts +11 -0
- package/dist/kernel/types.d.ts.map +1 -1
- package/dist/{loft-PMRx9iMG.cjs → loft-BcyyvWCj.cjs} +28 -28
- package/dist/{loft-BHn7GKm8.js → loft-CJMPx1NQ.js} +16 -16
- package/dist/{measurement-BfhEneUl.js → measurement-ByOztLxb.js} +3 -3
- package/dist/{measurement-B06hNs89.cjs → measurement-DU3ry-0Q.cjs} +3 -3
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-BEvGVcym.js → meshFns-D2gLyLFt.js} +3 -3
- package/dist/{meshFns-CJV_k_EQ.cjs → meshFns-DawUwI3W.cjs} +3 -3
- package/dist/{occtBoundary-CoXB2xvx.js → occtBoundary-CWzWqBCm.js} +436 -7
- package/dist/{occtBoundary-BFAaUtA7.cjs → occtBoundary-DH2VO-rq.cjs} +431 -2
- package/dist/operations/assemblyFns.d.ts +1 -0
- package/dist/operations/assemblyFns.d.ts.map +1 -1
- package/dist/operations/guidedSweepFns.d.ts +25 -0
- package/dist/operations/guidedSweepFns.d.ts.map +1 -0
- package/dist/operations/mateFns.d.ts +50 -0
- package/dist/operations/mateFns.d.ts.map +1 -0
- package/dist/operations/multiSweepFns.d.ts +32 -0
- package/dist/operations/multiSweepFns.d.ts.map +1 -0
- package/dist/operations/roofFns.d.ts +16 -0
- package/dist/operations/roofFns.d.ts.map +1 -0
- package/dist/operations/straightSkeleton.d.ts +28 -0
- package/dist/operations/straightSkeleton.d.ts.map +1 -0
- package/dist/{operations-CYGNxn5D.cjs → operations-CdELWxgv.cjs} +7 -7
- package/dist/{operations-B314mytX.js → operations-DiXo_4t9.js} +15 -15
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +13 -13
- package/dist/query.cjs +5 -5
- package/dist/query.js +7 -7
- package/dist/result.cjs +1 -1
- package/dist/result.js +1 -1
- package/dist/{shapeFns-Z_ScEjmn.cjs → shapeFns-3RYtsUVY.cjs} +54 -21
- package/dist/{shapeFns-CWd_ASDV.js → shapeFns-4ioRrhih.js} +52 -19
- package/dist/{shapeTypes-UqVCIO_T.cjs → shapeTypes-CMjrTv36.cjs} +1 -1
- package/dist/{shapeTypes-BU2LKv2S.js → shapeTypes-D0vfRxWb.js} +13 -13
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/{curveBuilders-CN72XaIQ.js → surfaceBuilders-B7Jxob8g.js} +106 -13
- package/dist/{curveBuilders-Du03_Yyf.cjs → surfaceBuilders-Xx9DRRxs.cjs} +96 -3
- package/dist/text/textBlueprints.d.ts +38 -0
- package/dist/text/textBlueprints.d.ts.map +1 -1
- package/dist/topology/api.d.ts +5 -0
- package/dist/topology/api.d.ts.map +1 -1
- package/dist/topology/booleanFns.d.ts +10 -1
- package/dist/topology/booleanFns.d.ts.map +1 -1
- package/dist/topology/colorFns.d.ts +38 -0
- package/dist/topology/colorFns.d.ts.map +1 -0
- package/dist/topology/curveFns.d.ts +1 -1
- package/dist/topology/curveFns.d.ts.map +1 -1
- package/dist/topology/faceTagFns.d.ts +44 -0
- package/dist/topology/faceTagFns.d.ts.map +1 -0
- package/dist/topology/hullFns.d.ts +16 -0
- package/dist/topology/hullFns.d.ts.map +1 -0
- package/dist/topology/minkowskiFns.d.ts +20 -0
- package/dist/topology/minkowskiFns.d.ts.map +1 -0
- package/dist/topology/modifierFns.d.ts.map +1 -1
- package/dist/topology/polyhedronFns.d.ts +8 -0
- package/dist/topology/polyhedronFns.d.ts.map +1 -0
- package/dist/topology/shapeFns.d.ts +4 -0
- package/dist/topology/shapeFns.d.ts.map +1 -1
- package/dist/topology/surfaceBuilders.d.ts +7 -0
- package/dist/topology/surfaceBuilders.d.ts.map +1 -1
- package/dist/topology/surfaceFns.d.ts +38 -0
- package/dist/topology/surfaceFns.d.ts.map +1 -0
- package/dist/{topology-A7-jUtHB.cjs → topology-D-nGjCzV.cjs} +19 -20
- package/dist/{topology-BupialMm.js → topology-DRP9zreU.js} +8 -9
- package/dist/topology.cjs +13 -14
- package/dist/topology.js +51 -52
- package/dist/{vectors-BhfKwL9J.js → vectors-CZV4ZrTz.js} +2 -2
- package/dist/{vectors-t1XG4LpL.cjs → vectors-DwFeX0Ja.cjs} +2 -2
- package/dist/vectors.cjs +2 -2
- package/dist/vectors.js +2 -2
- package/package.json +8 -7
- package/dist/cast-C107o5ow.cjs +0 -102
- package/dist/cast-D0OhP1nV.js +0 -103
package/dist/core/errors.d.ts
CHANGED
|
@@ -70,10 +70,35 @@ export declare const BrepErrorCode: {
|
|
|
70
70
|
readonly STL_IMPORT_FAILED: "STL_IMPORT_FAILED";
|
|
71
71
|
readonly IGES_EXPORT_FAILED: "IGES_EXPORT_FAILED";
|
|
72
72
|
readonly IGES_IMPORT_FAILED: "IGES_IMPORT_FAILED";
|
|
73
|
+
readonly DXF_IMPORT_FAILED: "DXF_IMPORT_FAILED";
|
|
74
|
+
readonly OBJ_IMPORT_FAILED: "OBJ_IMPORT_FAILED";
|
|
75
|
+
readonly THREEMF_IMPORT_FAILED: "THREEMF_IMPORT_FAILED";
|
|
73
76
|
readonly PARAMETER_NOT_FOUND: "PARAMETER_NOT_FOUND";
|
|
74
77
|
readonly INTERSECTION_FAILED: "INTERSECTION_FAILED";
|
|
75
78
|
readonly SELF_INTERSECTION_FAILED: "SELF_INTERSECTION_FAILED";
|
|
76
79
|
readonly FINDER_NOT_UNIQUE: "FINDER_NOT_UNIQUE";
|
|
80
|
+
readonly HULL_EMPTY_INPUT: "HULL_EMPTY_INPUT";
|
|
81
|
+
readonly HULL_FAILED: "HULL_FAILED";
|
|
82
|
+
readonly HULL_DEGENERATE: "HULL_DEGENERATE";
|
|
83
|
+
readonly HULL_NOT_3D: "HULL_NOT_3D";
|
|
84
|
+
readonly MINKOWSKI_FAILED: "MINKOWSKI_FAILED";
|
|
85
|
+
readonly MINKOWSKI_NULL_TOOL: "MINKOWSKI_NULL_TOOL";
|
|
86
|
+
readonly MINKOWSKI_NOT_3D: "MINKOWSKI_NOT_3D";
|
|
87
|
+
readonly POLYHEDRON_INSUFFICIENT_POINTS: "POLYHEDRON_INSUFFICIENT_POINTS";
|
|
88
|
+
readonly POLYHEDRON_INSUFFICIENT_FACES: "POLYHEDRON_INSUFFICIENT_FACES";
|
|
89
|
+
readonly POLYHEDRON_INVALID_INDEX: "POLYHEDRON_INVALID_INDEX";
|
|
90
|
+
readonly POLYHEDRON_FAILED: "POLYHEDRON_FAILED";
|
|
91
|
+
readonly ROOF_FAILED: "ROOF_FAILED";
|
|
92
|
+
readonly MULTI_SWEEP_INSUFFICIENT_SECTIONS: "MULTI_SWEEP_INSUFFICIENT_SECTIONS";
|
|
93
|
+
readonly MULTI_SWEEP_FAILED: "MULTI_SWEEP_FAILED";
|
|
94
|
+
readonly GUIDED_SWEEP_FAILED: "GUIDED_SWEEP_FAILED";
|
|
95
|
+
readonly FACE_TAG_INVALID: "FACE_TAG_INVALID";
|
|
96
|
+
readonly SURFACE_GRID_TOO_SMALL: "SURFACE_GRID_TOO_SMALL";
|
|
97
|
+
readonly SURFACE_GRID_JAGGED: "SURFACE_GRID_JAGGED";
|
|
98
|
+
readonly SURFACE_FAILED: "SURFACE_FAILED";
|
|
99
|
+
readonly ASSEMBLY_MATE_INVALID: "ASSEMBLY_MATE_INVALID";
|
|
100
|
+
readonly ASSEMBLY_SOLVE_FAILED: "ASSEMBLY_SOLVE_FAILED";
|
|
101
|
+
readonly ASSEMBLY_NOT_CONVERGED: "ASSEMBLY_NOT_CONVERGED";
|
|
77
102
|
};
|
|
78
103
|
/** Union of all known error code string literals. */
|
|
79
104
|
export type BrepErrorCode = (typeof BrepErrorCode)[keyof typeof BrepErrorCode];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAMpD,8CAA8C;AAC9C,MAAM,MAAM,aAAa,GACrB,gBAAgB,GAChB,YAAY,GACZ,WAAW,GACX,gBAAgB,GAChB,aAAa,GACb,aAAa,GACb,IAAI,GACJ,OAAO,CAAC;AAMZ;;;;GAIG;AACH,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"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"}
|
package/dist/core.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const occtBoundary = require("./occtBoundary-
|
|
3
|
+
const occtBoundary = require("./occtBoundary-DH2VO-rq.cjs");
|
|
4
4
|
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
5
|
-
const errors = require("./errors-
|
|
6
|
-
const vectors = require("./vectors-
|
|
7
|
-
const shapeTypes = require("./shapeTypes-
|
|
5
|
+
const errors = require("./errors-eRQu29oc.cjs");
|
|
6
|
+
const vectors = require("./vectors-DwFeX0Ja.cjs");
|
|
7
|
+
const shapeTypes = require("./shapeTypes-CMjrTv36.cjs");
|
|
8
8
|
const result = require("./result.cjs");
|
|
9
9
|
exports.resolveDirection = occtBoundary.resolveDirection;
|
|
10
10
|
exports.toVec2 = occtBoundary.toVec2;
|
package/dist/core.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { r, t, a } from "./occtBoundary-
|
|
1
|
+
import { r, t, a } from "./occtBoundary-CWzWqBCm.js";
|
|
2
2
|
import { D, H, R, v, a as a2, b, c, d, e, f, g, h, i, j, k, l, m, n, o } from "./vecOps-ZDdZWbwT.js";
|
|
3
|
-
import { O, a as a3, c as c2, b as b2, e as e2, f as f2, i as i2, d as d2, g as g2, m as m2, h as h2, j as j2, k as k2, o as o2, l as l2, q, s, t as t2, n as n2, p, u, r as r2, v as v2, w, x } from "./errors-
|
|
4
|
-
import { c as c3, a as a4, p as p2, r as r3, t as t3 } from "./vectors-
|
|
5
|
-
import { D as D2, c as c4, a as a5, b as b3, g as g3, i as i3, d as d3, e as e3, f as f3, h as h3, j as j3, k as k3, l as l3, m as m3, w as w2 } from "./shapeTypes-
|
|
3
|
+
import { O, a as a3, c as c2, b as b2, e as e2, f as f2, i as i2, d as d2, g as g2, m as m2, h as h2, j as j2, k as k2, o as o2, l as l2, q, s, t as t2, n as n2, p, u, r as r2, v as v2, w, x } from "./errors-Coh_5_19.js";
|
|
4
|
+
import { c as c3, a as a4, p as p2, r as r3, t as t3 } from "./vectors-CZV4ZrTz.js";
|
|
5
|
+
import { D as D2, c as c4, a as a5, b as b3, g as g3, i as i3, d as d3, e as e3, f as f3, h as h3, j as j3, k as k3, l as l3, m as m3, w as w2 } from "./shapeTypes-D0vfRxWb.js";
|
|
6
6
|
import { BrepBugError, bug } from "./result.js";
|
|
7
7
|
export {
|
|
8
8
|
BrepBugError,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as angle2d, s as samePoint, d as distance2d } from "./helpers-
|
|
1
|
+
import { a as angle2d, s as samePoint, d as distance2d } from "./helpers-SksQIreB.js";
|
|
2
2
|
import { D as DEG2RAD } from "./vecOps-ZDdZWbwT.js";
|
|
3
3
|
const PI_2 = 2 * Math.PI;
|
|
4
4
|
function positiveHalfAngle(angle) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as getKernel } from "./occtBoundary-
|
|
2
|
-
import { c as castShape, d as isEdge, m as isWire,
|
|
3
|
-
import { e as err, p as typeCastError, l as ok, u as unwrap } from "./errors-
|
|
1
|
+
import { g as getKernel } from "./occtBoundary-CWzWqBCm.js";
|
|
2
|
+
import { c as castShape, d as isEdge, m as isWire, n as gcWithScope } from "./shapeTypes-D0vfRxWb.js";
|
|
3
|
+
import { e as err, p as typeCastError, l as ok, u as unwrap } from "./errors-Coh_5_19.js";
|
|
4
4
|
let CURVE_TYPES_MAP = null;
|
|
5
5
|
const getCurveTypesMap = (refresh) => {
|
|
6
6
|
if (CURVE_TYPES_MAP && !refresh) return CURVE_TYPES_MAP;
|
|
@@ -149,7 +149,9 @@ function offsetWire2D(wire, offset, kind = "arc") {
|
|
|
149
149
|
const joinTypes = {
|
|
150
150
|
arc: oc.GeomAbs_JoinType.GeomAbs_Arc,
|
|
151
151
|
intersection: oc.GeomAbs_JoinType.GeomAbs_Intersection,
|
|
152
|
-
tangent: oc.GeomAbs_JoinType.GeomAbs_Tangent
|
|
152
|
+
tangent: oc.GeomAbs_JoinType.GeomAbs_Tangent,
|
|
153
|
+
chamfer: oc.GeomAbs_JoinType.GeomAbs_Intersection
|
|
154
|
+
// sharp/miter corners
|
|
153
155
|
};
|
|
154
156
|
const resultShape = getKernel().offsetWire2D(wire.wrapped, offset, joinTypes[kind]);
|
|
155
157
|
const wrapped = castShape(resultShape);
|
|
@@ -160,19 +162,19 @@ function offsetWire2D(wire, offset, kind = "arc") {
|
|
|
160
162
|
return ok(wrapped);
|
|
161
163
|
}
|
|
162
164
|
export {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
165
|
+
curveEndPoint as a,
|
|
166
|
+
getCurveType as b,
|
|
167
|
+
curveTangentAt as c,
|
|
168
|
+
curveStartPoint as d,
|
|
169
|
+
curveIsClosed as e,
|
|
170
|
+
findCurveType as f,
|
|
171
|
+
getOrientation as g,
|
|
172
|
+
curvePointAt as h,
|
|
173
|
+
curveLength as i,
|
|
174
|
+
approximateCurve as j,
|
|
175
|
+
curveIsPeriodic as k,
|
|
176
|
+
curvePeriod as l,
|
|
177
|
+
flipOrientation as m,
|
|
176
178
|
interpolateCurve as n,
|
|
177
179
|
offsetWire2D as o
|
|
178
180
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const occtBoundary = require("./occtBoundary-
|
|
3
|
-
const shapeTypes = require("./shapeTypes-
|
|
4
|
-
const errors = require("./errors-
|
|
2
|
+
const occtBoundary = require("./occtBoundary-DH2VO-rq.cjs");
|
|
3
|
+
const shapeTypes = require("./shapeTypes-CMjrTv36.cjs");
|
|
4
|
+
const errors = require("./errors-eRQu29oc.cjs");
|
|
5
5
|
let CURVE_TYPES_MAP = null;
|
|
6
6
|
const getCurveTypesMap = (refresh) => {
|
|
7
7
|
if (CURVE_TYPES_MAP && !refresh) return CURVE_TYPES_MAP;
|
|
@@ -150,7 +150,9 @@ function offsetWire2D(wire, offset, kind = "arc") {
|
|
|
150
150
|
const joinTypes = {
|
|
151
151
|
arc: oc.GeomAbs_JoinType.GeomAbs_Arc,
|
|
152
152
|
intersection: oc.GeomAbs_JoinType.GeomAbs_Intersection,
|
|
153
|
-
tangent: oc.GeomAbs_JoinType.GeomAbs_Tangent
|
|
153
|
+
tangent: oc.GeomAbs_JoinType.GeomAbs_Tangent,
|
|
154
|
+
chamfer: oc.GeomAbs_JoinType.GeomAbs_Intersection
|
|
155
|
+
// sharp/miter corners
|
|
154
156
|
};
|
|
155
157
|
const resultShape = occtBoundary.getKernel().offsetWire2D(wire.wrapped, offset, joinTypes[kind]);
|
|
156
158
|
const wrapped = shapeTypes.castShape(resultShape);
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import { u as unwrap, g as isOk, e as err, x as validationError, l as ok } from "./errors-
|
|
2
|
-
import { r as resolvePlane, b as planeToWorld, d as planeToLocal } from "./vectors-
|
|
3
|
-
import { g as getKernel, a as toVec3,
|
|
1
|
+
import { u as unwrap, g as isOk, e as err, x as validationError, l as ok } from "./errors-Coh_5_19.js";
|
|
2
|
+
import { r as resolvePlane, b as planeToWorld, d as planeToLocal } from "./vectors-CZV4ZrTz.js";
|
|
3
|
+
import { g as getKernel, a as toVec3, c as makeOcAx2 } from "./occtBoundary-CWzWqBCm.js";
|
|
4
4
|
import { n as vecScale, j as vecNormalize, v as vecAdd, o as vecSub, b as vecCross, m as vecRotate, R as RAD2DEG, g as vecLength, e as vecEquals, D as DEG2RAD } from "./vecOps-ZDdZWbwT.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { h as mirror, a as addHolesInFace, m as makeFace, B as Blueprint, C as Curve2D, i as make2dSegmentCurve, j as make2dArcFromCenter, k as approximateAsSvgCompatibleCurve, e as BoundingBox2d, l as edgeToCurve, n as make2dInerpolatedBSplineCurve, o as make2dCircle, p as make2dEllipse, q as deserializeCurve2D } from "./Blueprint-CdVaHDSx.js";
|
|
5
|
+
import { b as Flatbush, c as convertSvgEllipseParams, d as defaultsSplineOptions, S as Sketch, r as roundedRectangleBlueprint, e as Blueprints, C as CompoundBlueprint, f as cut2D, i as intersectCurves, g as fuse2D, m as make2dOffset, h as filletCurves, j as chamferCurves, o as organiseBlueprints, a as BlueprintSketcher, k as intersect2D, B as BaseSketcher2d, p as polysidesBlueprint } from "./boolean2D-D94Axs3i.js";
|
|
6
|
+
import { d as downcast, c as cast, e as faceCenter, n as normalAt, o as outerWire } from "./faceFns-CltrEfOo.js";
|
|
7
|
+
import { c as curveTangentAt, a as curveEndPoint, b as getCurveType, o as offsetWire2D } from "./curveFns-B85Glnfo.js";
|
|
8
|
+
import { a as makeLine, d as makeThreePointArc, e as makeTangentArc, f as makeEllipseArc, g as makeBezierCurve, b as assembleWire, h as addHolesInFace, m as makeFace, i as makeCircle, j as makeEllipse, c as makeHelix, k as makeBSplineApproximation } from "./surfaceBuilders-B7Jxob8g.js";
|
|
9
|
+
import { o as createWire, r as localGC, q as createFace, e as isFace, n as gcWithScope, c as castShape } from "./shapeTypes-D0vfRxWb.js";
|
|
10
|
+
import { m as mirror, B as Blueprint, C as Curve2D, a as make2dSegmentCurve, b as make2dArcFromCenter, c as approximateAsSvgCompatibleCurve, d as BoundingBox2d, e as edgeToCurve, f as make2dInerpolatedBSplineCurve, g as make2dCircle, h as make2dEllipse, i as deserializeCurve2D } from "./Blueprint-Cmh8lKc4.js";
|
|
12
11
|
import { bug } from "./result.js";
|
|
13
|
-
import { d as distance2d, p as polarAngle2d,
|
|
14
|
-
import {
|
|
15
|
-
import { m as makeCompound,
|
|
12
|
+
import { d as distance2d, p as polarAngle2d, f as polarToCartesian, P as PRECISION_OFFSET, h as squareDistance2d, s as samePoint$1, e as subtract2d, c as add2d } from "./helpers-SksQIreB.js";
|
|
13
|
+
import { d as getEdges } from "./shapeFns-4ioRrhih.js";
|
|
14
|
+
import { m as makeCompound, b as basicFaceExtrusion, r as revolution, a as makeSolid, c as complexExtrude, t as twistExtrude } from "./loft-CJMPx1NQ.js";
|
|
16
15
|
import opentype from "opentype.js";
|
|
17
|
-
import { c as cornerFinder } from "./cornerFinder-
|
|
16
|
+
import { c as cornerFinder } from "./cornerFinder-BBOYfsXl.js";
|
|
18
17
|
const stitchCurves = (curves, precision = 1e-7) => {
|
|
19
18
|
const startPoints = new Flatbush(curves.length);
|
|
20
19
|
curves.forEach((c) => {
|
|
@@ -1023,7 +1022,8 @@ async function loadFont(fontPath, fontFamily = "default", force = false) {
|
|
|
1023
1022
|
response = await fetch(fontPath);
|
|
1024
1023
|
} catch (e) {
|
|
1025
1024
|
throw new Error(
|
|
1026
|
-
`Failed to fetch font from ${fontPath}: ${e instanceof Error ? e.message : String(e)}
|
|
1025
|
+
`Failed to fetch font from ${fontPath}: ${e instanceof Error ? e.message : String(e)}`,
|
|
1026
|
+
{ cause: e }
|
|
1027
1027
|
);
|
|
1028
1028
|
}
|
|
1029
1029
|
if (!response.ok) {
|
|
@@ -1039,7 +1039,9 @@ async function loadFont(fontPath, fontFamily = "default", force = false) {
|
|
|
1039
1039
|
try {
|
|
1040
1040
|
font = opentype.parse(fontData);
|
|
1041
1041
|
} catch (e) {
|
|
1042
|
-
throw new Error(`Failed to parse font data: ${e instanceof Error ? e.message : String(e)}
|
|
1042
|
+
throw new Error(`Failed to parse font data: ${e instanceof Error ? e.message : String(e)}`, {
|
|
1043
|
+
cause: e
|
|
1044
|
+
});
|
|
1043
1045
|
}
|
|
1044
1046
|
FONT_REGISTER[fontFamily] = font;
|
|
1045
1047
|
if (!FONT_REGISTER["default"]) FONT_REGISTER["default"] = font;
|
|
@@ -1100,6 +1102,31 @@ function sketchText(text, textConfig, planeConfig = {}) {
|
|
|
1100
1102
|
)
|
|
1101
1103
|
);
|
|
1102
1104
|
}
|
|
1105
|
+
function textMetrics(text, options) {
|
|
1106
|
+
const fontSize = options?.fontSize ?? 1;
|
|
1107
|
+
const font = getFont(options?.fontFamily);
|
|
1108
|
+
if (!font) throw new Error("No font loaded. Call loadFont() first.");
|
|
1109
|
+
const width = font.getAdvanceWidth(text, fontSize);
|
|
1110
|
+
const scale = fontSize / font.unitsPerEm;
|
|
1111
|
+
const ascender = font.ascender * scale;
|
|
1112
|
+
const descender = font.descender * scale;
|
|
1113
|
+
return { width, height: ascender - descender, ascender, descender };
|
|
1114
|
+
}
|
|
1115
|
+
function fontMetrics(options) {
|
|
1116
|
+
const fontSize = options?.fontSize ?? 1;
|
|
1117
|
+
const font = getFont(options?.fontFamily);
|
|
1118
|
+
if (!font) throw new Error("No font loaded. Call loadFont() first.");
|
|
1119
|
+
const scale = fontSize / font.unitsPerEm;
|
|
1120
|
+
const ascender = font.ascender * scale;
|
|
1121
|
+
const descender = font.descender * scale;
|
|
1122
|
+
const lineGap = (font.tables?.os2?.sTypoLineGap ?? 0) * scale;
|
|
1123
|
+
return {
|
|
1124
|
+
ascender,
|
|
1125
|
+
descender,
|
|
1126
|
+
unitsPerEm: font.unitsPerEm,
|
|
1127
|
+
lineHeight: ascender - descender + lineGap
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1103
1130
|
const PROJECTION_PLANES = {
|
|
1104
1131
|
XY: { dir: [0, 0, 1], xAxis: [1, 0, 0] },
|
|
1105
1132
|
XZ: { dir: [0, -1, 0], xAxis: [1, 0, 0] },
|
|
@@ -1568,7 +1595,7 @@ function mirrorDrawing(drawing, centerOrDirection, origin, mode) {
|
|
|
1568
1595
|
return drawing.mirror(centerOrDirection, origin, mode);
|
|
1569
1596
|
}
|
|
1570
1597
|
export {
|
|
1571
|
-
|
|
1598
|
+
getFont as $,
|
|
1572
1599
|
makeBaseBox as A,
|
|
1573
1600
|
mirrorDrawing as B,
|
|
1574
1601
|
CompoundSketch as C,
|
|
@@ -1595,13 +1622,15 @@ export {
|
|
|
1595
1622
|
cameraFromPlane as X,
|
|
1596
1623
|
cameraLookAt as Y,
|
|
1597
1624
|
createCamera as Z,
|
|
1598
|
-
|
|
1625
|
+
fontMetrics as _,
|
|
1599
1626
|
DrawingPen as a,
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1627
|
+
isProjectionPlane as a0,
|
|
1628
|
+
loadFont as a1,
|
|
1629
|
+
makeProjectedEdges as a2,
|
|
1630
|
+
projectEdges as a3,
|
|
1631
|
+
sketchText as a4,
|
|
1632
|
+
textBlueprints as a5,
|
|
1633
|
+
textMetrics as a6,
|
|
1605
1634
|
Sketches as b,
|
|
1606
1635
|
compoundSketchExtrude as c,
|
|
1607
1636
|
compoundSketchFace as d,
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const errors = require("./errors-
|
|
3
|
-
const vectors = require("./vectors-
|
|
4
|
-
const occtBoundary = require("./occtBoundary-
|
|
2
|
+
const errors = require("./errors-eRQu29oc.cjs");
|
|
3
|
+
const vectors = require("./vectors-DwFeX0Ja.cjs");
|
|
4
|
+
const occtBoundary = require("./occtBoundary-DH2VO-rq.cjs");
|
|
5
5
|
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
6
|
-
const boolean2D = require("./boolean2D-
|
|
7
|
-
const faceFns = require("./faceFns-
|
|
8
|
-
const curveFns = require("./curveFns-
|
|
9
|
-
const
|
|
10
|
-
const shapeTypes = require("./shapeTypes-
|
|
11
|
-
const
|
|
12
|
-
const Blueprint = require("./Blueprint-a3ukJMG4.cjs");
|
|
6
|
+
const boolean2D = require("./boolean2D-CqacqjME.cjs");
|
|
7
|
+
const faceFns = require("./faceFns-DcndPHWm.cjs");
|
|
8
|
+
const curveFns = require("./curveFns-BXCbASW-.cjs");
|
|
9
|
+
const surfaceBuilders = require("./surfaceBuilders-Xx9DRRxs.cjs");
|
|
10
|
+
const shapeTypes = require("./shapeTypes-CMjrTv36.cjs");
|
|
11
|
+
const Blueprint = require("./Blueprint-BcbOBF-9.cjs");
|
|
13
12
|
const result = require("./result.cjs");
|
|
14
|
-
const helpers = require("./helpers-
|
|
15
|
-
const shapeFns = require("./shapeFns-
|
|
16
|
-
const loft = require("./loft-
|
|
13
|
+
const helpers = require("./helpers-CC21GeAr.cjs");
|
|
14
|
+
const shapeFns = require("./shapeFns-3RYtsUVY.cjs");
|
|
15
|
+
const loft = require("./loft-BcyyvWCj.cjs");
|
|
17
16
|
const opentype = require("opentype.js");
|
|
18
|
-
const cornerFinder = require("./cornerFinder-
|
|
17
|
+
const cornerFinder = require("./cornerFinder-Bqy8Lw2p.cjs");
|
|
19
18
|
const stitchCurves = (curves, precision = 1e-7) => {
|
|
20
19
|
const startPoints = new boolean2D.Flatbush(curves.length);
|
|
21
20
|
curves.forEach((c) => {
|
|
@@ -98,7 +97,7 @@ class Sketcher {
|
|
|
98
97
|
/** Draw a straight line to an absolute 2D point on the sketch plane. */
|
|
99
98
|
lineTo([x, y]) {
|
|
100
99
|
const endPoint = vectors.planeToWorld(this.plane, [x, y]);
|
|
101
|
-
this.pendingEdges.push(
|
|
100
|
+
this.pendingEdges.push(surfaceBuilders.makeLine(this.pointer, endPoint));
|
|
102
101
|
this._updatePointer(endPoint);
|
|
103
102
|
return this;
|
|
104
103
|
}
|
|
@@ -145,7 +144,7 @@ class Sketcher {
|
|
|
145
144
|
const tangent = curveFns.curveTangentAt(previousEdge, 1);
|
|
146
145
|
const scaledTangent = vecOps.vecScale(vecOps.vecNormalize(tangent), distance);
|
|
147
146
|
const endPoint = vecOps.vecAdd(scaledTangent, this.pointer);
|
|
148
|
-
this.pendingEdges.push(
|
|
147
|
+
this.pendingEdges.push(surfaceBuilders.makeLine(this.pointer, endPoint));
|
|
149
148
|
this._updatePointer(endPoint);
|
|
150
149
|
return this;
|
|
151
150
|
}
|
|
@@ -153,7 +152,7 @@ class Sketcher {
|
|
|
153
152
|
threePointsArcTo(end, innerPoint) {
|
|
154
153
|
const gpoint1 = vectors.planeToWorld(this.plane, innerPoint);
|
|
155
154
|
const gpoint2 = vectors.planeToWorld(this.plane, end);
|
|
156
|
-
this.pendingEdges.push(
|
|
155
|
+
this.pendingEdges.push(surfaceBuilders.makeThreePointArc(this.pointer, gpoint1, gpoint2));
|
|
157
156
|
this._updatePointer(gpoint2);
|
|
158
157
|
return this;
|
|
159
158
|
}
|
|
@@ -170,7 +169,7 @@ class Sketcher {
|
|
|
170
169
|
result.bug("Sketcher.tangentArcTo", "You need a previous edge to create a tangent arc");
|
|
171
170
|
const prevEnd = curveFns.curveEndPoint(previousEdge);
|
|
172
171
|
const prevTangent = curveFns.curveTangentAt(previousEdge, 1);
|
|
173
|
-
this.pendingEdges.push(
|
|
172
|
+
this.pendingEdges.push(surfaceBuilders.makeTangentArc(prevEnd, prevTangent, endPoint));
|
|
174
173
|
this._updatePointer(endPoint);
|
|
175
174
|
return this;
|
|
176
175
|
}
|
|
@@ -190,7 +189,7 @@ class Sketcher {
|
|
|
190
189
|
const sagDirection = vecOps.vecNormalize(crossResult);
|
|
191
190
|
const sagVector = vecOps.vecScale(sagDirection, sagitta);
|
|
192
191
|
const sagPoint = vecOps.vecAdd(midPoint, sagVector);
|
|
193
|
-
this.pendingEdges.push(
|
|
192
|
+
this.pendingEdges.push(surfaceBuilders.makeThreePointArc(this.pointer, sagPoint, endPoint));
|
|
194
193
|
this._updatePointer(endPoint);
|
|
195
194
|
return this;
|
|
196
195
|
}
|
|
@@ -250,7 +249,7 @@ class Sketcher {
|
|
|
250
249
|
);
|
|
251
250
|
const xDir = vecOps.vecRotate(this.plane.xDir, this.plane.zDir, rotationAngle * vecOps.DEG2RAD);
|
|
252
251
|
const arc = errors.unwrap(
|
|
253
|
-
|
|
252
|
+
surfaceBuilders.makeEllipseArc(
|
|
254
253
|
rx,
|
|
255
254
|
ry,
|
|
256
255
|
clockwise ? startAngle : endAngle,
|
|
@@ -302,7 +301,7 @@ class Sketcher {
|
|
|
302
301
|
}
|
|
303
302
|
const inWorldPoints = cp.map((p) => vectors.planeToWorld(this.plane, p));
|
|
304
303
|
const endPoint = vectors.planeToWorld(this.plane, end);
|
|
305
|
-
this.pendingEdges.push(errors.unwrap(
|
|
304
|
+
this.pendingEdges.push(errors.unwrap(surfaceBuilders.makeBezierCurve([this.pointer, ...inWorldPoints, endPoint])));
|
|
306
305
|
this._updatePointer(endPoint);
|
|
307
306
|
return this;
|
|
308
307
|
}
|
|
@@ -351,7 +350,7 @@ class Sketcher {
|
|
|
351
350
|
const endPoleDistance = vecOps.vecScale(vecOps.vecNormalize(endPoleDirection), endFactor * defaultDistance);
|
|
352
351
|
const endControl = vecOps.vecSub(endPoint, endPoleDistance);
|
|
353
352
|
this.pendingEdges.push(
|
|
354
|
-
errors.unwrap(
|
|
353
|
+
errors.unwrap(surfaceBuilders.makeBezierCurve([this.pointer, startControl, endControl, endPoint]))
|
|
355
354
|
);
|
|
356
355
|
this._updatePointer(endPoint);
|
|
357
356
|
return this;
|
|
@@ -368,16 +367,16 @@ class Sketcher {
|
|
|
368
367
|
const diff = vecOps.vecSub(this.pointer, this.firstPoint);
|
|
369
368
|
const startToEndVector = vecOps.vecNormalize(diff);
|
|
370
369
|
const normal = vecOps.vecCross(startToEndVector, this.plane.zDir);
|
|
371
|
-
const clonedWrapped = errors.unwrap(
|
|
370
|
+
const clonedWrapped = errors.unwrap(faceFns.downcast(wire.wrapped));
|
|
372
371
|
const mirroredRaw = Blueprint.mirror(clonedWrapped, normal, this.pointer);
|
|
373
|
-
const mirroredWrapped = errors.unwrap(
|
|
372
|
+
const mirroredWrapped = errors.unwrap(faceFns.downcast(mirroredRaw));
|
|
374
373
|
const mirroredWire = shapeTypes.createWire(mirroredWrapped);
|
|
375
|
-
const combinedWire = errors.unwrap(
|
|
374
|
+
const combinedWire = errors.unwrap(surfaceBuilders.assembleWire([wire, mirroredWire]));
|
|
376
375
|
return combinedWire;
|
|
377
376
|
}
|
|
378
377
|
buildWire() {
|
|
379
378
|
if (!this.pendingEdges.length) result.bug("Sketcher.buildWire", "No lines to convert into a wire");
|
|
380
|
-
let wire = errors.unwrap(
|
|
379
|
+
let wire = errors.unwrap(surfaceBuilders.assembleWire(this.pendingEdges));
|
|
381
380
|
if (this._mirrorWire) {
|
|
382
381
|
wire = this._mirrorWireOnStartEnd(wire);
|
|
383
382
|
}
|
|
@@ -421,7 +420,7 @@ const guessFaceFromWires = (wires) => {
|
|
|
421
420
|
});
|
|
422
421
|
const progress = r(new oc.Message_ProgressRange_1());
|
|
423
422
|
faceBuilder.Build(progress);
|
|
424
|
-
const newFace = errors.unwrap(
|
|
423
|
+
const newFace = errors.unwrap(faceFns.cast(faceBuilder.Shape()));
|
|
425
424
|
gc();
|
|
426
425
|
if (!shapeTypes.isFace(newFace)) {
|
|
427
426
|
result.bug("guessFaceFromWires", "Failed to create a face");
|
|
@@ -439,7 +438,7 @@ const fixWire = (wire, baseFace) => {
|
|
|
439
438
|
const faceFromWires = (wires) => {
|
|
440
439
|
let baseFace;
|
|
441
440
|
let holeWires;
|
|
442
|
-
const faceResult =
|
|
441
|
+
const faceResult = surfaceBuilders.makeFace(wires[0]);
|
|
443
442
|
if (errors.isOk(faceResult)) {
|
|
444
443
|
baseFace = faceResult.value;
|
|
445
444
|
holeWires = wires.slice(1);
|
|
@@ -447,7 +446,7 @@ const faceFromWires = (wires) => {
|
|
|
447
446
|
baseFace = guessFaceFromWires(wires);
|
|
448
447
|
holeWires = wires.slice(1).map((w) => fixWire(w, baseFace));
|
|
449
448
|
}
|
|
450
|
-
return
|
|
449
|
+
return surfaceBuilders.addHolesInFace(baseFace, holeWires);
|
|
451
450
|
};
|
|
452
451
|
const solidFromShellGenerator = (sketches, shellGenerator) => {
|
|
453
452
|
const shells = [];
|
|
@@ -494,7 +493,7 @@ class CompoundSketch {
|
|
|
494
493
|
/** Build a face from the outer boundary with inner wires subtracted as holes. */
|
|
495
494
|
face() {
|
|
496
495
|
const baseFace = this.outerSketch.face();
|
|
497
|
-
const newFace =
|
|
496
|
+
const newFace = surfaceBuilders.addHolesInFace(
|
|
498
497
|
baseFace,
|
|
499
498
|
this.innerSketches.map((s) => s.wire)
|
|
500
499
|
);
|
|
@@ -571,7 +570,7 @@ class CompoundSketch {
|
|
|
571
570
|
return base.clone().loftWith(outer.clone(), { ruled: loftConfig.ruled }, true);
|
|
572
571
|
});
|
|
573
572
|
const baseFaceRaw = this.face();
|
|
574
|
-
const baseFace = shapeTypes.createFace(errors.unwrap(
|
|
573
|
+
const baseFace = shapeTypes.createFace(errors.unwrap(faceFns.downcast(baseFaceRaw.wrapped)));
|
|
575
574
|
shells.push(baseFace, otherCompound.face());
|
|
576
575
|
return errors.unwrap(loft.makeSolid(shells));
|
|
577
576
|
}
|
|
@@ -615,7 +614,7 @@ class Sketches {
|
|
|
615
614
|
}
|
|
616
615
|
const sketchCircle = (radius, planeConfig = {}) => {
|
|
617
616
|
const plane = planeConfig.plane && typeof planeConfig.plane !== "string" ? { ...planeConfig.plane } : vectors.resolvePlane(planeConfig.plane ?? "XY", planeConfig.origin);
|
|
618
|
-
const wire = errors.unwrap(
|
|
617
|
+
const wire = errors.unwrap(surfaceBuilders.assembleWire([surfaceBuilders.makeCircle(radius, plane.origin, plane.zDir)]));
|
|
619
618
|
const sketch = new boolean2D.Sketch(wire, {
|
|
620
619
|
defaultOrigin: [...plane.origin],
|
|
621
620
|
defaultDirection: [...plane.zDir]
|
|
@@ -633,7 +632,7 @@ const sketchEllipse = (xRadius = 1, yRadius = 2, planeConfig = {}) => {
|
|
|
633
632
|
minR = xRadius;
|
|
634
633
|
}
|
|
635
634
|
const wire = errors.unwrap(
|
|
636
|
-
|
|
635
|
+
surfaceBuilders.assembleWire([errors.unwrap(surfaceBuilders.makeEllipse(majR, minR, plane.origin, plane.zDir, xDir))])
|
|
637
636
|
);
|
|
638
637
|
const sketch = new boolean2D.Sketch(wire, {
|
|
639
638
|
defaultOrigin: [...plane.origin],
|
|
@@ -695,7 +694,7 @@ const sketchParametricFunction = (func, planeConfig = {}, { pointsCount = 400, s
|
|
|
695
694
|
return vectors.planeToWorld(plane, point);
|
|
696
695
|
});
|
|
697
696
|
const wire = errors.unwrap(
|
|
698
|
-
|
|
697
|
+
surfaceBuilders.assembleWire([r(errors.unwrap(surfaceBuilders.makeBSplineApproximation(points, approximationConfig)))])
|
|
699
698
|
);
|
|
700
699
|
const sketch = new boolean2D.Sketch(wire, {
|
|
701
700
|
defaultOrigin: [...plane.origin],
|
|
@@ -708,7 +707,7 @@ const sketchHelix = (pitch, height, radius, center = [0, 0, 0], dir = [0, 0, 1],
|
|
|
708
707
|
const centerVec3 = occtBoundary.toVec3(center);
|
|
709
708
|
const dirVec3 = occtBoundary.toVec3(dir);
|
|
710
709
|
return new boolean2D.Sketch(
|
|
711
|
-
errors.unwrap(
|
|
710
|
+
errors.unwrap(surfaceBuilders.assembleWire([surfaceBuilders.makeHelix(pitch, height, radius, centerVec3, dirVec3, lefthand)]))
|
|
712
711
|
);
|
|
713
712
|
};
|
|
714
713
|
const makeBaseBox = (xLength, yLength, zLength) => {
|
|
@@ -1024,7 +1023,8 @@ async function loadFont(fontPath, fontFamily = "default", force = false) {
|
|
|
1024
1023
|
response = await fetch(fontPath);
|
|
1025
1024
|
} catch (e) {
|
|
1026
1025
|
throw new Error(
|
|
1027
|
-
`Failed to fetch font from ${fontPath}: ${e instanceof Error ? e.message : String(e)}
|
|
1026
|
+
`Failed to fetch font from ${fontPath}: ${e instanceof Error ? e.message : String(e)}`,
|
|
1027
|
+
{ cause: e }
|
|
1028
1028
|
);
|
|
1029
1029
|
}
|
|
1030
1030
|
if (!response.ok) {
|
|
@@ -1040,7 +1040,9 @@ async function loadFont(fontPath, fontFamily = "default", force = false) {
|
|
|
1040
1040
|
try {
|
|
1041
1041
|
font = opentype.parse(fontData);
|
|
1042
1042
|
} catch (e) {
|
|
1043
|
-
throw new Error(`Failed to parse font data: ${e instanceof Error ? e.message : String(e)}
|
|
1043
|
+
throw new Error(`Failed to parse font data: ${e instanceof Error ? e.message : String(e)}`, {
|
|
1044
|
+
cause: e
|
|
1045
|
+
});
|
|
1044
1046
|
}
|
|
1045
1047
|
FONT_REGISTER[fontFamily] = font;
|
|
1046
1048
|
if (!FONT_REGISTER["default"]) FONT_REGISTER["default"] = font;
|
|
@@ -1101,6 +1103,31 @@ function sketchText(text, textConfig, planeConfig = {}) {
|
|
|
1101
1103
|
)
|
|
1102
1104
|
);
|
|
1103
1105
|
}
|
|
1106
|
+
function textMetrics(text, options) {
|
|
1107
|
+
const fontSize = options?.fontSize ?? 1;
|
|
1108
|
+
const font = getFont(options?.fontFamily);
|
|
1109
|
+
if (!font) throw new Error("No font loaded. Call loadFont() first.");
|
|
1110
|
+
const width = font.getAdvanceWidth(text, fontSize);
|
|
1111
|
+
const scale = fontSize / font.unitsPerEm;
|
|
1112
|
+
const ascender = font.ascender * scale;
|
|
1113
|
+
const descender = font.descender * scale;
|
|
1114
|
+
return { width, height: ascender - descender, ascender, descender };
|
|
1115
|
+
}
|
|
1116
|
+
function fontMetrics(options) {
|
|
1117
|
+
const fontSize = options?.fontSize ?? 1;
|
|
1118
|
+
const font = getFont(options?.fontFamily);
|
|
1119
|
+
if (!font) throw new Error("No font loaded. Call loadFont() first.");
|
|
1120
|
+
const scale = fontSize / font.unitsPerEm;
|
|
1121
|
+
const ascender = font.ascender * scale;
|
|
1122
|
+
const descender = font.descender * scale;
|
|
1123
|
+
const lineGap = (font.tables?.os2?.sTypoLineGap ?? 0) * scale;
|
|
1124
|
+
return {
|
|
1125
|
+
ascender,
|
|
1126
|
+
descender,
|
|
1127
|
+
unitsPerEm: font.unitsPerEm,
|
|
1128
|
+
lineHeight: ascender - descender + lineGap
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1104
1131
|
const PROJECTION_PLANES = {
|
|
1105
1132
|
XY: { dir: [0, 0, 1], xAxis: [1, 0, 0] },
|
|
1106
1133
|
XZ: { dir: [0, -1, 0], xAxis: [1, 0, 0] },
|
|
@@ -1473,7 +1500,7 @@ const drawParametricFunction = (func, { pointsCount = 400, start = 0, stop = 1,
|
|
|
1473
1500
|
const edgesToDrawing = (edges) => {
|
|
1474
1501
|
const [r, gc] = shapeTypes.localGC();
|
|
1475
1502
|
const planeSketch = drawRectangle(1e3, 1e3).sketchOnPlane();
|
|
1476
|
-
const planeFace = r(errors.unwrap(
|
|
1503
|
+
const planeFace = r(errors.unwrap(surfaceBuilders.makeFace(planeSketch.wire)));
|
|
1477
1504
|
const curves = edges.map((e) => Blueprint.edgeToCurve(e, planeFace));
|
|
1478
1505
|
gc();
|
|
1479
1506
|
const stitchedCurves = stitchCurves(curves).map((s) => new Blueprint.Blueprint(s));
|
|
@@ -1496,7 +1523,7 @@ function drawProjection(shape, projectionCamera = "front") {
|
|
|
1496
1523
|
}
|
|
1497
1524
|
function drawFaceOutline(face) {
|
|
1498
1525
|
const [r, gc] = shapeTypes.localGC();
|
|
1499
|
-
const clonedFace = r(shapeTypes.createFace(errors.unwrap(
|
|
1526
|
+
const clonedFace = r(shapeTypes.createFace(errors.unwrap(faceFns.downcast(face.wrapped))));
|
|
1500
1527
|
const faceOuterWire = r(faceFns.outerWire(clonedFace));
|
|
1501
1528
|
const curves = shapeFns.getEdges(faceOuterWire).map((e) => Blueprint.edgeToCurve(e, face));
|
|
1502
1529
|
gc();
|
|
@@ -1600,6 +1627,7 @@ exports.drawingFillet = drawingFillet;
|
|
|
1600
1627
|
exports.drawingFuse = drawingFuse;
|
|
1601
1628
|
exports.drawingIntersect = drawingIntersect;
|
|
1602
1629
|
exports.drawingToSketchOnPlane = drawingToSketchOnPlane;
|
|
1630
|
+
exports.fontMetrics = fontMetrics;
|
|
1603
1631
|
exports.getFont = getFont;
|
|
1604
1632
|
exports.isProjectionPlane = isProjectionPlane;
|
|
1605
1633
|
exports.loadFont = loadFont;
|
|
@@ -1626,4 +1654,5 @@ exports.sketchSweep = sketchSweep;
|
|
|
1626
1654
|
exports.sketchText = sketchText;
|
|
1627
1655
|
exports.sketchWires = sketchWires;
|
|
1628
1656
|
exports.textBlueprints = textBlueprints;
|
|
1657
|
+
exports.textMetrics = textMetrics;
|
|
1629
1658
|
exports.translateDrawing = translateDrawing;
|
|
@@ -155,12 +155,46 @@ const BrepErrorCode = {
|
|
|
155
155
|
STL_IMPORT_FAILED: "STL_IMPORT_FAILED",
|
|
156
156
|
IGES_EXPORT_FAILED: "IGES_EXPORT_FAILED",
|
|
157
157
|
IGES_IMPORT_FAILED: "IGES_IMPORT_FAILED",
|
|
158
|
+
DXF_IMPORT_FAILED: "DXF_IMPORT_FAILED",
|
|
159
|
+
OBJ_IMPORT_FAILED: "OBJ_IMPORT_FAILED",
|
|
160
|
+
THREEMF_IMPORT_FAILED: "THREEMF_IMPORT_FAILED",
|
|
158
161
|
// Computation errors
|
|
159
162
|
PARAMETER_NOT_FOUND: "PARAMETER_NOT_FOUND",
|
|
160
163
|
INTERSECTION_FAILED: "INTERSECTION_FAILED",
|
|
161
164
|
SELF_INTERSECTION_FAILED: "SELF_INTERSECTION_FAILED",
|
|
162
165
|
// Query errors
|
|
163
|
-
FINDER_NOT_UNIQUE: "FINDER_NOT_UNIQUE"
|
|
166
|
+
FINDER_NOT_UNIQUE: "FINDER_NOT_UNIQUE",
|
|
167
|
+
// Hull errors
|
|
168
|
+
HULL_EMPTY_INPUT: "HULL_EMPTY_INPUT",
|
|
169
|
+
HULL_FAILED: "HULL_FAILED",
|
|
170
|
+
HULL_DEGENERATE: "HULL_DEGENERATE",
|
|
171
|
+
HULL_NOT_3D: "HULL_NOT_3D",
|
|
172
|
+
// Minkowski errors
|
|
173
|
+
MINKOWSKI_FAILED: "MINKOWSKI_FAILED",
|
|
174
|
+
MINKOWSKI_NULL_TOOL: "MINKOWSKI_NULL_TOOL",
|
|
175
|
+
MINKOWSKI_NOT_3D: "MINKOWSKI_NOT_3D",
|
|
176
|
+
// Polyhedron errors
|
|
177
|
+
POLYHEDRON_INSUFFICIENT_POINTS: "POLYHEDRON_INSUFFICIENT_POINTS",
|
|
178
|
+
POLYHEDRON_INSUFFICIENT_FACES: "POLYHEDRON_INSUFFICIENT_FACES",
|
|
179
|
+
POLYHEDRON_INVALID_INDEX: "POLYHEDRON_INVALID_INDEX",
|
|
180
|
+
POLYHEDRON_FAILED: "POLYHEDRON_FAILED",
|
|
181
|
+
// Roof errors
|
|
182
|
+
ROOF_FAILED: "ROOF_FAILED",
|
|
183
|
+
// Multi-section sweep errors
|
|
184
|
+
MULTI_SWEEP_INSUFFICIENT_SECTIONS: "MULTI_SWEEP_INSUFFICIENT_SECTIONS",
|
|
185
|
+
MULTI_SWEEP_FAILED: "MULTI_SWEEP_FAILED",
|
|
186
|
+
// Guide curve sweep errors
|
|
187
|
+
GUIDED_SWEEP_FAILED: "GUIDED_SWEEP_FAILED",
|
|
188
|
+
// Face tagging errors
|
|
189
|
+
FACE_TAG_INVALID: "FACE_TAG_INVALID",
|
|
190
|
+
// Surface errors
|
|
191
|
+
SURFACE_GRID_TOO_SMALL: "SURFACE_GRID_TOO_SMALL",
|
|
192
|
+
SURFACE_GRID_JAGGED: "SURFACE_GRID_JAGGED",
|
|
193
|
+
SURFACE_FAILED: "SURFACE_FAILED",
|
|
194
|
+
// Assembly mate errors
|
|
195
|
+
ASSEMBLY_MATE_INVALID: "ASSEMBLY_MATE_INVALID",
|
|
196
|
+
ASSEMBLY_SOLVE_FAILED: "ASSEMBLY_SOLVE_FAILED",
|
|
197
|
+
ASSEMBLY_NOT_CONVERGED: "ASSEMBLY_NOT_CONVERGED"
|
|
164
198
|
};
|
|
165
199
|
function makeError(kind, code, message, cause, metadata, suggestion) {
|
|
166
200
|
const base = { kind, code, message, cause };
|