# conformallab++

conformallab++ is a modern C++ reimplementation of the [ConformalLab](https://github.com/sechel/conformallab) software by Stefan Sechelmann for experiments in discrete conformal geometry and related mesh transformations.

> **Status:** early prototype stage. API, file formats, and CLI are subject to change.

## Features

- Discrete conformal geometry utilities (Clausen function, hyper-ideal tetrahedra, surface curves)
- Mesh I/O and conversion using CGAL — optional, only needed for the CLI app
- Linear algebra routines with Eigen
- Interactive mesh viewer using libigl / GLFW — optional
- Lightweight CLI with CLI11 and JSON configuration

## Build modes

The project uses three clearly separated CMake modes so you only pull in what you need.

| Mode | CMake flag | What gets built |
|------|-----------|-----------------|
| **Tests only** (default, used in CI) | *(none)* | `conformallab_tests` · deps: Eigen + GTest |
| **Viewer** | `-DWITH_VIEWER=ON` | `viewer` library · deps: libigl / GLFW / GLAD + Eigen |
| **Full app** | `-DWITH_CGAL=ON` | `conformallab_core` CLI + viewer · deps: CGAL + libigl / GLFW / GLAD + Eigen |

`-DWITH_CGAL=ON` automatically enables `WITH_VIEWER` because the CLI app uses the viewer library for mesh visualisation.

External dependencies ship as tarballs in `code/deps/tarballs/` and are extracted lazily at CMake configure time — no internet access needed after cloning (GTest is the only exception: fetched from GitHub via FetchContent).

## Prerequisites

| Tool | Minimum version |
|------|----------------|
| C++ compiler (GCC or Clang) | C++17 |
| CMake | 3.20 |

No system-level libraries are required for the default tests-only build. CGAL and libigl are header-only and bundled in the repo.

## Getting started

```bash
git clone https://codeberg.org/TMoussa/ConformalLabpp
cd ConformalLabpp
```

### Tests only (CI default)

```bash
cmake -S code -B build
cmake --build build --target conformallab_tests -j$(nproc)
ctest --test-dir build --output-on-failure
```

### Full CLI app (CGAL + viewer)

```bash
cmake -S code -B build -DWITH_CGAL=ON
cmake --build build -j$(nproc)
./code/bin/conformallab_core --input data/off/example.off --show
```

### Viewer only (no CGAL)

```bash
cmake -S code -B build -DWITH_VIEWER=ON
cmake --build build --target viewer -j$(nproc)
```

## Project structure

```
code/
├── include/               # Public headers (Clausen, hyper-ideal, mesh utils, …)
├── src/
│   ├── apps/v0/           # conformallab_core CLI app (requires WITH_CGAL)
│   └── viewer/            # simple_viewer (requires WITH_VIEWER)
├── tests/                 # GTest unit tests (always built)
└── deps/
    ├── tarballs/          # Bundled dependency archives
    ├── eigen-3.4.0/       # Header-only linear algebra (always extracted)
    ├── CGAL-6.1.1/        # Header-only geometry (extracted with WITH_CGAL)
    ├── libigl-2.6.0/      # Header-only viewer toolkit (extracted with WITH_VIEWER)
    ├── glfw-3.4/          # Windowing (extracted with WITH_VIEWER)
    ├── libigl-glad/       # OpenGL loader (extracted with WITH_VIEWER)
    └── single_includes/   # CLI11, json.hpp
```

## CI

Tests run automatically on push to `main`, `dev`, and `claude/**` branches via a self-hosted Gitea Actions runner (`eulernest`, ARM64 Raspberry Pi). The pipeline uses a minimal Docker image (`git.eulernest.eu/conformallab/ci-cpp:latest`) with cmake, g++, git, and Node.js 20 pre-installed.

The Dockerfile for the CI image lives in `.gitea/docker/Dockerfile.ci-cpp`. Build and push it once whenever the image needs updating:

```bash
docker buildx build \
  --platform linux/arm64 \
  -f .gitea/docker/Dockerfile.ci-cpp \
  -t git.eulernest.eu/conformallab/ci-cpp:latest \
  --push \
  .gitea/docker/
```

## License

conformallab++ is released under the MIT License (see [LICENSE](LICENSE)).
