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
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { g as getKernel } from "./occtBoundary-
|
|
2
|
-
import {
|
|
3
|
-
import { l as ok, d as isErr, e as err, x as validationError, B as BrepErrorCode, p as typeCastError, o as occtError } from "./errors-
|
|
4
|
-
import { r as resolvePlane } from "./vectors-
|
|
5
|
-
import { n as vecScale, v as vecAdd } from "./vecOps-ZDdZWbwT.js";
|
|
6
|
-
import { p as propagateOrigins,
|
|
1
|
+
import { g as getKernel } from "./occtBoundary-CWzWqBCm.js";
|
|
2
|
+
import { n as gcWithScope, c as castShape, h as isShape3D } from "./shapeTypes-D0vfRxWb.js";
|
|
3
|
+
import { l as ok, d as isErr, e as err, x as validationError, B as BrepErrorCode, p as typeCastError, o as occtError } from "./errors-Coh_5_19.js";
|
|
4
|
+
import { r as resolvePlane } from "./vectors-CZV4ZrTz.js";
|
|
5
|
+
import { H as HASH_CODE_MAX, n as vecScale, v as vecAdd } from "./vecOps-ZDdZWbwT.js";
|
|
6
|
+
import { a as getFaces, p as propagateOrigins, b as propagateOriginsByHash, c as getWires, d as getEdges } from "./shapeFns-4ioRrhih.js";
|
|
7
|
+
import { m as makeFace } from "./surfaceBuilders-B7Jxob8g.js";
|
|
7
8
|
function applyGlue(op, optimisation) {
|
|
8
9
|
const oc = getKernel().oc;
|
|
9
10
|
if (optimisation === "commonFace") {
|
|
@@ -13,6 +14,211 @@ function applyGlue(op, optimisation) {
|
|
|
13
14
|
op.SetGlue(oc.BOPAlgo_GlueEnum.BOPAlgo_GlueFull);
|
|
14
15
|
}
|
|
15
16
|
}
|
|
17
|
+
const shapeTagStore = /* @__PURE__ */ new WeakMap();
|
|
18
|
+
const tagMetadataStore = /* @__PURE__ */ new WeakMap();
|
|
19
|
+
function getTagMap(shape) {
|
|
20
|
+
let map = shapeTagStore.get(shape.wrapped);
|
|
21
|
+
if (!map) {
|
|
22
|
+
map = /* @__PURE__ */ new Map();
|
|
23
|
+
shapeTagStore.set(shape.wrapped, map);
|
|
24
|
+
}
|
|
25
|
+
return map;
|
|
26
|
+
}
|
|
27
|
+
function getMetaMap(shape) {
|
|
28
|
+
let map = tagMetadataStore.get(shape.wrapped);
|
|
29
|
+
if (!map) {
|
|
30
|
+
map = /* @__PURE__ */ new Map();
|
|
31
|
+
tagMetadataStore.set(shape.wrapped, map);
|
|
32
|
+
}
|
|
33
|
+
return map;
|
|
34
|
+
}
|
|
35
|
+
function tagFaces(shape, selector, tag) {
|
|
36
|
+
const faces = Array.isArray(selector) ? selector : getFaces(shape).filter(selector);
|
|
37
|
+
const tagMap = getTagMap(shape);
|
|
38
|
+
const existing = tagMap.get(tag) ?? /* @__PURE__ */ new Set();
|
|
39
|
+
for (const face of faces) {
|
|
40
|
+
existing.add(face.wrapped.HashCode(HASH_CODE_MAX));
|
|
41
|
+
}
|
|
42
|
+
tagMap.set(tag, existing);
|
|
43
|
+
return shape;
|
|
44
|
+
}
|
|
45
|
+
function findFacesByTag(shape, tag) {
|
|
46
|
+
const tagMap = shapeTagStore.get(shape.wrapped);
|
|
47
|
+
if (!tagMap) return [];
|
|
48
|
+
const hashes = tagMap.get(tag);
|
|
49
|
+
if (!hashes || hashes.size === 0) return [];
|
|
50
|
+
const result = [];
|
|
51
|
+
for (const face of getFaces(shape)) {
|
|
52
|
+
const hash = face.wrapped.HashCode(HASH_CODE_MAX);
|
|
53
|
+
if (hashes.has(hash)) {
|
|
54
|
+
result.push(face);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
function getFaceTags(shape) {
|
|
60
|
+
const result = /* @__PURE__ */ new Map();
|
|
61
|
+
const tagMap = shapeTagStore.get(shape.wrapped);
|
|
62
|
+
if (!tagMap) return result;
|
|
63
|
+
const faces = getFaces(shape);
|
|
64
|
+
const faceByHash = /* @__PURE__ */ new Map();
|
|
65
|
+
for (const face of faces) {
|
|
66
|
+
faceByHash.set(face.wrapped.HashCode(HASH_CODE_MAX), face);
|
|
67
|
+
}
|
|
68
|
+
for (const [tag, hashes] of tagMap) {
|
|
69
|
+
const taggedFaces = [];
|
|
70
|
+
for (const hash of hashes) {
|
|
71
|
+
const face = faceByHash.get(hash);
|
|
72
|
+
if (face) taggedFaces.push(face);
|
|
73
|
+
}
|
|
74
|
+
if (taggedFaces.length > 0) {
|
|
75
|
+
result.set(tag, taggedFaces);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
function setTagMetadata(shape, tag, metadata) {
|
|
81
|
+
const metaMap = getMetaMap(shape);
|
|
82
|
+
metaMap.set(tag, metadata);
|
|
83
|
+
return shape;
|
|
84
|
+
}
|
|
85
|
+
function getTagMetadata(shape, tag) {
|
|
86
|
+
return tagMetadataStore.get(shape.wrapped)?.get(tag);
|
|
87
|
+
}
|
|
88
|
+
function propagateFaceTags(op, inputs, result) {
|
|
89
|
+
const resultTagMap = getTagMap(result);
|
|
90
|
+
for (const input of inputs) {
|
|
91
|
+
const inputTagMap = shapeTagStore.get(input.wrapped);
|
|
92
|
+
if (!inputTagMap) continue;
|
|
93
|
+
const hashToTags = /* @__PURE__ */ new Map();
|
|
94
|
+
for (const [tag, hashes] of inputTagMap) {
|
|
95
|
+
for (const hash of hashes) {
|
|
96
|
+
const tags = hashToTags.get(hash) ?? [];
|
|
97
|
+
tags.push(tag);
|
|
98
|
+
hashToTags.set(hash, tags);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
for (const face of getFaces(input)) {
|
|
102
|
+
const hash = face.wrapped.HashCode(HASH_CODE_MAX);
|
|
103
|
+
const tags = hashToTags.get(hash);
|
|
104
|
+
if (!tags) continue;
|
|
105
|
+
if (op.IsDeleted?.(face.wrapped)) continue;
|
|
106
|
+
const modifiedList = op.Modified(face.wrapped);
|
|
107
|
+
const modSize = modifiedList.Size?.() ?? 0;
|
|
108
|
+
if (modSize > 0) {
|
|
109
|
+
const oc = getKernel().oc;
|
|
110
|
+
const copy = new oc.TopTools_ListOfShape_3(modifiedList);
|
|
111
|
+
while (copy.Size() > 0) {
|
|
112
|
+
const modFace = copy.First_1();
|
|
113
|
+
const modHash = modFace.HashCode(HASH_CODE_MAX);
|
|
114
|
+
for (const tag of tags) {
|
|
115
|
+
const set = resultTagMap.get(tag) ?? /* @__PURE__ */ new Set();
|
|
116
|
+
set.add(modHash);
|
|
117
|
+
resultTagMap.set(tag, set);
|
|
118
|
+
}
|
|
119
|
+
copy.RemoveFirst();
|
|
120
|
+
}
|
|
121
|
+
copy.delete();
|
|
122
|
+
} else {
|
|
123
|
+
for (const tag of tags) {
|
|
124
|
+
const set = resultTagMap.get(tag) ?? /* @__PURE__ */ new Set();
|
|
125
|
+
set.add(hash);
|
|
126
|
+
resultTagMap.set(tag, set);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const inputMetaMap = tagMetadataStore.get(input.wrapped);
|
|
131
|
+
if (inputMetaMap) {
|
|
132
|
+
const resultMetaMap = getMetaMap(result);
|
|
133
|
+
for (const [tag, meta] of inputMetaMap) {
|
|
134
|
+
if (!resultMetaMap.has(tag)) {
|
|
135
|
+
resultMetaMap.set(tag, meta);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const shapeColorStore = /* @__PURE__ */ new WeakMap();
|
|
142
|
+
const faceColorStore = /* @__PURE__ */ new WeakMap();
|
|
143
|
+
function getFaceColorMap(shape) {
|
|
144
|
+
let map = faceColorStore.get(shape.wrapped);
|
|
145
|
+
if (!map) {
|
|
146
|
+
map = /* @__PURE__ */ new Map();
|
|
147
|
+
faceColorStore.set(shape.wrapped, map);
|
|
148
|
+
}
|
|
149
|
+
return map;
|
|
150
|
+
}
|
|
151
|
+
function parseColor(input) {
|
|
152
|
+
if (typeof input === "string") {
|
|
153
|
+
let hex = input.startsWith("#") ? input.slice(1) : input;
|
|
154
|
+
if (hex.length === 3) {
|
|
155
|
+
hex = hex.charAt(0) + hex.charAt(0) + hex.charAt(1) + hex.charAt(1) + hex.charAt(2) + hex.charAt(2);
|
|
156
|
+
}
|
|
157
|
+
const r = parseInt(hex.slice(0, 2), 16) / 255;
|
|
158
|
+
const g = parseInt(hex.slice(2, 4), 16) / 255;
|
|
159
|
+
const b = parseInt(hex.slice(4, 6), 16) / 255;
|
|
160
|
+
return [r, g, b, 1];
|
|
161
|
+
}
|
|
162
|
+
if (input.length === 3) {
|
|
163
|
+
return [input[0], input[1], input[2], 1];
|
|
164
|
+
}
|
|
165
|
+
return [input[0], input[1], input[2], input[3]];
|
|
166
|
+
}
|
|
167
|
+
function colorShape(shape, color) {
|
|
168
|
+
shapeColorStore.set(shape.wrapped, parseColor(color));
|
|
169
|
+
return shape;
|
|
170
|
+
}
|
|
171
|
+
function colorFaces(shape, faces, color) {
|
|
172
|
+
const parsed = parseColor(color);
|
|
173
|
+
const map = getFaceColorMap(shape);
|
|
174
|
+
for (const face of faces) {
|
|
175
|
+
map.set(face.wrapped.HashCode(HASH_CODE_MAX), parsed);
|
|
176
|
+
}
|
|
177
|
+
return shape;
|
|
178
|
+
}
|
|
179
|
+
function getShapeColor(shape) {
|
|
180
|
+
return shapeColorStore.get(shape.wrapped);
|
|
181
|
+
}
|
|
182
|
+
function getFaceColor(shape, face) {
|
|
183
|
+
const map = faceColorStore.get(shape.wrapped);
|
|
184
|
+
if (!map) return void 0;
|
|
185
|
+
return map.get(face.wrapped.HashCode(HASH_CODE_MAX));
|
|
186
|
+
}
|
|
187
|
+
function propagateColors(op, inputs, result) {
|
|
188
|
+
for (const input of inputs) {
|
|
189
|
+
const c = shapeColorStore.get(input.wrapped);
|
|
190
|
+
if (c) {
|
|
191
|
+
shapeColorStore.set(result.wrapped, c);
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const resultFaceMap = getFaceColorMap(result);
|
|
196
|
+
for (const input of inputs) {
|
|
197
|
+
const inputFaceMap = faceColorStore.get(input.wrapped);
|
|
198
|
+
if (!inputFaceMap || inputFaceMap.size === 0) continue;
|
|
199
|
+
for (const face of getFaces(input)) {
|
|
200
|
+
const hash = face.wrapped.HashCode(HASH_CODE_MAX);
|
|
201
|
+
const color = inputFaceMap.get(hash);
|
|
202
|
+
if (!color) continue;
|
|
203
|
+
if (op.IsDeleted?.(face.wrapped)) continue;
|
|
204
|
+
const modifiedList = op.Modified(face.wrapped);
|
|
205
|
+
const modSize = modifiedList.Size?.() ?? 0;
|
|
206
|
+
if (modSize > 0) {
|
|
207
|
+
const oc = getKernel().oc;
|
|
208
|
+
const copy = new oc.TopTools_ListOfShape_3(modifiedList);
|
|
209
|
+
while (copy.Size() > 0) {
|
|
210
|
+
const modFace = copy.First_1();
|
|
211
|
+
const modHash = modFace.HashCode(HASH_CODE_MAX);
|
|
212
|
+
resultFaceMap.set(modHash, color);
|
|
213
|
+
copy.RemoveFirst();
|
|
214
|
+
}
|
|
215
|
+
copy.delete();
|
|
216
|
+
} else {
|
|
217
|
+
resultFaceMap.set(hash, color);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
16
222
|
function validateShape3D(shape, label) {
|
|
17
223
|
if (shape.wrapped.IsNull()) {
|
|
18
224
|
return err(validationError(BrepErrorCode.NULL_SHAPE_INPUT, `${label} is a null shape`));
|
|
@@ -71,6 +277,8 @@ function fuse(a, b, { optimisation = "none", simplify = false, signal } = {}) {
|
|
|
71
277
|
);
|
|
72
278
|
if (fuseResult.ok) {
|
|
73
279
|
propagateOrigins(fuseOp, [a, b], fuseResult.value);
|
|
280
|
+
propagateFaceTags(fuseOp, [a, b], fuseResult.value);
|
|
281
|
+
propagateColors(fuseOp, [a, b], fuseResult.value);
|
|
74
282
|
}
|
|
75
283
|
return fuseResult;
|
|
76
284
|
}
|
|
@@ -90,6 +298,8 @@ function cut(base, tool, { optimisation = "none", simplify = false, signal } = {
|
|
|
90
298
|
const cutResult = castToShape3D(cutOp.Shape(), "CUT_NOT_3D", "Cut did not produce a 3D shape");
|
|
91
299
|
if (cutResult.ok) {
|
|
92
300
|
propagateOrigins(cutOp, [base, tool], cutResult.value);
|
|
301
|
+
propagateFaceTags(cutOp, [base, tool], cutResult.value);
|
|
302
|
+
propagateColors(cutOp, [base, tool], cutResult.value);
|
|
93
303
|
}
|
|
94
304
|
return cutResult;
|
|
95
305
|
}
|
|
@@ -112,6 +322,8 @@ function intersect(a, b, { simplify = false, signal } = {}) {
|
|
|
112
322
|
);
|
|
113
323
|
if (intResult.ok) {
|
|
114
324
|
propagateOrigins(intOp, [a, b], intResult.value);
|
|
325
|
+
propagateFaceTags(intOp, [a, b], intResult.value);
|
|
326
|
+
propagateColors(intOp, [a, b], intResult.value);
|
|
115
327
|
}
|
|
116
328
|
return intResult;
|
|
117
329
|
}
|
|
@@ -187,6 +399,8 @@ function cutAll(base, tools, { optimisation = "none", simplify = false, signal }
|
|
|
187
399
|
);
|
|
188
400
|
if (cutAllResult.ok) {
|
|
189
401
|
propagateOrigins(cutOp, [base, ...tools], cutAllResult.value);
|
|
402
|
+
propagateFaceTags(cutOp, [base, ...tools], cutAllResult.value);
|
|
403
|
+
propagateColors(cutOp, [base, ...tools], cutAllResult.value);
|
|
190
404
|
}
|
|
191
405
|
return cutAllResult;
|
|
192
406
|
}
|
|
@@ -249,6 +463,74 @@ function section(shape, plane, { approximation = true, planeSize = 1e4 } = {}) {
|
|
|
249
463
|
sectionFace.delete();
|
|
250
464
|
}
|
|
251
465
|
}
|
|
466
|
+
function sectionToFace(shape, plane, options = {}) {
|
|
467
|
+
const sectionResult = section(shape, plane, options);
|
|
468
|
+
if (!sectionResult.ok) return sectionResult;
|
|
469
|
+
const wires = getWires(sectionResult.value);
|
|
470
|
+
if (wires.length === 0) {
|
|
471
|
+
const edges = getEdges(sectionResult.value);
|
|
472
|
+
if (edges.length === 0) {
|
|
473
|
+
return err(occtError("SECTION_FAILED", "sectionToFace: section produced no geometry"));
|
|
474
|
+
}
|
|
475
|
+
const oc = getKernel().oc;
|
|
476
|
+
const remaining = [...edges];
|
|
477
|
+
while (remaining.length > 0) {
|
|
478
|
+
const first = remaining.shift();
|
|
479
|
+
if (!first) break;
|
|
480
|
+
const wireEdges = [first];
|
|
481
|
+
let added = true;
|
|
482
|
+
while (added && remaining.length > 0) {
|
|
483
|
+
added = false;
|
|
484
|
+
for (let i = 0; i < remaining.length; i++) {
|
|
485
|
+
const candidate = remaining[i];
|
|
486
|
+
if (!candidate) continue;
|
|
487
|
+
const probe = new oc.BRepBuilderAPI_MakeWire_1();
|
|
488
|
+
for (const e of wireEdges) {
|
|
489
|
+
probe.Add_1(e.wrapped);
|
|
490
|
+
}
|
|
491
|
+
probe.Add_1(candidate.wrapped);
|
|
492
|
+
const connects = probe.Error() === oc.BRepBuilderAPI_WireError.BRepBuilderAPI_WireDone;
|
|
493
|
+
probe.delete();
|
|
494
|
+
if (connects) {
|
|
495
|
+
wireEdges.push(candidate);
|
|
496
|
+
remaining.splice(i, 1);
|
|
497
|
+
added = true;
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
const wb = new oc.BRepBuilderAPI_MakeWire_1();
|
|
503
|
+
for (const e of wireEdges) {
|
|
504
|
+
wb.Add_1(e.wrapped);
|
|
505
|
+
}
|
|
506
|
+
if (wb.IsDone()) {
|
|
507
|
+
wires.push(castShape(wb.Wire()));
|
|
508
|
+
}
|
|
509
|
+
wb.delete();
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
if (wires.length === 0) {
|
|
513
|
+
return err(occtError("SECTION_FAILED", "sectionToFace: section produced no usable geometry"));
|
|
514
|
+
}
|
|
515
|
+
let outerIdx = 0;
|
|
516
|
+
let maxDiag = -1;
|
|
517
|
+
for (let i = 0; i < wires.length; i++) {
|
|
518
|
+
const w = wires[i];
|
|
519
|
+
if (!w) continue;
|
|
520
|
+
const bb = getKernel().boundingBox(w.wrapped);
|
|
521
|
+
const dx = bb.max[0] - bb.min[0];
|
|
522
|
+
const dy = bb.max[1] - bb.min[1];
|
|
523
|
+
const dz = bb.max[2] - bb.min[2];
|
|
524
|
+
const diag = dx * dx + dy * dy + dz * dz;
|
|
525
|
+
if (diag > maxDiag) {
|
|
526
|
+
maxDiag = diag;
|
|
527
|
+
outerIdx = i;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
const outer = wires[outerIdx];
|
|
531
|
+
const holes = wires.filter((_, i) => i !== outerIdx);
|
|
532
|
+
return makeFace(outer, holes.length > 0 ? holes : void 0);
|
|
533
|
+
}
|
|
252
534
|
function split(shape, tools) {
|
|
253
535
|
if (tools.length === 0) return ok(shape);
|
|
254
536
|
if (shape.wrapped.IsNull()) {
|
|
@@ -290,13 +572,25 @@ function slice(shape, planes, options = {}) {
|
|
|
290
572
|
return ok(results);
|
|
291
573
|
}
|
|
292
574
|
export {
|
|
293
|
-
|
|
294
|
-
|
|
575
|
+
propagateColors as a,
|
|
576
|
+
sectionToFace as b,
|
|
295
577
|
cut as c,
|
|
296
|
-
|
|
297
|
-
|
|
578
|
+
slice as d,
|
|
579
|
+
split as e,
|
|
298
580
|
fuse as f,
|
|
299
|
-
|
|
581
|
+
fuseAll as g,
|
|
582
|
+
cutAll as h,
|
|
300
583
|
intersect as i,
|
|
301
|
-
|
|
584
|
+
applyGlue as j,
|
|
585
|
+
colorFaces as k,
|
|
586
|
+
colorShape as l,
|
|
587
|
+
findFacesByTag as m,
|
|
588
|
+
getFaceColor as n,
|
|
589
|
+
getFaceTags as o,
|
|
590
|
+
propagateFaceTags as p,
|
|
591
|
+
getShapeColor as q,
|
|
592
|
+
getTagMetadata as r,
|
|
593
|
+
section as s,
|
|
594
|
+
setTagMetadata as t,
|
|
595
|
+
tagFaces as u
|
|
302
596
|
};
|