Skip to content

Commit a972adc

Browse files
authored
Merge pull request #56 from AdaWorldAPI/claude/charming-johnson-ufstpw
feat(fma): FMA-addressed 3D anatomy — triangle rasterizer + canonical GUID + /FMA server
2 parents 6c2eed9 + e0cd766 commit a972adc

17 files changed

Lines changed: 53540 additions & 0 deletions

fma/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/target
2+
Cargo.lock
3+
# fetched geometry (run ./fetch_data.sh)
4+
/data/parts
5+
/data/isa_parts
6+
/data/combined_element_parts.txt
7+
*.zip
8+
# render outputs
9+
/fma_frames
10+
/mesh
11+
/guid
12+
/anchor
13+
/turntable

fma/Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "fma"
3+
version = "0.1.0"
4+
edition = "2021"
5+
publish = false
6+
description = "FMA-addressed 3D human anatomy — triangle rasterizer + canonical GUID + /FMA server"
7+
license = "Apache-2.0"
8+
9+
# Standalone crate, intentionally isolated from the q2 Quarto workspace.
10+
[workspace]
11+
12+
[dependencies]
13+
png = "0.17"
14+
15+
[profile.release]
16+
opt-level = 3
17+
codegen-units = 1

fma/README.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# fma — FMA-addressed 3D human anatomy
2+
3+
Real connected anatomical geometry (triangle meshes), addressed by the
4+
Foundational Model of Anatomy (FMA), rendered solid on the CPU and served under
5+
`/FMA`. Sibling of the cubus `/torso` route — same idea, real geometry.
6+
7+
> Three things, one system: **geometry** (triangles) ⟷ **address** (canonical
8+
> GUID per part) ⟷ **route** (`/FMA`, `/FMA/turntable`, `/FMA/live`).
9+
10+
![skeleton](docs/mesh_bones.png) ![tissues](docs/mesh_tissues.png)
11+
12+
602K-triangle skeleton · 6.2M-triangle tissue body · `docs/frame_0067.png` is one
13+
turntable frame.
14+
15+
## Pipeline
16+
17+
```
18+
BodyParts3D meshes ──tissue (is_a tree)──► triangle rasterizer (z-buffer + Gouraud)
19+
│ └─► solid renders / 360 turntable
20+
└──part_of distinguished name──► canonical GUID classid::HEEL::HIP::TWIG::F4::F5:IDENTITY
21+
(prefix-routable cascade + golden-stride identity mint)
22+
```
23+
24+
- **Geometry** is the real mesh triangles (not gaussian splats): per-triangle
25+
z-buffered fill with smooth per-vertex (Gouraud) normals, two-sided shading,
26+
FMA-tissue color (bone ivory, muscle red, vessel red, nerve yellow, …).
27+
- **Address** is the OGAR-canon node key: each part's **distinguished name** is
28+
its `part_of` ancestry (`human body / cardiovascular system / … / aorta`);
29+
the GUID cascade tiers are FNV-1a of the cumulative ancestor prefix (so
30+
siblings share leading groups — prefix-routable), and the **IDENTITY** tier is
31+
the **golden-stride mint** (`GOLDEN_RATIO × EULER_GAMMA`, stride-4/offset-20 —
32+
the helix CurveRuler, same generator as bgz17 / bgz-hhtl-d / helix).
33+
34+
## Binaries
35+
36+
| bin | what |
37+
|---|---|
38+
| `mesh` | static solid render (`bones` / `tissues` / `all`) → `mesh/mesh_<mode>.png` |
39+
| `turntable` | parallel 360° prerender, N frames → `fma_frames/frame_NNNN.png` |
40+
| `serve` | dep-free std HTTP server, all routes under `/FMA` (binds `0.0.0.0:$PORT`) |
41+
| `guid` | mint the part_of GUID per FMA node → `guid/guid_manifest.tsv`, `guid/fj_guid.tsv` |
42+
| `converge` | **v3**: cascading-HHTL `(part_of:is_a)` **canonical NodeGuid**`guid/guid_converged.tsv` |
43+
| `anchor` | compression study: cascade vs raw-cartesian vs Cartesian-Skeleton hybrid |
44+
45+
## Routes (`serve`)
46+
47+
All under `/FMA` — no case-only `/fma` vs `/FMA` overlap.
48+
49+
| route | serves |
50+
|---|---|
51+
| `GET /FMA` | viewer: renders + tissue legend + live part lookup |
52+
| `GET /FMA/skeleton.png`, `GET /FMA/body.png` | solid skeleton / tissue body (PNG) |
53+
| `GET /FMA/guid/<FMAID>` | `{container, guid, distinguished_name}` (JSON) |
54+
| `GET /FMA/manifest` | full GUID manifest (TSV) |
55+
| `GET /FMA/turntable` | 360° turntable, 90 fps autoplay (LazyLock-prebuffered frames) |
56+
| `GET /FMA/live` | interactive drag-to-rotate over the same frames |
57+
| `GET /FMA/frame/<i>` | one turntable frame (PNG, from the RAM prebuffer) |
58+
59+
## Three coexisting FMA addressings (lose neither version)
60+
61+
The Ada workspace has two independent FMA bodies of work; this crate adds a third
62+
that converges them **without replacing either** — disjoint files, disjoint routes:
63+
64+
| version | what | axis | where |
65+
|---|---|---|---|
66+
| **v1** (other session) | FMA **heart** graph, canonical `NodeGuid`, served at **`/fma`** | `is_a` (taxonomy) | `crates/osint-bake/.../fma.rs`, `cockpit/.../FmaGraph.tsx` |
67+
| **v2** (this crate, `guid`) | **full-body** part_of FNV cascade + 3D mesh at **`/FMA`** | `part_of` (mereology) | `fma/src/bin/guid.rs` |
68+
| **v3** (this crate, `converge`) | cascading-HHTL **canonical `NodeGuid`** | **`(part_of:is_a)`** | `fma/src/bin/converge.rs` |
69+
70+
**v3 is the convergence.** Each 8:8 HHTL tier packs both axes — `high = part_of`
71+
(mixin / family / basin: *where*), `low = is_a` (identity / type: *what*) —
72+
cascading HEEL→HIP→TWIG so the high-byte chain prefix-routes the body partonomy
73+
and the low-byte chain prefix-routes the type taxonomy: **both hierarchies in one
74+
key, routable on either axis at every level.** The 16-byte layout is byte-identical
75+
to `lance_graph_contract::canonical_node::NodeGuid` (OGAR canon, locked 2026-06-13:
76+
`classid·HEEL·HIP·TWIG·family·identity`), and `classid` uses the same `0x0A0x`
77+
`ConceptDomain::Anatomy` space as v1's bake (`0x0A01` soft tissue, `0x0A02`
78+
skeleton) — so a heart node from v1 and a heart node from v3 share `classid`. v3
79+
is dep-free (emits the canonical bytes directly) so this crate stays standalone.
80+
81+
```text
82+
aorta subtree (v3): classid HEEL HIP TWIG family·identity
83+
FMA3736 ascending 00000a01-0901-0702-0e02-000105·880ff7 part_of:ascending aorta is_a:ascending aorta
84+
FMA3789 abdominal 00000a01-0901-0702-0e02-000305·aea610 part_of:abdominal aorta is_a:abdominal aorta
85+
^ shared classid + HEEL/HIP/TWIG = same region AND same vessel type; tail disambiguates
86+
```
87+
88+
## Run
89+
90+
```sh
91+
./fetch_data.sh # BodyParts3D meshes + combined map
92+
cargo run --release --bin guid # v2 part_of GUID manifest
93+
cargo run --release --bin converge # v3 (part_of:is_a) canonical NodeGuid → guid/guid_converged.tsv
94+
cargo run --release --bin mesh -- data/isa_parts/isa_BP3D_4.0_obj_99 \
95+
data/combined_element_parts.txt data/inclusion.txt data/isa_inclusion.txt mesh tissues
96+
cargo run --release --bin turntable # 270 frames (3s @ 90fps)
97+
PORT=8088 cargo run --release --bin serve # open http://localhost:8088/FMA
98+
```
99+
100+
Build with AVX-512 (x86-64-v4): `RUSTFLAGS="-C target-cpu=native"` (or `x86-64-v4`).
101+
102+
## Data & attribution
103+
104+
`data/*.txt` are the small BodyParts3D ID/relation maps (committed). The meshes
105+
are fetched by `fetch_data.sh` (not committed).
106+
107+
- Geometry: **BodyParts3D**, © The Database Center for Life Science, licensed
108+
under **CC Attribution-Share Alike 2.1 Japan**.
109+
- Ontology: **Foundational Model of Anatomy (FMA)**.
110+
- Code: Apache-2.0.

0 commit comments

Comments
 (0)