brepjs 8.8.2 → 8.8.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/curves.d.ts.map +1 -1
- package/dist/2d/lib/Curve2D.d.ts.map +1 -1
- package/dist/2d/lib/approximations.d.ts.map +1 -1
- package/dist/2d/lib/makeCurves.d.ts.map +1 -1
- package/dist/2d/lib/ocWrapper.d.ts.map +1 -1
- package/dist/2d.cjs +2 -2
- package/dist/2d.js +3 -3
- package/dist/Blueprint-BmFJ4caY.cjs +1439 -0
- package/dist/Blueprint-DsoGiJNJ.js +1440 -0
- package/dist/{boolean2D-q5FOdOQW.cjs → boolean2D-BQk8LNmZ.cjs} +212 -127
- package/dist/{boolean2D-Dgnuy63w.js → boolean2D-D5O0F3J8.js} +212 -127
- package/dist/{booleanFns-CFit7JYt.cjs → booleanFns-CVM3dOTP.cjs} +210 -130
- package/dist/{booleanFns--Orezl-b.js → booleanFns-DOyKxL7q.js} +210 -130
- package/dist/brepjs.cjs +457 -304
- package/dist/brepjs.js +551 -398
- package/dist/core/disposal.d.ts +44 -3
- package/dist/core/disposal.d.ts.map +1 -1
- package/dist/core/geometryHelpers.d.ts.map +1 -1
- package/dist/core/kernelCall.d.ts +20 -0
- package/dist/core/kernelCall.d.ts.map +1 -1
- package/dist/core/memory.d.ts +1 -1
- package/dist/core/memory.d.ts.map +1 -1
- package/dist/core.cjs +4 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +11 -8
- package/dist/{cornerFinder-KNTFoGrm.js → cornerFinder-DH6EwYfL.js} +1 -1
- package/dist/{cornerFinder-v4un1Fr9.cjs → cornerFinder-XAV2ywVS.cjs} +1 -1
- package/dist/curveFns-BHRYwxBM.js +281 -0
- package/dist/{curveFns-6ovDM_sR.cjs → curveFns-BsAHC3Qv.cjs} +137 -36
- package/dist/{drawFns-WgXeXHH1.cjs → drawFns-CsmUF97U.cjs} +181 -101
- package/dist/{drawFns-XwroLxdb.js → drawFns-hD05g0ZQ.js} +181 -101
- package/dist/faceFns-DNQss51F.cjs +358 -0
- package/dist/faceFns-q5CR9pOW.js +359 -0
- package/dist/{helpers-CRfqaW0Y.cjs → helpers-aylLv0_I.cjs} +13 -10
- package/dist/{helpers-CtBCzEqs.js → helpers-tNdaX01G.js} +13 -10
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/io/importFns.d.ts.map +1 -1
- package/dist/io.cjs +131 -63
- package/dist/io.js +131 -63
- package/dist/loft-CjEEqz2P.cjs +530 -0
- package/dist/loft-DTRcYrq2.js +531 -0
- package/dist/measurement-B6_cxjpw.cjs +200 -0
- package/dist/measurement-BXqFvcGh.js +201 -0
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-CPNNlpbw.cjs → meshFns-CTc1CRkF.cjs} +1 -1
- package/dist/{meshFns-DAmWVyEp.js → meshFns-DDFl7gLN.js} +1 -1
- package/dist/operations/exporterFns.d.ts.map +1 -1
- package/dist/operations/exporterUtils.d.ts +3 -3
- package/dist/operations/exporterUtils.d.ts.map +1 -1
- package/dist/operations/exporters.d.ts.map +1 -1
- package/dist/operations/extrude.d.ts.map +1 -1
- package/dist/operations/extrudeFns.d.ts.map +1 -1
- package/dist/operations/loft.d.ts.map +1 -1
- package/dist/operations/multiSweepFns.d.ts.map +1 -1
- package/dist/{operations-vN0tcoaU.js → operations-jRE2QbPo.js} +261 -166
- package/dist/{operations-BQ25CPI8.cjs → operations-pxjbW4Er.cjs} +261 -166
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/query/shapeDistanceFilter.d.ts.map +1 -1
- package/dist/query.cjs +66 -14
- package/dist/query.js +67 -15
- package/dist/{shapeFns-C785aeVn.cjs → shapeFns-D4CRxxmF.cjs} +61 -7
- package/dist/{shapeFns-ClpALED4.js → shapeFns-DNnBK8fG.js} +61 -7
- package/dist/{shapeTypes-DnwCo942.js → shapeTypes-Bi_9RZa2.js} +50 -19
- package/dist/{shapeTypes-CIijJxCz.cjs → shapeTypes-CWuX602K.cjs} +32 -1
- package/dist/sketching/CompoundSketch.d.ts.map +1 -1
- package/dist/sketching/Sketch.d.ts.map +1 -1
- package/dist/sketching/Sketcher.d.ts.map +1 -1
- package/dist/sketching/Sketcher2d.d.ts.map +1 -1
- package/dist/sketching/cannedSketches.d.ts.map +1 -1
- package/dist/sketching/draw.d.ts.map +1 -1
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/surfaceBuilders-CLal3WlK.cjs +429 -0
- package/dist/surfaceBuilders-W9Y25CIb.js +430 -0
- package/dist/topology/curveBuilders.d.ts.map +1 -1
- package/dist/topology/shapeFns.d.ts.map +1 -1
- package/dist/topology/solidBuilders.d.ts.map +1 -1
- package/dist/topology/surfaceBuilders.d.ts.map +1 -1
- package/dist/{topology-CqyxpmEh.js → topology-CMM6vAzx.js} +6 -6
- package/dist/{topology-zG8maSDK.cjs → topology-CNw-wsmG.cjs} +6 -6
- package/dist/topology.cjs +6 -6
- package/dist/topology.js +6 -6
- package/package.json +4 -1
- package/dist/Blueprint-BmbNUnGI.cjs +0 -1185
- package/dist/Blueprint-C-JJkkwL.js +0 -1186
- package/dist/curveFns-BhQECv8e.js +0 -180
- package/dist/faceFns-3PDjBeW7.js +0 -272
- package/dist/faceFns-CxaLWOjc.cjs +0 -271
- package/dist/loft-CVb-IjEI.cjs +0 -372
- package/dist/loft-DMFjK6lk.js +0 -373
- package/dist/measurement-CecYIt3s.cjs +0 -134
- package/dist/measurement-DHDLAH7-.js +0 -135
- package/dist/surfaceBuilders-CC0ZQGix.cjs +0 -289
- package/dist/surfaceBuilders-CrJtFu2a.js +0 -290
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { g as getKernel } from "./occtBoundary-DvBywHyU.js";
|
|
2
|
-
import { c as castShape, d as isEdge, m as isWire, n as gcWithScope } from "./shapeTypes-DnwCo942.js";
|
|
3
|
-
import { e as err, p as typeCastError, l as ok, u as unwrap } from "./errors-DJ92ermb.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 r = gcWithScope();
|
|
44
|
-
const adaptor = r(getAdaptor(shape));
|
|
45
|
-
const technicalType = adaptor.GetType && adaptor.GetType();
|
|
46
|
-
return unwrap(findCurveType(technicalType));
|
|
47
|
-
}
|
|
48
|
-
function curveStartPoint(shape) {
|
|
49
|
-
const r = gcWithScope();
|
|
50
|
-
const adaptor = r(getAdaptor(shape));
|
|
51
|
-
const pnt = r(adaptor.Value(adaptor.FirstParameter()));
|
|
52
|
-
return [pnt.X(), pnt.Y(), pnt.Z()];
|
|
53
|
-
}
|
|
54
|
-
function curveEndPoint(shape) {
|
|
55
|
-
const r = gcWithScope();
|
|
56
|
-
const adaptor = r(getAdaptor(shape));
|
|
57
|
-
const pnt = r(adaptor.Value(adaptor.LastParameter()));
|
|
58
|
-
return [pnt.X(), pnt.Y(), pnt.Z()];
|
|
59
|
-
}
|
|
60
|
-
function curvePointAt(shape, position = 0.5) {
|
|
61
|
-
const r = gcWithScope();
|
|
62
|
-
const adaptor = r(getAdaptor(shape));
|
|
63
|
-
const pnt = r(adaptor.Value(mapParam(adaptor, position)));
|
|
64
|
-
return [pnt.X(), pnt.Y(), pnt.Z()];
|
|
65
|
-
}
|
|
66
|
-
function curveTangentAt(shape, position = 0.5) {
|
|
67
|
-
const oc = getKernel().oc;
|
|
68
|
-
const r = gcWithScope();
|
|
69
|
-
const adaptor = r(getAdaptor(shape));
|
|
70
|
-
const param = mapParam(adaptor, position);
|
|
71
|
-
const tmpPnt = r(new oc.gp_Pnt_1());
|
|
72
|
-
const tmpVec = r(new oc.gp_Vec_1());
|
|
73
|
-
adaptor.D1(param, tmpPnt, tmpVec);
|
|
74
|
-
return [tmpVec.X(), tmpVec.Y(), tmpVec.Z()];
|
|
75
|
-
}
|
|
76
|
-
function curveLength(shape) {
|
|
77
|
-
const oc = getKernel().oc;
|
|
78
|
-
const r = gcWithScope();
|
|
79
|
-
const props = r(new oc.GProp_GProps_1());
|
|
80
|
-
oc.BRepGProp.LinearProperties(shape.wrapped, props, true, false);
|
|
81
|
-
return props.Mass();
|
|
82
|
-
}
|
|
83
|
-
function curveIsClosed(shape) {
|
|
84
|
-
const r = gcWithScope();
|
|
85
|
-
const adaptor = r(getAdaptor(shape));
|
|
86
|
-
return adaptor.IsClosed();
|
|
87
|
-
}
|
|
88
|
-
function curveIsPeriodic(shape) {
|
|
89
|
-
const r = gcWithScope();
|
|
90
|
-
const adaptor = r(getAdaptor(shape));
|
|
91
|
-
return adaptor.IsPeriodic();
|
|
92
|
-
}
|
|
93
|
-
function curvePeriod(shape) {
|
|
94
|
-
const adaptor = getAdaptor(shape);
|
|
95
|
-
const result = adaptor.Period();
|
|
96
|
-
adaptor.delete();
|
|
97
|
-
return result;
|
|
98
|
-
}
|
|
99
|
-
function getOrientation(shape) {
|
|
100
|
-
const oc = getKernel().oc;
|
|
101
|
-
const orient = shape.wrapped.Orientation_1();
|
|
102
|
-
return orient === oc.TopAbs_Orientation.TopAbs_FORWARD ? "forward" : "backward";
|
|
103
|
-
}
|
|
104
|
-
function flipOrientation(shape) {
|
|
105
|
-
return castShape(shape.wrapped.Reversed());
|
|
106
|
-
}
|
|
107
|
-
function interpolateCurve(points, options = {}) {
|
|
108
|
-
if (points.length < 2) {
|
|
109
|
-
return err(typeCastError("INTERPOLATE_MIN_POINTS", "Interpolation requires at least 2 points"));
|
|
110
|
-
}
|
|
111
|
-
try {
|
|
112
|
-
const result = getKernel().interpolatePoints(points, options);
|
|
113
|
-
const cast = castShape(result);
|
|
114
|
-
if (!isEdge(cast)) {
|
|
115
|
-
return err(typeCastError("INTERPOLATE_NOT_EDGE", "Interpolation did not produce an edge"));
|
|
116
|
-
}
|
|
117
|
-
return ok(cast);
|
|
118
|
-
} catch (e) {
|
|
119
|
-
return err(
|
|
120
|
-
typeCastError(
|
|
121
|
-
"INTERPOLATE_FAILED",
|
|
122
|
-
`Interpolation failed: ${e instanceof Error ? e.message : String(e)}`
|
|
123
|
-
)
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function approximateCurve(points, options = {}) {
|
|
128
|
-
if (points.length < 2) {
|
|
129
|
-
return err(typeCastError("APPROXIMATE_MIN_POINTS", "Approximation requires at least 2 points"));
|
|
130
|
-
}
|
|
131
|
-
try {
|
|
132
|
-
const result = getKernel().approximatePoints(points, options);
|
|
133
|
-
const cast = castShape(result);
|
|
134
|
-
if (!isEdge(cast)) {
|
|
135
|
-
return err(typeCastError("APPROXIMATE_NOT_EDGE", "Approximation did not produce an edge"));
|
|
136
|
-
}
|
|
137
|
-
return ok(cast);
|
|
138
|
-
} catch (e) {
|
|
139
|
-
return err(
|
|
140
|
-
typeCastError(
|
|
141
|
-
"APPROXIMATE_FAILED",
|
|
142
|
-
`Approximation failed: ${e instanceof Error ? e.message : String(e)}`
|
|
143
|
-
)
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
function offsetWire2D(wire, offset, kind = "arc") {
|
|
148
|
-
const oc = getKernel().oc;
|
|
149
|
-
const joinTypes = {
|
|
150
|
-
arc: oc.GeomAbs_JoinType.GeomAbs_Arc,
|
|
151
|
-
intersection: oc.GeomAbs_JoinType.GeomAbs_Intersection,
|
|
152
|
-
tangent: oc.GeomAbs_JoinType.GeomAbs_Tangent,
|
|
153
|
-
chamfer: oc.GeomAbs_JoinType.GeomAbs_Intersection
|
|
154
|
-
// sharp/miter corners
|
|
155
|
-
};
|
|
156
|
-
const resultShape = getKernel().offsetWire2D(wire.wrapped, offset, joinTypes[kind]);
|
|
157
|
-
const wrapped = castShape(resultShape);
|
|
158
|
-
if (!isWire(wrapped)) {
|
|
159
|
-
wrapped[Symbol.dispose]();
|
|
160
|
-
return err(typeCastError("OFFSET_NOT_WIRE", "Offset did not produce a Wire"));
|
|
161
|
-
}
|
|
162
|
-
return ok(wrapped);
|
|
163
|
-
}
|
|
164
|
-
export {
|
|
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,
|
|
178
|
-
interpolateCurve as n,
|
|
179
|
-
offsetWire2D as o
|
|
180
|
-
};
|
package/dist/faceFns-3PDjBeW7.js
DELETED
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
import { g as getKernel, a as toVec3, d as toOcPnt } from "./occtBoundary-DvBywHyU.js";
|
|
2
|
-
import { c as castShape, h as isShape3D$1, m as isWire$1, n as gcWithScope } from "./shapeTypes-DnwCo942.js";
|
|
3
|
-
import { e as err, p as typeCastError, l as ok, a as andThen, u as unwrap } from "./errors-DJ92ermb.js";
|
|
4
|
-
let _topoMap = null;
|
|
5
|
-
const asTopo = (entity) => {
|
|
6
|
-
if (!_topoMap) {
|
|
7
|
-
const oc = getKernel().oc;
|
|
8
|
-
const ta = oc.TopAbs_ShapeEnum;
|
|
9
|
-
_topoMap = /* @__PURE__ */ new Map([
|
|
10
|
-
["vertex", ta.TopAbs_VERTEX],
|
|
11
|
-
["edge", ta.TopAbs_EDGE],
|
|
12
|
-
["wire", ta.TopAbs_WIRE],
|
|
13
|
-
["face", ta.TopAbs_FACE],
|
|
14
|
-
["shell", ta.TopAbs_SHELL],
|
|
15
|
-
["solid", ta.TopAbs_SOLID],
|
|
16
|
-
["solidCompound", ta.TopAbs_COMPSOLID],
|
|
17
|
-
["compound", ta.TopAbs_COMPOUND],
|
|
18
|
-
["shape", ta.TopAbs_SHAPE]
|
|
19
|
-
]);
|
|
20
|
-
}
|
|
21
|
-
return _topoMap.get(entity);
|
|
22
|
-
};
|
|
23
|
-
const iterTopo = function* iterTopo2(shape, topo) {
|
|
24
|
-
const topoToShapeType = {
|
|
25
|
-
vertex: "vertex",
|
|
26
|
-
edge: "edge",
|
|
27
|
-
wire: "wire",
|
|
28
|
-
face: "face",
|
|
29
|
-
shell: "shell",
|
|
30
|
-
solid: "solid",
|
|
31
|
-
solidCompound: "compsolid",
|
|
32
|
-
compound: "compound",
|
|
33
|
-
shape: "compound"
|
|
34
|
-
// fallback; 'shape' isn't used in iterShapes
|
|
35
|
-
};
|
|
36
|
-
const shapeType2 = topoToShapeType[topo];
|
|
37
|
-
if (shapeType2) {
|
|
38
|
-
const shapes = getKernel().iterShapes(shape, shapeType2);
|
|
39
|
-
for (const s of shapes) yield s;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const shapeType = (shape) => {
|
|
43
|
-
if (shape.IsNull()) return err(typeCastError("NULL_SHAPE", "This shape has no type, it is null"));
|
|
44
|
-
return ok(shape.ShapeType());
|
|
45
|
-
};
|
|
46
|
-
let _downcastMap = null;
|
|
47
|
-
function getDowncastMap() {
|
|
48
|
-
if (!_downcastMap) {
|
|
49
|
-
const oc = getKernel().oc;
|
|
50
|
-
const ta = oc.TopAbs_ShapeEnum;
|
|
51
|
-
_downcastMap = /* @__PURE__ */ new Map([
|
|
52
|
-
[ta.TopAbs_VERTEX, oc.TopoDS.Vertex_1],
|
|
53
|
-
[ta.TopAbs_EDGE, oc.TopoDS.Edge_1],
|
|
54
|
-
[ta.TopAbs_WIRE, oc.TopoDS.Wire_1],
|
|
55
|
-
[ta.TopAbs_FACE, oc.TopoDS.Face_1],
|
|
56
|
-
[ta.TopAbs_SHELL, oc.TopoDS.Shell_1],
|
|
57
|
-
[ta.TopAbs_SOLID, oc.TopoDS.Solid_1],
|
|
58
|
-
[ta.TopAbs_COMPSOLID, oc.TopoDS.CompSolid_1],
|
|
59
|
-
[ta.TopAbs_COMPOUND, oc.TopoDS.Compound_1]
|
|
60
|
-
]);
|
|
61
|
-
}
|
|
62
|
-
return _downcastMap;
|
|
63
|
-
}
|
|
64
|
-
function downcast(shape) {
|
|
65
|
-
return andThen(shapeType(shape), (myType) => {
|
|
66
|
-
const caster = getDowncastMap().get(myType);
|
|
67
|
-
if (!caster)
|
|
68
|
-
return err(typeCastError("NO_WRAPPER", "Could not find a wrapper for this shape type"));
|
|
69
|
-
return ok(caster(shape));
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
function cast(shape) {
|
|
73
|
-
if (shape.IsNull()) {
|
|
74
|
-
return err(typeCastError("NULL_SHAPE", "Cannot cast a null shape"));
|
|
75
|
-
}
|
|
76
|
-
return ok(castShape(shape));
|
|
77
|
-
}
|
|
78
|
-
function isShape3D(shape) {
|
|
79
|
-
return isShape3D$1(shape);
|
|
80
|
-
}
|
|
81
|
-
function isWire(shape) {
|
|
82
|
-
return isWire$1(shape);
|
|
83
|
-
}
|
|
84
|
-
function isCompSolid(shape) {
|
|
85
|
-
const st = shape.wrapped.ShapeType();
|
|
86
|
-
const oc = getKernel().oc;
|
|
87
|
-
return st === oc.TopAbs_ShapeEnum.TopAbs_COMPSOLID;
|
|
88
|
-
}
|
|
89
|
-
function fromBREP(data) {
|
|
90
|
-
const oc = getKernel().oc;
|
|
91
|
-
return cast(oc.BRepToolsWrapper.Read(data));
|
|
92
|
-
}
|
|
93
|
-
function getSurfaceType(face) {
|
|
94
|
-
const oc = getKernel().oc;
|
|
95
|
-
const r = gcWithScope();
|
|
96
|
-
const adaptor = r(new oc.BRepAdaptor_Surface_2(face.wrapped, false));
|
|
97
|
-
const ga = oc.GeomAbs_SurfaceType;
|
|
98
|
-
const CAST_MAP = /* @__PURE__ */ new Map([
|
|
99
|
-
[ga.GeomAbs_Plane, "PLANE"],
|
|
100
|
-
[ga.GeomAbs_Cylinder, "CYLINDRE"],
|
|
101
|
-
[ga.GeomAbs_Cone, "CONE"],
|
|
102
|
-
[ga.GeomAbs_Sphere, "SPHERE"],
|
|
103
|
-
[ga.GeomAbs_Torus, "TORUS"],
|
|
104
|
-
[ga.GeomAbs_BezierSurface, "BEZIER_SURFACE"],
|
|
105
|
-
[ga.GeomAbs_BSplineSurface, "BSPLINE_SURFACE"],
|
|
106
|
-
[ga.GeomAbs_SurfaceOfRevolution, "REVOLUTION_SURFACE"],
|
|
107
|
-
[ga.GeomAbs_SurfaceOfExtrusion, "EXTRUSION_SURFACE"],
|
|
108
|
-
[ga.GeomAbs_OffsetSurface, "OFFSET_SURFACE"],
|
|
109
|
-
[ga.GeomAbs_OtherSurface, "OTHER_SURFACE"]
|
|
110
|
-
]);
|
|
111
|
-
const surfType = CAST_MAP.get(adaptor.GetType());
|
|
112
|
-
if (!surfType) {
|
|
113
|
-
return err(
|
|
114
|
-
typeCastError("UNKNOWN_SURFACE_TYPE", "Unrecognized surface type from OCCT adapter")
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
return ok(surfType);
|
|
118
|
-
}
|
|
119
|
-
function faceGeomType(face) {
|
|
120
|
-
return unwrap(getSurfaceType(face));
|
|
121
|
-
}
|
|
122
|
-
function faceOrientation(face) {
|
|
123
|
-
const oc = getKernel().oc;
|
|
124
|
-
const orient = face.wrapped.Orientation_1();
|
|
125
|
-
return orient === oc.TopAbs_Orientation.TopAbs_FORWARD ? "forward" : "backward";
|
|
126
|
-
}
|
|
127
|
-
function flipFaceOrientation(face) {
|
|
128
|
-
return castShape(face.wrapped.Reversed());
|
|
129
|
-
}
|
|
130
|
-
function uvBounds(face) {
|
|
131
|
-
const oc = getKernel().oc;
|
|
132
|
-
const uMin = { current: 0 };
|
|
133
|
-
const uMax = { current: 0 };
|
|
134
|
-
const vMin = { current: 0 };
|
|
135
|
-
const vMax = { current: 0 };
|
|
136
|
-
oc.BRepTools.UVBounds_1(face.wrapped, uMin, uMax, vMin, vMax);
|
|
137
|
-
return {
|
|
138
|
-
uMin: uMin.current,
|
|
139
|
-
uMax: uMax.current,
|
|
140
|
-
vMin: vMin.current,
|
|
141
|
-
vMax: vMax.current
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
function pointOnSurface(face, u, v) {
|
|
145
|
-
const oc = getKernel().oc;
|
|
146
|
-
const r = gcWithScope();
|
|
147
|
-
const bounds = uvBounds(face);
|
|
148
|
-
const adaptor = r(new oc.BRepAdaptor_Surface_2(face.wrapped, false));
|
|
149
|
-
const p = r(new oc.gp_Pnt_1());
|
|
150
|
-
const absU = u * (bounds.uMax - bounds.uMin) + bounds.uMin;
|
|
151
|
-
const absV = v * (bounds.vMax - bounds.vMin) + bounds.vMin;
|
|
152
|
-
adaptor.D0(absU, absV, p);
|
|
153
|
-
return [p.X(), p.Y(), p.Z()];
|
|
154
|
-
}
|
|
155
|
-
function uvCoordinates(face, point) {
|
|
156
|
-
const oc = getKernel().oc;
|
|
157
|
-
const r = gcWithScope();
|
|
158
|
-
const v = toVec3(point);
|
|
159
|
-
const surface = r(oc.BRep_Tool.Surface_2(face.wrapped));
|
|
160
|
-
const projected = r(
|
|
161
|
-
new oc.GeomAPI_ProjectPointOnSurf_2(
|
|
162
|
-
r(toOcPnt(v)),
|
|
163
|
-
surface,
|
|
164
|
-
oc.Extrema_ExtAlgo.Extrema_ExtAlgo_Grad
|
|
165
|
-
)
|
|
166
|
-
);
|
|
167
|
-
const uPtr = { current: 0 };
|
|
168
|
-
const vPtr = { current: 0 };
|
|
169
|
-
projected.LowerDistanceParameters(uPtr, vPtr);
|
|
170
|
-
return [uPtr.current, vPtr.current];
|
|
171
|
-
}
|
|
172
|
-
function projectPointOnFace(face, point) {
|
|
173
|
-
const oc = getKernel().oc;
|
|
174
|
-
const r = gcWithScope();
|
|
175
|
-
const v = toVec3(point);
|
|
176
|
-
try {
|
|
177
|
-
const surface = r(oc.BRep_Tool.Surface_2(face.wrapped));
|
|
178
|
-
const projected = r(
|
|
179
|
-
new oc.GeomAPI_ProjectPointOnSurf_2(
|
|
180
|
-
r(toOcPnt(v)),
|
|
181
|
-
surface,
|
|
182
|
-
oc.Extrema_ExtAlgo.Extrema_ExtAlgo_Grad
|
|
183
|
-
)
|
|
184
|
-
);
|
|
185
|
-
if (projected.NbPoints() === 0) {
|
|
186
|
-
return err(typeCastError("PROJECTION_FAILED", "No projection found on the face"));
|
|
187
|
-
}
|
|
188
|
-
const uPtr = { current: 0 };
|
|
189
|
-
const vPtr = { current: 0 };
|
|
190
|
-
projected.LowerDistanceParameters(uPtr, vPtr);
|
|
191
|
-
const nearestPnt = r(projected.NearestPoint());
|
|
192
|
-
const projectedPoint = [nearestPnt.X(), nearestPnt.Y(), nearestPnt.Z()];
|
|
193
|
-
return ok({
|
|
194
|
-
uv: [uPtr.current, vPtr.current],
|
|
195
|
-
point: projectedPoint,
|
|
196
|
-
distance: projected.LowerDistance()
|
|
197
|
-
});
|
|
198
|
-
} catch (e) {
|
|
199
|
-
return err(
|
|
200
|
-
typeCastError(
|
|
201
|
-
"PROJECTION_FAILED",
|
|
202
|
-
`Point projection failed: ${e instanceof Error ? e.message : String(e)}`
|
|
203
|
-
)
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
function normalAt(face, locationPoint) {
|
|
208
|
-
const oc = getKernel().oc;
|
|
209
|
-
const r = gcWithScope();
|
|
210
|
-
let u;
|
|
211
|
-
let v;
|
|
212
|
-
if (!locationPoint) {
|
|
213
|
-
const bounds = uvBounds(face);
|
|
214
|
-
u = 0.5 * (bounds.uMin + bounds.uMax);
|
|
215
|
-
v = 0.5 * (bounds.vMin + bounds.vMax);
|
|
216
|
-
} else {
|
|
217
|
-
[u, v] = uvCoordinates(face, locationPoint);
|
|
218
|
-
}
|
|
219
|
-
const p = r(new oc.gp_Pnt_1());
|
|
220
|
-
const vn = r(new oc.gp_Vec_1());
|
|
221
|
-
const props = r(new oc.BRepGProp_Face_2(face.wrapped, false));
|
|
222
|
-
props.Normal(u, v, p, vn);
|
|
223
|
-
return [vn.X(), vn.Y(), vn.Z()];
|
|
224
|
-
}
|
|
225
|
-
function faceCenter(face) {
|
|
226
|
-
const oc = getKernel().oc;
|
|
227
|
-
const r = gcWithScope();
|
|
228
|
-
const props = r(new oc.GProp_GProps_1());
|
|
229
|
-
oc.BRepGProp.SurfaceProperties_2(face.wrapped, props, 1e-7, true);
|
|
230
|
-
const center = r(props.CentreOfMass());
|
|
231
|
-
return [center.X(), center.Y(), center.Z()];
|
|
232
|
-
}
|
|
233
|
-
function classifyPointOnFace(face, point, tolerance = 1e-6) {
|
|
234
|
-
const [u, v] = uvCoordinates(face, point);
|
|
235
|
-
return getKernel().classifyPointOnFace(face.wrapped, u, v, tolerance);
|
|
236
|
-
}
|
|
237
|
-
function outerWire(face) {
|
|
238
|
-
const oc = getKernel().oc;
|
|
239
|
-
return castShape(oc.BRepTools.OuterWire(face.wrapped));
|
|
240
|
-
}
|
|
241
|
-
function innerWires(face) {
|
|
242
|
-
const outer = outerWire(face);
|
|
243
|
-
const allWires = Array.from(iterTopo(face.wrapped, "wire")).map(
|
|
244
|
-
(w) => castShape(unwrap(downcast(w)))
|
|
245
|
-
);
|
|
246
|
-
const result = allWires.filter((w) => !w.wrapped.IsSame(outer.wrapped));
|
|
247
|
-
return result;
|
|
248
|
-
}
|
|
249
|
-
export {
|
|
250
|
-
isShape3D as a,
|
|
251
|
-
isWire as b,
|
|
252
|
-
cast as c,
|
|
253
|
-
downcast as d,
|
|
254
|
-
faceCenter as e,
|
|
255
|
-
faceGeomType as f,
|
|
256
|
-
getSurfaceType as g,
|
|
257
|
-
uvCoordinates as h,
|
|
258
|
-
iterTopo as i,
|
|
259
|
-
fromBREP as j,
|
|
260
|
-
innerWires as k,
|
|
261
|
-
asTopo as l,
|
|
262
|
-
classifyPointOnFace as m,
|
|
263
|
-
normalAt as n,
|
|
264
|
-
outerWire as o,
|
|
265
|
-
pointOnSurface as p,
|
|
266
|
-
faceOrientation as q,
|
|
267
|
-
flipFaceOrientation as r,
|
|
268
|
-
isCompSolid as s,
|
|
269
|
-
projectPointOnFace as t,
|
|
270
|
-
uvBounds as u,
|
|
271
|
-
shapeType as v
|
|
272
|
-
};
|