brepjs 8.0.2 → 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.cjs +2 -2
- package/dist/2d.js +3 -3
- package/dist/{Blueprint-B9fhnpFp.js → Blueprint-DnAO3gr5.js} +8 -9
- package/dist/{Blueprint-VGbo3izk.cjs → Blueprint-FxmMji4s.cjs} +9 -10
- package/dist/{boolean2D-_WiqPxWZ.js → boolean2D-BnZKKBWU.js} +10 -10
- package/dist/{boolean2D-B1XrGVgx.cjs → boolean2D-BrjHZfWn.cjs} +10 -10
- package/dist/{booleanFns-CkccZ7UL.js → booleanFns-Ct3wDnhc.js} +3 -3
- package/dist/{booleanFns-BxW-N3rP.cjs → booleanFns-ND7sZvhu.cjs} +3 -3
- package/dist/brepjs.cjs +63 -64
- package/dist/brepjs.js +111 -113
- package/dist/{cast-C4Ff_1Qe.js → cast-BEg1mN7n.js} +2 -2
- package/dist/{cast-DIiyxDLo.cjs → cast-CqDc8oFW.cjs} +2 -2
- package/dist/core.cjs +3 -3
- package/dist/core.js +3 -3
- package/dist/{cornerFinder-DzGzfiqb.js → cornerFinder-89obDwGi.js} +1 -1
- package/dist/{cornerFinder-BndBNtJE.cjs → cornerFinder-BKsCkrXd.cjs} +1 -1
- package/dist/{curveBuilders-BUoFO1UG.cjs → curveBuilders-BjtdNw1B.cjs} +2 -2
- package/dist/{curveBuilders-CBlIWlbU.js → curveBuilders-U26XDfxg.js} +2 -2
- package/dist/curveFns-BoG_iA07.cjs +375 -0
- package/dist/curveFns-Cg99XKe2.js +376 -0
- package/dist/{drawFns-D2eDcf4k.cjs → drawFns-C-MCkYj6.cjs} +15 -16
- package/dist/{drawFns-Btmlh_Oz.js → drawFns-DJV-nOox.js} +12 -13
- package/dist/{faceFns-DDzCECn3.js → faceFns-CyokaCDr.js} +3 -3
- package/dist/{faceFns-NDRFeekj.cjs → faceFns-DcSCjDG0.cjs} +3 -3
- package/dist/{helpers-Ck8GJ58k.cjs → helpers--iZxPeJg.cjs} +9 -9
- package/dist/{helpers-jku2V1DY.js → helpers-CRx_ks-u.js} +6 -6
- 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/{loft-DJXwxV_L.cjs → loft-8asn63t4.cjs} +4 -4
- package/dist/{loft-Bk9EM0gZ.js → loft-jIkZRqHm.js} +4 -4
- package/dist/{measurement-DlXaTzKc.js → measurement-DWv8kK6J.js} +3 -3
- package/dist/{measurement-LcGh4wV0.cjs → measurement-lRLwaoqD.cjs} +3 -3
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-c8lDKfYy.cjs → meshFns-DWuLC3fk.cjs} +29 -9
- package/dist/{meshFns-Djzdn-CS.js → meshFns-DgAIL1B-.js} +29 -9
- package/dist/{occtBoundary-6kQSl3cF.cjs → occtBoundary-DHtzU4tz.cjs} +72 -61
- package/dist/{occtBoundary-CqXvDhZY.js → occtBoundary-DYsksDtE.js} +72 -61
- package/dist/operations/patternFns.d.ts.map +1 -1
- package/dist/{operations-CrQlFDHc.js → operations-B8FHVC22.js} +32 -10
- package/dist/{operations-Do-WZGXc.cjs → operations-CCFPvtd-.cjs} +32 -10
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/query.cjs +5 -5
- package/dist/query.js +6 -6
- package/dist/{shapeTypes-BJ3Hmskg.cjs → shapeTypes-b_lhwQB7.cjs} +1 -1
- package/dist/{shapeTypes-C9sUsmEW.js → shapeTypes-i7VwMRwc.js} +1 -1
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/topology/meshFns.d.ts.map +1 -1
- package/dist/{topology-CtfUZwLR.js → topology-Bh-aPIxA.js} +7 -8
- package/dist/{topology-DXq8dLsi.cjs → topology-ByOn_z3E.cjs} +12 -13
- package/dist/topology.cjs +33 -34
- package/dist/topology.js +50 -51
- package/dist/{vectors-BVgXsYWl.js → vectors-DWLjb9-P.js} +1 -1
- package/dist/{vectors-DK2hEKcI.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-BrJDkaWi.cjs +0 -177
- package/dist/curveFns-BshHA9Ys.js +0 -178
- package/dist/shapeFns-DQtpzndX.js +0 -203
- package/dist/shapeFns-cN4qGpbO.cjs +0 -202
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const occtBoundary = require("./occtBoundary-DHtzU4tz.cjs");
|
|
3
|
+
const shapeTypes = require("./shapeTypes-b_lhwQB7.cjs");
|
|
4
|
+
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
5
|
+
const cast = require("./cast-CqDc8oFW.cjs");
|
|
6
|
+
const errors = require("./errors-DK1VAdP4.cjs");
|
|
7
|
+
let CURVE_TYPES_MAP = null;
|
|
8
|
+
const getCurveTypesMap = (refresh) => {
|
|
9
|
+
if (CURVE_TYPES_MAP && !refresh) return CURVE_TYPES_MAP;
|
|
10
|
+
const oc = occtBoundary.getKernel().oc;
|
|
11
|
+
const ga = oc.GeomAbs_CurveType;
|
|
12
|
+
CURVE_TYPES_MAP = /* @__PURE__ */ new Map([
|
|
13
|
+
[ga.GeomAbs_Line, "LINE"],
|
|
14
|
+
[ga.GeomAbs_Circle, "CIRCLE"],
|
|
15
|
+
[ga.GeomAbs_Ellipse, "ELLIPSE"],
|
|
16
|
+
[ga.GeomAbs_Hyperbola, "HYPERBOLA"],
|
|
17
|
+
[ga.GeomAbs_Parabola, "PARABOLA"],
|
|
18
|
+
[ga.GeomAbs_BezierCurve, "BEZIER_CURVE"],
|
|
19
|
+
[ga.GeomAbs_BSplineCurve, "BSPLINE_CURVE"],
|
|
20
|
+
[ga.GeomAbs_OffsetCurve, "OFFSET_CURVE"],
|
|
21
|
+
[ga.GeomAbs_OtherCurve, "OTHER_CURVE"]
|
|
22
|
+
]);
|
|
23
|
+
return CURVE_TYPES_MAP;
|
|
24
|
+
};
|
|
25
|
+
const findCurveType = (type) => {
|
|
26
|
+
let shapeType = getCurveTypesMap().get(type);
|
|
27
|
+
if (!shapeType) shapeType = getCurveTypesMap(true).get(type);
|
|
28
|
+
if (!shapeType) return errors.err(errors.typeCastError("UNKNOWN_CURVE_TYPE", "Unknown curve type"));
|
|
29
|
+
return errors.ok(shapeType);
|
|
30
|
+
};
|
|
31
|
+
function clone(shape) {
|
|
32
|
+
return shapeTypes.castShape(errors.unwrap(cast.downcast(shape.wrapped)));
|
|
33
|
+
}
|
|
34
|
+
function toBREP(shape) {
|
|
35
|
+
const oc = occtBoundary.getKernel().oc;
|
|
36
|
+
return oc.BRepToolsWrapper.Write(shape.wrapped);
|
|
37
|
+
}
|
|
38
|
+
function getHashCode(shape) {
|
|
39
|
+
return shape.wrapped.HashCode(vecOps.HASH_CODE_MAX);
|
|
40
|
+
}
|
|
41
|
+
function isEmpty(shape) {
|
|
42
|
+
return shape.wrapped.IsNull();
|
|
43
|
+
}
|
|
44
|
+
function isSameShape(a, b) {
|
|
45
|
+
return a.wrapped.IsSame(b.wrapped);
|
|
46
|
+
}
|
|
47
|
+
function isEqualShape(a, b) {
|
|
48
|
+
return a.wrapped.IsEqual(b.wrapped);
|
|
49
|
+
}
|
|
50
|
+
function simplify(shape) {
|
|
51
|
+
const oc = occtBoundary.getKernel().oc;
|
|
52
|
+
const r = shapeTypes.gcWithScope();
|
|
53
|
+
const upgrader = r(new oc.ShapeUpgrade_UnifySameDomain_2(shape.wrapped, true, true, false));
|
|
54
|
+
upgrader.Build();
|
|
55
|
+
return shapeTypes.castShape(upgrader.Shape());
|
|
56
|
+
}
|
|
57
|
+
function translate(shape, v) {
|
|
58
|
+
const oc = occtBoundary.getKernel().oc;
|
|
59
|
+
const trsf = new oc.gp_Trsf_1();
|
|
60
|
+
const vec = occtBoundary.toOcVec(v);
|
|
61
|
+
trsf.SetTranslation_1(vec);
|
|
62
|
+
const transformer = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, trsf, true);
|
|
63
|
+
const result = shapeTypes.castShape(transformer.Shape());
|
|
64
|
+
transformer.delete();
|
|
65
|
+
trsf.delete();
|
|
66
|
+
vec.delete();
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
function rotate(shape, angle, position = [0, 0, 0], direction = [0, 0, 1]) {
|
|
70
|
+
const oc = occtBoundary.getKernel().oc;
|
|
71
|
+
const trsf = new oc.gp_Trsf_1();
|
|
72
|
+
const ax1 = occtBoundary.makeOcAx1(position, direction);
|
|
73
|
+
trsf.SetRotation_1(ax1, angle * vecOps.DEG2RAD);
|
|
74
|
+
const transformer = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, trsf, true);
|
|
75
|
+
const result = shapeTypes.castShape(transformer.Shape());
|
|
76
|
+
transformer.delete();
|
|
77
|
+
trsf.delete();
|
|
78
|
+
ax1.delete();
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
function mirror(shape, planeNormal = [0, 1, 0], planeOrigin = [0, 0, 0]) {
|
|
82
|
+
const oc = occtBoundary.getKernel().oc;
|
|
83
|
+
const trsf = new oc.gp_Trsf_1();
|
|
84
|
+
const ax2 = occtBoundary.makeOcAx2(planeOrigin, planeNormal);
|
|
85
|
+
trsf.SetMirror_3(ax2);
|
|
86
|
+
const transformer = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, trsf, true);
|
|
87
|
+
const result = shapeTypes.castShape(transformer.Shape());
|
|
88
|
+
transformer.delete();
|
|
89
|
+
trsf.delete();
|
|
90
|
+
ax2.delete();
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
function scale(shape, factor, center = [0, 0, 0]) {
|
|
94
|
+
const oc = occtBoundary.getKernel().oc;
|
|
95
|
+
const trsf = new oc.gp_Trsf_1();
|
|
96
|
+
const pnt = occtBoundary.toOcPnt(center);
|
|
97
|
+
trsf.SetScale(pnt, factor);
|
|
98
|
+
const transformer = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, trsf, true);
|
|
99
|
+
const result = shapeTypes.castShape(transformer.Shape());
|
|
100
|
+
transformer.delete();
|
|
101
|
+
trsf.delete();
|
|
102
|
+
pnt.delete();
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
const topoCache = /* @__PURE__ */ new WeakMap();
|
|
106
|
+
function getOrCreateCache(shape) {
|
|
107
|
+
let entry = topoCache.get(shape.wrapped);
|
|
108
|
+
if (!entry) {
|
|
109
|
+
entry = {};
|
|
110
|
+
topoCache.set(shape.wrapped, entry);
|
|
111
|
+
}
|
|
112
|
+
return entry;
|
|
113
|
+
}
|
|
114
|
+
function getEdges(shape) {
|
|
115
|
+
const cache = getOrCreateCache(shape);
|
|
116
|
+
if (cache.edges) return cache.edges;
|
|
117
|
+
const edges = Array.from(cast.iterTopo(shape.wrapped, "edge")).map(
|
|
118
|
+
(e) => shapeTypes.castShape(errors.unwrap(cast.downcast(e)))
|
|
119
|
+
);
|
|
120
|
+
cache.edges = edges;
|
|
121
|
+
return edges;
|
|
122
|
+
}
|
|
123
|
+
function getFaces(shape) {
|
|
124
|
+
const cache = getOrCreateCache(shape);
|
|
125
|
+
if (cache.faces) return cache.faces;
|
|
126
|
+
const faces = Array.from(cast.iterTopo(shape.wrapped, "face")).map(
|
|
127
|
+
(e) => shapeTypes.castShape(errors.unwrap(cast.downcast(e)))
|
|
128
|
+
);
|
|
129
|
+
cache.faces = faces;
|
|
130
|
+
return faces;
|
|
131
|
+
}
|
|
132
|
+
function getWires(shape) {
|
|
133
|
+
const cache = getOrCreateCache(shape);
|
|
134
|
+
if (cache.wires) return cache.wires;
|
|
135
|
+
const wires = Array.from(cast.iterTopo(shape.wrapped, "wire")).map(
|
|
136
|
+
(e) => shapeTypes.castShape(errors.unwrap(cast.downcast(e)))
|
|
137
|
+
);
|
|
138
|
+
cache.wires = wires;
|
|
139
|
+
return wires;
|
|
140
|
+
}
|
|
141
|
+
function getVertices(shape) {
|
|
142
|
+
return Array.from(cast.iterTopo(shape.wrapped, "vertex")).map(
|
|
143
|
+
(e) => shapeTypes.castShape(errors.unwrap(cast.downcast(e)))
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
function* iterEdges(shape) {
|
|
147
|
+
for (const e of cast.iterTopo(shape.wrapped, "edge")) {
|
|
148
|
+
yield shapeTypes.castShape(errors.unwrap(cast.downcast(e)));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function* iterFaces(shape) {
|
|
152
|
+
for (const f of cast.iterTopo(shape.wrapped, "face")) {
|
|
153
|
+
yield shapeTypes.castShape(errors.unwrap(cast.downcast(f)));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function* iterWires(shape) {
|
|
157
|
+
for (const w of cast.iterTopo(shape.wrapped, "wire")) {
|
|
158
|
+
yield shapeTypes.castShape(errors.unwrap(cast.downcast(w)));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function* iterVertices(shape) {
|
|
162
|
+
for (const v of cast.iterTopo(shape.wrapped, "vertex")) {
|
|
163
|
+
yield shapeTypes.castShape(errors.unwrap(cast.downcast(v)));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function getBounds(shape) {
|
|
167
|
+
const oc = occtBoundary.getKernel().oc;
|
|
168
|
+
const bbox = new oc.Bnd_Box_1();
|
|
169
|
+
oc.BRepBndLib.Add(shape.wrapped, bbox, true);
|
|
170
|
+
const xMin = { current: 0 };
|
|
171
|
+
const yMin = { current: 0 };
|
|
172
|
+
const zMin = { current: 0 };
|
|
173
|
+
const xMax = { current: 0 };
|
|
174
|
+
const yMax = { current: 0 };
|
|
175
|
+
const zMax = { current: 0 };
|
|
176
|
+
bbox.Get(xMin, yMin, zMin, xMax, yMax, zMax);
|
|
177
|
+
bbox.delete();
|
|
178
|
+
return {
|
|
179
|
+
xMin: xMin.current,
|
|
180
|
+
xMax: xMax.current,
|
|
181
|
+
yMin: yMin.current,
|
|
182
|
+
yMax: yMax.current,
|
|
183
|
+
zMin: zMin.current,
|
|
184
|
+
zMax: zMax.current
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function describe(shape) {
|
|
188
|
+
return {
|
|
189
|
+
kind: shapeTypes.getShapeKind(shape),
|
|
190
|
+
faceCount: getFaces(shape).length,
|
|
191
|
+
edgeCount: getEdges(shape).length,
|
|
192
|
+
wireCount: getWires(shape).length,
|
|
193
|
+
vertexCount: getVertices(shape).length,
|
|
194
|
+
valid: occtBoundary.getKernel().isValid(shape.wrapped),
|
|
195
|
+
bounds: getBounds(shape)
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function vertexPosition(vertex) {
|
|
199
|
+
const oc = occtBoundary.getKernel().oc;
|
|
200
|
+
const pnt = oc.BRep_Tool.Pnt(vertex.wrapped);
|
|
201
|
+
const result = [pnt.X(), pnt.Y(), pnt.Z()];
|
|
202
|
+
pnt.delete();
|
|
203
|
+
return result;
|
|
204
|
+
}
|
|
205
|
+
function getAdaptor(shape) {
|
|
206
|
+
const oc = occtBoundary.getKernel().oc;
|
|
207
|
+
const st = shape.wrapped.ShapeType();
|
|
208
|
+
const e = oc.TopAbs_ShapeEnum;
|
|
209
|
+
if (st === e.TopAbs_WIRE) {
|
|
210
|
+
return new oc.BRepAdaptor_CompCurve_2(shape.wrapped, false);
|
|
211
|
+
}
|
|
212
|
+
return new oc.BRepAdaptor_Curve_2(shape.wrapped);
|
|
213
|
+
}
|
|
214
|
+
function mapParam(adaptor, t) {
|
|
215
|
+
const first = Number(adaptor.FirstParameter());
|
|
216
|
+
const last = Number(adaptor.LastParameter());
|
|
217
|
+
return first + (last - first) * t;
|
|
218
|
+
}
|
|
219
|
+
function getCurveType(shape) {
|
|
220
|
+
const r = shapeTypes.gcWithScope();
|
|
221
|
+
const adaptor = r(getAdaptor(shape));
|
|
222
|
+
const technicalType = adaptor.GetType && adaptor.GetType();
|
|
223
|
+
return errors.unwrap(findCurveType(technicalType));
|
|
224
|
+
}
|
|
225
|
+
function curveStartPoint(shape) {
|
|
226
|
+
const r = shapeTypes.gcWithScope();
|
|
227
|
+
const adaptor = r(getAdaptor(shape));
|
|
228
|
+
const pnt = r(adaptor.Value(adaptor.FirstParameter()));
|
|
229
|
+
return [pnt.X(), pnt.Y(), pnt.Z()];
|
|
230
|
+
}
|
|
231
|
+
function curveEndPoint(shape) {
|
|
232
|
+
const r = shapeTypes.gcWithScope();
|
|
233
|
+
const adaptor = r(getAdaptor(shape));
|
|
234
|
+
const pnt = r(adaptor.Value(adaptor.LastParameter()));
|
|
235
|
+
return [pnt.X(), pnt.Y(), pnt.Z()];
|
|
236
|
+
}
|
|
237
|
+
function curvePointAt(shape, position = 0.5) {
|
|
238
|
+
const r = shapeTypes.gcWithScope();
|
|
239
|
+
const adaptor = r(getAdaptor(shape));
|
|
240
|
+
const pnt = r(adaptor.Value(mapParam(adaptor, position)));
|
|
241
|
+
return [pnt.X(), pnt.Y(), pnt.Z()];
|
|
242
|
+
}
|
|
243
|
+
function curveTangentAt(shape, position = 0.5) {
|
|
244
|
+
const oc = occtBoundary.getKernel().oc;
|
|
245
|
+
const r = shapeTypes.gcWithScope();
|
|
246
|
+
const adaptor = r(getAdaptor(shape));
|
|
247
|
+
const param = mapParam(adaptor, position);
|
|
248
|
+
const tmpPnt = r(new oc.gp_Pnt_1());
|
|
249
|
+
const tmpVec = r(new oc.gp_Vec_1());
|
|
250
|
+
adaptor.D1(param, tmpPnt, tmpVec);
|
|
251
|
+
return [tmpVec.X(), tmpVec.Y(), tmpVec.Z()];
|
|
252
|
+
}
|
|
253
|
+
function curveLength(shape) {
|
|
254
|
+
const oc = occtBoundary.getKernel().oc;
|
|
255
|
+
const r = shapeTypes.gcWithScope();
|
|
256
|
+
const props = r(new oc.GProp_GProps_1());
|
|
257
|
+
oc.BRepGProp.LinearProperties(shape.wrapped, props, true, false);
|
|
258
|
+
return props.Mass();
|
|
259
|
+
}
|
|
260
|
+
function curveIsClosed(shape) {
|
|
261
|
+
const r = shapeTypes.gcWithScope();
|
|
262
|
+
const adaptor = r(getAdaptor(shape));
|
|
263
|
+
return adaptor.IsClosed();
|
|
264
|
+
}
|
|
265
|
+
function curveIsPeriodic(shape) {
|
|
266
|
+
const r = shapeTypes.gcWithScope();
|
|
267
|
+
const adaptor = r(getAdaptor(shape));
|
|
268
|
+
return adaptor.IsPeriodic();
|
|
269
|
+
}
|
|
270
|
+
function curvePeriod(shape) {
|
|
271
|
+
const adaptor = getAdaptor(shape);
|
|
272
|
+
const result = adaptor.Period();
|
|
273
|
+
adaptor.delete();
|
|
274
|
+
return result;
|
|
275
|
+
}
|
|
276
|
+
function getOrientation(shape) {
|
|
277
|
+
const oc = occtBoundary.getKernel().oc;
|
|
278
|
+
const orient = shape.wrapped.Orientation_1();
|
|
279
|
+
return orient === oc.TopAbs_Orientation.TopAbs_FORWARD ? "forward" : "backward";
|
|
280
|
+
}
|
|
281
|
+
function flipOrientation(shape) {
|
|
282
|
+
return shapeTypes.castShape(shape.wrapped.Reversed());
|
|
283
|
+
}
|
|
284
|
+
function interpolateCurve(points, options = {}) {
|
|
285
|
+
if (points.length < 2) {
|
|
286
|
+
return errors.err(errors.typeCastError("INTERPOLATE_MIN_POINTS", "Interpolation requires at least 2 points"));
|
|
287
|
+
}
|
|
288
|
+
try {
|
|
289
|
+
const result = occtBoundary.getKernel().interpolatePoints(points, options);
|
|
290
|
+
const cast2 = shapeTypes.castShape(result);
|
|
291
|
+
if (!shapeTypes.isEdge(cast2)) {
|
|
292
|
+
return errors.err(errors.typeCastError("INTERPOLATE_NOT_EDGE", "Interpolation did not produce an edge"));
|
|
293
|
+
}
|
|
294
|
+
return errors.ok(cast2);
|
|
295
|
+
} catch (e) {
|
|
296
|
+
return errors.err(
|
|
297
|
+
errors.typeCastError(
|
|
298
|
+
"INTERPOLATE_FAILED",
|
|
299
|
+
`Interpolation failed: ${e instanceof Error ? e.message : String(e)}`
|
|
300
|
+
)
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
function approximateCurve(points, options = {}) {
|
|
305
|
+
if (points.length < 2) {
|
|
306
|
+
return errors.err(errors.typeCastError("APPROXIMATE_MIN_POINTS", "Approximation requires at least 2 points"));
|
|
307
|
+
}
|
|
308
|
+
try {
|
|
309
|
+
const result = occtBoundary.getKernel().approximatePoints(points, options);
|
|
310
|
+
const cast2 = shapeTypes.castShape(result);
|
|
311
|
+
if (!shapeTypes.isEdge(cast2)) {
|
|
312
|
+
return errors.err(errors.typeCastError("APPROXIMATE_NOT_EDGE", "Approximation did not produce an edge"));
|
|
313
|
+
}
|
|
314
|
+
return errors.ok(cast2);
|
|
315
|
+
} catch (e) {
|
|
316
|
+
return errors.err(
|
|
317
|
+
errors.typeCastError(
|
|
318
|
+
"APPROXIMATE_FAILED",
|
|
319
|
+
`Approximation failed: ${e instanceof Error ? e.message : String(e)}`
|
|
320
|
+
)
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function offsetWire2D(wire, offset, kind = "arc") {
|
|
325
|
+
const oc = occtBoundary.getKernel().oc;
|
|
326
|
+
const joinTypes = {
|
|
327
|
+
arc: oc.GeomAbs_JoinType.GeomAbs_Arc,
|
|
328
|
+
intersection: oc.GeomAbs_JoinType.GeomAbs_Intersection,
|
|
329
|
+
tangent: oc.GeomAbs_JoinType.GeomAbs_Tangent
|
|
330
|
+
};
|
|
331
|
+
const resultShape = occtBoundary.getKernel().offsetWire2D(wire.wrapped, offset, joinTypes[kind]);
|
|
332
|
+
const wrapped = shapeTypes.castShape(resultShape);
|
|
333
|
+
if (!shapeTypes.isWire(wrapped)) {
|
|
334
|
+
wrapped[Symbol.dispose]();
|
|
335
|
+
return errors.err(errors.typeCastError("OFFSET_NOT_WIRE", "Offset did not produce a Wire"));
|
|
336
|
+
}
|
|
337
|
+
return errors.ok(wrapped);
|
|
338
|
+
}
|
|
339
|
+
exports.approximateCurve = approximateCurve;
|
|
340
|
+
exports.clone = clone;
|
|
341
|
+
exports.curveEndPoint = curveEndPoint;
|
|
342
|
+
exports.curveIsClosed = curveIsClosed;
|
|
343
|
+
exports.curveIsPeriodic = curveIsPeriodic;
|
|
344
|
+
exports.curveLength = curveLength;
|
|
345
|
+
exports.curvePeriod = curvePeriod;
|
|
346
|
+
exports.curvePointAt = curvePointAt;
|
|
347
|
+
exports.curveStartPoint = curveStartPoint;
|
|
348
|
+
exports.curveTangentAt = curveTangentAt;
|
|
349
|
+
exports.describe = describe;
|
|
350
|
+
exports.findCurveType = findCurveType;
|
|
351
|
+
exports.flipOrientation = flipOrientation;
|
|
352
|
+
exports.getBounds = getBounds;
|
|
353
|
+
exports.getCurveType = getCurveType;
|
|
354
|
+
exports.getEdges = getEdges;
|
|
355
|
+
exports.getFaces = getFaces;
|
|
356
|
+
exports.getHashCode = getHashCode;
|
|
357
|
+
exports.getOrientation = getOrientation;
|
|
358
|
+
exports.getVertices = getVertices;
|
|
359
|
+
exports.getWires = getWires;
|
|
360
|
+
exports.interpolateCurve = interpolateCurve;
|
|
361
|
+
exports.isEmpty = isEmpty;
|
|
362
|
+
exports.isEqualShape = isEqualShape;
|
|
363
|
+
exports.isSameShape = isSameShape;
|
|
364
|
+
exports.iterEdges = iterEdges;
|
|
365
|
+
exports.iterFaces = iterFaces;
|
|
366
|
+
exports.iterVertices = iterVertices;
|
|
367
|
+
exports.iterWires = iterWires;
|
|
368
|
+
exports.mirror = mirror;
|
|
369
|
+
exports.offsetWire2D = offsetWire2D;
|
|
370
|
+
exports.rotate = rotate;
|
|
371
|
+
exports.scale = scale;
|
|
372
|
+
exports.simplify = simplify;
|
|
373
|
+
exports.toBREP = toBREP;
|
|
374
|
+
exports.translate = translate;
|
|
375
|
+
exports.vertexPosition = vertexPosition;
|