# tarydon/nori architecture

> Architecture diagram of the GitHub repository tarydon/nori, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tarydon/nori
- Repository: https://github.com/tarydon/nori

## Overview

#### Purpose and Structure
Nori is a C# foundation for 2D/3D geometry and engineering applications: geometry, drawings, models, meshing, simulation, interchange formats, and OpenGL visualization. The main reusable library is `Core/Nori.Core.csproj`; solution-level composition is in `Nori.slnx` and `Nori.proj`.

#### Entry Points and Hosts
There is no single product executable. Consumers enter through the Core library or runnable shells/demos:
- Console demos: `Demos/ConShell/Program.cs`, `Demos/BenchShell/Program.cs`
- OpenGL demo: `Demos/GLShell/Program.cs`
- WPF interactive demo: `Demos/WPFDemo/App.xaml`, `Demos/WPFDemo/MainWindow.xaml.cs`
- Developer console: `Tools/Console/Console.cs`, `Tools/Console/Commands.cs`

Host adapters isolate windowing, input, dispatch, and OpenGL-context concerns from application/model code: `Host/GLFW/Host.cs`, `Host/WPF/Host.cs`, `Host/WPF/OpenGL.cs`.

#### Core Geometry and 2D Drawing
`Core/Geom` is the computational foundation: points/vectors/matrices, bounds, curves/polygons, collision, tessellation, convex hulls, and NURBS. Key paths are `Core/Geom/Point.cs`, `Core/Geom/PolyOps.cs`, and `Core/Geom/FastTess2D.cs`.

2D CAD-like drawing entities and operations sit above that layer in `Core/Drawing`, including drawing representation, snapping, stitching, dimensions, and line fonts: `Core/Drawing/Ent2.cs`, `Core/Drawing/Dwg2.cs`, `Core/Drawing/DwgSnap.cs`. The primary boundary is geometric primitives versus user-facing drawing/entity semantics.

#### 3D Models, Meshes, and Sheet Metal
The 3D model layer represents curves, surfaces, and entities: `Core/Model/Ent3.cs`, `Core/Model/E3Surface.cs`, `Core/Model/Model3.cs`. Mesh construction and topology form a downstream discretized representation for rendering or engineering operations: `Core/Mesh/Mesh.cs`, `Core/Mesh/MeshBuild.cs`, `Core/Mesh/CSMesher.cs`.

Sheet-metal processing is a distinct model transformation pipeline: flexible/flat forms and bend data are processed by `Core/Model/Tenkai/SheetMetalizer.cs` and `Core/Model/Tenkai/Unfolder.cs`. Typical flow is imported or constructed geometry → model/surface entities → mesh or flattened sheet output.

#### File and Resource Boundaries
`Core/IO` owns parsing and serialization rather than exposing file formats directly to geometry code. Supported boundaries include DXF, STEP, STL, PNG, T3X, and custom stream formats: `Core/IO/DXF/DXFReader.cs`, `Core/IO/STEP/STPReader.cs`, `Core/IO/STL.cs`.

Runtime assets are repository-managed under `Wad`, including DXF fonts/ignore lists and OpenGL shaders: `Wad/DXF/default.lfont`, `Wad/GL/Shader/Index.txt`, `Wad/AuManifest.txt`. `NORIROOT` locates this repository/resource root.

#### Simulation and Spatial Queries
Simulation components build on geometric and mesh representations for mechanisms, collision, and broad-phase acceleration. Important components are `Core/Sim/Mechanism.cs`, `Core/Sim/OBBTree.cs`, and `Core/Sim/OBBCollider.cs`. This creates a control flow from modeled meshes/entities into bounding-volume construction and collision/kinematic evaluation.

#### Rendering Stack
Lux is the rendering/scene layer over OpenGL: `Lux/Lux.cs`, `Lux/Scene/Scene.cs`, `Lux/Shader/Shader.cs`. View-node adapters bridge domain objects to GPU/renderable scene nodes, e.g. `Lux/VNodes/Ent2VN.cs`, `Lux/VNodes/Ent3VN.cs`, and `Lux/VNodes/MechanismVN.cs`.

Rendering depends on an OpenGL runtime and platform host implementation—GLFW or WPF—not external network services. Shader source is loaded from `Wad/GL/Shader`; font rendering is represented by `Lux/Font/FreeType.cs` and bundled font assets.

Main entry points: [`Core/Model/Model3.cs`](https://github.com/tarydon/nori/blob/main/Core/Model/Model3.cs) (3D Model), [`Core/Sim/Mechanism.cs`](https://github.com/tarydon/nori/blob/main/Core/Sim/Mechanism.cs) (Simulation), [`Lux/Lux.cs`](https://github.com/tarydon/nori/blob/main/Lux/Lux.cs) (Lux renderer), [`Lux/VNodes/Ent3VN.cs`](https://github.com/tarydon/nori/blob/main/Lux/VNodes/Ent3VN.cs) (View-node adapters)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core domain"]
  node_core["Nori Core<br/>C&#35; library<br/>[Nori.Core.csproj]"]
  node_geom["Geometry kernel"]
  node_drawing["2D Drawing<br/>drawing model"]
  node_model["3D Model<br/>model layer<br/>[Model3.cs]"]
  node_mesh["Mesh topology<br/>[MeshBuild.cs]"]
  node_sheet["Sheet metal<br/>transformation<br/>[SheetMetalizer.cs]"]
  node_io["Format I/O<br/>serialization"]
  node_sim["Simulation<br/>[Mechanism.cs]"]
  node_obb["OBB acceleration<br/>spatial query<br/>[OBBTree.cs]"]
end

subgraph group_render["Rendering and hosts"]
  node_lux["Lux renderer<br/>rendering library<br/>[Lux.cs]"]
  node_scene["Scene graph<br/>[Scene.cs]"]
  node_vnodes["View-node adapters<br/>domain adapters<br/>[Ent3VN.cs]"]
  node_hosts["Platform hosts<br/>host adapters<br/>[Host.cs]"]
  node_shells["Console shells<br/>runnable hosts<br/>[Program.cs]"]
  node_glshell["OpenGL demo<br/>runnable host<br/>[Program.cs]"]
  node_wpfdemo["WPF demo<br/>runnable host<br/>[App.xaml]"]
end

subgraph group_resources["Resources"]
  node_assets["Wad assets<br/>runtime assets"]
  node_shaders["Shader sources<br/>GPU assets"]
end

node_core -->|"contains"| node_geom
node_geom -->|"primitives for"| node_drawing
node_geom -->|"primitives for"| node_model
node_model -->|"discretizes to"| node_mesh
node_model -->|"processed by"| node_sheet
node_io -->|"imports / exports"| node_drawing
node_io -->|"imports / exports"| node_model
node_model -->|"drives"| node_sim
node_mesh -->|"supports"| node_sim
node_sim -->|"uses"| node_obb
node_drawing -->|"adapted by"| node_vnodes
node_model -->|"adapted by"| node_vnodes
node_sim -->|"adapted by"| node_vnodes
node_vnodes -->|"populates"| node_scene
node_scene -->|"rendered by"| node_lux
node_lux -->|"requires GL context"| node_hosts
node_assets -.->|"provides fonts and lists"| node_io
node_shaders -->|"loaded by"| node_lux
node_shells -->|"consumes"| node_core
node_glshell -->|"runs"| node_lux
node_wpfdemo -->|"uses WPF host"| node_hosts

click node_core "https://github.com/tarydon/nori/blob/main/Core/Nori.Core.csproj"
click node_geom "https://github.com/tarydon/nori/tree/main/Core/Geom"
click node_drawing "https://github.com/tarydon/nori/tree/main/Core/Drawing"
click node_model "https://github.com/tarydon/nori/blob/main/Core/Model/Model3.cs"
click node_mesh "https://github.com/tarydon/nori/blob/main/Core/Mesh/MeshBuild.cs"
click node_sheet "https://github.com/tarydon/nori/blob/main/Core/Model/Tenkai/SheetMetalizer.cs"
click node_io "https://github.com/tarydon/nori/tree/main/Core/IO"
click node_sim "https://github.com/tarydon/nori/blob/main/Core/Sim/Mechanism.cs"
click node_obb "https://github.com/tarydon/nori/blob/main/Core/Sim/OBBTree.cs"
click node_lux "https://github.com/tarydon/nori/blob/main/Lux/Lux.cs"
click node_scene "https://github.com/tarydon/nori/blob/main/Lux/Scene/Scene.cs"
click node_vnodes "https://github.com/tarydon/nori/blob/main/Lux/VNodes/Ent3VN.cs"
click node_hosts "https://github.com/tarydon/nori/blob/main/Host/GLFW/Host.cs"
click node_shells "https://github.com/tarydon/nori/blob/main/Demos/ConShell/Program.cs"
click node_glshell "https://github.com/tarydon/nori/blob/main/Demos/GLShell/Program.cs"
click node_wpfdemo "https://github.com/tarydon/nori/blob/main/Demos/WPFDemo/App.xaml"
click node_assets "https://github.com/tarydon/nori/tree/main/Wad"
click node_shaders "https://github.com/tarydon/nori/tree/main/Wad/GL/Shader"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_core,node_geom,node_drawing,node_model,node_mesh,node_sheet,node_io,node_sim,node_obb toneBlue
class node_lux,node_scene,node_vnodes,node_hosts,node_shells,node_glshell,node_wpfdemo toneAmber
class node_assets,node_shaders toneMint
```

## Components

### Core domain

Reusable geometry, modeling, engineering, and file boundaries.

- [Nori Core](https://github.com/tarydon/nori/blob/main/Core/Nori.Core.csproj): C# library · Main reusable foundation library. · `Core/Nori.Core.csproj`
- [Geometry kernel](https://github.com/tarydon/nori/tree/main/Core/Geom): geometry · Computational primitives, curves, polygons, and tessellation. · `Core/Geom`
- [2D Drawing](https://github.com/tarydon/nori/tree/main/Core/Drawing): drawing model · CAD-like entities and drawing operations. · `Core/Drawing`
- [3D Model](https://github.com/tarydon/nori/blob/main/Core/Model/Model3.cs): model layer · Curves, surfaces, and 3D entities. · `Core/Model/Model3.cs`
- [Mesh topology](https://github.com/tarydon/nori/blob/main/Core/Mesh/MeshBuild.cs): mesh · Discretized mesh construction and topology. · `Core/Mesh/MeshBuild.cs`
- [Sheet metal](https://github.com/tarydon/nori/blob/main/Core/Model/Tenkai/SheetMetalizer.cs): transformation · Bend processing and unfolding pipeline. · `Core/Model/Tenkai/SheetMetalizer.cs`
- [Format I/O](https://github.com/tarydon/nori/tree/main/Core/IO): serialization · Parses and writes engineering interchange formats. · `Core/IO`
- [Simulation](https://github.com/tarydon/nori/blob/main/Core/Sim/Mechanism.cs): simulation · Mechanisms, broad phase, and collision evaluation. · `Core/Sim/Mechanism.cs`
- [OBB acceleration](https://github.com/tarydon/nori/blob/main/Core/Sim/OBBTree.cs): spatial query · Bounding-volume trees and collision tests. · `Core/Sim/OBBTree.cs`

### Rendering and hosts

Scene rendering, platform adapters, and runnable shells.

- [Lux renderer](https://github.com/tarydon/nori/blob/main/Lux/Lux.cs): rendering library · OpenGL scene and shader rendering layer. · `Lux/Lux.cs`
- [Scene graph](https://github.com/tarydon/nori/blob/main/Lux/Scene/Scene.cs): scene · Renderable scene composition. · `Lux/Scene/Scene.cs`
- [View-node adapters](https://github.com/tarydon/nori/blob/main/Lux/VNodes/Ent3VN.cs): domain adapters · Converts drawing, model, and mechanism objects into render nodes. · `Lux/VNodes/Ent3VN.cs`
- [Platform hosts](https://github.com/tarydon/nori/blob/main/Host/GLFW/Host.cs): host adapters · Isolates windowing, input, dispatch, and GL contexts. · `Host/GLFW/Host.cs`
- [Console shells](https://github.com/tarydon/nori/blob/main/Demos/ConShell/Program.cs): runnable hosts · Demo and developer console entry points. · `Demos/ConShell/Program.cs`
- [OpenGL demo](https://github.com/tarydon/nori/blob/main/Demos/GLShell/Program.cs): runnable host · `Demos/GLShell/Program.cs`
- [WPF demo](https://github.com/tarydon/nori/blob/main/Demos/WPFDemo/App.xaml): runnable host · Interactive WPF application entry point. · `Demos/WPFDemo/App.xaml`

### Resources

Repository-managed runtime assets.

- [Wad assets](https://github.com/tarydon/nori/tree/main/Wad): runtime assets · Shaders, fonts, and format resources located through NORIROOT. · `Wad`
- [Shader sources](https://github.com/tarydon/nori/tree/main/Wad/GL/Shader): GPU assets · `Wad/GL/Shader`

## Connections

- Nori Core → Geometry kernel: contains
- Geometry kernel → 2D Drawing: primitives for
- Geometry kernel → 3D Model: primitives for
- 3D Model → Mesh topology: discretizes to
- 3D Model → Sheet metal: processed by
- Format I/O → 2D Drawing: imports / exports
- Format I/O → 3D Model: imports / exports
- 3D Model → Simulation: drives
- Mesh topology → Simulation: supports
- Simulation → OBB acceleration: uses
- 2D Drawing → View-node adapters: adapted by
- 3D Model → View-node adapters: adapted by
- Simulation → View-node adapters: adapted by
- View-node adapters → Scene graph: populates
- Scene graph → Lux renderer: rendered by
- Lux renderer → Platform hosts: requires GL context
- Wad assets → Format I/O: provides fonts and lists
- Shader sources → Lux renderer: loaded by
- Console shells → Nori Core: consumes
- OpenGL demo → Lux renderer: runs
- WPF demo → Platform hosts: uses WPF host
