@constructorfleet/sketchforge-engine 1.28.0 → 1.29.0
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/engine.d.ts.map +1 -1
- package/dist/engine.js +102 -81
- package/dist/engine.js.map +1 -1
- package/dist/faceMetadata.d.ts +4 -0
- package/dist/faceMetadata.d.ts.map +1 -0
- package/dist/faceMetadata.js +71 -0
- package/dist/faceMetadata.js.map +1 -0
- package/dist/parametricRecompute.d.ts +22 -4
- package/dist/parametricRecompute.d.ts.map +1 -1
- package/dist/parametricRecompute.js +448 -123
- package/dist/parametricRecompute.js.map +1 -1
- package/dist/serverCadOperations.d.ts.map +1 -1
- package/dist/serverCadOperations.js +46 -3
- package/dist/serverCadOperations.js.map +1 -1
- package/dist/serverCadProperties.d.ts.map +1 -1
- package/dist/serverCadProperties.js +52 -3
- package/dist/serverCadProperties.js.map +1 -1
- package/dist/skfProject.d.ts +1 -1
- package/dist/skfProject.js +1 -1
- package/dist/stlImport.d.ts.map +1 -1
- package/dist/stlImport.js +9 -1
- package/dist/stlImport.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { createLocalId } from "./localIds.js";
|
|
2
|
+
import { shapeFaces } from "./serverCadShell.js";
|
|
3
|
+
import { canonicalizeShape } from "./workplaneShapes.js";
|
|
4
|
+
const UNIQUE_CURVED_FACE_SURFACES = new Set(["cone", "sphere", "torus", "cylinder"]);
|
|
5
|
+
/** Preserve face IDs and colors only when topology has a unique geometric counterpart. */
|
|
6
|
+
export async function preserveUnambiguousFaceMetadata(previous, next) {
|
|
7
|
+
if (!previous.faceIds?.length && !previous.faceColors)
|
|
8
|
+
return next;
|
|
9
|
+
const before = await shapeFaces(previous);
|
|
10
|
+
const after = await shapeFaces(next);
|
|
11
|
+
const signature = (face) => face.normal
|
|
12
|
+
? `${face.surfaceType}:${Math.round(face.normal.x * 1000)}:${Math.round(face.normal.y * 1000)}:${Math.round(face.normal.z * 1000)}:${face.facing ?? "interior"}`
|
|
13
|
+
: undefined;
|
|
14
|
+
const beforeBySignature = new Map();
|
|
15
|
+
const afterBySignature = new Map();
|
|
16
|
+
for (const face of before) {
|
|
17
|
+
const key = signature(face);
|
|
18
|
+
if (key)
|
|
19
|
+
beforeBySignature.set(key, [...(beforeBySignature.get(key) ?? []), face]);
|
|
20
|
+
}
|
|
21
|
+
for (const face of after) {
|
|
22
|
+
const key = signature(face);
|
|
23
|
+
if (key)
|
|
24
|
+
afterBySignature.set(key, [...(afterBySignature.get(key) ?? []), face]);
|
|
25
|
+
}
|
|
26
|
+
const beforeBySurface = new Map();
|
|
27
|
+
const afterBySurface = new Map();
|
|
28
|
+
for (const face of before)
|
|
29
|
+
beforeBySurface.set(face.surfaceType, [...(beforeBySurface.get(face.surfaceType) ?? []), face]);
|
|
30
|
+
for (const face of after)
|
|
31
|
+
afterBySurface.set(face.surfaceType, [...(afterBySurface.get(face.surfaceType) ?? []), face]);
|
|
32
|
+
const beforeForAfter = new Map();
|
|
33
|
+
const matchedBefore = new Set();
|
|
34
|
+
for (const face of after) {
|
|
35
|
+
const key = signature(face);
|
|
36
|
+
const oldMatches = key ? beforeBySignature.get(key) ?? [] : [];
|
|
37
|
+
const newMatches = key ? afterBySignature.get(key) ?? [] : [];
|
|
38
|
+
if (oldMatches.length === 1 && newMatches.length === 1) {
|
|
39
|
+
beforeForAfter.set(face.index, oldMatches[0]);
|
|
40
|
+
matchedBefore.add(oldMatches[0].index);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
for (const face of after) {
|
|
44
|
+
if (beforeForAfter.has(face.index) || !UNIQUE_CURVED_FACE_SURFACES.has(face.surfaceType))
|
|
45
|
+
continue;
|
|
46
|
+
const oldMatches = beforeBySurface.get(face.surfaceType) ?? [];
|
|
47
|
+
const newMatches = afterBySurface.get(face.surfaceType) ?? [];
|
|
48
|
+
if (oldMatches.length === 1 && newMatches.length === 1 && !matchedBefore.has(oldMatches[0].index)) {
|
|
49
|
+
beforeForAfter.set(face.index, oldMatches[0]);
|
|
50
|
+
matchedBefore.add(oldMatches[0].index);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const ids = after.map((face) => beforeForAfter.get(face.index)?.id
|
|
54
|
+
?? `face_${createLocalId(`${next.id}-${face.index}`)}`);
|
|
55
|
+
const mappedColors = {};
|
|
56
|
+
for (const [key, color] of Object.entries(previous.faceColors ?? {})) {
|
|
57
|
+
const oldIndex = /^\d+$/.test(key) ? Number(key) : -1;
|
|
58
|
+
const oldFace = oldIndex >= 0 ? before[oldIndex] : before.find((face) => face.id === key);
|
|
59
|
+
if (!oldFace)
|
|
60
|
+
continue;
|
|
61
|
+
const matched = after.find((face) => beforeForAfter.get(face.index)?.index === oldFace.index);
|
|
62
|
+
if (matched)
|
|
63
|
+
mappedColors[ids[matched.index]] = color;
|
|
64
|
+
}
|
|
65
|
+
return canonicalizeShape({
|
|
66
|
+
...next,
|
|
67
|
+
faceIds: ids,
|
|
68
|
+
faceColors: Object.keys(mappedColors).length ? mappedColors : undefined,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=faceMetadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"faceMetadata.js","sourceRoot":"","sources":["../src/faceMetadata.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAsB,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,2BAA2B,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AAErF,0FAA0F;AAC1F,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,QAAwB,EACxB,IAAoB;IAEpB,IAAI,CAAC,QAAQ,CAAC,OAAO,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,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACtD,MAAM,OAAO,GAAG,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC;QAC1F,IAAI,CAAC,OAAO;YAAE,SAAS;QACvB,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9F,IAAI,OAAO;YAAE,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAE,CAAC,GAAG,KAAK,CAAC;IACzD,CAAC;IACD,OAAO,iBAAiB,CAAC;QACvB,GAAG,IAAI;QACP,OAAO,EAAE,GAAG;QACZ,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;KACxE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EdgeTreatmentHistoryEntry, WorkplaneShape } from "./domain/sketchforge.js";
|
|
2
|
+
import type { ProjectDocument } from "./projectStore.js";
|
|
2
3
|
export type RecomputeTreeResult = {
|
|
3
4
|
ok: true;
|
|
4
5
|
shapes: WorkplaneShape[];
|
|
@@ -6,14 +7,31 @@ export type RecomputeTreeResult = {
|
|
|
6
7
|
matchCount: number;
|
|
7
8
|
} | {
|
|
8
9
|
ok: false;
|
|
9
|
-
reason: "recompute_failed" | "dependency_missing" | "dependency_ambiguous";
|
|
10
|
+
reason: "recompute_failed" | "dependency_missing" | "dependency_ambiguous" | "dependency_cycle";
|
|
10
11
|
message?: string;
|
|
11
12
|
};
|
|
13
|
+
type RecomputeNode = {
|
|
14
|
+
shape: WorkplaneShape;
|
|
15
|
+
dependencies: string[];
|
|
16
|
+
order: number;
|
|
17
|
+
};
|
|
18
|
+
export declare function deterministicRecomputeSchedule(nodes: ReadonlyMap<string, RecomputeNode>, affected: ReadonlySet<string>, dependents: ReadonlyMap<string, readonly string[]>): string[] | undefined;
|
|
12
19
|
/** Where a treatment was applied, so reverting it later carries any move made since. */
|
|
13
20
|
export declare function edgeTreatmentAppliedFrame(shape: WorkplaneShape): NonNullable<EdgeTreatmentHistoryEntry["appliedFrame"]>;
|
|
14
21
|
/** Replay one supported all-edge treatment on rebuilt source geometry without carrying transient edge indexes forward. */
|
|
15
|
-
export declare function replaySingleAllEdgeTreatment(original: WorkplaneShape, rebuilt: WorkplaneShape, draftPrismAngle?: number | undefined): Promise<WorkplaneShape>;
|
|
16
|
-
/**
|
|
17
|
-
export declare function
|
|
22
|
+
export declare function replaySingleAllEdgeTreatment(original: WorkplaneShape, rebuilt: WorkplaneShape, draftPrismAngle?: number | undefined, previous?: WorkplaneShape): Promise<WorkplaneShape>;
|
|
23
|
+
/** Replace a rebuilt sketch output in a project snapshot before scheduling its dependents. */
|
|
24
|
+
export declare function replaceSketchOutput(roots: WorkplaneShape[], sourceId: string, replacement: WorkplaneShape): {
|
|
25
|
+
shapes: WorkplaneShape[];
|
|
26
|
+
matchCount: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Recompute every dependent node in deterministic dependency order.
|
|
30
|
+
*
|
|
31
|
+
* `project` already contains the newly rebuilt outputs named by
|
|
32
|
+
* `changedSourceIds`; only their retained dependents are evaluated here.
|
|
33
|
+
*/
|
|
34
|
+
export declare function recompute(project: Pick<ProjectDocument, "shapes">, changedSourceIds: readonly string[], previousProject?: Pick<ProjectDocument, "shapes">): Promise<RecomputeTreeResult>;
|
|
18
35
|
export declare function findSketchOutput(roots: WorkplaneShape[], sourceId: string): WorkplaneShape[];
|
|
36
|
+
export {};
|
|
19
37
|
//# sourceMappingURL=parametricRecompute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parametricRecompute.d.ts","sourceRoot":"","sources":["../src/parametricRecompute.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parametricRecompute.d.ts","sourceRoot":"","sources":["../src/parametricRecompute.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAwB,yBAAyB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC/G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAOzD,MAAM,MAAM,mBAAmB,GAC3B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IAAC,OAAO,EAAE,cAAc,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACnF;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,kBAAkB,GAAG,oBAAoB,GAAG,sBAAsB,GAAG,kBAAkB,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAErI,KAAK,aAAa,GAAG;IACnB,KAAK,EAAE,cAAc,CAAC;IACtB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,EACzC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,EAC7B,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,GACjD,MAAM,EAAE,GAAG,SAAS,CAsBtB;AAED,wFAAwF;AACxF,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,cAAc,GAAG,WAAW,CAAC,yBAAyB,CAAC,cAAc,CA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