Rust-Kern Etappe 0 + erster Teil Etappe 1: Crate dossier-core (src-tauri/core), einmal geladen, synchron aufgerufen; Polygon-Booleans aus Rust (i_overlay) ersetzen polygon-clipping

- src-tauri/core: flache f64-Kodierung fuer die WASM-Grenze, Polygon-Booleans (Vereinigung/Differenz/Schnitt,
  Umlaufsinn-unabhaengig wie polygon-clipping, Unsinn verworfen statt Panic); cargo-Tests
- engine/coreWasm.ts: initCore() vor dem ersten Render (main.tsx, alle Fenster), CLI mit Byte-Provider,
  Vitest per Setup-Datei; core() synchron
- geometry/polygonBool.ts: Fassade mit gleicher Datenform; Schatten, Baurecht, Aussenbemassung, Dach-Skelett,
  Aussparungen und 2D-Booleans umgestellt; polygon-clipping aus den Abhaengigkeiten entfernt (Lockfile wieder
  synchron mit package.json)
- Tests: Walm auf L prueft Dachebenen statt Zahl konvexer Stuecke, Aussparung mikrometergenau (Ganzzahlraster)
- check.mjs/CI bauen und testen das neue Crate; CLAUDE.md: neuer Kern-Code entsteht in Rust

Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
Claude committed 2026-10-27 21:01:14 +00:00
1 parent c70438dba0
commit 6f1554e69b
29 files changed
+1238 -157

No files matched your search

+1 -1
View File
@@ -16,5 +16,5 @@ jobs:
- run: npm ci
# IFC-Prüfung in exportIfc.validate.test.ts ([B1]); ohne ifcopenshell würde sie übersprungen.
- run: pip install ifcopenshell pytest
- run: npm run build:truck && npm run build:engine3d && npm run build:engine && npm run build:kernel2d && npm run build:dwgimport
- run: npm run build:core && npm run build:truck && npm run build:engine3d && npm run build:engine && npm run build:kernel2d && npm run build:dwgimport
- run: npm run check
+12 -2
View File
@@ -7,13 +7,22 @@ Rust-Engines `render2d` und `render3d` (WebGPU/Metal) — kein three.js, kein We
## Vor jedem Abschluss
```
npm run check # tsc, vitest, cargo test aller 5 Crates (--fast: ohne Rust)
npm run check # tsc, vitest, cargo test aller 6 Crates (--fast: ohne Rust)
npm run build:cli # nur nötig, wenn src/cli oder src/core geändert wurden
```
WASM-Pakete (`src/engine/pkg*`) sind nicht im Repo: vor vitest mit `npm run build:truck|engine3d|engine|kernel2d|dwgimport`
WASM-Pakete (`src/engine/pkg*`) sind nicht im Repo: vor vitest mit `npm run build:core|truck|engine3d|engine|kernel2d|dwgimport`
bauen. Test zuerst, dann Code. Ein Schritt endet mit grünen Tests und gelöschtem Altcode (keine Doppelspur).
## Rust-Kern (Umstellung läuft, Entscheid 27.10.)
Der Kern wandert vollständig nach Rust (`src-tauri/core`, Crate `dossier-core`): Etappe 0 Lader ·
1 2D-Geometrie · 2 Geometrie-Ableitungen · 3 Plan/Schnitt/Ansicht · 4 Modell und Ops; die UI bleibt TSX.
**Neuer Kern-Code entsteht in Rust**, nicht in TS. Wer eine TS-Kernfunktion portiert, löscht die TS-Fassung
im selben Schritt (keine Doppelspur). Geladen wird der Kern einmal (`engine/coreWasm.ts`: App `initCore()`
vor dem Rendern, CLI mit Byte-Provider, Vitest per Setup-Datei), danach synchron über `core()`. Daten über
die Grenze als flache `Float64Array`s. truck (`trucksolid`) bleibt eigenes WASM-Modul (Panic-Isolation).
## Architektur (harte Grenze, vom Test `src/core/boundary.test.ts` geprüft)
- **Kern**: `model/ geometry/ plan/ io/ export/ analysis/ materials/ text/ engine/ net/ core/` — importiert nie
@@ -41,6 +50,7 @@ bauen. Test zuerst, dann Code. Ein Schritt endet mit grünen Tests und gelöscht
| `src/net` | einziges Tor ins Netz (`netFetch`, Offline-Modus, Host-Liste) |
| `src-tauri/render2d, render3d` | die zwei Anzeige-Engines (Rust → WASM/Metal) |
| `src-tauri/trucksolid` | B-Rep (truck 0.6): Körper, Booleans, STEP, Kennwerte, Kollision |
| `src-tauri/core` | Rust-Kern (`dossier-core`): Polygon-Booleans (i_overlay), wächst etappenweise |
| `src-tauri/kernel2d, dwgimport` | 2D-Geometrie-Referenz, DWG-Import |
## Konventionen
+512 -119
View File
@@ -23,7 +23,6 @@
"jszip": "^3.10.1",
"lcms-wasm": "^1.0.5",
"pdfjs-dist": "^6.2.108",
"polygon-clipping": "^0.15.7",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"svg2pdf.js": "^2.7.0"
@@ -700,6 +699,24 @@
"node": ">=12"
}
},
"node_modules/@esbuild/netbsd-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz",
"integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"netbsd"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/netbsd-x64": {
"version": "0.21.5",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz",
@@ -717,6 +734,24 @@
"node": ">=12"
}
},
"node_modules/@esbuild/openbsd-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz",
"integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openbsd"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/openbsd-x64": {
"version": "0.21.5",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz",
@@ -734,6 +769,24 @@
"node": ">=12"
}
},
"node_modules/@esbuild/openharmony-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz",
"integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openharmony"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/sunos-x64": {
"version": "0.21.5",
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz",
@@ -1033,9 +1086,6 @@
"cpu": [
"arm64"
],
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1056,9 +1106,6 @@
"cpu": [
"arm64"
],
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1079,9 +1126,6 @@
"cpu": [
"riscv64"
],
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1102,9 +1146,6 @@
"cpu": [
"x64"
],
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1125,9 +1166,6 @@
"cpu": [
"x64"
],
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1328,9 +1366,6 @@
"arm64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1348,9 +1383,6 @@
"arm64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1368,9 +1400,6 @@
"ppc64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1388,9 +1417,6 @@
"s390x"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1408,9 +1434,6 @@
"x64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1428,9 +1451,6 @@
"x64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1609,9 +1629,6 @@
"arm"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1626,9 +1643,6 @@
"arm"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1643,9 +1657,6 @@
"arm64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1660,9 +1671,6 @@
"arm64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1677,9 +1685,6 @@
"loong64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1694,9 +1699,6 @@
"loong64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1711,9 +1713,6 @@
"ppc64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1728,9 +1727,6 @@
"ppc64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1745,9 +1741,6 @@
"riscv64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1762,9 +1755,6 @@
"riscv64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1779,9 +1769,6 @@
"s390x"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1796,9 +1783,6 @@
"x64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1813,9 +1797,6 @@
"x64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -2012,9 +1993,6 @@
"arm64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
@@ -2032,9 +2010,6 @@
"arm64"
],
"dev": true,
"libc": [
"musl"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
@@ -2052,9 +2027,6 @@
"riscv64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
@@ -2072,9 +2044,6 @@
"x64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
@@ -2092,9 +2061,6 @@
"x64"
],
"dev": true,
"libc": [
"musl"
],
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
@@ -4427,9 +4393,6 @@
"arm64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -4451,9 +4414,6 @@
"arm64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -4475,9 +4435,6 @@
"x64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -4499,9 +4456,6 @@
"x64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -5004,16 +4958,6 @@
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/polygon-clipping": {
"version": "0.15.7",
"resolved": "https://registry.npmjs.org/polygon-clipping/-/polygon-clipping-0.15.7.tgz",
"integrity": "sha512-nhfdr83ECBg6xtqOAJab1tbksbBAOMUltN60bU+llHVOL0e5Onm1WpAXXWXVB39L8AJFssoIhEVuy/S90MmotA==",
"license": "MIT",
"dependencies": {
"robust-predicates": "^3.0.2",
"splaytree": "^3.1.0"
}
},
"node_modules/possible-typed-array-names": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz",
@@ -5580,15 +5524,6 @@
"specificity": "bin/specificity"
}
},
"node_modules/splaytree": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/splaytree/-/splaytree-3.2.3.tgz",
"integrity": "sha512-7OXrNWzy6CK+r7Ch9OLPBDTKfB6XlWHjX4P0RU5B3IgFuWPeYN0XtRtlexGRjgbQxpfaUve6jTAwBGWuGntz/w==",
"license": "MIT",
"engines": {
"node": ">=18.20 || >=20"
}
},
"node_modules/stackback": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz",
@@ -6241,6 +6176,420 @@
}
}
},
"node_modules/vitest/node_modules/@esbuild/aix-ppc64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz",
"integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==",
"cpu": [
"ppc64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"aix"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/android-arm": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz",
"integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==",
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/android-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz",
"integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/android-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz",
"integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/darwin-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz",
"integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/darwin-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz",
"integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/freebsd-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz",
"integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"freebsd"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/freebsd-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz",
"integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"freebsd"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/linux-arm": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz",
"integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==",
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/linux-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz",
"integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/linux-ia32": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz",
"integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==",
"cpu": [
"ia32"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/linux-loong64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz",
"integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==",
"cpu": [
"loong64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/linux-mips64el": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz",
"integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==",
"cpu": [
"mips64el"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/linux-ppc64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz",
"integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==",
"cpu": [
"ppc64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/linux-riscv64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz",
"integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==",
"cpu": [
"riscv64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/linux-s390x": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz",
"integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==",
"cpu": [
"s390x"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/linux-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz",
"integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/netbsd-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz",
"integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"netbsd"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/openbsd-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz",
"integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openbsd"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/sunos-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz",
"integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"sunos"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/win32-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz",
"integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/win32-ia32": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz",
"integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==",
"cpu": [
"ia32"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@esbuild/win32-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz",
"integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/vitest/node_modules/@vitest/mocker": {
"version": "4.1.9",
"resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.9.tgz",
@@ -6268,6 +6617,50 @@
}
}
},
"node_modules/vitest/node_modules/esbuild": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz",
"integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"peer": true,
"bin": {
"esbuild": "bin/esbuild"
},
"engines": {
"node": ">=18"
},
"optionalDependencies": {
"@esbuild/aix-ppc64": "0.28.2",
"@esbuild/android-arm": "0.28.2",
"@esbuild/android-arm64": "0.28.2",
"@esbuild/android-x64": "0.28.2",
"@esbuild/darwin-arm64": "0.28.2",
"@esbuild/darwin-x64": "0.28.2",
"@esbuild/freebsd-arm64": "0.28.2",
"@esbuild/freebsd-x64": "0.28.2",
"@esbuild/linux-arm": "0.28.2",
"@esbuild/linux-arm64": "0.28.2",
"@esbuild/linux-ia32": "0.28.2",
"@esbuild/linux-loong64": "0.28.2",
"@esbuild/linux-mips64el": "0.28.2",
"@esbuild/linux-ppc64": "0.28.2",
"@esbuild/linux-riscv64": "0.28.2",
"@esbuild/linux-s390x": "0.28.2",
"@esbuild/linux-x64": "0.28.2",
"@esbuild/netbsd-arm64": "0.28.2",
"@esbuild/netbsd-x64": "0.28.2",
"@esbuild/openbsd-arm64": "0.28.2",
"@esbuild/openbsd-x64": "0.28.2",
"@esbuild/openharmony-arm64": "0.28.2",
"@esbuild/sunos-x64": "0.28.2",
"@esbuild/win32-arm64": "0.28.2",
"@esbuild/win32-ia32": "0.28.2",
"@esbuild/win32-x64": "0.28.2"
}
},
"node_modules/vitest/node_modules/vite": {
"version": "8.1.2",
"resolved": "https://registry.npmjs.org/vite/-/vite-8.1.2.tgz",
+1 -1
View File
@@ -24,6 +24,7 @@
"build:engine3d": "wasm-pack build src-tauri/render3d --release --target web --out-dir ../../src/engine/pkg3d --out-name render3d --no-default-features --features web",
"build:kernel2d": "wasm-pack build src-tauri/kernel2d --release --target web --out-dir ../../src/engine/pkgKernel2d --out-name kernel2d --no-default-features --features web",
"build:dwgimport": "wasm-pack build src-tauri/dwgimport --release --target web --out-dir ../../src/engine/pkgDwgImport --out-name dwgimport --no-default-features --features web",
"build:core": "wasm-pack build src-tauri/core --release --target web --out-dir ../../src/engine/pkgCore --out-name core --no-default-features --features web",
"build:truck": "wasm-pack build src-tauri/trucksolid --release --target web --out-dir ../../src/engine/pkgTruck --out-name trucksolid --no-default-features --features web"
},
"dependencies": {
@@ -41,7 +42,6 @@
"jszip": "^3.10.1",
"lcms-wasm": "^1.0.5",
"pdfjs-dist": "^6.2.108",
"polygon-clipping": "^0.15.7",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"svg2pdf.js": "^2.7.0"
+1 -1
View File
@@ -7,7 +7,7 @@
import { spawnSync } from "node:child_process";
const fast = process.argv.includes("--fast");
const crates = ["render2d", "render3d", "kernel2d", "trucksolid", "dwgimport"];
const crates = ["core", "render2d", "render3d", "kernel2d", "trucksolid", "dwgimport"];
const steps = [
{ name: "tsc", cmd: "npx", args: ["tsc", "--noEmit", "-p", "."] },
{ name: "vitest", cmd: "npx", args: ["vitest", "run"] },
+174
View File
@@ -0,0 +1,174 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "bumpalo"
version = "3.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
[[package]]
name = "cfg-if"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
[[package]]
name = "console_error_panic_hook"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
dependencies = [
"cfg-if",
"wasm-bindgen",
]
[[package]]
name = "dossier-core"
version = "0.1.0"
dependencies = [
"console_error_panic_hook",
"i_overlay",
"wasm-bindgen",
]
[[package]]
name = "i_float"
version = "5.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ecaff1ce29bcacd72cdf581ba6fce636ef4c4e0b2da7e7846dd0137d98141e2"
dependencies = [
"libm",
]
[[package]]
name = "i_key_sort"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14269ee362009550495e20650ff3c2bca14a8147fe251e216760381ffed90b6f"
[[package]]
name = "i_overlay"
version = "9.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "913fd692c02408adc76cead636f8e7e07c705f8b995a8b54b454b995e8e197d5"
dependencies = [
"i_float",
"i_key_sort",
"i_shape",
"i_tree",
]
[[package]]
name = "i_shape"
version = "5.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa1878f91ef7921feaf1b2346253ebc5e661878b22d5715195c1d5dcf0f20ae5"
dependencies = [
"i_float",
]
[[package]]
name = "i_tree"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "048af31de955890c62a8506fec511335a5089e91e1c516537add16f96c507d84"
[[package]]
name = "libm"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
[[package]]
name = "once_cell"
version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "proc-macro2"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rustversion"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
[[package]]
name = "syn"
version = "3.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
[[package]]
name = "wasm-bindgen"
version = "0.2.129"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409"
dependencies = [
"cfg-if",
"once_cell",
"rustversion",
"wasm-bindgen-macro",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.129"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.129"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7"
dependencies = [
"bumpalo",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.129"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6"
dependencies = [
"unicode-ident",
]
+27
View File
@@ -0,0 +1,27 @@
# Eigener leerer Workspace-Block wie render2d/kernel2d: entkoppelt das Crate vom cad-tauri-Workspace.
[workspace]
[package]
name = "dossier-core"
version = "0.1.0"
edition = "2021"
description = "Rust-Kern von Dossier (Umstellung des TS-Kerns, Etappen 0-4): Geometrie, Ableitung, spaeter Modell und Ops. Headless per `cargo test`, per wasm-pack (Feature \"web\") als src/engine/pkgCore."
license = "AGPL-3.0-or-later"
[lib]
name = "dossier_core"
crate-type = ["cdylib", "rlib"]
[features]
default = []
# Browser-/Node-Bindings (wasm-bindgen); nur fuer wasm32-unknown-unknown.
web = ["dep:wasm-bindgen", "dep:console_error_panic_hook"]
[dependencies]
i_overlay = { version = "9.1", default-features = false }
wasm-bindgen = { version = "0.2", optional = true }
console_error_panic_hook = { version = "0.1", optional = true }
[profile.release]
opt-level = 3
lto = true
+77
View File
@@ -0,0 +1,77 @@
//! Flache Kodierung von Mehrfach-Polygonen für die WASM-Grenze:
//! `[n_polys, (n_rings, (n_pts, x0, y0, x1, y1, …)…)…]`. Ringe offen (ohne Schlusspunkt),
//! Ring 0 eines Polygons ist der Aussenring, weitere sind Löcher.
/// Polygon = Ringe; Ring = Punkte.
pub type Ring = Vec<[f64; 2]>;
pub type Polygon = Vec<Ring>;
/// Liest Polygone; bei kaputten Daten (zu kurz, negative Zählungen) `None`.
pub fn decode(buf: &[f64]) -> Option<Vec<Polygon>> {
let mut i = 0usize;
let mut next = |buf: &[f64]| -> Option<f64> {
let v = *buf.get(i)?;
i += 1;
Some(v)
};
let count = |v: f64| -> Option<usize> {
if v.is_finite() && v >= 0.0 && v.fract() == 0.0 && v < 1e9 {
Some(v as usize)
} else {
None
}
};
let n_polys = count(next(buf)?)?;
let mut out = Vec::with_capacity(n_polys.min(1 << 16));
for _ in 0..n_polys {
let n_rings = count(next(buf)?)?;
let mut poly = Vec::with_capacity(n_rings.min(1 << 16));
for _ in 0..n_rings {
let n_pts = count(next(buf)?)?;
let mut ring = Vec::with_capacity(n_pts.min(1 << 20));
for _ in 0..n_pts {
let x = next(buf)?;
let y = next(buf)?;
ring.push([x, y]);
}
poly.push(ring);
}
out.push(poly);
}
Some(out)
}
pub fn encode(polys: &[Polygon]) -> Vec<f64> {
let mut out = vec![polys.len() as f64];
for p in polys {
out.push(p.len() as f64);
for r in p {
out.push(r.len() as f64);
for pt in r {
out.push(pt[0]);
out.push(pt[1]);
}
}
}
out
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn hin_und_zurueck() {
let polys = vec![vec![vec![[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]], vec![[0.2, 0.2], [0.4, 0.2], [0.3, 0.3]]]];
assert_eq!(decode(&encode(&polys)), Some(polys));
}
#[test]
fn kaputte_daten() {
assert_eq!(decode(&[]), None);
assert_eq!(decode(&[1.0, 1.0, 3.0, 0.0]), None);
assert_eq!(decode(&[-1.0]), None);
assert_eq!(decode(&[f64::NAN]), None);
assert_eq!(decode(&[0.0]), Some(vec![]));
}
}
+11
View File
@@ -0,0 +1,11 @@
//! Rust-Kern von Dossier. Wächst etappenweise aus dem TS-Kern (`src/model`, `src/geometry`,
//! `src/plan`, …) heraus; jede umgestellte Funktion verschwindet dort (keine Doppelspur).
//! TS ruft den Kern synchron über `src/engine/coreWasm.ts` auf (einmal beim Start geladen).
//!
//! Datenübergabe: flache `f64`-Puffer (s. [`flat`]), kein JSON — schnell und ohne Serde-Kosten.
pub mod flat;
pub mod polygon_bool;
#[cfg(feature = "web")]
mod web;
+149
View File
@@ -0,0 +1,149 @@
//! Polygon-Booleans (Vereinigung, Differenz, Schnitt) über `i_overlay` — ersetzt die JS-Bibliothek
//! `polygon-clipping` im TS-Kern (Schatten, Baurecht, Bemassung, Dächer, Aussparungen, 2D-Booleans).
//!
//! Semantik wie `polygon-clipping`: Mehrere Eingabepolygone werden unabhängig von ihrem
//! Umlaufsinn vereinigt. Dazu wird jedes Polygon ausgerichtet (Aussenring gegen, Löcher im
//! Uhrzeigersinn) und mit der Non-Zero-Regel gerechnet. Ergebnis: Aussenring gegen den
//! Uhrzeigersinn, Löcher im Uhrzeigersinn, Ringe offen; ungültige Punkte (NaN/∞) und
//! entartete Ringe (< 3 Punkte, Fläche 0) werden vorher verworfen.
use crate::flat::{Polygon, Ring};
use i_overlay::core::fill_rule::FillRule;
use i_overlay::core::overlay_rule::OverlayRule;
use i_overlay::float::single::SingleFloatOverlay;
fn signed_area(r: &Ring) -> f64 {
let n = r.len();
let mut a = 0.0;
for i in 0..n {
let p = r[i];
let q = r[(i + 1) % n];
a += p[0] * q[1] - q[0] * p[1];
}
a / 2.0
}
/// Ring säubern: nur endliche Punkte, doppelten Schlusspunkt weg; `None` bei Entartung.
fn clean_ring(r: &Ring) -> Option<Ring> {
let mut out: Ring = r.iter().copied().filter(|p| p[0].is_finite() && p[1].is_finite()).collect();
while out.len() > 1 && out.first() == out.last() {
out.pop();
}
if out.len() < 3 || signed_area(&out).abs() < 1e-18 {
return None;
}
Some(out)
}
/// Polygon ausrichten: Aussenring CCW, Löcher CW. Ohne gültigen Aussenring `None`.
fn orient(p: &Polygon) -> Option<Polygon> {
let mut rings = p.iter();
let mut outer = clean_ring(rings.next()?)?;
if signed_area(&outer) < 0.0 {
outer.reverse();
}
let mut out = vec![outer];
for r in rings {
if let Some(mut h) = clean_ring(r) {
if signed_area(&h) > 0.0 {
h.reverse();
}
out.push(h);
}
}
Some(out)
}
fn prepare(polys: &[Polygon]) -> Vec<Polygon> {
polys.iter().filter_map(orient).collect()
}
fn run(subj: &[Polygon], clip: &[Polygon], rule: OverlayRule) -> Vec<Polygon> {
let s = prepare(subj);
let c = prepare(clip);
if s.is_empty() && !matches!(rule, OverlayRule::Union) {
return vec![];
}
if s.is_empty() && c.is_empty() {
return vec![];
}
s.overlay(&c, rule, FillRule::NonZero)
}
/// Vereinigung aller Polygone.
pub fn union(polys: &[Polygon]) -> Vec<Polygon> {
run(polys, &[], OverlayRule::Union)
}
/// `a` minus Vereinigung von `b`.
pub fn difference(a: &[Polygon], b: &[Polygon]) -> Vec<Polygon> {
if b.is_empty() {
return union(a);
}
run(a, b, OverlayRule::Difference)
}
/// Schnitt von `a` und `b`.
pub fn intersection(a: &[Polygon], b: &[Polygon]) -> Vec<Polygon> {
run(a, b, OverlayRule::Intersect)
}
#[cfg(test)]
mod tests {
use super::*;
fn rect(x0: f64, y0: f64, x1: f64, y1: f64) -> Polygon {
vec![vec![[x0, y0], [x1, y0], [x1, y1], [x0, y1]]]
}
fn area(polys: &[Polygon]) -> f64 {
polys.iter().map(|p| p.iter().map(signed_area).sum::<f64>()).sum()
}
#[test]
fn vereinigung_ueberlappend_und_gemischter_umlaufsinn() {
let mut b = rect(1.0, 0.0, 3.0, 1.0);
b[0].reverse(); // im Uhrzeigersinn
let u = union(&[rect(0.0, 0.0, 2.0, 1.0), b]);
assert_eq!(u.len(), 1);
assert!((area(&u) - 3.0).abs() < 1e-9);
assert!(signed_area(&u[0][0]) > 0.0);
}
#[test]
fn differenz_erzeugt_loch() {
let d = difference(&[rect(0.0, 0.0, 4.0, 4.0)], &[rect(1.0, 1.0, 2.0, 2.0)]);
assert_eq!(d.len(), 1);
assert_eq!(d[0].len(), 2);
assert!(signed_area(&d[0][1]) < 0.0);
assert!((area(&d) - 15.0).abs() < 1e-9);
}
#[test]
fn schnitt_und_leer() {
let i = intersection(&[rect(0.0, 0.0, 2.0, 2.0)], &[rect(1.0, 1.0, 3.0, 3.0)]);
assert!((area(&i) - 1.0).abs() < 1e-9);
assert!(intersection(&[rect(0.0, 0.0, 1.0, 1.0)], &[rect(2.0, 2.0, 3.0, 3.0)]).is_empty());
assert!(difference(&[], &[rect(0.0, 0.0, 1.0, 1.0)]).is_empty());
assert!(union(&[]).is_empty());
}
#[test]
fn unsinn_wird_verworfen() {
let bad = vec![vec![[f64::NAN, 0.0], [1.0, 0.0]]];
assert!(union(&[bad]).is_empty());
let degenerate = vec![vec![[0.0, 0.0], [1.0, 0.0], [2.0, 0.0]]];
assert!(union(&[degenerate]).is_empty());
// Doppelter Schlusspunkt wie in polygon-clipping-Eingaben.
let closed = vec![vec![[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 0.0]]];
assert!((area(&union(&[closed])) - 0.5).abs() < 1e-9);
}
#[test]
fn buendige_kanten() {
// Zwei Rechtecke mit gemeinsamer Kante → ein Polygon ohne Naht.
let u = union(&[rect(0.0, 0.0, 1.0, 1.0), rect(1.0, 0.0, 2.0, 1.0)]);
assert_eq!(u.len(), 1);
assert_eq!(u[0].len(), 1);
assert!((area(&u) - 2.0).abs() < 1e-9);
}
}
+35
View File
@@ -0,0 +1,35 @@
//! wasm-bindgen-Fassade (Feature "web"). Eingaben/Ausgaben als flache `f64`-Puffer (s. `flat`).
//! Kaputte Eingaben ergeben ein leeres Ergebnis statt eines Panics (ein Panic legt das ganze
//! WASM-Modul lahm, [14]).
use crate::flat::{decode, encode};
use crate::polygon_bool;
use wasm_bindgen::prelude::wasm_bindgen;
#[wasm_bindgen(start)]
pub fn start() {
console_error_panic_hook::set_once();
}
/// Version des Kern-Moduls (für Diagnose/Startprotokoll).
#[wasm_bindgen]
pub fn core_version() -> String {
env!("CARGO_PKG_VERSION").to_string()
}
#[wasm_bindgen]
pub fn poly_union(a: &[f64]) -> Vec<f64> {
encode(&polygon_bool::union(&decode(a).unwrap_or_default()))
}
#[wasm_bindgen]
pub fn poly_difference(a: &[f64], b: &[f64]) -> Vec<f64> {
let (Some(a), Some(b)) = (decode(a), decode(b)) else { return encode(&[]) };
encode(&polygon_bool::difference(&a, &b))
}
#[wasm_bindgen]
pub fn poly_intersection(a: &[f64], b: &[f64]) -> Vec<f64> {
let (Some(a), Some(b)) = (decode(a), decode(b)) else { return encode(&[]) };
encode(&polygon_bool::intersection(&a, &b))
}
+2 -2
View File
@@ -7,8 +7,8 @@
// • Gebäude-Grundfläche: Wände aller Geschosse und freie Körper (ohne Abzugskörper). Vorsprünge
// (Dachüberstand, Balkone) und ihre Sonderregeln zählen nicht.
import polygonClipping from "polygon-clipping";
import type { MultiPolygon, Pair, Polygon as PcPolygon } from "polygon-clipping";
import * as polygonClipping from "../geometry/polygonBool";
import type { MultiPolygon, Pair, Polygon as PcPolygon } from "../geometry/polygonBool";
import type { Project, SiteRules, Vec2 } from "../model/types";
import { getFloor, getWallType, wallTypeThickness } from "../model/types";
import { wallVerticalExtent } from "../model/wall";
+2 -2
View File
@@ -6,8 +6,8 @@
// Dächern als Vereinigung konvexer Hüllen (Prisma ∪ verschobenes Prisma). Modell: x = Ost,
// y = Nord, Höhen über dem Geländenullpunkt (Meter).
import polygonClipping from "polygon-clipping";
import type { Pair, Polygon as PcPolygon } from "polygon-clipping";
import * as polygonClipping from "../geometry/polygonBool";
import type { Pair, Polygon as PcPolygon } from "../geometry/polygonBool";
import type { Project, Vec2 } from "../model/types";
import { wallVerticalExtent } from "../model/wall";
import { roofBaseElevation, roofGeometry } from "../geometry/roof";
+3
View File
@@ -43,6 +43,7 @@ import {
planToSvgString,
serializeProject,
setWasmBytesProvider,
initCore,
validateProject,
} from "../core";
import type { Project } from "../core";
@@ -74,6 +75,7 @@ function wasmDir(): string {
}
const WASM_FILES: Record<string, string> = {
core: "pkgCore/core_bg.wasm",
render3d: "pkg3d/render3d_bg.wasm",
trucksolid: "pkgTruck/trucksolid_bg.wasm",
};
@@ -126,6 +128,7 @@ export async function run(argv: string[]): Promise<number> {
if (!rel) throw new Error(`unbekanntes WASM-Modul ${name}`);
return readFileSync(join(wasmDir(), rel));
});
await initCore();
const project = loadProject(file);
const scale = Number(args.flags.get("scale") ?? 100);
const allCodes = new Set(project.layers.map((l) => l.code));
+1
View File
@@ -9,6 +9,7 @@ export { exportObj, exportStl } from "../export/exportMesh";
export { exportProjectStep } from "../export/exportStep";
export { planToSvgString } from "../export/planToSvgString";
export { setWasmBytesProvider } from "../engine/wasmSource";
export { initCore, coreReady } from "../engine/coreWasm";
export { applyOps, diffToOps, validateProject, validateOps } from "./ops";
export type { CoreOp } from "./ops";
export type { Project, DrawingLevel } from "../model/types";
+1
View File
@@ -93,6 +93,7 @@ export {
openingVerticalExtent,
} from "../geometry/opening";
export { autoExteriorDimensions } from "../geometry/autoDimensions";
export * as polygonBool from "../geometry/polygonBool";
export type { AutoDimension } from "../geometry/autoDimensions";
export {
+12 -10
View File
@@ -1,11 +1,11 @@
// 2D-Boolean-Operationen (Union / Subtract / Intersect) für GESCHLOSSENE
// 2D-Zeichenelemente (Drawing2D). Ergänzt Split/Join (`splitJoin.ts`). Wandelt
// Drawing2D ↔ polygon-clipping-Format (Martinez-Algorithmus, robust) und liefert
// Drawing2D ↔ Ring-/Polygon-Format der Polygon-Booleans des Rust-Kerns (`polygonBool`, i_overlay) und liefert
// neue Drawing2D-Listen. Stil-, Kategorie- und Level-Attribute werden geerbt
// (vom ersten bzw. Basis-Element).
//
// Loch-Handling: Das Drawing2D-Modell kennt KEINE Innenringe (Löcher). Liefert
// polygon-clipping ein Polygon mit Innenringen, wird der Außenring als gefüllte
// der Polygon-Kern ein Polygon mit Innenringen, wird der Außenring als gefüllte
// Form emittiert und JEDER Innenring als SEPARATE, ungefüllte geschlossene
// Polylinie (Loch-Umriss). So geht keine Geometrie verloren und nichts crasht;
// der Lochrand bleibt sichtbar, ohne dass eine gefüllte Insel entsteht.
@@ -16,8 +16,10 @@
//
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
import polygonClipping from "polygon-clipping";
import type { MultiPolygon, Polygon, Ring } from "polygon-clipping";
import { polygonBool as polygonClipping } from "../core";
type MultiPolygon = polygonClipping.MultiPolygon;
type Polygon = polygonClipping.Polygon;
type Ring = polygonClipping.Ring;
import type { Drawing2D, Drawing2DGeom, Vec2 } from "../model/types";
import { toPolyForm } from "./splitJoin";
import type { PolyForm } from "./splitJoin";
@@ -30,9 +32,9 @@ export function isClosedArea(geom: Drawing2DGeom): boolean {
}
/**
* Wandelt ein geschlossenes Drawing2D in ein polygon-clipping-`Polygon`
* Wandelt ein geschlossenes Drawing2D in ein Kern-`Polygon`
* (Ring-Liste). Reuse: `toPolyForm` aus splitJoin liefert die Stützpunkte. Der
* Ring wird als `[x,y]`-Paare gebildet; polygon-clipping schließt selbst
* Ring wird als `[x,y]`-Paare gebildet; der Kern schließt selbst
* (erster==letzter ist nicht erforderlich, aber unschädlich). Liefert `null`,
* wenn die Form nicht geschlossen ist oder zu wenige Punkte hat.
*/
@@ -45,12 +47,12 @@ export function drawingToPolygon(geom: Drawing2DGeom): Polygon | null {
return [ring];
}
/** PolyForm → polygon-clipping-Ring (`[x,y]`-Paare). */
/** PolyForm → Kern-Ring (`[x,y]`-Paare). */
function formToRing(form: PolyForm): Ring {
return form.pts.map((p): [number, number] => [p.x, p.y]);
}
/** Ein polygon-clipping-Ring → Vec2-Punktliste (für fromPolyForm/Drawing2D). */
/** Ein Kern-Ring → Vec2-Punktliste (für fromPolyForm/Drawing2D). */
function ringToPts(ring: Ring): Vec2[] {
// polygon-clipping liefert geschlossene Ringe (letzter == erster Punkt). Den
// doppelten Schlusspunkt entfernen, damit unsere Polyline-Form sauber ist.
@@ -109,7 +111,7 @@ function ringDrawing(src: Drawing2D, pts: Vec2[], filled: boolean): Drawing2D {
}
/**
* Wandelt eine polygon-clipping-`MultiPolygon` in Drawing2D[] zurück. Je Polygon
* Wandelt eine Kern-`MultiPolygon` in Drawing2D[] zurück. Je Polygon
* wird der Außenring (filled) emittiert; jeder Innenring (Loch) als separater
* ungefüllter geschlossener Umriss. Quelle liefert Stil/Kategorie/Level.
*/
@@ -129,7 +131,7 @@ function multiPolygonToDrawings(
return out;
}
/** Geschlossene Quellen → polygon-clipping-Polygone (mit Drawing-Zuordnung). */
/** Geschlossene Quellen → Kern-Polygone (mit Drawing-Zuordnung). */
function collectPolygons(
srcs: Drawing2D[],
): { poly: Polygon; src: Drawing2D }[] {
+15
View File
@@ -0,0 +1,15 @@
// Vitest-Setup: Rust-Kern synchron laden, damit Kern-Funktionen in jedem Test verfügbar sind.
// Fehlt das Paket, bricht jeder Test mit einem Hinweis ab (vorher `npm run build:core`).
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { initCoreSync } from "./coreWasm";
const file = fileURLToPath(new URL("./pkgCore/core_bg.wasm", import.meta.url));
let bytes: Buffer;
try {
bytes = readFileSync(file);
} catch {
throw new Error(`Rust-Kern fehlt (${file}): zuerst \`npm run build:core\`.`);
}
initCoreSync(new Uint8Array(bytes));
+35
View File
@@ -0,0 +1,35 @@
// Lader des Rust-Kerns (`src-tauri/core` → `src/engine/pkgCore`). Der Kern wird EINMAL geladen —
// App: `initCore()` vor dem ersten Render (main.tsx), CLI: `initCore()` mit Byte-Provider
// (wasmSource.ts), Tests: `initCoreSync()` in der Vitest-Setup-Datei — und danach synchron über
// `core()` aufgerufen, passend zu den synchronen Aufrufern im TS-Kern.
import * as wasm from "./pkgCore/core.js";
import { wasmInitArg } from "./wasmSource";
export type CoreModule = typeof wasm;
let ready = false;
/** Lädt den Kern asynchron (Browser/Tauri/Electron per URL, Node über den Byte-Provider). */
export async function initCore(): Promise<void> {
if (ready) return;
await wasm.default(await wasmInitArg("core"));
ready = true;
}
/** Lädt den Kern synchron aus vorliegenden Bytes (Node: Tests, Werkzeuge). */
export function initCoreSync(bytes: BufferSource): void {
if (ready) return;
wasm.initSync({ module: bytes });
ready = true;
}
export function coreReady(): boolean {
return ready;
}
/** Der geladene Kern; wirft, wenn `initCore()` noch nicht gelaufen ist (Programmierfehler). */
export function core(): CoreModule {
if (!ready) throw new Error("Rust-Kern nicht geladen: initCore() muss vor der ersten Kern-Funktion laufen.");
return wasm;
}
+2 -2
View File
@@ -8,8 +8,8 @@
// schiefe Wände fehlen in den Ketten. Ergebnis sind gewöhnliche Bemassungen (Drawing2D), danach
// frei bearbeitbar.
import polygonClipping from "polygon-clipping";
import type { Pair, Polygon as PcPolygon } from "polygon-clipping";
import * as polygonClipping from "./polygonBool";
import type { Pair, Polygon as PcPolygon } from "./polygonBool";
import type { Drawing2D, Project, Vec2, Wall } from "../model/types";
import { getWallType, wallTypeThickness } from "../model/types";
import { openingJambs } from "./opening";
+33
View File
@@ -0,0 +1,33 @@
import { describe, expect, it } from "vitest";
import { difference, intersection, union } from "./polygonBool";
import type { MultiPolygon, Ring } from "./polygonBool";
const rect = (x0: number, y0: number, x1: number, y1: number): Ring => [[x0, y0], [x1, y0], [x1, y1], [x0, y1]];
const ringArea = (r: Ring) => {
let a = 0;
for (let i = 0; i + 1 < r.length; i++) a += r[i][0] * r[i + 1][1] - r[i + 1][0] * r[i][1];
return a / 2;
};
const area = (mp: MultiPolygon) => mp.reduce((s, p) => s + p.reduce((t, r) => t + ringArea(r), 0), 0);
describe("Polygon-Booleans aus dem Rust-Kern", () => {
it("Vereinigung mit Polygon- und MultiPolygon-Eingaben, Ringe geschlossen", () => {
const u = union([rect(0, 0, 2, 1)], [[rect(1, 0, 3, 1).reverse()]]);
expect(u).toHaveLength(1);
expect(area(u)).toBeCloseTo(3, 9);
const r = u[0][0];
expect(r[0]).toEqual(r[r.length - 1]);
});
it("Differenz mit Loch, Schnitt über mehrere Argumente", () => {
const d = difference([rect(0, 0, 4, 4)], [rect(1, 1, 2, 2)], [rect(3, 3, 5, 5)]);
expect(area(d)).toBeCloseTo(16 - 1 - 1, 9);
expect(d[0].length).toBe(2);
const i = intersection([rect(0, 0, 4, 4)], [rect(1, 1, 5, 5)], [rect(0, 2, 5, 5)]);
expect(area(i)).toBeCloseTo(3 * 2, 9);
});
it("leer und Unsinn", () => {
expect(union([])).toEqual([]);
expect(intersection([rect(0, 0, 1, 1)], [rect(5, 5, 6, 6)])).toEqual([]);
expect(union([[[Number.NaN, 0], [1, 0]]])).toEqual([]);
});
});
+85
View File
@@ -0,0 +1,85 @@
// Polygon-Booleans des Rust-Kerns (`src-tauri/core/src/polygon_bool.rs`, i_overlay) — Ersatz für
// `polygon-clipping` mit derselben Form der Daten, damit die Aufrufer unverändert bleiben:
// Ring = [x, y]-Paare MIT Schlusspunkt im Ergebnis, Polygon = Ringe (0 aussen), MultiPolygon.
// Eingaben dürfen offen oder geschlossen sein und beliebigen Umlaufsinn haben.
// Genauigkeit: i_overlay rechnet auf einem Ganzzahlraster über die Ausdehnung der Eingabe
// (≈ Ausdehnung / 2³⁰, bei 50 m also ~5·10⁻⁸ m) und vereinfacht kollineare Punkte. Konvexe
// Zerlegungen können daher anders ausfallen als mit polygon-clipping (gleiche Fläche/Ebene).
// union(a, ...rest) Vereinigung aller
// difference(a, ...rest) a minus Vereinigung von rest
// intersection(a, ...rest) Schnitt aller
import { core } from "../engine/coreWasm";
export type Pair = [number, number];
export type Ring = Pair[];
export type Polygon = Ring[];
export type MultiPolygon = Polygon[];
export type Geom = Polygon | MultiPolygon;
/** Polygon oder MultiPolygon → MultiPolygon (Polygon: erstes Element ist ein Ring aus Paaren). */
function asMulti(g: Geom): MultiPolygon {
if (g.length === 0) return [];
const first = g[0] as unknown[];
const isPolygon = first.length > 0 && Array.isArray(first[0]) && typeof (first[0] as unknown[])[0] === "number";
return isPolygon ? [g as Polygon] : (g as MultiPolygon);
}
function encode(geoms: Geom[]): Float64Array {
const polys = geoms.flatMap(asMulti);
let n = 1;
for (const p of polys) {
n += 1;
for (const r of p) n += 1 + 2 * r.length;
}
const out = new Float64Array(n);
let i = 0;
out[i++] = polys.length;
for (const p of polys) {
out[i++] = p.length;
for (const r of p) {
out[i++] = r.length;
for (const [x, y] of r) {
out[i++] = x;
out[i++] = y;
}
}
}
return out;
}
function decode(buf: Float64Array): MultiPolygon {
let i = 0;
const nPolys = buf[i++] ?? 0;
const out: MultiPolygon = [];
for (let p = 0; p < nPolys; p++) {
const nRings = buf[i++];
const poly: Polygon = [];
for (let r = 0; r < nRings; r++) {
const nPts = buf[i++];
const ring: Ring = [];
for (let k = 0; k < nPts; k++) {
ring.push([buf[i], buf[i + 1]]);
i += 2;
}
if (ring.length > 0) ring.push([ring[0][0], ring[0][1]]);
poly.push(ring);
}
out.push(poly);
}
return out;
}
export function union(a: Geom, ...rest: Geom[]): MultiPolygon {
return decode(core().poly_union(encode([a, ...rest])));
}
export function difference(a: Geom, ...rest: Geom[]): MultiPolygon {
return decode(core().poly_difference(encode([a]), encode(rest)));
}
export function intersection(a: Geom, ...rest: Geom[]): MultiPolygon {
let acc = encode([a]);
for (const g of rest) acc = core().poly_intersection(acc, encode([g]));
return decode(acc);
}
+1 -1
View File
@@ -368,7 +368,7 @@ const swapLine = (l: [Vec2, Vec2]): [Vec2, Vec2] => [swap2(l[0]), swap2(l[1])];
*/
export function roofGeometry(roof: Roof, eavesZ: number): RoofGeometry {
// Memo je Dach-Objekt: Dächer sind immutabel (structural sharing), die Berechnung (Skelett über
// polygon-clipping) kostet ~50 ms je Dach und wird je Ableitung (3D, Schnitt, Pick, Highlight …)
// Polygon-Booleans) kostet ~50 ms je Dach und wird je Ableitung (3D, Schnitt, Pick, Highlight …)
// mehrfach gebraucht — vorher rechnete jeder Aufruf neu (projectToModel3d: ~550 ms bei 10 Dächern).
const hit = roofGeometryCache.get(roof);
if (hit && hit.eavesZ === eavesZ) return hit.geo;
+13 -1
View File
@@ -33,7 +33,19 @@ describe("roofGeometry", () => {
const base = { id: "R", type: "roof", floorId: "eg", categoryCode: "31", outline: L, shape: "walm", pitchDeg: 45, overhang: 0, ridgeAxis: "x" } as unknown as Roof;
it("Walm auf L nutzt das Skelett, Rechteck bleibt Bounding-Box", () => {
expect(isRectilinearNonRect(L)).toBe(true);
expect(roofGeometry(base, 0).planes.length).toBe(8);
// Sechs Dachebenen (Süd, Ost, Nord und West des Hauptbaus, Kehl- und Flügelfläche); wie viele
// konvexe Stücke je Ebene entstehen, hängt vom Polygon-Kern ab und wird nicht geprüft.
const g = roofGeometry(base, 0);
const planeKey = (pts: number[][]) => {
const [a, b, c] = pts;
const u = [b[0] - a[0], b[1] - a[1], b[2] - a[2]], v = [c[0] - a[0], c[1] - a[1], c[2] - a[2]];
const n = [u[1] * v[2] - u[2] * v[1], u[2] * v[0] - u[0] * v[2], u[0] * v[1] - u[1] * v[0]];
const l = Math.hypot(n[0], n[1], n[2]) * Math.sign(n[2] || 1);
const k = n.map((x) => x / l);
return [...k, k[0] * a[0] + k[1] * a[1] + k[2] * a[2]].map((x) => x.toFixed(4)).join(",");
};
expect(new Set(g.planes.map((p) => planeKey(p.pts))).size).toBe(6);
expect(g.planes.reduce((s, p) => s + planArea(p.pts), 0)).toBeCloseTo(11 * 4 + 8 * 2, 6);
const rect = { ...base, outline: L.slice(0, 1).concat([{ x: 11, y: 0 }, { x: 11, y: 6 }, { x: 0, y: 6 }]) };
expect(roofGeometry(rect, 0).planes.length).toBe(4);
});
+3 -3
View File
@@ -10,15 +10,15 @@
// die NIEDRIGSTE Ebene aller Kanten, deren Keil den Punkt enthält:
// z(p) = e + tan(Neigung) · min{ dist(p, Gerade f) | p ∈ Keil(f) }.
// Die Fläche von e = (Traufpolygon ∩ Keil(e)) minus alle Bereiche, in denen eine
// andere Kante tiefer liegt. Polygon-Booleans über `polygon-clipping`
// andere Kante tiefer liegt. Polygon-Booleans über den Rust-Kern (`polygonBool`)
// (Martinez, wie `editors/booleanOps.ts`). Danach in KONVEXE Teilflächen zerlegt
// (Ohr-Schnitt + Hertel–Mehlhorn), weil Renderer/Schnitt konvexe Flächen
// erwarten (Fächer-Triangulierung, Cyrus–Beck).
//
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
import polygonClipping from "polygon-clipping";
import type { MultiPolygon, Ring } from "polygon-clipping";
import * as polygonClipping from "./polygonBool";
import type { MultiPolygon, Ring } from "./polygonBool";
import type { Vec2 } from "../model/types";
import type { Vec3 } from "./roof";
+22 -7
View File
@@ -7,6 +7,7 @@ import { DrawingLevelsWindowApp } from "./native/DrawingLevelsWindowApp";
import { LayerSettingsWindowApp } from "./native/LayerSettingsWindowApp";
import { ContextImportWindowApp } from "./native/ContextImportWindowApp";
import { ErrorBoundary } from "./ui/ErrorBoundary";
import { initCore } from "./core";
import { getLanguage, setLanguage } from "./i18n";
import type { Language } from "./i18n";
import { applyThemeMode, getStoredThemeMode } from "./theme/themeMode";
@@ -79,10 +80,24 @@ function RootByWindowKind() {
return <App />;
}
createRoot(document.getElementById("root")!).render(
<StrictMode>
<ErrorBoundary>
<RootByWindowKind />
</ErrorBoundary>
</StrictMode>,
);
// Rust-Kern (src-tauri/core) einmal laden, BEVOR irgendein Fenster rendert: die Kern-Funktionen
// rufen ihn danach synchron auf (engine/coreWasm.ts). Scheitert das Laden, gibt es keinen
// sinnvollen Betrieb — die Meldung erscheint statt der App.
const root = createRoot(document.getElementById("root")!);
initCore()
.then(() =>
root.render(
<StrictMode>
<ErrorBoundary>
<RootByWindowKind />
</ErrorBoundary>
</StrictMode>,
),
)
.catch((err: unknown) => {
root.render(
<div style={{ padding: 24, fontFamily: "system-ui", color: "#8a1a1a" }}>
Dossier-Kern konnte nicht geladen werden: {err instanceof Error ? err.message : String(err)}
</div>,
);
});
+3 -2
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import type { Pair } from "polygon-clipping";
import type { Pair } from "../geometry/polygonBool";
import { generatePlan } from "./generatePlan";
import { sampleProject } from "../model/sampleProject";
import type { ExtrudedSolid, Project } from "../model/types";
@@ -23,7 +23,8 @@ describe("Abzugskoerper — Polygon-Kern", () => {
it("Durchbruch quer: zwei Restteile", () => {
const r = subtractRings(sq(0, 0, 4, 0.3), [sq(1, -1, 2, 1)])!;
expect(r).toHaveLength(2);
expect(r.reduce((s, x) => s + area(x.pts), 0)).toBeCloseTo(0.9, 9);
// Polygon-Kern rechnet auf einem Ganzzahlraster (≈ Ausdehnung / 2³⁰): Mikrometer-genau.
expect(r.reduce((s, x) => s + area(x.pts), 0)).toBeCloseTo(0.9, 6);
});
it("ohne Ueberschneidung: null (Original bleibt)", () => {
expect(subtractRings(sq(0, 0, 1, 1), [sq(5, 5, 6, 6)])).toBeNull();
+3 -3
View File
@@ -15,8 +15,8 @@
// Polygone mit Loch (Körper ganz im Bauteil) werden über einen Steg an den Aussenring
// gehängt (Schlüsselloch); die beiden Stegkanten sind nicht gestrichen (`noStrokeEdges`).
import polygonClipping from "polygon-clipping";
import type { Pair, Polygon as PcPolygon, MultiPolygon } from "polygon-clipping";
import * as polygonClipping from "../geometry/polygonBool";
import type { Pair, Polygon as PcPolygon, MultiPolygon } from "../geometry/polygonBool";
import type { ExtrudedSolid, Project, Vec2 } from "../model/types";
import { getFloor } from "../model/types";
import { ceilingVerticalExtent, columnVerticalExtent } from "../model/wall";
@@ -75,7 +75,7 @@ function signedArea(r: Pair[]): number {
return a / 2;
}
/** Ring ohne doppelten Schlusspunkt (polygon-clipping liefert geschlossene Ringe). */
/** Ring ohne doppelten Schlusspunkt (der Polygon-Kern liefert geschlossene Ringe). */
function openRing(r: Pair[]): Pair[] {
if (r.length > 1) {
const a = r[0];
+2
View File
@@ -4,5 +4,7 @@ export default defineConfig({
test: {
environment: "node",
include: ["src/**/*.test.ts"],
// Rust-Kern (pkgCore) vor jedem Testmodul synchron laden.
setupFiles: ["src/engine/coreWasm.setup.ts"],
},
});