# dlr-sc/tigl architecture

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

- Interactive diagram: https://gitdiagram.com/dlr-sc/tigl
- Repository: https://github.com/dlr-sc/tigl

## Overview

The TiGL project is a large-scale, multi‐language, geometry processing framework that computes and manipulates aircraft geometries stored in CPACS files. Its core is built in C/C++ (using CMake for configuration and build), and it wraps its functionality for several external interfaces, including Python, Java, MATLAB, and FORTRAN. In addition, it provides a Qt-based GUI called the “TiGL Viewer” for visualization. The code also draws on heavy geometry processing using the OpenCASCADE CAD kernel.

##### Main Components
- Core Geometry Engine: This resides in the “src” directory and is split into many aspects like:
– CPACS Parsing/Configuration (directories such as src/configuration and src/generated).
– Geometric computations (subdirectories like src/geometry, src/guide_curves, src/wing, src/fuselage, src/engine_nacelle, etc.).
– Boolean operations and CAD export, for instance in src/exports.
– Utilities like logging (src/logging), math (src/math), and system support (src/system).
- API/Interface Layer: The “src/api” directory exposes functions to external applications (for C/C++).
- Language-Specific Bindings: The “bindings” directory provides language wrappers (Python, Java, MATLAB, FORTRAN) so that the geometry engine can be used externally.
- Graphical User Interface: The “TIGLViewer” directory hosts the Qt-based visualization tool so that users can load and examine aircraft geometries.
- Testing and Continuous Integration: There are extensive tests (in tests) plus CI (via .github/workflows and CI directories) that form an essential part of the quality assurance architecture.
- Build System & Tooling: CMake files in the root and subdirectories along with CI scripts (ci, cmake) orchestrate compilation and integration with external third-party libraries and tools (notably OpenCASCADE, boost, and googletest).

##### Relationships and Interactions
- CPACS Input → CPACS Parser (configuration modules in “src/configuration” and “src/generated”) → Core Geometry Engine.
- The Core Geometry Engine relies on the OpenCASCADE CAD kernel (an external library) for representing and operating on NURBS surfaces.
- The computed geometry data is then provided through the API (src/api) to external clients.
- Language-specific bindings in “bindings” wrap the native API functions and allow usage in Python, Java, MATLAB, and FORTRAN.
- The TiGL Viewer (in TIGLViewer) directly uses the core geometry engine through the C++ API for rendering and interacting with the geometry.
- The export modules (under src/exports) provide conversion of the internal geometry to standard formats like STEP, IGES, VTK, STL, etc.
- Tests (unit and integration) interface with almost every part of the system to ensure correctness and robustness.
- CI pipelines (via GitHub Actions and Conda scripts in ci) trigger builds and tests for multiple operating systems, ensuring cross-platform compatibility.

##### Architectural Patterns & Design Principles
- Layered/Multi-tiered design: With a clear separation between the core computational logic, API exposure, and presentation (GUI and language bindings).
- Modularity: The code is divided into a large number of modules (configuration, geometry, wing, fuselage, engine, etc.). Each module is developed and tested more or less independently.
- Abstraction and Interface Orientation: The use of an API layer (src/api) and language bindings abstract the core engine from application-specific implementations.
- Reusability and Extensibility: Bindings to many languages allow TiGL to be reused in different environments, and its export functions facilitate integration with external CAD tools.
- Continuous integration and testing principles: Underlined by the extensive test directories and CI configurations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Layer
    CPACSInput["CPACS File Input"]:::dataLayer
    CPACS_Config["CPACS Configuration"]:::dataLayer
    CPACS_Gen["Generated Configuration"]:::dataLayer

    %% Business Logic Layer
    Engine["Core Geometry Engine"]:::businessLogic
    GeoComp["Geometric Computations"]:::businessLogic
    Wing["Wing Module"]:::businessLogic
    Fuselage["Fuselage Module"]:::businessLogic
    EngineMod["Engine/Nacelle Module"]:::businessLogic
    Guide["Guide Curves Module"]:::businessLogic
    BoolOp["Boolean Operations"]:::businessLogic
    CADExport["CAD Export"]:::businessLogic
    Util["Utility Modules"]:::businessLogic
    Logging["Logging"]:::businessLogic
    MathMod["Math"]:::businessLogic
    SystemSupp["System Support"]:::businessLogic

    %% Presentation/Interface Layer
    API["API/Interface Layer"]:::presentation
    Bindings["Language-specific Bindings"]:::presentation
    Viewer["TiGL Viewer (GUI)"]:::presentation

    %% Infrastructure Layer
    Testing["Testing & CI Infrastructure"]:::infrastructure
    Build["Build System & Tooling"]:::infrastructure

    %% External Dependencies
    OCascade["OpenCASCADE CAD Kernel"]:::external
    ThirdParty["Third-party Libraries"]:::external

    %% Connections - Data Layer to Business Logic
    CPACSInput --> CPACS_Config
    CPACSInput --> CPACS_Gen
    CPACS_Config --> Engine
    CPACS_Gen --> Engine

    %% Connections - Business Logic internal structure
    Engine --> GeoComp
    Engine --> BoolOp
    Engine --> CADExport
    Engine --> Util

    GeoComp --> Wing
    GeoComp --> Fuselage
    GeoComp --> EngineMod
    GeoComp --> Guide

    Util --> Logging
    Util --> MathMod
    Util --> SystemSupp

    %% Connections - Business Logic to Presentation
    Engine --> API
    API --> Bindings
    API --> Viewer

    %% Connection - External dependencies used by Business Logic
    Engine -->|"uses"| OCascade
    Engine -->|"linksWith"| ThirdParty

    %% Connections - Infrastructure
    Build -.->|"orchestrates"| Engine
    Testing -.->|"verifies"| Engine

    %% Styling
    classDef dataLayer fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef businessLogic fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef presentation fill:#FFFF99,stroke:#000,stroke-width:1px;
    classDef infrastructure fill:#d3d3d3,stroke:#000,stroke-width:1px;
    classDef external fill:#FFB6C1,stroke:#000,stroke-width:1px;

    %% Click Events for Data Layer
    click CPACS_Config "https://github.com/dlr-sc/tigl/tree/master/src/configuration"
    click CPACS_Gen "https://github.com/dlr-sc/tigl/tree/master/src/generated"

    %% Click Events for Business Logic Layer
    click Engine "https://github.com/dlr-sc/tigl/tree/master/src"
    click GeoComp "https://github.com/dlr-sc/tigl/tree/master/src/geometry"
    click Wing "https://github.com/dlr-sc/tigl/tree/master/src/wing"
    click Fuselage "https://github.com/dlr-sc/tigl/tree/master/src/fuselage"
    click EngineMod "https://github.com/dlr-sc/tigl/tree/master/src/engine_nacelle"
    click Guide "https://github.com/dlr-sc/tigl/tree/master/src/guide_curves"
    click BoolOp "https://github.com/dlr-sc/tigl/tree/master/src/boolean_operations"
    click CADExport "https://github.com/dlr-sc/tigl/tree/master/src/exports"
    click Logging "https://github.com/dlr-sc/tigl/tree/master/src/logging"
    click MathMod "https://github.com/dlr-sc/tigl/tree/master/src/math"
    click SystemSupp "https://github.com/dlr-sc/tigl/tree/master/src/system"

    %% Click Events for Presentation/Interface Layer
    click API "https://github.com/dlr-sc/tigl/tree/master/src/api"
    click Bindings "https://github.com/dlr-sc/tigl/tree/master/bindings"
    click Viewer "https://github.com/dlr-sc/tigl/tree/master/TIGLViewer"

    %% Click Events for Infrastructure Layer
    click Testing "https://github.com/dlr-sc/tigl/tree/master/tests"
    click Build "https://github.com/dlr-sc/tigl/tree/master/cmake"

    %% Click Event for External Dependencies
    click ThirdParty "https://github.com/dlr-sc/tigl/tree/master/thirdparty"
```
