# fatilhan/vtk-medical-core architecture

> Architecture diagram of the GitHub repository fatilhan/vtk-medical-core, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fatilhan/vtk-medical-core
- Repository: https://github.com/fatilhan/vtk-medical-core

## Overview

##### Project type and purpose
- This is a native C++ dynamic‐link library (DLL) exposing a simple C‐style API.
- Its purpose is to encapsulate complex VTK‐based medical‐imaging pipelines (DICOM loading, 2D/3D rendering, window/level) behind a thin, language-agnostic facade, so that any GUI (WPF, Qt, Python, etc.) can call it.

##### File structure
- Top-level:
- CMakeLists.txt, CMakePresets.json – build configuration
- LICENSE, README.md – project metadata
- .gitignore, .gitattributes
- Source directory (OpTomoVTKImaging):
- OpTomoVTKImaging.cpp/.h – DLL entry points, extern "C" API definitions
- Model.cpp/.h – core engine: orchestrates VTK pipelines (loading, rendering, slicing, window/level)
- No frontend in this repo; this project is purely the backend library.

##### README for additional insights
- Architecture is explicitly described as a “layer” between visualization engine (VTK) and GUI clients.
- Key dependencies: VTK (9.x+), CMake, C++ compiler.
- Highlights a C‐style API boundary (extern "C") for language interoperability.

a. Main components:
- Frontend Application(s) (WPF/C#, Qt/C++, Python, etc.)
- DLL API Layer (extern "C" functions in OpTomoVTKImaging.cpp)
- Core Engine (Model.cpp):
– DICOM Loader
– 3D Volume Renderer
– 2D Slice Generator
– Window/Level Controller
- VTK Library (external dependency)
- Build System (CMake) – shown off to the side (optional)
b. Relationships and interactions:
- Frontend → calls → DLL API Layer
- API Layer → delegates → Core Engine modules
- Core Engine → invokes → VTK pipelines (VTK classes/objects)
- Data flows: File I/O (DICOM) → in-memory volume → processing → rendered output (buffers or callbacks back to frontend)
c. Architectural patterns and design principles:
- Layered (Facade) pattern: API layer hides VTK complexity
- Separation of concerns: API boundary, core logic, external lib
- Language-independent boundary (extern "C")
d. Key technologies & libraries:
- C++17+ (or C++14)
- VTK 9.x
- CMake for cross-platform build (Windows/.dll, Linux/.so, macOS/.dylib)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend
    Frontend["Frontend Application(s)\n(WPF, Qt, Python, etc.)"]:::frontend

    %% DLL Container
    subgraph "OpTomoVTKImaging.dll"
        direction TB
        API["DLL API Layer\nextern \"C\""]:::api

        subgraph "Core Engine"
            direction TB
            DICOM["DICOM Loader"]:::core
            Volume["3D Volume Renderer"]:::core
            Slice["2D Slice Generator"]:::core
            WL["Window/Level Controller"]:::core
        end
    end

    %% External Dependencies
    VTK["VTK Library"]:::external

    %% Build System
    CMake["CMake Build System"]:::build

    %% Project Metadata
    Meta["Project Metadata\n(README.md, LICENSE)"]:::metadata

    %% Connections
    Frontend -->|"LoadDICOM(folderPath)\nRenderSlice(plane)"| API
    API -->|"delegate to Loader"| DICOM
    API -->|"delegate to Renderer"| Volume
    API -->|"delegate to Slicer"| Slice
    API -->|"delegate to WL Controller"| WL

    DICOM -->|"uses VTK pipelines"| VTK
    Volume -->|"uses VTK pipelines"| VTK
    Slice -->|"uses VTK pipelines"| VTK
    WL -->|"uses VTK pipelines"| VTK

    CMake -.->|builds| API
    CMake -.->|builds| DICOM
    CMake -.->|builds| Volume
    CMake -.->|builds| Slice
    CMake -.->|builds| WL

    Meta --- Frontend

    %% Click Events
    click API "https://github.com/fatilhan/vtk-medical-core/blob/master/OpTomoVTKImaging/OpTomoVTKImaging.cpp"
    click API "https://github.com/fatilhan/vtk-medical-core/blob/master/OpTomoVTKImaging/OpTomoVTKImaging.h"
    click DICOM "https://github.com/fatilhan/vtk-medical-core/blob/master/OpTomoVTKImaging/Model.cpp"
    click DICOM "https://github.com/fatilhan/vtk-medical-core/blob/master/OpTomoVTKImaging/Model.h"
    click Volume "https://github.com/fatilhan/vtk-medical-core/blob/master/OpTomoVTKImaging/Model.cpp"
    click Volume "https://github.com/fatilhan/vtk-medical-core/blob/master/OpTomoVTKImaging/Model.h"
    click Slice "https://github.com/fatilhan/vtk-medical-core/blob/master/OpTomoVTKImaging/Model.cpp"
    click Slice "https://github.com/fatilhan/vtk-medical-core/blob/master/OpTomoVTKImaging/Model.h"
    click WL "https://github.com/fatilhan/vtk-medical-core/blob/master/OpTomoVTKImaging/Model.cpp"
    click WL "https://github.com/fatilhan/vtk-medical-core/blob/master/OpTomoVTKImaging/Model.h"
    click CMake "https://github.com/fatilhan/vtk-medical-core/blob/master/CMakeLists.txt"
    click CMake "https://github.com/fatilhan/vtk-medical-core/blob/master/OpTomoVTKImaging/CMakeLists.txt"
    click Meta "https://github.com/fatilhan/vtk-medical-core/blob/master/README.md"
    click Meta "https://github.com/fatilhan/vtk-medical-core/tree/master/LICENSE"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef api fill:#90EE90,stroke:#000,stroke-width:1px
    classDef core fill:#FFA500,stroke:#000,stroke-width:1px
    classDef external fill:#DDA0DD,stroke:#000,stroke-width:1px
    classDef build fill:#D3D3D3,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5
    classDef metadata fill:#FFFFE0,stroke:#000,stroke-width:1px
```
