# pixaranimationstudios/opensubdiv architecture

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

- Interactive diagram: https://gitdiagram.com/pixaranimationstudios/opensubdiv
- Repository: https://github.com/pixaranimationstudios/opensubdiv

## Overview

##### Main Components
- Core Library Modules:
– There are several core modules spread across the “opensubdiv” directory, each implementing different aspects of subdivision surface processing. Key modules include:
- HBR (Hierarchical Basis Representation): Deals with the hierarchical mesh and editable topology.
- FAR (Feature Adaptive Refinement): Contains algorithms for patch table construction and adaptive refinement.
- OSD (OpenSubdiv): Implements high-performance evaluation kernels for different processing backends.
- SDC (Subdivision Scheme Computations): Provides subdivision scheme definitions and related algorithms.
- BFR (Barycentric Face Representations) and VTR (Vertex-based Refinement): Also play roles in generating limit surfaces and managing intermediate representations.
- Backend Implementations:
- Build and Configuration Infrastructure:
– CMakeLists.txt and the “cmake” directory (including Find* modules) set up the configuration, dependency resolution, and cross-platform build logic.
- Examples, Tutorials, and Regression Tests:
– The “examples”, “tutorials”, and “regression” directories show how the library is integrated into practical applications (e.g., glViewer, dxViewer, mtlViewer) and are valuable for understanding usage patterns.
- Documentation:
– The “documentation” directory and associated scripts provide additional architectural insights and usage guidelines.

##### Representing Relationships and Interactions
- Layered Architecture:
– At the base, represent the core build/configuration layer (with CMake and build scripts) that sets up the build environment and the proper detection of external libraries.
- Backend Abstraction Layer:
- Client and Example Applications:
- External Dependencies:
– Mark external libraries like GLFW, Ptex, CUDA, TBB, OpenCL, DX11 SDK, and Metal. Connect these to the relevant modules (e.g., note that some examples use GLFW for windowing and input, while backend modules depend on CUDA or Metal for GPU acceleration). Also, indicate dependencies on documentation tools (Doxygen, Graphviz, Docutils) for the documentation generation process.

##### Highlighting Architectural Patterns and Design Principles
- Modular, Layered Design:
– Emphasize the separation of concerns (build configuration, core processing, backend-specific evaluation, and example/demo applications).
- Extensibility:
– The use of various CMake build options (evidenced by the numerous “-DNO_*” flags) implies an extensible design where components (like PTex support or OpenMP) can be enabled or disabled.
- Abstraction and Backend Decoupling:
– The system design isolates the high-level algorithms from the hardware-specific implementations via abstraction layers (for instance, similar API calls in OSD that route to either CPU or GPU evaluators).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build and Configuration Layer
    subgraph "Build and Configuration"
        CMS["CMakeLists.txt"]:::build
        CMD["cmake Directory"]:::build
        CONFIG["opensubdiv-config.cmake.in"]:::build
    end

    %% Core Library Modules Layer
    subgraph "Core Library Modules"
        HBR["HBR Module"]:::core
        FAR["FAR Module"]:::core
        SDC["SDC Module"]:::core
        BFR["BFR Module"]:::core
        VTR["VTR Module"]:::core
        OSD["OSD Module"]:::core
    end

    %% Backend Implementations Layer
    subgraph "Backend Implementations"
        BE["Backend Evaluators"]:::backend
    end

    %% Client Applications Layer
    subgraph "Client Applications"
        EX["Examples"]:::client
        TUT["Tutorials"]:::client
        REG["Regression Tests"]:::client
    end

    %% External Dependencies
    subgraph "External Dependencies"
        EXT1["GLFW & Ptex"]:::external
        EXT2["CUDA, OpenCL, DX11, Metal, TBB, OpenMP"]:::external
        EXT3["Documentation Tools"]:::external
    end

    %% Documentation
    DOC["Documentation"]:::core

    %% Connections: Build and Configuration to Core Modules
    CMS -->|"configures"| HBR
    CMD -->|"configures"| HBR
    CONFIG -->|"configures"| HBR

    %% Connections within Core Library Modules
    HBR -->|"provides_topology"| FAR
    FAR -->|"supplies_refinement"| OSD
    FAR -->|"uses_scheme"| SDC
    FAR -->|"uses_representation"| BFR
    FAR -->|"uses_representation"| VTR

    %% Connection from Core to Backend Implementations
    OSD -->|"delegates_evaluation"| BE

    %% Client Applications invoking Core modules
    EX -->|"calls_API"| OSD
    TUT -->|"calls_API"| OSD
    REG -->|"calls_API"| OSD

    %% External Dependencies linked to relevant components
    EXT1 --- HBR
    EXT1 --- OSD
    EXT2 --- BE
    DOC --- EXT3

    %% Documentation linked with Client Applications for guidance
    DOC --- EX
    DOC --- TUT
    DOC --- REG

    %% Click Events
    click HBR "https://github.com/pixaranimationstudios/opensubdiv/tree/release/opensubdiv/hbr"
    click FAR "https://github.com/pixaranimationstudios/opensubdiv/tree/release/opensubdiv/far"
    click OSD "https://github.com/pixaranimationstudios/opensubdiv/tree/release/opensubdiv/osd"
    click SDC "https://github.com/pixaranimationstudios/opensubdiv/tree/release/opensubdiv/sdc"
    click BFR "https://github.com/pixaranimationstudios/opensubdiv/tree/release/opensubdiv/bfr"
    click VTR "https://github.com/pixaranimationstudios/opensubdiv/tree/release/opensubdiv/vtr"
    click BE "https://github.com/pixaranimationstudios/opensubdiv/tree/release/opensubdiv/osd"
    click CMS "https://github.com/pixaranimationstudios/opensubdiv/blob/release/CMakeLists.txt"
    click CMD "https://github.com/pixaranimationstudios/opensubdiv/tree/release/cmake"
    click CONFIG "https://github.com/pixaranimationstudios/opensubdiv/blob/release/opensubdiv-config.cmake.in"
    click EX "https://github.com/pixaranimationstudios/opensubdiv/tree/release/examples"
    click TUT "https://github.com/pixaranimationstudios/opensubdiv/tree/release/tutorials"
    click REG "https://github.com/pixaranimationstudios/opensubdiv/tree/release/regression"
    click DOC "https://github.com/pixaranimationstudios/opensubdiv/tree/release/documentation"

    %% Styles
    classDef build fill:#f4a261, stroke:#333, color:#fff;
    classDef core fill:#2a9d8f, stroke:#333, color:#fff;
    classDef backend fill:#e76f51, stroke:#333, color:#fff;
    classDef client fill:#264653, stroke:#333, color:#fff;
    classDef external fill:#6a994e, stroke:#333, color:#fff;
```
