# tudelft3d/val3dity architecture

> Architecture diagram of the GitHub repository tudelft3d/val3dity, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tudelft3d/val3dity
- Repository: https://github.com/tudelft3d/val3dity

## Overview

##### Main Components

a. Input Processing Layer
- Supported input formats (CityJSON, OBJ, OFF, IndoorGML, etc.)
- Input validation components
- File parsing modules

b. Core Validation Engine
- Geometry primitive processors
- ISO19107 validation rules
- Topological validation components
- Error detection system

c. Output Generation Layer
- Validation report generator
- Error code mapping
- Output formatters

##### Key Architectural Elements

a. Primary Components:
**[Input Files] → [Input Parser] → [Validation Engine] → [Report Generator] → [Output Report]**

b. Validation Engine Details:
**[Geometry Primitives]**
- ↓
**[Validation Rules]**
- ↓
**[Error Detection]**
- ↓
**[Error Classification]**

##### Important Relationships

a. Core Classes (from src/):
**[Primitive] ←→ [Surface]**
- ↓           ↓
**[Solid] ←→ [CompositeSurface]**
- ↓
**[MultiSolid/CompositeSolid]**

b. Validation Flow:
**[Input Parser] → [GeometryTemplate] → [Primitive Validation]**
- ↓
- [Topological Validation]
- ↓
- [Error Collection]

##### Implementation Details

a. Core Components:
**[Input Handlers]**
- CityJSON Parser
- OBJ Parser
- IndoorGML Parser
- ↓
**[Validation Core]**
- Primitive Validators
- Shell Validators
- Topological Validators
- ↓
**[Output Handlers]**
- Report Generator
- Error Classifier

##### Additional Elements

- Version information and supported standards
- External tool integration (viz3dity)
- Error code reference (as shown in the documentation)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        IF[Input Files]
        IP["Input Parser"]:::input
        GT["Geometry Template"]:::input
    end

    subgraph "Core Validation"
        direction TB
        subgraph "Primitive Handlers"
            direction TB
            PR["Primitive"]:::core
            SU["Surface"]:::core
            SO["Solid"]:::core
            CS["Composite Solid"]:::core
            MS["Multi Solid"]:::core
        end

        subgraph "Validation Components"
            direction TB
            VPT["Primitive Topology Validator"]:::core
            VSH["Shell Validator"]:::core
            V3D["Val3dity Core"]:::core
        end

        subgraph "Geometry Tools"
            GT1["Geometry Tools"]:::tools
        end
    end

    subgraph "External Libraries"
        CGAL["CGAL"]:::external
        GEOS["GEOS"]:::external
        EIGEN["Eigen"]:::external
    end

    subgraph "Output Generation"
        RG["Report Generator"]:::output
        EC["Error Classification"]:::output
        OR["Output Report"]:::output
    end

    subgraph "Testing Framework"
        TD["Test Data"]:::test
        VR["Validation Reports"]:::test
    end

    %% Relationships
    IF --> IP
    IP --> GT
    GT --> PR
    PR --> SU
    PR --> SO
    SO --> CS
    SO --> MS
    
    PR --> VPT
    SO --> VSH
    VPT --> V3D
    VSH --> V3D
    
    V3D --> RG
    RG --> EC
    EC --> OR
    
    GT1 --> PR
    GT1 --> SO
    
    CGAL --> GT1
    GEOS --> GT1
    EIGEN --> GT1
    
    TD --> IP
    VR --> RG

    %% Click Events
    click IP "https://github.com/tudelft3d/val3dity/blob/main/src/input.cpp"
    click GT "https://github.com/tudelft3d/val3dity/blob/main/src/GeometryTemplate.cpp"
    click PR "https://github.com/tudelft3d/val3dity/blob/main/src/Primitive.cpp"
    click SU "https://github.com/tudelft3d/val3dity/blob/main/src/Surface.cpp"
    click SO "https://github.com/tudelft3d/val3dity/blob/main/src/Solid.cpp"
    click CS "https://github.com/tudelft3d/val3dity/blob/main/src/CompositeSolid.cpp"
    click MS "https://github.com/tudelft3d/val3dity/blob/main/src/MultiSolid.cpp"
    click VPT "https://github.com/tudelft3d/val3dity/blob/main/src/validate_prim_toporel.cpp"
    click VSH "https://github.com/tudelft3d/val3dity/blob/main/src/validate_shell.cpp"
    click V3D "https://github.com/tudelft3d/val3dity/blob/main/src/val3dity.cpp"
    click GT1 "https://github.com/tudelft3d/val3dity/blob/main/src/geomtools.cpp"
    click RG "https://github.com/tudelft3d/val3dity/tree/main/report_browser/"
    click TD "https://github.com/tudelft3d/val3dity/tree/main/data/test_geometry_generic/"
    
    %% Styling
    classDef input fill:#3498db
    classDef core fill:#2ecc71
    classDef output fill:#f1c40f
    classDef tools fill:#95a5a6
    classDef external fill:#7f8c8d
    classDef test fill:#e74c3c

    %% Legend
    subgraph Legend
        L1["Input Processing"]:::input
        L2["Core Components"]:::core
        L3["Output Generation"]:::output
        L4["Tools"]:::tools
        L5["External Libraries"]:::external
        L6["Testing"]:::test
    end
```
