fluidcad 0.0.32 → 0.0.34
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/README.md +3 -2
- package/bin/commands/init.js +55 -0
- package/bin/commands/mcp.js +33 -0
- package/bin/commands/serve.js +77 -0
- package/bin/fluidcad.js +15 -107
- package/lib/dist/common/scene-object.d.ts +4 -1
- package/lib/dist/common/scene-object.js +9 -2
- package/lib/dist/common/solid.d.ts +4 -1
- package/lib/dist/common/solid.js +13 -0
- package/lib/dist/core/2d/tarc.d.ts +20 -2
- package/lib/dist/core/2d/tarc.js +24 -0
- package/lib/dist/core/index.d.ts +2 -1
- package/lib/dist/core/index.js +1 -0
- package/lib/dist/core/interfaces.d.ts +107 -2
- package/lib/dist/core/load.d.ts +2 -2
- package/lib/dist/core/repeat.js +62 -46
- package/lib/dist/core/rib.d.ts +18 -0
- package/lib/dist/core/rib.js +37 -0
- package/lib/dist/features/2d/arc.d.ts +8 -2
- package/lib/dist/features/2d/arc.js +94 -17
- package/lib/dist/features/2d/back.js +3 -2
- package/lib/dist/features/2d/sketch.d.ts +4 -0
- package/lib/dist/features/2d/sketch.js +21 -0
- package/lib/dist/features/2d/tarc-constrained.d.ts +2 -0
- package/lib/dist/features/2d/tarc-constrained.js +8 -0
- package/lib/dist/features/2d/tarc-radius-to-object.d.ts +16 -0
- package/lib/dist/features/2d/tarc-radius-to-object.js +58 -0
- package/lib/dist/features/2d/tarc-to-object.d.ts +18 -0
- package/lib/dist/features/2d/tarc-to-object.js +66 -0
- package/lib/dist/features/2d/tarc-to-point-tangent.d.ts +2 -0
- package/lib/dist/features/2d/tarc-to-point-tangent.js +3 -0
- package/lib/dist/features/2d/tarc-to-point.d.ts +2 -0
- package/lib/dist/features/2d/tarc-to-point.js +3 -0
- package/lib/dist/features/2d/tarc-with-tangent.d.ts +2 -0
- package/lib/dist/features/2d/tarc-with-tangent.js +3 -0
- package/lib/dist/features/2d/tarc.d.ts +2 -0
- package/lib/dist/features/2d/tarc.js +3 -0
- package/lib/dist/features/extrude-base.d.ts +9 -0
- package/lib/dist/features/extrude-base.js +22 -0
- package/lib/dist/features/extrude-to-face.js +1 -5
- package/lib/dist/features/extrude-two-distances.js +1 -2
- package/lib/dist/features/extrude.js +1 -2
- package/lib/dist/features/load.d.ts +6 -0
- package/lib/dist/features/load.js +53 -1
- package/lib/dist/features/mirror-feature.d.ts +3 -2
- package/lib/dist/features/mirror-feature.js +1 -1
- package/lib/dist/features/repeat-circular.d.ts +3 -3
- package/lib/dist/features/repeat-circular.js +8 -1
- package/lib/dist/features/repeat-linear.d.ts +4 -2
- package/lib/dist/features/repeat-linear.js +10 -1
- package/lib/dist/features/repeat-matrix.d.ts +3 -1
- package/lib/dist/features/repeat-matrix.js +7 -2
- package/lib/dist/features/rib.d.ts +31 -0
- package/lib/dist/features/rib.js +321 -0
- package/lib/dist/features/select.d.ts +1 -0
- package/lib/dist/features/select.js +81 -10
- package/lib/dist/features/shell.d.ts +4 -1
- package/lib/dist/features/shell.js +14 -3
- package/lib/dist/filters/edge/belongs-to-face.d.ts +12 -9
- package/lib/dist/filters/edge/belongs-to-face.js +64 -15
- package/lib/dist/filters/filter-builder-base.d.ts +25 -0
- package/lib/dist/filters/filter-builder-base.js +47 -0
- package/lib/dist/filters/filter.js +39 -14
- package/lib/dist/filters/from-object.d.ts +4 -0
- package/lib/dist/filters/from-object.js +10 -0
- package/lib/dist/helpers/clone-transform.d.ts +2 -1
- package/lib/dist/helpers/scene-helpers.d.ts +1 -1
- package/lib/dist/helpers/scene-helpers.js +146 -12
- package/lib/dist/index.d.ts +7 -1
- package/lib/dist/index.js +3 -3
- package/lib/dist/io/file-import.d.ts +5 -1
- package/lib/dist/io/file-import.js +29 -18
- package/lib/dist/math/lazy-matrix.d.ts +31 -0
- package/lib/dist/math/lazy-matrix.js +66 -0
- package/lib/dist/oc/color-transfer.d.ts +19 -8
- package/lib/dist/oc/color-transfer.js +70 -12
- package/lib/dist/oc/constraints/constraint-solver-adaptor.d.ts +5 -0
- package/lib/dist/oc/constraints/constraint-solver-adaptor.js +16 -0
- package/lib/dist/oc/constraints/constraint-solver.d.ts +4 -0
- package/lib/dist/oc/constraints/curve/curve-constraint-solver.d.ts +4 -0
- package/lib/dist/oc/constraints/curve/curve-constraint-solver.js +3 -0
- package/lib/dist/oc/constraints/geometric/geometric-constraint-solver.d.ts +6 -1
- package/lib/dist/oc/constraints/geometric/geometric-constraint-solver.js +4 -0
- package/lib/dist/oc/constraints/geometric/tangent-arc-from-point-tangent.d.ts +8 -0
- package/lib/dist/oc/constraints/geometric/tangent-arc-from-point-tangent.js +111 -0
- package/lib/dist/oc/constraints/geometric/tangent-arc-radius-to-object.d.ts +8 -0
- package/lib/dist/oc/constraints/geometric/tangent-arc-radius-to-object.js +161 -0
- package/lib/dist/oc/extrude-ops.d.ts +2 -1
- package/lib/dist/oc/extrude-ops.js +51 -2
- package/lib/dist/oc/mesh.d.ts +9 -4
- package/lib/dist/oc/mesh.js +14 -13
- package/lib/dist/oc/rib-ops.d.ts +35 -0
- package/lib/dist/oc/rib-ops.js +619 -0
- package/lib/dist/oc/shell-ops.d.ts +2 -1
- package/lib/dist/oc/shell-ops.js +5 -2
- package/lib/dist/oc/topology-index.d.ts +6 -0
- package/lib/dist/oc/topology-index.js +36 -0
- package/lib/dist/rendering/mesh-builder.d.ts +3 -0
- package/lib/dist/rendering/mesh-builder.js +8 -4
- package/lib/dist/rendering/render-edge.d.ts +2 -1
- package/lib/dist/rendering/render-edge.js +2 -2
- package/lib/dist/rendering/render-face.d.ts +2 -1
- package/lib/dist/rendering/render-face.js +2 -2
- package/lib/dist/rendering/render-solid.d.ts +2 -1
- package/lib/dist/rendering/render-solid.js +3 -5
- package/lib/dist/rendering/render-wire.d.ts +2 -1
- package/lib/dist/rendering/render-wire.js +2 -2
- package/lib/dist/rendering/render.d.ts +4 -0
- package/lib/dist/rendering/render.js +50 -2
- package/lib/dist/rendering/scene-compare.js +3 -0
- package/lib/dist/rendering/scene.d.ts +1 -0
- package/lib/dist/rendering/scene.js +4 -0
- package/lib/dist/scene-manager.d.ts +4 -2
- package/lib/dist/scene-manager.js +12 -4
- package/lib/dist/tests/features/2d/arc.test.js +64 -0
- package/lib/dist/tests/features/2d/back.test.js +17 -1
- package/lib/dist/tests/features/2d/tarc.test.js +157 -0
- package/lib/dist/tests/features/color-lineage.test.js +18 -0
- package/lib/dist/tests/features/filter-positional.test.d.ts +1 -0
- package/lib/dist/tests/features/filter-positional.test.js +129 -0
- package/lib/dist/tests/features/repeat-user-repro.test.d.ts +1 -0
- package/lib/dist/tests/features/repeat-user-repro.test.js +60 -0
- package/lib/dist/tests/features/rib.test.d.ts +1 -0
- package/lib/dist/tests/features/rib.test.js +598 -0
- package/lib/dist/tests/features/shell.test.js +36 -0
- package/lib/dist/tests/global-setup.js +2 -1
- package/lib/dist/tests/helpers/extract-blocks.d.ts +9 -0
- package/lib/dist/tests/helpers/extract-blocks.js +56 -0
- package/lib/dist/tests/llm-docs-examples.test.d.ts +1 -0
- package/lib/dist/tests/llm-docs-examples.test.js +62 -0
- package/lib/dist/tests/scene-compare.test.d.ts +1 -0
- package/lib/dist/tests/scene-compare.test.js +77 -0
- package/lib/dist/tests/setup.js +2 -1
- package/lib/dist/tsconfig.tsbuildinfo +1 -1
- package/llm-docs/.coverage-allowlist.txt +9 -0
- package/llm-docs/api/arc.md +48 -0
- package/llm-docs/api/axis.md +42 -0
- package/llm-docs/api/bezier.md +42 -0
- package/llm-docs/api/booleans.md +44 -0
- package/llm-docs/api/chamfer.md +40 -0
- package/llm-docs/api/circle.md +36 -0
- package/llm-docs/api/color.md +34 -0
- package/llm-docs/api/connect.md +41 -0
- package/llm-docs/api/constraint-qualifiers.md +48 -0
- package/llm-docs/api/copy.md +63 -0
- package/llm-docs/api/cursor-lines.md +50 -0
- package/llm-docs/api/cursor-move.md +61 -0
- package/llm-docs/api/cut.md +55 -0
- package/llm-docs/api/draft.md +36 -0
- package/llm-docs/api/edge-filter.md +57 -0
- package/llm-docs/api/ellipse.md +34 -0
- package/llm-docs/api/extrude.md +74 -0
- package/llm-docs/api/face-filter.md +61 -0
- package/llm-docs/api/fillet.md +51 -0
- package/llm-docs/api/index.json +139 -0
- package/llm-docs/api/line.md +42 -0
- package/llm-docs/api/load.md +37 -0
- package/llm-docs/api/local.md +38 -0
- package/llm-docs/api/loft.md +37 -0
- package/llm-docs/api/mirror.md +44 -0
- package/llm-docs/api/offset.md +36 -0
- package/llm-docs/api/part.md +40 -0
- package/llm-docs/api/plane.md +44 -0
- package/llm-docs/api/polygon.md +37 -0
- package/llm-docs/api/primitive-solids.md +39 -0
- package/llm-docs/api/project-intersect.md +48 -0
- package/llm-docs/api/rect.md +48 -0
- package/llm-docs/api/remove.md +32 -0
- package/llm-docs/api/repeat.md +79 -0
- package/llm-docs/api/revolve.md +38 -0
- package/llm-docs/api/rib.md +40 -0
- package/llm-docs/api/rotate.md +37 -0
- package/llm-docs/api/select.md +41 -0
- package/llm-docs/api/shell.md +41 -0
- package/llm-docs/api/sketch.md +76 -0
- package/llm-docs/api/slot.md +36 -0
- package/llm-docs/api/split-trim.md +42 -0
- package/llm-docs/api/sweep.md +43 -0
- package/llm-docs/api/tarc.md +45 -0
- package/llm-docs/api/tcircle.md +38 -0
- package/llm-docs/api/tline.md +42 -0
- package/llm-docs/api/translate.md +40 -0
- package/llm-docs/api/types/aline.md +35 -0
- package/llm-docs/api/types/arc-angles.md +29 -0
- package/llm-docs/api/types/arc-points.md +48 -0
- package/llm-docs/api/types/axis-like.md +38 -0
- package/llm-docs/api/types/axis.md +21 -0
- package/llm-docs/api/types/boolean-operation.md +50 -0
- package/llm-docs/api/types/circular-repeat-options.md +31 -0
- package/llm-docs/api/types/common.md +32 -0
- package/llm-docs/api/types/cut.md +125 -0
- package/llm-docs/api/types/draft.md +21 -0
- package/llm-docs/api/types/extrudable-geometry.md +23 -0
- package/llm-docs/api/types/extrude.md +194 -0
- package/llm-docs/api/types/geometry.md +51 -0
- package/llm-docs/api/types/hline.md +35 -0
- package/llm-docs/api/types/linear-repeat-options.md +31 -0
- package/llm-docs/api/types/loft.md +154 -0
- package/llm-docs/api/types/mirror.md +35 -0
- package/llm-docs/api/types/offset.md +31 -0
- package/llm-docs/api/types/plane-like.md +35 -0
- package/llm-docs/api/types/plane-transform-options.md +29 -0
- package/llm-docs/api/types/plane.md +21 -0
- package/llm-docs/api/types/point-like.md +22 -0
- package/llm-docs/api/types/point2dlike.md +26 -0
- package/llm-docs/api/types/polygon.md +46 -0
- package/llm-docs/api/types/rect.md +128 -0
- package/llm-docs/api/types/revolve.md +102 -0
- package/llm-docs/api/types/rib.md +133 -0
- package/llm-docs/api/types/scene-object.md +33 -0
- package/llm-docs/api/types/select.md +21 -0
- package/llm-docs/api/types/shell.md +54 -0
- package/llm-docs/api/types/slot.md +43 -0
- package/llm-docs/api/types/sweep.md +189 -0
- package/llm-docs/api/types/tangent-arc-two-objects.md +46 -0
- package/llm-docs/api/types/transformable.md +93 -0
- package/llm-docs/api/types/trim.md +27 -0
- package/llm-docs/api/types/two-objects-tangent-line.md +46 -0
- package/llm-docs/api/types/vertex.md +17 -0
- package/llm-docs/api/types/vline.md +35 -0
- package/llm-docs/concepts/coordinate-system.md +45 -0
- package/llm-docs/concepts/history-and-rollback.md +40 -0
- package/llm-docs/concepts/last-selection.md +49 -0
- package/llm-docs/concepts/scene-graph.md +37 -0
- package/llm-docs/index.json +1750 -0
- package/mcp/dist/client.d.ts +64 -0
- package/mcp/dist/client.js +248 -0
- package/mcp/dist/discovery.d.ts +11 -0
- package/mcp/dist/discovery.js +78 -0
- package/mcp/dist/docs-index.d.ts +81 -0
- package/mcp/dist/docs-index.js +261 -0
- package/mcp/dist/resources.d.ts +4 -0
- package/mcp/dist/resources.js +115 -0
- package/mcp/dist/server.d.ts +12 -0
- package/mcp/dist/server.js +489 -0
- package/mcp/dist/tools/coordination.d.ts +9 -0
- package/mcp/dist/tools/coordination.js +46 -0
- package/mcp/dist/tools/docs.d.ts +66 -0
- package/mcp/dist/tools/docs.js +122 -0
- package/mcp/dist/tools/engine.d.ts +56 -0
- package/mcp/dist/tools/engine.js +145 -0
- package/mcp/dist/tools/inspection.d.ts +75 -0
- package/mcp/dist/tools/inspection.js +121 -0
- package/mcp/dist/tools/screenshot.d.ts +63 -0
- package/mcp/dist/tools/screenshot.js +263 -0
- package/mcp/dist/tools/source.d.ts +84 -0
- package/mcp/dist/tools/source.js +434 -0
- package/mcp/dist/tools/workspaces.d.ts +13 -0
- package/mcp/dist/tools/workspaces.js +33 -0
- package/mcp/dist/types.d.ts +18 -0
- package/mcp/dist/types.js +11 -0
- package/package.json +19 -5
- package/server/dist/code-editor.d.ts +36 -0
- package/server/dist/code-editor.js +8 -0
- package/server/dist/fluidcad-server.d.ts +50 -0
- package/server/dist/fluidcad-server.js +153 -1
- package/server/dist/global-registry.d.ts +30 -0
- package/server/dist/global-registry.js +126 -0
- package/server/dist/index.js +171 -26
- package/server/dist/instance-file.d.ts +31 -0
- package/server/dist/instance-file.js +73 -0
- package/server/dist/lint-fluid-js.d.ts +15 -0
- package/server/dist/lint-fluid-js.js +271 -0
- package/server/dist/routes/editor.d.ts +24 -0
- package/server/dist/routes/editor.js +44 -0
- package/server/dist/routes/export.d.ts +1 -1
- package/server/dist/routes/export.js +45 -8
- package/server/dist/routes/health.d.ts +7 -0
- package/server/dist/routes/health.js +14 -0
- package/server/dist/routes/lint.d.ts +10 -0
- package/server/dist/routes/lint.js +28 -0
- package/server/dist/routes/render.d.ts +33 -0
- package/server/dist/routes/render.js +34 -0
- package/server/dist/routes/scene.d.ts +5 -0
- package/server/dist/routes/scene.js +48 -0
- package/server/dist/routes/screenshot.js +68 -1
- package/server/dist/ws-protocol.d.ts +56 -2
- package/ui/dist/assets/{index-DMw0OYCF.js → index-BdqrMDRu.js} +30 -30
- package/ui/dist/index.html +1 -1
|
@@ -121,16 +121,37 @@ export class ExtrudeOps {
|
|
|
121
121
|
edgeFaces: edgeFacesRaw.map(({ edge, face }) => ({ edge, face: findFace(face) })),
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
|
-
static applyDraftOnSideFaces(solid, firstFace, lastFace, plane, angle) {
|
|
124
|
+
static applyDraftOnSideFaces(solid, firstFace, lastFace, plane, angle, excludeFaces = []) {
|
|
125
125
|
const oc = getOC();
|
|
126
126
|
const [dir, disposeDir] = Convert.toGpDir(plane.normal);
|
|
127
127
|
const [pln, disposePln] = Convert.toGpPln(plane);
|
|
128
128
|
const solidRaw = solid.getShape();
|
|
129
129
|
const firstFaceRaw = firstFace.getShape();
|
|
130
130
|
const lastFaceRaw = lastFace.getShape();
|
|
131
|
+
const excludeRaw = excludeFaces.map(s => s.getShape());
|
|
131
132
|
const draftMaker = new oc.BRepOffsetAPI_DraftAngle(solidRaw);
|
|
132
|
-
const sideFaces = Explorer.findShapes(solidRaw, Explorer.getOcShapeType("face")).filter(f => !f.IsSame(firstFaceRaw)
|
|
133
|
+
const sideFaces = Explorer.findShapes(solidRaw, Explorer.getOcShapeType("face")).filter(f => !f.IsSame(firstFaceRaw)
|
|
134
|
+
&& !f.IsSame(lastFaceRaw)
|
|
135
|
+
&& !excludeRaw.some(e => f.IsSame(e)));
|
|
133
136
|
for (const face of sideFaces) {
|
|
137
|
+
// Skip faces whose surface normal is parallel to the draft pull
|
|
138
|
+
// direction — drafting them is geometrically degenerate (you can't
|
|
139
|
+
// tilt a face around an axis parallel to the face's own normal) and
|
|
140
|
+
// OCC fails the whole Build() if any such face is added. Non-planar
|
|
141
|
+
// faces get drafted unconditionally.
|
|
142
|
+
const adaptor = new oc.BRepAdaptor_Surface(Explorer.toFace(face), true);
|
|
143
|
+
if (adaptor.GetType() === oc.GeomAbs_SurfaceType.GeomAbs_Plane) {
|
|
144
|
+
const facePlane = adaptor.Plane();
|
|
145
|
+
const ax = facePlane.Axis().Direction();
|
|
146
|
+
const dot = Math.abs(ax.Dot(dir));
|
|
147
|
+
adaptor.delete();
|
|
148
|
+
if (dot > 0.999) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
adaptor.delete();
|
|
154
|
+
}
|
|
134
155
|
draftMaker.Add(Explorer.toFace(face), dir, angle, pln, true);
|
|
135
156
|
}
|
|
136
157
|
const progress = new oc.Message_ProgressRange();
|
|
@@ -150,14 +171,42 @@ export class ExtrudeOps {
|
|
|
150
171
|
const newLastFace = modifiedLast.length > 0
|
|
151
172
|
? ShapeFactory.fromShape(modifiedLast[0])
|
|
152
173
|
: lastFace;
|
|
174
|
+
// Capture the post-draft images of every input face we care about
|
|
175
|
+
// BEFORE deleting the maker. This lets the caller remap pre-draft
|
|
176
|
+
// face buckets onto the drafted result.
|
|
177
|
+
const remapMap = new Map();
|
|
178
|
+
const captureRemap = (raw) => {
|
|
179
|
+
const list = ShapeOps.shapeListToArray(draftMaker.Modified(raw));
|
|
180
|
+
remapMap.set(raw, list.length > 0
|
|
181
|
+
? list.map(r => ShapeFactory.fromShape(r))
|
|
182
|
+
: [ShapeFactory.fromShape(raw)]);
|
|
183
|
+
};
|
|
184
|
+
captureRemap(firstFaceRaw);
|
|
185
|
+
captureRemap(lastFaceRaw);
|
|
186
|
+
for (const ex of excludeRaw) {
|
|
187
|
+
captureRemap(ex);
|
|
188
|
+
}
|
|
189
|
+
for (const sf of sideFaces) {
|
|
190
|
+
captureRemap(sf);
|
|
191
|
+
}
|
|
153
192
|
const result = draftMaker.Shape();
|
|
154
193
|
draftMaker.delete();
|
|
155
194
|
disposeDir();
|
|
156
195
|
disposePln();
|
|
196
|
+
const remapFace = (face) => {
|
|
197
|
+
const raw = face.getShape();
|
|
198
|
+
for (const [k, v] of remapMap) {
|
|
199
|
+
if (k.IsSame(raw)) {
|
|
200
|
+
return v;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return [face];
|
|
204
|
+
};
|
|
157
205
|
return {
|
|
158
206
|
solid: ShapeFactory.fromShape(result),
|
|
159
207
|
firstFace: newFirstFace,
|
|
160
208
|
lastFace: newLastFace,
|
|
209
|
+
remapFace,
|
|
161
210
|
};
|
|
162
211
|
}
|
|
163
212
|
static applyDraft(shape, direction, angle) {
|
package/lib/dist/oc/mesh.d.ts
CHANGED
|
@@ -7,6 +7,11 @@ export interface MeshData {
|
|
|
7
7
|
indices: number[];
|
|
8
8
|
count?: number;
|
|
9
9
|
}
|
|
10
|
+
export interface MeshConfig {
|
|
11
|
+
linDefl: number;
|
|
12
|
+
angDefl: number;
|
|
13
|
+
}
|
|
14
|
+
export declare const DEFAULT_MESH_CONFIG: MeshConfig;
|
|
10
15
|
export interface EnsureTriangulatedOptions {
|
|
11
16
|
linDefl?: number;
|
|
12
17
|
angDefl?: number;
|
|
@@ -15,15 +20,15 @@ export interface EnsureTriangulatedOptions {
|
|
|
15
20
|
checkFreeEdges?: boolean;
|
|
16
21
|
}
|
|
17
22
|
export declare class Mesh {
|
|
18
|
-
static triangulateFace(face: Face, vertexOffset?: number): MeshData | null;
|
|
19
|
-
static discretizeEdge(edge: Shape): MeshData;
|
|
23
|
+
static triangulateFace(face: Face, vertexOffset?: number, opts?: EnsureTriangulatedOptions): MeshData | null;
|
|
24
|
+
static discretizeEdge(edge: Shape, opts?: EnsureTriangulatedOptions): MeshData;
|
|
20
25
|
/**
|
|
21
26
|
* Triangulates `shape` only if it doesn't already have an up-to-date
|
|
22
27
|
* triangulation at the requested deflection. Returns true when a fresh
|
|
23
28
|
* mesh was built, false when the stored one was reused.
|
|
24
29
|
*/
|
|
25
30
|
static ensureTriangulated(shape: TopoDS_Shape, opts?: EnsureTriangulatedOptions): boolean;
|
|
26
|
-
static triangulateFaceRaw(face: TopoDS_Face, vertexOffset?: number): MeshData | null;
|
|
31
|
+
static triangulateFaceRaw(face: TopoDS_Face, vertexOffset?: number, opts?: EnsureTriangulatedOptions): MeshData | null;
|
|
27
32
|
static extractFaceTriangulationRaw(face: TopoDS_Face, vertexOffset?: number): MeshData | null;
|
|
28
33
|
/**
|
|
29
34
|
* Reads the polyline stored for `edge` as a polygon-on-triangulation of
|
|
@@ -36,5 +41,5 @@ export declare class Mesh {
|
|
|
36
41
|
* meshed face). Caller must have already run `ensureTriangulated` on the
|
|
37
42
|
* edge or its parent wire.
|
|
38
43
|
*/
|
|
39
|
-
static discretizeEdgeRaw(edge: TopoDS_Shape): MeshData;
|
|
44
|
+
static discretizeEdgeRaw(edge: TopoDS_Shape, opts?: EnsureTriangulatedOptions): MeshData;
|
|
40
45
|
}
|
package/lib/dist/oc/mesh.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { getOC } from "./init.js";
|
|
2
2
|
import { Explorer } from "./explorer.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export const DEFAULT_MESH_CONFIG = {
|
|
4
|
+
linDefl: 0.1,
|
|
5
|
+
angDefl: 0.5,
|
|
6
|
+
};
|
|
6
7
|
export class Mesh {
|
|
7
8
|
// Wrapper methods (public API for external callers)
|
|
8
|
-
static triangulateFace(face, vertexOffset = 0) {
|
|
9
|
-
return Mesh.triangulateFaceRaw(face.getShape(), vertexOffset);
|
|
9
|
+
static triangulateFace(face, vertexOffset = 0, opts) {
|
|
10
|
+
return Mesh.triangulateFaceRaw(face.getShape(), vertexOffset, opts);
|
|
10
11
|
}
|
|
11
|
-
static discretizeEdge(edge) {
|
|
12
|
-
return Mesh.discretizeEdgeRaw(edge.getShape());
|
|
12
|
+
static discretizeEdge(edge, opts) {
|
|
13
|
+
return Mesh.discretizeEdgeRaw(edge.getShape(), opts);
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* Triangulates `shape` only if it doesn't already have an up-to-date
|
|
@@ -18,8 +19,8 @@ export class Mesh {
|
|
|
18
19
|
*/
|
|
19
20
|
static ensureTriangulated(shape, opts = {}) {
|
|
20
21
|
const oc = getOC();
|
|
21
|
-
const linDefl = opts.linDefl ??
|
|
22
|
-
const angDefl = opts.angDefl ??
|
|
22
|
+
const linDefl = opts.linDefl ?? DEFAULT_MESH_CONFIG.linDefl;
|
|
23
|
+
const angDefl = opts.angDefl ?? DEFAULT_MESH_CONFIG.angDefl;
|
|
23
24
|
const relative = opts.relative ?? false;
|
|
24
25
|
const checkFreeEdges = opts.checkFreeEdges ?? true;
|
|
25
26
|
if (oc.BRepTools.Triangulation(shape, linDefl, checkFreeEdges)) {
|
|
@@ -31,9 +32,9 @@ export class Mesh {
|
|
|
31
32
|
return true;
|
|
32
33
|
}
|
|
33
34
|
// Raw methods (for oc-internal use)
|
|
34
|
-
static triangulateFaceRaw(face, vertexOffset = 0) {
|
|
35
|
+
static triangulateFaceRaw(face, vertexOffset = 0, opts) {
|
|
35
36
|
try {
|
|
36
|
-
Mesh.ensureTriangulated(face);
|
|
37
|
+
Mesh.ensureTriangulated(face, opts);
|
|
37
38
|
}
|
|
38
39
|
catch (e) {
|
|
39
40
|
console.error("Face mesh failed", e);
|
|
@@ -151,14 +152,14 @@ export class Mesh {
|
|
|
151
152
|
* meshed face). Caller must have already run `ensureTriangulated` on the
|
|
152
153
|
* edge or its parent wire.
|
|
153
154
|
*/
|
|
154
|
-
static discretizeEdgeRaw(edge) {
|
|
155
|
+
static discretizeEdgeRaw(edge, opts) {
|
|
155
156
|
const oc = getOC();
|
|
156
157
|
const ocEdge = oc.TopoDS.Edge(edge);
|
|
157
158
|
if (oc.BRep_Tool.Degenerated(ocEdge)) {
|
|
158
159
|
ocEdge.delete();
|
|
159
160
|
return { vertices: [], normals: [], indices: [] };
|
|
160
161
|
}
|
|
161
|
-
Mesh.ensureTriangulated(edge);
|
|
162
|
+
Mesh.ensureTriangulated(edge, opts);
|
|
162
163
|
const loc = new oc.TopLoc_Location();
|
|
163
164
|
const polyHandle = oc.BRep_Tool.Polygon3D(ocEdge, loc);
|
|
164
165
|
if (polyHandle.IsNull()) {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Face } from "../common/face.js";
|
|
2
|
+
import { Wire } from "../common/wire.js";
|
|
3
|
+
import { Shape } from "../common/shape.js";
|
|
4
|
+
import { Point } from "../math/point.js";
|
|
5
|
+
import { Plane } from "../math/plane.js";
|
|
6
|
+
import { Vector3d } from "../math/vector3d.js";
|
|
7
|
+
export interface RibConformResult {
|
|
8
|
+
solids: Shape[];
|
|
9
|
+
startFaces: Face[];
|
|
10
|
+
endFaces: Face[];
|
|
11
|
+
sideFaces: Face[];
|
|
12
|
+
internalFaces: Face[];
|
|
13
|
+
}
|
|
14
|
+
export declare class RibOps {
|
|
15
|
+
static makeRibProfile(spineWire: Wire, thickness: number, plane: Plane): Face;
|
|
16
|
+
static makeRibProfileParallel(spineWire: Wire, thickness: number, plane: Plane): Face;
|
|
17
|
+
static makeParallelRibClosedWire(spineWire: Wire, thickness: number, plane: Plane): Wire;
|
|
18
|
+
static makeTaperedRibPrism(spineWire: Wire, thickness: number, plane: Plane, direction: Vector3d, extrudeLength: number, draftAngleRad: number): {
|
|
19
|
+
solid: Shape;
|
|
20
|
+
firstFace: Shape;
|
|
21
|
+
lastFace: Shape;
|
|
22
|
+
};
|
|
23
|
+
static computeSpinePerpendicularDirection(spineWire: Wire, plane: Plane): Vector3d;
|
|
24
|
+
static extendSpineWire(spineWire: Wire, scopeShapes: Shape[], _plane: Plane): Wire;
|
|
25
|
+
static computeExtrudeDistanceAlongDirection(direction: Vector3d, origin: Point, scopeShapes: Shape[]): number;
|
|
26
|
+
static computeExtrudeDistance(plane: Plane, scopeShapes: Shape[]): number;
|
|
27
|
+
static conformRibToScope(ribSolid: Shape, scopeShapes: Shape[], originalSpineWire: Wire, prismFirstFace: Shape, prismLastFace: Shape, extrudeDirection: Vector3d): RibConformResult;
|
|
28
|
+
private static collectFaceImages;
|
|
29
|
+
private static tryGetFacePlane;
|
|
30
|
+
private static buildBoundingBoxSlabs;
|
|
31
|
+
private static makeAxisAlignedSlab;
|
|
32
|
+
private static offsetWireOnPlane;
|
|
33
|
+
private static makeOpenFaceWithCaps;
|
|
34
|
+
private static makeClosedWireWithCaps;
|
|
35
|
+
}
|