# hjwdzh/manifoldplus architecture

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

- Interactive diagram: https://gitdiagram.com/hjwdzh/manifoldplus
- Repository: https://github.com/hjwdzh/manifoldplus

## Overview

##### Project type and purpose
- This is a C++ command-line computational geometry tool (“ManifoldPlus”) that ingests arbitrary triangle soup models (OBJ/OFF), processes them through a pipeline of spatial data structures and geometric operations, and outputs a watertight manifold mesh in OBJ format.
- It is neither a web service nor a full-stack app—it is a native executable with a clear linear processing flow.

##### File structure
- Top level
- 3rd_party/ – Embedded Eigen (linear algebra) and LibIGL (geometry utilities) submodules
- CMakeLists.txt, compile.sh, examples.sh – Build and example drivers
- data/, res/ – Sample input meshes and result teaser images
- src/ – Core pipeline code files:
– main.cc – Entry point and orchestration
– Parser.{h,cc} – Command-line argument parsing
– IO.{h,cc} – Model file import/export
– Octree.{h,cc} – Spatial subdivision
– MeshProjector.{h,cc} – Plane-fitting per cell
– Intersection.{h,cc} – Compute cell boundary intersections
– Manifold.{h,cc} – Surface reconstruction onto a watertight mesh
– types.h – Shared data types
- Patterns
- Modular pipeline: each module handles one stage of the geometry workflow
- CMake-driven build, single executable output

##### README for additional insights
- Dependencies: Eigen & LibIGL (submodule init required)
- Usage: “./ManifoldPlus --input input.obj --output output.obj --depth 8”
- Example scripts that loop over data/ to generate results/

##### Detail
- Where Eigen and LibIGL are invoked
- Build system and scripts as part of the development-to-run workflow (compile.sh → build/ → executable)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build System
    compile["/ compile.sh /"]:::scripts
    cmake["CMakeLists.txt"]:::scripts
    compile --> cmake
    cmake --> build["ManifoldPlus (executable)"]:::core

    %% Pipeline Start
    build --> main["main.cc"]:::cli_io
    click main "https://github.com/hjwdzh/manifoldplus/blob/master/src/main.cc"

    %% CLI and Configuration
    main --> parser["Parser"]:::cli_io
    click parser "https://github.com/hjwdzh/manifoldplus/blob/master/src/Parser.cc"
    click parser "https://github.com/hjwdzh/manifoldplus/blob/master/src/Parser.h"

    %% IO Read
    parser --> io_read["IO Module"]:::cli_io
    click io_read "https://github.com/hjwdzh/manifoldplus/blob/master/src/IO.cc"
    click io_read "https://github.com/hjwdzh/manifoldplus/blob/master/src/IO.h"
    io_read --> raw["Raw TriangleSoup"]:::data
    click raw "https://github.com/hjwdzh/manifoldplus/tree/master/data/"

    %% Octree Stage
    raw --> octree["Octree"]:::core
    click octree "https://github.com/hjwdzh/manifoldplus/blob/master/src/Octree.cc"
    click octree "https://github.com/hjwdzh/manifoldplus/blob/master/src/Octree.h"
    octree --> octree_struct["OctreeTree"]:::data

    %% Projection Stage
    octree_struct --> projector["MeshProjector"]:::core
    click projector "https://github.com/hjwdzh/manifoldplus/blob/master/src/MeshProjector.cc"
    click projector "https://github.com/hjwdzh/manifoldplus/blob/master/src/MeshProjector.h"
    projector --> planes["PlaneCoeffs"]:::data

    %% Intersection Stage
    planes --> intersect["Intersection"]:::core
    click intersect "https://github.com/hjwdzh/manifoldplus/blob/master/src/Intersection.cc"
    click intersect "https://github.com/hjwdzh/manifoldplus/blob/master/src/Intersection.h"
    intersect --> points["IntersectionPoints"]:::data

    %% Manifold Reconstruction
    points --> manifold["Manifold"]:::core
    click manifold "https://github.com/hjwdzh/manifoldplus/blob/master/src/Manifold.cc"
    click manifold "https://github.com/hjwdzh/manifoldplus/blob/master/src/Manifold.h"
    manifold --> mesh_final["ManifoldMesh"]:::data

    %% IO Write
    mesh_final --> io_write["IO Module"]:::cli_io
    io_write --> output["output.obj"]:::data
    click output "https://github.com/hjwdzh/manifoldplus/tree/master/res/"

    %% External Libraries
    eigen["Eigen"]:::extlibs
    libigl["LibIGL"]:::extlibs
    eigen -.-> octree
    eigen -.-> projector
    eigen -.-> intersect
    eigen -.-> manifold
    libigl -.-> io_read
    libigl -.-> io_write
    libigl -.-> manifold

    %% Example Runner
    examples["/ examples.sh /"]:::scripts
    examples --> build
    examples --> raw
    examples --> output

    %% Shared Types
    types["types.h"]:::cli_io
    click types "https://github.com/hjwdzh/manifoldplus/blob/master/src/types.h"
    main -.-> types
    parser -.-> types
    io_read -.-> types
    octree -.-> types
    projector -.-> types
    intersect -.-> types
    manifold -.-> types

    %% Classes
    classDef cli_io fill:#FFA500,stroke:#333,stroke-width:1px;
    classDef core fill:#32CD32,stroke:#333,stroke-width:1px;
    classDef extlibs fill:#1E90FF,stroke:#333,stroke-width:1px;
    classDef data fill:#D3D3D3,stroke:#333,stroke-width:1px;
    classDef scripts fill:#CCCCCC,stroke:#333,stroke-width:1px;
```
