Skip to main content

hypergraph_rs/raster/instruments/
mod.rs

1//! The three Lawverian 3D instruments (PHASE-R-MAP §3): pure `DeckWorld ->
2//! SceneGraph3D` builders, one per instrument, direct transcriptions of the
3//! deck's draw functions minus canvas calls. Feature-gated `cells3d` (S9
4//! lane gate — 3D spatial embeddings are library/CLI capability only).
5
6pub mod cylinder;
7pub mod sankey;
8pub mod terrain;
9
10use crate::raster::deck::DeckWorld;
11use crate::raster::SceneGraph3D;
12
13/// Which of the three Lawverian instruments to build.
14#[derive(Debug, Clone, Copy, PartialEq, Eq)]
15pub enum Instrument {
16    /// Instrument I — the adjoint cylinder (Task 7).
17    Cylinder,
18    /// Instrument II — the contradiction terrain (Task 8).
19    Terrain,
20    /// Instrument III — the OCC hyper-Sankey (Task 9).
21    Sankey,
22}
23
24/// Which scalar sets a community's height on the cylinder (D-R1). Default
25/// `OrgDegree` mirrors the deck's `o(C) = orgOf(c)`. `HullFill` is a
26/// structural alternative — internal-link density as a fraction of the
27/// maximum possible pairwise links (`|links| / C(|C|,2)`, clamped to
28/// `[0,1]`) — exposed for callers who want a "how full is this hull"
29/// reading instead of "how connected is this community"; no golden number
30/// asserts it (no owner ruling needed for a non-default option).
31#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
32pub enum CylinderHeight {
33    #[default]
34    OrgDegree,
35    HullFill,
36}
37
38/// Options shared across instrument builders. Only `cylinder_height`
39/// applies today (Task 7); future tasks may add Terrain/Sankey knobs here.
40#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
41pub struct InstrumentOpts {
42    pub cylinder_height: CylinderHeight,
43}
44
45/// Build the scene graph for `inst` over `world`. Pure function of
46/// `(inst, world, opts)` — camera-independent, deterministic (Task 7 Step 3
47/// test contract).
48pub fn build(inst: Instrument, world: &DeckWorld, opts: &InstrumentOpts) -> SceneGraph3D {
49    match inst {
50        Instrument::Cylinder => cylinder::build_cylinder(world, opts),
51        Instrument::Terrain => terrain::build_terrain(world, opts),
52        Instrument::Sankey => {
53            let zoom = if world.zoom == 1 {
54                sankey::Zoom::Coarse
55            } else {
56                sankey::Zoom::Fine
57            };
58            sankey::build_sankey(&world.industries, zoom).scene
59        }
60    }
61}