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,190 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const occtBoundary = require("./occtBoundary-du8_ex-p.cjs");
|
|
3
|
-
const shapeTypes = require("./shapeTypes-DKhwEnUM.cjs");
|
|
4
|
-
const errors = require("./errors-DK1VAdP4.cjs");
|
|
5
|
-
let CURVE_TYPES_MAP = null;
|
|
6
|
-
const getCurveTypesMap = (refresh) => {
|
|
7
|
-
if (CURVE_TYPES_MAP && !refresh) return CURVE_TYPES_MAP;
|
|
8
|
-
const oc = occtBoundary.getKernel().oc;
|
|
9
|
-
const ga = oc.GeomAbs_CurveType;
|
|
10
|
-
CURVE_TYPES_MAP = /* @__PURE__ */ new Map([
|
|
11
|
-
[ga.GeomAbs_Line, "LINE"],
|
|
12
|
-
[ga.GeomAbs_Circle, "CIRCLE"],
|
|
13
|
-
[ga.GeomAbs_Ellipse, "ELLIPSE"],
|
|
14
|
-
[ga.GeomAbs_Hyperbola, "HYPERBOLA"],
|
|
15
|
-
[ga.GeomAbs_Parabola, "PARABOLA"],
|
|
16
|
-
[ga.GeomAbs_BezierCurve, "BEZIER_CURVE"],
|
|
17
|
-
[ga.GeomAbs_BSplineCurve, "BSPLINE_CURVE"],
|
|
18
|
-
[ga.GeomAbs_OffsetCurve, "OFFSET_CURVE"],
|
|
19
|
-
[ga.GeomAbs_OtherCurve, "OTHER_CURVE"]
|
|
20
|
-
]);
|
|
21
|
-
return CURVE_TYPES_MAP;
|
|
22
|
-
};
|
|
23
|
-
const findCurveType = (type) => {
|
|
24
|
-
let shapeType = getCurveTypesMap().get(type);
|
|
25
|
-
if (!shapeType) shapeType = getCurveTypesMap(true).get(type);
|
|
26
|
-
if (!shapeType) return errors.err(errors.typeCastError("UNKNOWN_CURVE_TYPE", "Unknown curve type"));
|
|
27
|
-
return errors.ok(shapeType);
|
|
28
|
-
};
|
|
29
|
-
function getAdaptor(shape) {
|
|
30
|
-
const oc = occtBoundary.getKernel().oc;
|
|
31
|
-
const st = shape.wrapped.ShapeType();
|
|
32
|
-
const e = oc.TopAbs_ShapeEnum;
|
|
33
|
-
if (st === e.TopAbs_WIRE) {
|
|
34
|
-
return new oc.BRepAdaptor_CompCurve_2(shape.wrapped, false);
|
|
35
|
-
}
|
|
36
|
-
return new oc.BRepAdaptor_Curve_2(shape.wrapped);
|
|
37
|
-
}
|
|
38
|
-
function mapParam(adaptor, t) {
|
|
39
|
-
const first = Number(adaptor.FirstParameter());
|
|
40
|
-
const last = Number(adaptor.LastParameter());
|
|
41
|
-
return first + (last - first) * t;
|
|
42
|
-
}
|
|
43
|
-
function getCurveType(shape) {
|
|
44
|
-
const adaptor = getAdaptor(shape);
|
|
45
|
-
const technicalType = adaptor.GetType && adaptor.GetType();
|
|
46
|
-
const result = errors.unwrap(findCurveType(technicalType));
|
|
47
|
-
adaptor.delete();
|
|
48
|
-
return result;
|
|
49
|
-
}
|
|
50
|
-
function curveStartPoint(shape) {
|
|
51
|
-
const adaptor = getAdaptor(shape);
|
|
52
|
-
const pnt = adaptor.Value(adaptor.FirstParameter());
|
|
53
|
-
const result = [pnt.X(), pnt.Y(), pnt.Z()];
|
|
54
|
-
pnt.delete();
|
|
55
|
-
adaptor.delete();
|
|
56
|
-
return result;
|
|
57
|
-
}
|
|
58
|
-
function curveEndPoint(shape) {
|
|
59
|
-
const adaptor = getAdaptor(shape);
|
|
60
|
-
const pnt = adaptor.Value(adaptor.LastParameter());
|
|
61
|
-
const result = [pnt.X(), pnt.Y(), pnt.Z()];
|
|
62
|
-
pnt.delete();
|
|
63
|
-
adaptor.delete();
|
|
64
|
-
return result;
|
|
65
|
-
}
|
|
66
|
-
function curvePointAt(shape, position = 0.5) {
|
|
67
|
-
const adaptor = getAdaptor(shape);
|
|
68
|
-
const pnt = adaptor.Value(mapParam(adaptor, position));
|
|
69
|
-
const result = [pnt.X(), pnt.Y(), pnt.Z()];
|
|
70
|
-
pnt.delete();
|
|
71
|
-
adaptor.delete();
|
|
72
|
-
return result;
|
|
73
|
-
}
|
|
74
|
-
function curveTangentAt(shape, position = 0.5) {
|
|
75
|
-
const oc = occtBoundary.getKernel().oc;
|
|
76
|
-
const adaptor = getAdaptor(shape);
|
|
77
|
-
const param = mapParam(adaptor, position);
|
|
78
|
-
const tmpPnt = new oc.gp_Pnt_1();
|
|
79
|
-
const tmpVec = new oc.gp_Vec_1();
|
|
80
|
-
adaptor.D1(param, tmpPnt, tmpVec);
|
|
81
|
-
const result = [tmpVec.X(), tmpVec.Y(), tmpVec.Z()];
|
|
82
|
-
tmpPnt.delete();
|
|
83
|
-
tmpVec.delete();
|
|
84
|
-
adaptor.delete();
|
|
85
|
-
return result;
|
|
86
|
-
}
|
|
87
|
-
function curveLength(shape) {
|
|
88
|
-
const oc = occtBoundary.getKernel().oc;
|
|
89
|
-
const props = new oc.GProp_GProps_1();
|
|
90
|
-
oc.BRepGProp.LinearProperties(shape.wrapped, props, true, false);
|
|
91
|
-
const len = props.Mass();
|
|
92
|
-
props.delete();
|
|
93
|
-
return len;
|
|
94
|
-
}
|
|
95
|
-
function curveIsClosed(shape) {
|
|
96
|
-
const adaptor = getAdaptor(shape);
|
|
97
|
-
const result = adaptor.IsClosed();
|
|
98
|
-
adaptor.delete();
|
|
99
|
-
return result;
|
|
100
|
-
}
|
|
101
|
-
function curveIsPeriodic(shape) {
|
|
102
|
-
const adaptor = getAdaptor(shape);
|
|
103
|
-
const result = adaptor.IsPeriodic();
|
|
104
|
-
adaptor.delete();
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
function curvePeriod(shape) {
|
|
108
|
-
const adaptor = getAdaptor(shape);
|
|
109
|
-
const result = adaptor.Period();
|
|
110
|
-
adaptor.delete();
|
|
111
|
-
return result;
|
|
112
|
-
}
|
|
113
|
-
function getOrientation(shape) {
|
|
114
|
-
const oc = occtBoundary.getKernel().oc;
|
|
115
|
-
const orient = shape.wrapped.Orientation_1();
|
|
116
|
-
return orient === oc.TopAbs_Orientation.TopAbs_FORWARD ? "forward" : "backward";
|
|
117
|
-
}
|
|
118
|
-
function flipOrientation(shape) {
|
|
119
|
-
return shapeTypes.castShape(shape.wrapped.Reversed());
|
|
120
|
-
}
|
|
121
|
-
function interpolateCurve(points, options = {}) {
|
|
122
|
-
if (points.length < 2) {
|
|
123
|
-
return errors.err(errors.typeCastError("INTERPOLATE_MIN_POINTS", "Interpolation requires at least 2 points"));
|
|
124
|
-
}
|
|
125
|
-
try {
|
|
126
|
-
const result = occtBoundary.getKernel().interpolatePoints(points, options);
|
|
127
|
-
const cast = shapeTypes.castShape(result);
|
|
128
|
-
if (!shapeTypes.isEdge(cast)) {
|
|
129
|
-
return errors.err(errors.typeCastError("INTERPOLATE_NOT_EDGE", "Interpolation did not produce an edge"));
|
|
130
|
-
}
|
|
131
|
-
return errors.ok(cast);
|
|
132
|
-
} catch (e) {
|
|
133
|
-
return errors.err(
|
|
134
|
-
errors.typeCastError(
|
|
135
|
-
"INTERPOLATE_FAILED",
|
|
136
|
-
`Interpolation failed: ${e instanceof Error ? e.message : String(e)}`
|
|
137
|
-
)
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
function approximateCurve(points, options = {}) {
|
|
142
|
-
if (points.length < 2) {
|
|
143
|
-
return errors.err(errors.typeCastError("APPROXIMATE_MIN_POINTS", "Approximation requires at least 2 points"));
|
|
144
|
-
}
|
|
145
|
-
try {
|
|
146
|
-
const result = occtBoundary.getKernel().approximatePoints(points, options);
|
|
147
|
-
const cast = shapeTypes.castShape(result);
|
|
148
|
-
if (!shapeTypes.isEdge(cast)) {
|
|
149
|
-
return errors.err(errors.typeCastError("APPROXIMATE_NOT_EDGE", "Approximation did not produce an edge"));
|
|
150
|
-
}
|
|
151
|
-
return errors.ok(cast);
|
|
152
|
-
} catch (e) {
|
|
153
|
-
return errors.err(
|
|
154
|
-
errors.typeCastError(
|
|
155
|
-
"APPROXIMATE_FAILED",
|
|
156
|
-
`Approximation failed: ${e instanceof Error ? e.message : String(e)}`
|
|
157
|
-
)
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
function offsetWire2D(wire, offset, kind = "arc") {
|
|
162
|
-
const oc = occtBoundary.getKernel().oc;
|
|
163
|
-
const joinTypes = {
|
|
164
|
-
arc: oc.GeomAbs_JoinType.GeomAbs_Arc,
|
|
165
|
-
intersection: oc.GeomAbs_JoinType.GeomAbs_Intersection,
|
|
166
|
-
tangent: oc.GeomAbs_JoinType.GeomAbs_Tangent
|
|
167
|
-
};
|
|
168
|
-
const resultShape = occtBoundary.getKernel().offsetWire2D(wire.wrapped, offset, joinTypes[kind]);
|
|
169
|
-
const wrapped = shapeTypes.castShape(resultShape);
|
|
170
|
-
if (!shapeTypes.isWire(wrapped)) {
|
|
171
|
-
wrapped[Symbol.dispose]();
|
|
172
|
-
return errors.err(errors.typeCastError("OFFSET_NOT_WIRE", "Offset did not produce a Wire"));
|
|
173
|
-
}
|
|
174
|
-
return errors.ok(wrapped);
|
|
175
|
-
}
|
|
176
|
-
exports.approximateCurve = approximateCurve;
|
|
177
|
-
exports.curveEndPoint = curveEndPoint;
|
|
178
|
-
exports.curveIsClosed = curveIsClosed;
|
|
179
|
-
exports.curveIsPeriodic = curveIsPeriodic;
|
|
180
|
-
exports.curveLength = curveLength;
|
|
181
|
-
exports.curvePeriod = curvePeriod;
|
|
182
|
-
exports.curvePointAt = curvePointAt;
|
|
183
|
-
exports.curveStartPoint = curveStartPoint;
|
|
184
|
-
exports.curveTangentAt = curveTangentAt;
|
|
185
|
-
exports.findCurveType = findCurveType;
|
|
186
|
-
exports.flipOrientation = flipOrientation;
|
|
187
|
-
exports.getCurveType = getCurveType;
|
|
188
|
-
exports.getOrientation = getOrientation;
|
|
189
|
-
exports.interpolateCurve = interpolateCurve;
|
|
190
|
-
exports.offsetWire2D = offsetWire2D;
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { g as getKernel } from "./occtBoundary-CwegMzqc.js";
|
|
2
|
-
import { c as castShape, d as isEdge, m as isWire } from "./shapeTypes-BlSElW8z.js";
|
|
3
|
-
import { e as err, p as typeCastError, l as ok, u as unwrap } from "./errors-wGhcJMpB.js";
|
|
4
|
-
let CURVE_TYPES_MAP = null;
|
|
5
|
-
const getCurveTypesMap = (refresh) => {
|
|
6
|
-
if (CURVE_TYPES_MAP && !refresh) return CURVE_TYPES_MAP;
|
|
7
|
-
const oc = getKernel().oc;
|
|
8
|
-
const ga = oc.GeomAbs_CurveType;
|
|
9
|
-
CURVE_TYPES_MAP = /* @__PURE__ */ new Map([
|
|
10
|
-
[ga.GeomAbs_Line, "LINE"],
|
|
11
|
-
[ga.GeomAbs_Circle, "CIRCLE"],
|
|
12
|
-
[ga.GeomAbs_Ellipse, "ELLIPSE"],
|
|
13
|
-
[ga.GeomAbs_Hyperbola, "HYPERBOLA"],
|
|
14
|
-
[ga.GeomAbs_Parabola, "PARABOLA"],
|
|
15
|
-
[ga.GeomAbs_BezierCurve, "BEZIER_CURVE"],
|
|
16
|
-
[ga.GeomAbs_BSplineCurve, "BSPLINE_CURVE"],
|
|
17
|
-
[ga.GeomAbs_OffsetCurve, "OFFSET_CURVE"],
|
|
18
|
-
[ga.GeomAbs_OtherCurve, "OTHER_CURVE"]
|
|
19
|
-
]);
|
|
20
|
-
return CURVE_TYPES_MAP;
|
|
21
|
-
};
|
|
22
|
-
const findCurveType = (type) => {
|
|
23
|
-
let shapeType = getCurveTypesMap().get(type);
|
|
24
|
-
if (!shapeType) shapeType = getCurveTypesMap(true).get(type);
|
|
25
|
-
if (!shapeType) return err(typeCastError("UNKNOWN_CURVE_TYPE", "Unknown curve type"));
|
|
26
|
-
return ok(shapeType);
|
|
27
|
-
};
|
|
28
|
-
function getAdaptor(shape) {
|
|
29
|
-
const oc = getKernel().oc;
|
|
30
|
-
const st = shape.wrapped.ShapeType();
|
|
31
|
-
const e = oc.TopAbs_ShapeEnum;
|
|
32
|
-
if (st === e.TopAbs_WIRE) {
|
|
33
|
-
return new oc.BRepAdaptor_CompCurve_2(shape.wrapped, false);
|
|
34
|
-
}
|
|
35
|
-
return new oc.BRepAdaptor_Curve_2(shape.wrapped);
|
|
36
|
-
}
|
|
37
|
-
function mapParam(adaptor, t) {
|
|
38
|
-
const first = Number(adaptor.FirstParameter());
|
|
39
|
-
const last = Number(adaptor.LastParameter());
|
|
40
|
-
return first + (last - first) * t;
|
|
41
|
-
}
|
|
42
|
-
function getCurveType(shape) {
|
|
43
|
-
const adaptor = getAdaptor(shape);
|
|
44
|
-
const technicalType = adaptor.GetType && adaptor.GetType();
|
|
45
|
-
const result = unwrap(findCurveType(technicalType));
|
|
46
|
-
adaptor.delete();
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
49
|
-
function curveStartPoint(shape) {
|
|
50
|
-
const adaptor = getAdaptor(shape);
|
|
51
|
-
const pnt = adaptor.Value(adaptor.FirstParameter());
|
|
52
|
-
const result = [pnt.X(), pnt.Y(), pnt.Z()];
|
|
53
|
-
pnt.delete();
|
|
54
|
-
adaptor.delete();
|
|
55
|
-
return result;
|
|
56
|
-
}
|
|
57
|
-
function curveEndPoint(shape) {
|
|
58
|
-
const adaptor = getAdaptor(shape);
|
|
59
|
-
const pnt = adaptor.Value(adaptor.LastParameter());
|
|
60
|
-
const result = [pnt.X(), pnt.Y(), pnt.Z()];
|
|
61
|
-
pnt.delete();
|
|
62
|
-
adaptor.delete();
|
|
63
|
-
return result;
|
|
64
|
-
}
|
|
65
|
-
function curvePointAt(shape, position = 0.5) {
|
|
66
|
-
const adaptor = getAdaptor(shape);
|
|
67
|
-
const pnt = adaptor.Value(mapParam(adaptor, position));
|
|
68
|
-
const result = [pnt.X(), pnt.Y(), pnt.Z()];
|
|
69
|
-
pnt.delete();
|
|
70
|
-
adaptor.delete();
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
73
|
-
function curveTangentAt(shape, position = 0.5) {
|
|
74
|
-
const oc = getKernel().oc;
|
|
75
|
-
const adaptor = getAdaptor(shape);
|
|
76
|
-
const param = mapParam(adaptor, position);
|
|
77
|
-
const tmpPnt = new oc.gp_Pnt_1();
|
|
78
|
-
const tmpVec = new oc.gp_Vec_1();
|
|
79
|
-
adaptor.D1(param, tmpPnt, tmpVec);
|
|
80
|
-
const result = [tmpVec.X(), tmpVec.Y(), tmpVec.Z()];
|
|
81
|
-
tmpPnt.delete();
|
|
82
|
-
tmpVec.delete();
|
|
83
|
-
adaptor.delete();
|
|
84
|
-
return result;
|
|
85
|
-
}
|
|
86
|
-
function curveLength(shape) {
|
|
87
|
-
const oc = getKernel().oc;
|
|
88
|
-
const props = new oc.GProp_GProps_1();
|
|
89
|
-
oc.BRepGProp.LinearProperties(shape.wrapped, props, true, false);
|
|
90
|
-
const len = props.Mass();
|
|
91
|
-
props.delete();
|
|
92
|
-
return len;
|
|
93
|
-
}
|
|
94
|
-
function curveIsClosed(shape) {
|
|
95
|
-
const adaptor = getAdaptor(shape);
|
|
96
|
-
const result = adaptor.IsClosed();
|
|
97
|
-
adaptor.delete();
|
|
98
|
-
return result;
|
|
99
|
-
}
|
|
100
|
-
function curveIsPeriodic(shape) {
|
|
101
|
-
const adaptor = getAdaptor(shape);
|
|
102
|
-
const result = adaptor.IsPeriodic();
|
|
103
|
-
adaptor.delete();
|
|
104
|
-
return result;
|
|
105
|
-
}
|
|
106
|
-
function curvePeriod(shape) {
|
|
107
|
-
const adaptor = getAdaptor(shape);
|
|
108
|
-
const result = adaptor.Period();
|
|
109
|
-
adaptor.delete();
|
|
110
|
-
return result;
|
|
111
|
-
}
|
|
112
|
-
function getOrientation(shape) {
|
|
113
|
-
const oc = getKernel().oc;
|
|
114
|
-
const orient = shape.wrapped.Orientation_1();
|
|
115
|
-
return orient === oc.TopAbs_Orientation.TopAbs_FORWARD ? "forward" : "backward";
|
|
116
|
-
}
|
|
117
|
-
function flipOrientation(shape) {
|
|
118
|
-
return castShape(shape.wrapped.Reversed());
|
|
119
|
-
}
|
|
120
|
-
function interpolateCurve(points, options = {}) {
|
|
121
|
-
if (points.length < 2) {
|
|
122
|
-
return err(typeCastError("INTERPOLATE_MIN_POINTS", "Interpolation requires at least 2 points"));
|
|
123
|
-
}
|
|
124
|
-
try {
|
|
125
|
-
const result = getKernel().interpolatePoints(points, options);
|
|
126
|
-
const cast = castShape(result);
|
|
127
|
-
if (!isEdge(cast)) {
|
|
128
|
-
return err(typeCastError("INTERPOLATE_NOT_EDGE", "Interpolation did not produce an edge"));
|
|
129
|
-
}
|
|
130
|
-
return ok(cast);
|
|
131
|
-
} catch (e) {
|
|
132
|
-
return err(
|
|
133
|
-
typeCastError(
|
|
134
|
-
"INTERPOLATE_FAILED",
|
|
135
|
-
`Interpolation failed: ${e instanceof Error ? e.message : String(e)}`
|
|
136
|
-
)
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
function approximateCurve(points, options = {}) {
|
|
141
|
-
if (points.length < 2) {
|
|
142
|
-
return err(typeCastError("APPROXIMATE_MIN_POINTS", "Approximation requires at least 2 points"));
|
|
143
|
-
}
|
|
144
|
-
try {
|
|
145
|
-
const result = getKernel().approximatePoints(points, options);
|
|
146
|
-
const cast = castShape(result);
|
|
147
|
-
if (!isEdge(cast)) {
|
|
148
|
-
return err(typeCastError("APPROXIMATE_NOT_EDGE", "Approximation did not produce an edge"));
|
|
149
|
-
}
|
|
150
|
-
return ok(cast);
|
|
151
|
-
} catch (e) {
|
|
152
|
-
return err(
|
|
153
|
-
typeCastError(
|
|
154
|
-
"APPROXIMATE_FAILED",
|
|
155
|
-
`Approximation failed: ${e instanceof Error ? e.message : String(e)}`
|
|
156
|
-
)
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
function offsetWire2D(wire, offset, kind = "arc") {
|
|
161
|
-
const oc = getKernel().oc;
|
|
162
|
-
const joinTypes = {
|
|
163
|
-
arc: oc.GeomAbs_JoinType.GeomAbs_Arc,
|
|
164
|
-
intersection: oc.GeomAbs_JoinType.GeomAbs_Intersection,
|
|
165
|
-
tangent: oc.GeomAbs_JoinType.GeomAbs_Tangent
|
|
166
|
-
};
|
|
167
|
-
const resultShape = getKernel().offsetWire2D(wire.wrapped, offset, joinTypes[kind]);
|
|
168
|
-
const wrapped = castShape(resultShape);
|
|
169
|
-
if (!isWire(wrapped)) {
|
|
170
|
-
wrapped[Symbol.dispose]();
|
|
171
|
-
return err(typeCastError("OFFSET_NOT_WIRE", "Offset did not produce a Wire"));
|
|
172
|
-
}
|
|
173
|
-
return ok(wrapped);
|
|
174
|
-
}
|
|
175
|
-
export {
|
|
176
|
-
curveTangentAt as a,
|
|
177
|
-
curvePointAt as b,
|
|
178
|
-
curveIsClosed as c,
|
|
179
|
-
curveEndPoint as d,
|
|
180
|
-
curveStartPoint as e,
|
|
181
|
-
curveLength as f,
|
|
182
|
-
approximateCurve as g,
|
|
183
|
-
curveIsPeriodic as h,
|
|
184
|
-
curvePeriod as i,
|
|
185
|
-
findCurveType as j,
|
|
186
|
-
flipOrientation as k,
|
|
187
|
-
getCurveType as l,
|
|
188
|
-
getOrientation as m,
|
|
189
|
-
interpolateCurve as n,
|
|
190
|
-
offsetWire2D as o
|
|
191
|
-
};
|
package/dist/loft-BzWFokmC.cjs
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const occtBoundary = require("./occtBoundary-du8_ex-p.cjs");
|
|
3
|
-
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
4
|
-
const cast = require("./cast-DkB0GKmQ.cjs");
|
|
5
|
-
const errors = require("./errors-DK1VAdP4.cjs");
|
|
6
|
-
const shapeTypes = require("./shapeTypes-DKhwEnUM.cjs");
|
|
7
|
-
const shapeHelpers = require("./shapeHelpers-B2SXz1p4.cjs");
|
|
8
|
-
function buildLawFromProfile(extrusionLength, { profile, endFactor = 1 }) {
|
|
9
|
-
const oc = occtBoundary.getKernel().oc;
|
|
10
|
-
const r = shapeTypes.gcWithScope();
|
|
11
|
-
let law;
|
|
12
|
-
if (profile === "s-curve") {
|
|
13
|
-
law = r(new oc.Law_S());
|
|
14
|
-
law.Set_1(0, 1, extrusionLength, endFactor);
|
|
15
|
-
} else if (profile === "linear") {
|
|
16
|
-
law = r(new oc.Law_Linear());
|
|
17
|
-
law.Set(0, 1, extrusionLength, endFactor);
|
|
18
|
-
} else {
|
|
19
|
-
return errors.err(
|
|
20
|
-
errors.validationError("UNSUPPORTED_PROFILE", `Unsupported extrusion profile: ${String(profile)}`)
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
return errors.ok(law.Trim(0, extrusionLength, 1e-6));
|
|
24
|
-
}
|
|
25
|
-
const basicFaceExtrusion = (face, extrusionVec) => {
|
|
26
|
-
const oc = occtBoundary.getKernel().oc;
|
|
27
|
-
const [r, gc] = shapeTypes.localGC();
|
|
28
|
-
const vec = occtBoundary.toVec3(extrusionVec);
|
|
29
|
-
const ocVec = r(new oc.gp_Vec_4(vec[0], vec[1], vec[2]));
|
|
30
|
-
const solidBuilder = r(new oc.BRepPrimAPI_MakePrism_1(face.wrapped, ocVec, false, true));
|
|
31
|
-
const solid = shapeTypes.createSolid(errors.unwrap(cast.downcast(solidBuilder.Shape())));
|
|
32
|
-
gc();
|
|
33
|
-
return solid;
|
|
34
|
-
};
|
|
35
|
-
const revolution = (face, center = [0, 0, 0], direction = [0, 0, 1], angle = 360) => {
|
|
36
|
-
const oc = occtBoundary.getKernel().oc;
|
|
37
|
-
const [r, gc] = shapeTypes.localGC();
|
|
38
|
-
const centerVec = occtBoundary.toVec3(center);
|
|
39
|
-
const directionVec = occtBoundary.toVec3(direction);
|
|
40
|
-
const ax = r(occtBoundary.makeOcAx1(centerVec, directionVec));
|
|
41
|
-
const revolBuilder = r(new oc.BRepPrimAPI_MakeRevol_1(face.wrapped, ax, angle * vecOps.DEG2RAD, false));
|
|
42
|
-
const result = errors.andThen(cast.cast(revolBuilder.Shape()), (shape) => {
|
|
43
|
-
if (!cast.isShape3D(shape))
|
|
44
|
-
return errors.err(errors.typeCastError("REVOLUTION_NOT_3D", "Revolution did not produce a 3D shape"));
|
|
45
|
-
return errors.ok(shape);
|
|
46
|
-
});
|
|
47
|
-
gc();
|
|
48
|
-
return result;
|
|
49
|
-
};
|
|
50
|
-
function genericSweep(wire, spine, {
|
|
51
|
-
frenet = false,
|
|
52
|
-
auxiliarySpine,
|
|
53
|
-
law = null,
|
|
54
|
-
transitionMode = "right",
|
|
55
|
-
withContact,
|
|
56
|
-
support,
|
|
57
|
-
forceProfileSpineOthogonality
|
|
58
|
-
} = {}, shellMode = false) {
|
|
59
|
-
const oc = occtBoundary.getKernel().oc;
|
|
60
|
-
const [r, gc] = shapeTypes.localGC();
|
|
61
|
-
const withCorrection = transitionMode === "round" ? true : !!forceProfileSpineOthogonality;
|
|
62
|
-
const sweepBuilder = r(new oc.BRepOffsetAPI_MakePipeShell(spine.wrapped));
|
|
63
|
-
{
|
|
64
|
-
const mode = {
|
|
65
|
-
transformed: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_Transformed,
|
|
66
|
-
round: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_RoundCorner,
|
|
67
|
-
right: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_RightCorner
|
|
68
|
-
}[transitionMode];
|
|
69
|
-
if (mode) sweepBuilder.SetTransitionMode(mode);
|
|
70
|
-
}
|
|
71
|
-
if (support) {
|
|
72
|
-
sweepBuilder.SetMode_4(support);
|
|
73
|
-
} else if (frenet) {
|
|
74
|
-
sweepBuilder.SetMode_1(frenet);
|
|
75
|
-
}
|
|
76
|
-
if (auxiliarySpine) {
|
|
77
|
-
sweepBuilder.SetMode_5(
|
|
78
|
-
auxiliarySpine.wrapped,
|
|
79
|
-
false,
|
|
80
|
-
oc.BRepFill_TypeOfContact.BRepFill_NoContact
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
if (!law) sweepBuilder.Add_1(wire.wrapped, !!withContact, withCorrection);
|
|
84
|
-
else sweepBuilder.SetLaw_1(wire.wrapped, law, !!withContact, withCorrection);
|
|
85
|
-
const progress = r(new oc.Message_ProgressRange_1());
|
|
86
|
-
sweepBuilder.Build(progress);
|
|
87
|
-
if (!sweepBuilder.IsDone()) {
|
|
88
|
-
gc();
|
|
89
|
-
return errors.err(errors.occtError("SWEEP_FAILED", "Sweep operation failed"));
|
|
90
|
-
}
|
|
91
|
-
if (!shellMode) {
|
|
92
|
-
sweepBuilder.MakeSolid();
|
|
93
|
-
}
|
|
94
|
-
const shape = errors.unwrap(cast.cast(sweepBuilder.Shape()));
|
|
95
|
-
if (!cast.isShape3D(shape)) {
|
|
96
|
-
gc();
|
|
97
|
-
return errors.err(errors.typeCastError("SWEEP_NOT_3D", "Sweep did not produce a 3D shape"));
|
|
98
|
-
}
|
|
99
|
-
if (shellMode) {
|
|
100
|
-
const startWire = errors.unwrap(cast.cast(sweepBuilder.FirstShape()));
|
|
101
|
-
const endWire = errors.unwrap(cast.cast(sweepBuilder.LastShape()));
|
|
102
|
-
if (!cast.isWire(startWire)) {
|
|
103
|
-
gc();
|
|
104
|
-
return errors.err(errors.typeCastError("SWEEP_START_NOT_WIRE", "Sweep did not produce a start Wire"));
|
|
105
|
-
}
|
|
106
|
-
if (!cast.isWire(endWire)) {
|
|
107
|
-
gc();
|
|
108
|
-
return errors.err(errors.typeCastError("SWEEP_END_NOT_WIRE", "Sweep did not produce an end Wire"));
|
|
109
|
-
}
|
|
110
|
-
gc();
|
|
111
|
-
return errors.ok([shape, startWire, endWire]);
|
|
112
|
-
}
|
|
113
|
-
gc();
|
|
114
|
-
return errors.ok(shape);
|
|
115
|
-
}
|
|
116
|
-
function complexExtrude(wire, center, normal, profileShape, shellMode = false) {
|
|
117
|
-
const [r, gc] = shapeTypes.localGC();
|
|
118
|
-
const centerVec = occtBoundary.toVec3(center);
|
|
119
|
-
const normalVec = occtBoundary.toVec3(normal);
|
|
120
|
-
const endVec = vecOps.vecAdd(centerVec, normalVec);
|
|
121
|
-
const mainSpineEdge = r(shapeHelpers.makeLine(centerVec, endVec));
|
|
122
|
-
const spine = r(errors.unwrap(shapeHelpers.assembleWire([mainSpineEdge])));
|
|
123
|
-
const law = profileShape ? r(errors.unwrap(buildLawFromProfile(vecOps.vecLength(normalVec), profileShape))) : null;
|
|
124
|
-
const result = shellMode ? genericSweep(wire, spine, { law }, shellMode) : genericSweep(wire, spine, { law }, shellMode);
|
|
125
|
-
gc();
|
|
126
|
-
return result;
|
|
127
|
-
}
|
|
128
|
-
function twistExtrude(wire, angleDegrees, center, normal, profileShape, shellMode = false) {
|
|
129
|
-
const [r, gc] = shapeTypes.localGC();
|
|
130
|
-
const centerVec = occtBoundary.toVec3(center);
|
|
131
|
-
const normalVec = occtBoundary.toVec3(normal);
|
|
132
|
-
const endVec = vecOps.vecAdd(centerVec, normalVec);
|
|
133
|
-
const mainSpineEdge = r(shapeHelpers.makeLine(centerVec, endVec));
|
|
134
|
-
const spine = r(errors.unwrap(shapeHelpers.assembleWire([mainSpineEdge])));
|
|
135
|
-
const extrusionLength = vecOps.vecLength(normalVec);
|
|
136
|
-
const pitch = 360 / angleDegrees * extrusionLength;
|
|
137
|
-
const radius = 1;
|
|
138
|
-
const auxiliarySpine = r(shapeHelpers.makeHelix(pitch, extrusionLength, radius, centerVec, normalVec));
|
|
139
|
-
const law = profileShape ? r(errors.unwrap(buildLawFromProfile(extrusionLength, profileShape))) : null;
|
|
140
|
-
const result = shellMode ? genericSweep(wire, spine, { auxiliarySpine, law }, shellMode) : genericSweep(wire, spine, { auxiliarySpine, law }, shellMode);
|
|
141
|
-
gc();
|
|
142
|
-
return result;
|
|
143
|
-
}
|
|
144
|
-
const loft = (wires, { ruled = true, startPoint, endPoint } = {}, returnShell = false) => {
|
|
145
|
-
if (wires.length === 0 && !startPoint && !endPoint) {
|
|
146
|
-
return errors.err(errors.validationError("LOFT_EMPTY", "Loft requires at least one wire or start/end point"));
|
|
147
|
-
}
|
|
148
|
-
const oc = occtBoundary.getKernel().oc;
|
|
149
|
-
const [r, gc] = shapeTypes.localGC();
|
|
150
|
-
const loftBuilder = r(new oc.BRepOffsetAPI_ThruSections(!returnShell, ruled, 1e-6));
|
|
151
|
-
if (startPoint) {
|
|
152
|
-
loftBuilder.AddVertex(r(shapeHelpers.makeVertex(occtBoundary.toVec3(startPoint))).wrapped);
|
|
153
|
-
}
|
|
154
|
-
wires.forEach((w) => loftBuilder.AddWire(w.wrapped));
|
|
155
|
-
if (endPoint) {
|
|
156
|
-
loftBuilder.AddVertex(r(shapeHelpers.makeVertex(occtBoundary.toVec3(endPoint))).wrapped);
|
|
157
|
-
}
|
|
158
|
-
const progress = r(new oc.Message_ProgressRange_1());
|
|
159
|
-
loftBuilder.Build(progress);
|
|
160
|
-
if (!loftBuilder.IsDone()) {
|
|
161
|
-
gc();
|
|
162
|
-
return errors.err(errors.occtError("LOFT_FAILED", "Loft operation failed"));
|
|
163
|
-
}
|
|
164
|
-
const result = errors.andThen(cast.cast(loftBuilder.Shape()), (shape) => {
|
|
165
|
-
if (!cast.isShape3D(shape))
|
|
166
|
-
return errors.err(errors.typeCastError("LOFT_NOT_3D", "Loft did not produce a 3D shape"));
|
|
167
|
-
return errors.ok(shape);
|
|
168
|
-
});
|
|
169
|
-
gc();
|
|
170
|
-
return result;
|
|
171
|
-
};
|
|
172
|
-
exports.basicFaceExtrusion = basicFaceExtrusion;
|
|
173
|
-
exports.buildLawFromProfile = buildLawFromProfile;
|
|
174
|
-
exports.complexExtrude = complexExtrude;
|
|
175
|
-
exports.genericSweep = genericSweep;
|
|
176
|
-
exports.loft = loft;
|
|
177
|
-
exports.revolution = revolution;
|
|
178
|
-
exports.twistExtrude = twistExtrude;
|