diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..4f22c9a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +name: CI + +on: + push: + branches: ["**"] + pull_request: + +jobs: + build-and-test: + name: Build & test (${{ matrix.os }} / ${{ matrix.cxx }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + cxx: [g++, clang++] + exclude: + # macOS g++ is an alias for clang; one clang job there is enough. + - os: macos-latest + cxx: g++ + steps: + - uses: actions/checkout@v4 + + - name: Build (dependency-free, single recipe) + run: make CXX=${{ matrix.cxx }} + + - name: Run test suite + run: ./tests/run_tests.sh ./flatland + + - name: Smoke-test the committed time-series example + run: | + ./flatland examples/sphere_areas/sphere_coarse.obj \ + -b examples/with_fields/timeseries_demo/timeseries.txt -j > /dev/null + + cmake-build: + name: CMake build (Ubuntu) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Configure & build with CMake + run: | + cmake -S src -B build -DCMAKE_BUILD_TYPE=Release + cmake --build build --config Release + - name: Run test suite against CMake binary + run: ./tests/run_tests.sh ./build/flatland diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bf70044 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# Build artifacts +/build/ +src/build/ +/flatland +*.o +*.ppm + +# OS cruft +.DS_Store diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9741c7a --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ +# FlatLand — dependency-free build. +# +# No CMake, no third-party libraries: just a C++17 compiler. Ideal for airgapped +# or minimal systems. +# +# make # build ./flatland +# make test # build, then run the test suite +# make clean # remove build artifacts +# +# Override the compiler if needed: make CXX=clang++ + +CXX ?= c++ +CXXFLAGS ?= -std=c++17 -O2 -Wall +LDFLAGS ?= -pthread +SRC = src/main.cpp +BIN = flatland + +$(BIN): $(SRC) + $(CXX) $(CXXFLAGS) $(SRC) -o $(BIN) $(LDFLAGS) + +.PHONY: test clean +test: $(BIN) + ./tests/run_tests.sh ./$(BIN) + +clean: + rm -f $(BIN) diff --git a/README.md b/README.md index 3a57856..ad3c389 100644 --- a/README.md +++ b/README.md @@ -1,156 +1,193 @@ # FlatLand -FlatLand is a modular C++ utility designed for the geometric analysis and visualization of 3D models via orthographic projection and rasterization. -While primarily focused on computing the projected silhouette and visible surface area of 3D meshes (OBJ format), the latest version introduces scalar field mapping. This allows users to project arbitrary data (e.g., temperature, stress, pressure) defined on nodes or faces onto the 2D viewing plane, generating average value statistics and heatmap visualizations. +FlatLand is a small, dependency-free C++ utility for the geometric analysis of 3D +meshes (OBJ and STL) via orthographic projection and software rasterization. -The tool features a custom Z-buffer implementation for depth testing and edge-function rasterization for high-fidelity coverage calculations. It is optimized for batch processing, supporting runtime precision switching (Float vs Double) and per-view resolution settings. +Its core job is computing the **projected (visible) surface area** of a mesh from +arbitrary viewing angles. On top of that it can map a **scalar field** (defined per +node or per face — temperature, pressure, radiance, stress, …) onto the visible +projection and report per-view statistics: average, min, max, and the **area +integral** `∫ f dA`. The integral is deliberately generic: supply a radiance field +and it is radiant intensity; supply pressure and it is a force; FlatLand itself +stays domain-agnostic. -## Key Features - - **Projected Area Analysis**: Accurate calculation of visible surface area from arbitrary viewing angles. - - **Scalar Data Mapping**: Load external data files (node-based or face-based) to compute visible average values and generate heatmap images. - - **Flexible Batch Mode**: Process thousands of views with a single load of the mesh geometry. Supports overriding resolution and data files per-view. - - **Runtime Precision**: Switch between float (speed) and double (accuracy) arithmetic via CLI flags. - - **Visual Output**: export .ppm heatmaps of the projected mesh. - - **JSON Integration**: Structured output for easy parsing in automated pipelines. +It is built for **time-dependent batches** — sweep thousands of timesteps with a +changing view direction *and* a changing field over a fixed mesh, in seconds. -## Build Instructions -The tool relies on standard C++17 and CMake (3.14+). No third-party dependencies are required. +## Design goals +- **Reliable** — clean error handling (no crashes on bad input), a test suite, and CI. +- **Fast** — multi-threaded batch processing; ~1000 changing-field/changing-view + timesteps on a 70k-triangle mesh in a couple of seconds. +- **Dependency-free** — standard C++17 and nothing else. Builds with a single + compiler invocation, which matters on minimal or airgapped systems. + +## Build + +FlatLand is a single `.cpp` file. No third-party libraries. + +**Simplest recipe (airgapped-friendly):** ```shell -# Clone the repository -git clone https://github.com/Interfluo/flatland.git -cd flatland +make # produces ./flatland +``` -# Build using the provided helper script -./run_build.sh +**Or a single compiler call, no build system at all:** +```shell +c++ -std=c++17 -O2 -pthread src/main.cpp -o flatland ``` -Alternatively, you can build manually via CMake: + +**Or via CMake (3.14+):** ```shell -mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Release -cmake --build . --config Release +cmake -S src -B build -DCMAKE_BUILD_TYPE=Release +cmake --build build ``` -To verify the build: +Verify: ```shell -./build/flatland --help +./flatland --help +make test # build + run the test suite ``` +> The only system requirement is a C++17 compiler with threads (`-pthread`), +> available out of the box with stock GCC or Clang. + ## Usage ```shell ./flatland [options] ``` -### Core options -| Flag | Arguments | Description | -| :--- | :-------- | :---------- | -| -v | x y z | Add a single view direction. Can be repeated multiple times. | -| -b | file | Load views from a batch file (see format below). | -| -o | prefix | "Save heatmap images with this filename prefix (e.g., out_0000.ppm)." | -| -j | none | Output results as structured JSON to stdout. | -| -h | none | Show help message. | -### Simulation Parameters +### Meshes +OBJ and STL (binary or ASCII) are accepted, auto-detected by file extension. STL +triangles carry no shared vertices, so STL fields are face-based. + +### Options | Flag | Arguments | Description | | :--- | :-------- | :---------- | -| -r | val | Set default pixel resolution (default: 0.001). Used if a batch entry doesn't specify one.| -| -d | file | "Path to a default scalar data file (text file, one value per line)."| -| -p | mode | "Set math precision: float (default, faster) or double (higher accuracy)."| -| --no-cull |none | Disable backface culling (renders all matching faces).| +| `-v, --view` | x y z | Add a view direction (vector). Repeatable. | +| `-a, --angle` | az el | Add a view by azimuth/elevation in degrees. Repeatable. | +| `-b, --batch` | file | Load views/timesteps from a file (see format below). Additive with `-v`/`-a`. | +| `-r, --res` | val | Default pixel resolution (default `0.001`). | +| `-d, --data` | file[@col] | Default scalar field file (see [Field files](#field-files)). | +| `--field-mode` | node\|face\|auto | Force field interpretation (default `auto`, inferred from row count). | +| `-p, --precision` | mode | `float` (default, faster) or `double` (more accurate). | +| `-t, --threads` | n | Worker threads for batch views (default: auto / all cores). | +| `--no-cull` | — | Disable backface culling (render all faces). | +| `-o, --out` | prefix | Save PPM heatmaps as `_.ppm`. | +| `-j, --json` | — | Emit structured JSON to stdout. | +| `-h, --help` | — | Show help. | + +### Views +A view is a direction the camera looks along. Specify it as a raw vector (`-v x y z`) +or by **azimuth/elevation in degrees** (`-a az el`), where azimuth sweeps around `+Z` +from `+X` and elevation rises from the XY-plane. Both forms are repeatable and can be +mixed with a batch file. + +### Field files +A field file is a matrix: **one row per mesh entity** (vertex or face), and **one or +more whitespace-separated columns**. Each column is a timestep, so an entire time +series can live in a single file. Append `@` to a data path to pick a column +(default `0`), e.g. `fields.txt@7`. A classic one-value-per-line file is just the +single-column case. Node-vs-face is inferred from the row count; use `--field-mode` +to force it when the vertex and face counts coincide. + +### Per-view outputs +| Field | Meaning | +| :--- | :--- | +| `area` | Visible projected area = `covered_pixels × resolution²`. | +| `average` | Mean field value over visible pixels (requires a data file). | +| `integral` | Area integral of the field: `Σ value × pixel_area` (= radiant intensity, force, …). | +| `min` / `max` | Field extremes over visible pixels. | + +> **Accuracy note:** coverage is computed by point-sampling pixel centers with edge +> functions and a Z-buffer. Area therefore converges as resolution increases; choose +> a resolution fine enough to resolve thin features (use `-o` to inspect). + +## Time-dependent / batch workflow + +The batch file is the time-series interface: **one line per timestep**. Each line is +either a direction vector or an azimuth/elevation angle, followed by an optional +resolution and/or field selector: -### Batch File Format -The batch file (-b) allows for defining mixed-resolution or mixed-data jobs. Each line represents a view. ```text - [resolution] [data_file_path] + [resolution] [data[@col]] # direction vector +a [resolution] [data[@col]] # azimuth / elevation (degrees) ``` - - resolution and data_file_path are optional. - - If omitted, the global defaults (set via -r and -d) are used. - -**Example** views.txt: +- `resolution` and `data` are optional and order-independent — a pure number is read + as a resolution, anything else as a data-file path. Omitted values fall back to + `-r` / `-d`. +- Pair a single field matrix with `@` to advance the field per timestep + (`field.txt@0`, `field.txt@1`, …) without one file per step. +- Relative data paths resolve against the **batch file's directory**, so a case folder + is portable and runs from any working directory. +- Lines starting with `#` are comments. + +Each distinct field file is loaded once into a shared, read-only cache; workers extract +their timestep's column concurrently, so a single shared matrix is never re-parsed +per thread. + +**Example** `timeseries.txt` (orbit in azimuth, advancing one field column per step): ```text -# Standard view using global defaults -1.0 0.0 0.0 - -# High-resolution view (0.005 pixel size) -0.0 1.0 0.0 0.005 +# a field.txt@ +a 0 20 0.002 field.txt@0 +a 15 20 0.002 field.txt@1 +a 30 20 0.002 field.txt@2 +``` +```shell +./flatland part.obj -b timeseries.txt -j > results.json +``` -# View with specific scalar data file overlay -0.0 0.0 1.0 0.002 ./pressure_load_case_2.txt +### Generating a time series +`examples/with_fields/generate_field.py` builds an orbiting-view / evolving-field case +using **only the Python standard library** (no numpy/pyvista). It writes a single +multi-column field file plus an angle-based batch: +```shell +python3 examples/with_fields/generate_field.py bunny.obj data 1000 0.002 +./flatland bunny.obj -b data/timeseries.txt -j > results.json +``` +A small ready-to-run demo (two files: one matrix + one batch) is committed at +`examples/with_fields/timeseries_demo/`: +```shell +./flatland examples/sphere_areas/sphere_coarse.obj \ + -b examples/with_fields/timeseries_demo/timeseries.txt ``` -### Examples -**1. Basic Area Calculation**: Calculate the projected area of bunny.obj from the X-axis using default settings. +## Examples +**1. Basic area** — projected area of the bunny down the X axis: ```shell ./flatland bunny.obj -v 1 0 0 ``` -**2. Heatmap Generation with Double Precision**: Map values from temps.txt onto the mesh, render a heatmap to heat_0000.ppm, using high-precision math. +**2. STL + angle view** — an STL part viewed from azimuth 45°, elevation 30°: +```shell +./flatland part.stl -a 45 30 +``` +**3. Field heatmap, double precision** — map `temps.txt`, render to `heat_0000.ppm`: ```shell ./flatland engine.obj -v 0 1 1 -d temps.txt -p double -o heat ``` -**3. JSON Pipeline**: Run a batch of views defined in views.txt, outputting strict JSON for a Python script to ingest. +**4. Time series from one matrix** — orbit views, one field column per step, to JSON: ```shell -./flatland part.obj -b views.txt -j > results.json +./flatland part.obj -b timeseries.txt -j > results.json ``` -## Benchmarks - -### Benchmark 1: Bunny -In this benchmark, we test the impact of varying resolution (pixel area) against computed projected area and note execution times. We use the [Stanford Bunny](https://docs.pyvista.org/api/examples/_autosummary/pyvista.examples.downloads.download_bunny.html#pyvista.examples.downloads.download_bunny) geometry. - -
- -

Pixel size vs image quality

-
- -The projected area calculation converges as expected, and execution times remain fast even for the highest resolution cases. - - - - - - - - -
- -

Projected Area error for Bunnyn

-
- -

Execution time for Bunny

-
- -*Note, that the lowest resolution image is 4x4 pixels while highest resolution image is 12070x15402 pixels.* - -### Benchmark 2: Sphere -This benchmark exercises the tool on an [Icosphere](https://docs.pyvista.org/api/utilities/_autosummary/pyvista.icosphere -) of varying subdivision levels. This is a vital validation case since the area of a unit sphere is known to be $\pi$ from any view angle. - -
- -

Varying Icosphere subdivision levels

-
+## Validation -The results demonstrate exponential convergence towards the correct analytical answer as mesh and pixel resolution increase. - - - - - - - - -
- -

Projected Area error for Icosphere

-
- -

Execution time for Icosphere

-
- - -## Notes / Tips - -1. **Batch Processing**: For large datasets, always use the batch file (-b) option. Repeatedly calling the tool from the CLI incurs overhead from re-loading and parsing the OBJ file every time. - -2. **Resolution**: Use the image output (-o) to perform a sweep of pixel sizes when setting up a new case. Ensure you are not under-resolving thin geometry features. - -3. **Culling**: Running without back-face culling (--no-cull) is supported but rarely necessary unless you are dealing with non-manifold or open surface meshes where "inside" faces contribute to the silhouette. +Two analytical checks (also enforced by the test suite): +- **Cube** — the projected area of a unit cube along an axis is exactly `1`. +- **Sphere** — the projected area of a unit sphere is `π` from any direction; FlatLand + converges to `π` as mesh and pixel resolution increase. +Run the suite (dependency-free, bash + awk): +```shell +make test # or: ./tests/run_tests.sh +``` +CI builds with GCC and Clang (Linux + macOS) and via CMake on every push — see +`.github/workflows/ci.yml`. + +## Tips +1. **Batch over repeated CLI calls** — one `-b` run loads and parses the mesh once; + repeatedly invoking the binary re-parses the OBJ every time. +2. **Pick resolution deliberately** — sweep `-r` with `-o` image output when setting up + a new case so thin geometry isn't under-resolved. +3. **Threads** — batch views run in parallel automatically; cap with `-t` if you need + to leave cores free. +4. **Culling** — `--no-cull` is for non-manifold or open surfaces where "inside" faces + should still contribute to the silhouette. diff --git a/examples/with_fields/cases.txt b/examples/with_fields/cases.txt deleted file mode 100644 index a4c2d8f..0000000 --- a/examples/with_fields/cases.txt +++ /dev/null @@ -1,9 +0,0 @@ -# nx ny nz r file -1 0 0 0.0001 data/face_field_0.txt -1 0 0 0.0001 data/node_field_0.txt -0 1 0 0.0001 data/node_field_0.txt -0 0 1 0.0001 data/node_field_0.txt -0 1 0 0.0001 data/node_field_5.txt -0 1 0 0.0001 data/node_field_20.txt -0 1 0 0.0010 data/node_field_20.txt -0 1 0 0.0100 data/node_field_20.txt \ No newline at end of file diff --git a/examples/with_fields/generate_field.py b/examples/with_fields/generate_field.py index 38c017d..37c9d1e 100644 --- a/examples/with_fields/generate_field.py +++ b/examples/with_fields/generate_field.py @@ -1,21 +1,77 @@ -import numpy as np -import pyvista as pv +#!/usr/bin/env python3 +"""Generate a time-dependent FlatLand case: orbiting view + evolving scalar field. +Dependency-free: parses the OBJ itself and uses only the Python standard library +(no numpy / pyvista), so the example reproduces with a stock Python 3. -def save_field(filename, values): - lines = [f"{i}\n" for i in values] - - with open(filename, "w") as f: - f.writelines(lines) - return None +It writes a single multi-column field file (one row per vertex, one column per +timestep) and a batch file whose lines select a column per timestep: + + a field.txt@ + +The whole time series therefore lives in two files regardless of step count. + +Usage: + python3 generate_field.py [num_steps] [resolution] + +Example: + python3 generate_field.py bunny.obj data 1000 0.002 + ../../src/build/flatland bunny.obj -b data/timeseries.txt -j > results.json +""" +import math +import os +import sys + + +def load_vertices(path): + verts = [] + with open(path) as f: + for line in f: + if line.startswith("v "): + _, x, y, z = line.split()[:4] + verts.append((float(x), float(y), float(z))) + if not verts: + raise SystemExit(f"no vertices found in {path}") + return verts + + +def main(): + if len(sys.argv) < 3: + raise SystemExit(__doc__) + mesh = sys.argv[1] + out_dir = sys.argv[2] + steps = int(sys.argv[3]) if len(sys.argv) > 3 else 200 + res = float(sys.argv[4]) if len(sys.argv) > 4 else 0.001 + + verts = load_vertices(mesh) + os.makedirs(out_dir, exist_ok=True) + + # Normalize x into [0, 1] so the traveling wave is mesh-independent. + xs = [v[0] for v in verts] + x0, x1 = min(xs), max(xs) + span = (x1 - x0) or 1.0 + nx = [(v[0] - x0) / span for v in verts] + + # One field column per timestep; a wave that sweeps along x as time advances. + freq = 4.0 + field_path = os.path.join(out_dir, "field.txt") + with open(field_path, "w") as ff: + for i in range(len(verts)): + row = (f"{math.sin(freq * math.pi * nx[i] - 2.0 * math.pi * t / steps):.6f}" + for t in range(steps)) + ff.write(" ".join(row) + "\n") + + # Batch: orbit the mesh in azimuth (slight tilt), one column per timestep. + # Field path is a bare name; FlatLand resolves it against the batch file's dir. + batch_path = os.path.join(out_dir, "timeseries.txt") + with open(batch_path, "w") as batch: + batch.write("# a field.txt@\n") + for t in range(steps): + az = 360.0 * t / steps + batch.write(f"a {az:.4f} 20 {res} field.txt@{t}\n") + + print(f"Wrote {steps}-column field to {field_path} and batch to {batch_path}") if __name__ == "__main__": - mesh = pv.read("bunny.obj") - - for i, v in enumerate(np.linspace(4, 20, 21)): - node_field = np.sin(np.pi*v*mesh.points[:, 0]) - face_field = np.sin(np.pi*v*mesh.cell_centers().points[:, 0]) - - save_field(f"data/node_field_{i}.txt", node_field) - save_field(f"data/face_field_{i}.txt", face_field) + main() diff --git a/examples/with_fields/timeseries_demo/field.txt b/examples/with_fields/timeseries_demo/field.txt new file mode 100644 index 0000000..f5f399e --- /dev/null +++ b/examples/with_fields/timeseries_demo/field.txt @@ -0,0 +1,162 @@ +-0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 +-0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 +-0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 +0.160970 0.410929 0.632884 0.811709 0.935217 0.994992 0.986959 0.911667 0.774247 0.584062 0.354075 0.099958 -0.160970 -0.410929 -0.632884 -0.811709 -0.935217 -0.994992 -0.986959 -0.911667 -0.774247 -0.584062 -0.354075 -0.099958 +0.160970 0.410929 0.632884 0.811709 0.935217 0.994992 0.986959 0.911667 0.774247 0.584062 0.354075 0.099958 -0.160970 -0.410929 -0.632884 -0.811709 -0.935217 -0.994992 -0.986959 -0.911667 -0.774247 -0.584062 -0.354075 -0.099958 +-0.160970 0.099958 0.354075 0.584062 0.774247 0.911667 0.986959 0.994992 0.935217 0.811709 0.632884 0.410929 0.160970 -0.099958 -0.354075 -0.584062 -0.774247 -0.911667 -0.986959 -0.994992 -0.935217 -0.811709 -0.632884 -0.410929 +-0.160970 0.099958 0.354075 0.584062 0.774247 0.911667 0.986959 0.994992 0.935217 0.811709 0.632884 0.410929 0.160970 -0.099958 -0.354075 -0.584062 -0.774247 -0.911667 -0.986959 -0.994992 -0.935217 -0.811709 -0.632884 -0.410929 +-0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 +-0.806606 -0.932107 -0.994086 -0.988320 -0.915201 -0.779713 -0.591089 -0.362183 -0.108595 0.152393 0.402997 0.626137 0.806606 0.932107 0.994086 0.988320 0.915201 0.779713 0.591089 0.362183 0.108595 -0.152393 -0.402997 -0.626137 +0.806606 0.626137 0.402997 0.152393 -0.108595 -0.362183 -0.591089 -0.779713 -0.915201 -0.988320 -0.994086 -0.932107 -0.806606 -0.626137 -0.402997 -0.152393 0.108595 0.362183 0.591089 0.779713 0.915201 0.988320 0.994086 0.932107 +0.806606 0.626137 0.402997 0.152393 -0.108595 -0.362183 -0.591089 -0.779713 -0.915201 -0.988320 -0.994086 -0.932107 -0.806606 -0.626137 -0.402997 -0.152393 0.108595 0.362183 0.591089 0.779713 0.915201 0.988320 0.994086 0.932107 +-0.806606 -0.932107 -0.994086 -0.988320 -0.915201 -0.779713 -0.591089 -0.362183 -0.108595 0.152393 0.402997 0.626137 0.806606 0.932107 0.994086 0.988320 0.915201 0.779713 0.591089 0.362183 0.108595 -0.152393 -0.402997 -0.626137 +0.932032 0.994064 0.988351 0.915284 0.779842 0.591255 0.362375 0.108800 -0.152190 -0.402809 -0.625976 -0.806485 -0.932032 -0.994064 -0.988351 -0.915284 -0.779842 -0.591255 -0.362375 -0.108800 0.152190 0.402809 0.625976 0.806485 +-0.932032 -0.806485 -0.625976 -0.402809 -0.152190 0.108800 0.362375 0.591255 0.779842 0.915284 0.988351 0.994064 0.932032 0.806485 0.625976 0.402809 0.152190 -0.108800 -0.362375 -0.591255 -0.779842 -0.915284 -0.988351 -0.994064 +-0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 +-0.932032 -0.806485 -0.625976 -0.402809 -0.152190 0.108800 0.362375 0.591255 0.779842 0.915284 0.988351 0.994064 0.932032 0.806485 0.625976 0.402809 0.152190 -0.108800 -0.362375 -0.591255 -0.779842 -0.915284 -0.988351 -0.994064 +0.932032 0.994064 0.988351 0.915284 0.779842 0.591255 0.362375 0.108800 -0.152190 -0.402809 -0.625976 -0.806485 -0.932032 -0.994064 -0.988351 -0.915284 -0.779842 -0.591255 -0.362375 -0.108800 0.152190 0.402809 0.625976 0.806485 +-0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 +0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 +0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 +0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 -0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 +0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 -0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 +-0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 +0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 -0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 +0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 -0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 +0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 +0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 +0.932032 0.994064 0.988351 0.915284 0.779842 0.591255 0.362375 0.108800 -0.152190 -0.402809 -0.625976 -0.806485 -0.932032 -0.994064 -0.988351 -0.915284 -0.779842 -0.591255 -0.362375 -0.108800 0.152190 0.402809 0.625976 0.806485 +-0.932032 -0.806485 -0.625976 -0.402809 -0.152190 0.108800 0.362375 0.591255 0.779842 0.915284 0.988351 0.994064 0.932032 0.806485 0.625976 0.402809 0.152190 -0.108800 -0.362375 -0.591255 -0.779842 -0.915284 -0.988351 -0.994064 +-0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 +-0.932032 -0.806485 -0.625976 -0.402809 -0.152190 0.108800 0.362375 0.591255 0.779842 0.915284 0.988351 0.994064 0.932032 0.806485 0.625976 0.402809 0.152190 -0.108800 -0.362375 -0.591255 -0.779842 -0.915284 -0.988351 -0.994064 +0.932032 0.994064 0.988351 0.915284 0.779842 0.591255 0.362375 0.108800 -0.152190 -0.402809 -0.625976 -0.806485 -0.932032 -0.994064 -0.988351 -0.915284 -0.779842 -0.591255 -0.362375 -0.108800 0.152190 0.402809 0.625976 0.806485 +0.932032 0.806485 0.625976 0.402809 0.152190 -0.108800 -0.362375 -0.591255 -0.779842 -0.915284 -0.988351 -0.994064 -0.932032 -0.806485 -0.625976 -0.402809 -0.152190 0.108800 0.362375 0.591255 0.779842 0.915284 0.988351 0.994064 +0.932032 0.806485 0.625976 0.402809 0.152190 -0.108800 -0.362375 -0.591255 -0.779842 -0.915284 -0.988351 -0.994064 -0.932032 -0.806485 -0.625976 -0.402809 -0.152190 0.108800 0.362375 0.591255 0.779842 0.915284 0.988351 0.994064 +0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 -0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 +0.932032 0.806485 0.625976 0.402809 0.152190 -0.108800 -0.362375 -0.591255 -0.779842 -0.915284 -0.988351 -0.994064 -0.932032 -0.806485 -0.625976 -0.402809 -0.152190 0.108800 0.362375 0.591255 0.779842 0.915284 0.988351 0.994064 +0.932032 0.806485 0.625976 0.402809 0.152190 -0.108800 -0.362375 -0.591255 -0.779842 -0.915284 -0.988351 -0.994064 -0.932032 -0.806485 -0.625976 -0.402809 -0.152190 0.108800 0.362375 0.591255 0.779842 0.915284 0.988351 0.994064 +-0.932032 -0.994064 -0.988351 -0.915284 -0.779842 -0.591255 -0.362375 -0.108800 0.152190 0.402809 0.625976 0.806485 0.932032 0.994064 0.988351 0.915284 0.779842 0.591255 0.362375 0.108800 -0.152190 -0.402809 -0.625976 -0.806485 +-0.932032 -0.994064 -0.988351 -0.915284 -0.779842 -0.591255 -0.362375 -0.108800 0.152190 0.402809 0.625976 0.806485 0.932032 0.994064 0.988351 0.915284 0.779842 0.591255 0.362375 0.108800 -0.152190 -0.402809 -0.625976 -0.806485 +-0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 +-0.932032 -0.994064 -0.988351 -0.915284 -0.779842 -0.591255 -0.362375 -0.108800 0.152190 0.402809 0.625976 0.806485 0.932032 0.994064 0.988351 0.915284 0.779842 0.591255 0.362375 0.108800 -0.152190 -0.402809 -0.625976 -0.806485 +-0.932032 -0.994064 -0.988351 -0.915284 -0.779842 -0.591255 -0.362375 -0.108800 0.152190 0.402809 0.625976 0.806485 0.932032 0.994064 0.988351 0.915284 0.779842 0.591255 0.362375 0.108800 -0.152190 -0.402809 -0.625976 -0.806485 +0.800141 0.617634 0.393036 0.141653 -0.119383 -0.372283 -0.599813 -0.786466 -0.919523 -0.989916 -0.992848 -0.928119 -0.800141 -0.617634 -0.393036 -0.141653 0.119383 0.372283 0.599813 0.786466 0.919523 0.989916 0.992848 0.928119 +-0.800141 -0.928119 -0.992848 -0.989916 -0.919523 -0.786466 -0.599813 -0.372283 -0.119383 0.141653 0.393036 0.617634 0.800141 0.928119 0.992848 0.989916 0.919523 0.786466 0.599813 0.372283 0.119383 -0.141653 -0.393036 -0.617634 +-0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 +-0.852508 -0.958748 -0.999651 -0.972429 -0.878937 -0.725548 -0.522714 -0.284257 -0.026429 0.233200 0.476937 0.688172 0.852508 0.958748 0.999651 0.972429 0.878937 0.725548 0.522714 0.284257 0.026429 -0.233200 -0.476937 -0.688172 +-0.351342 -0.097052 0.163852 0.413590 0.635143 0.813411 0.936247 0.995279 0.986485 0.910463 0.772395 0.581689 0.351342 0.097052 -0.163852 -0.413590 -0.635143 -0.813411 -0.936247 -0.995279 -0.986485 -0.910463 -0.772395 -0.581689 +-0.959869 -0.854576 -0.691046 -0.480422 -0.237058 0.022461 0.280450 0.519326 0.722811 0.877038 0.971496 0.999748 0.959869 0.854576 0.691046 0.480422 0.237058 -0.022461 -0.280450 -0.519326 -0.722811 -0.877038 -0.971496 -0.999748 +0.852508 0.688172 0.476937 0.233200 -0.026429 -0.284257 -0.522714 -0.725548 -0.878937 -0.972429 -0.999651 -0.958748 -0.852508 -0.688172 -0.476937 -0.233200 0.026429 0.284257 0.522714 0.725548 0.878937 0.972429 0.999651 0.958748 +0.959869 0.999748 0.971496 0.877038 0.722811 0.519326 0.280450 0.022461 -0.237058 -0.480422 -0.691046 -0.854576 -0.959869 -0.999748 -0.971496 -0.877038 -0.722811 -0.519326 -0.280450 -0.022461 0.237058 0.480422 0.691046 0.854576 +0.351342 0.581689 0.772395 0.910463 0.986485 0.995279 0.936247 0.813411 0.635143 0.413590 0.163852 -0.097052 -0.351342 -0.581689 -0.772395 -0.910463 -0.986485 -0.995279 -0.936247 -0.813411 -0.635143 -0.413590 -0.163852 0.097052 +-0.800141 -0.928119 -0.992848 -0.989916 -0.919523 -0.786466 -0.599813 -0.372283 -0.119383 0.141653 0.393036 0.617634 0.800141 0.928119 0.992848 0.989916 0.919523 0.786466 0.599813 0.372283 0.119383 -0.141653 -0.393036 -0.617634 +0.800141 0.617634 0.393036 0.141653 -0.119383 -0.372283 -0.599813 -0.786466 -0.919523 -0.989916 -0.992848 -0.928119 -0.800141 -0.617634 -0.393036 -0.141653 0.119383 0.372283 0.599813 0.786466 0.919523 0.989916 0.992848 0.928119 +-0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 +0.852508 0.688172 0.476937 0.233200 -0.026429 -0.284257 -0.522714 -0.725548 -0.878937 -0.972429 -0.999651 -0.958748 -0.852508 -0.688172 -0.476937 -0.233200 0.026429 0.284257 0.522714 0.725548 0.878937 0.972429 0.999651 0.958748 +0.351342 0.581689 0.772395 0.910463 0.986485 0.995279 0.936247 0.813411 0.635143 0.413590 0.163852 -0.097052 -0.351342 -0.581689 -0.772395 -0.910463 -0.986485 -0.995279 -0.936247 -0.813411 -0.635143 -0.413590 -0.163852 0.097052 +-0.852508 -0.958748 -0.999651 -0.972429 -0.878937 -0.725548 -0.522714 -0.284257 -0.026429 0.233200 0.476937 0.688172 0.852508 0.958748 0.999651 0.972429 0.878937 0.725548 0.522714 0.284257 0.026429 -0.233200 -0.476937 -0.688172 +-0.351342 -0.097052 0.163852 0.413590 0.635143 0.813411 0.936247 0.995279 0.986485 0.910463 0.772395 0.581689 0.351342 0.097052 -0.163852 -0.413590 -0.635143 -0.813411 -0.936247 -0.995279 -0.986485 -0.910463 -0.772395 -0.581689 +-0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 +-0.997549 -0.981667 -0.898886 -0.754847 -0.559366 -0.325766 -0.069965 0.190604 0.438183 0.655901 0.828921 0.945451 0.997549 0.981667 0.898886 0.754847 0.559366 0.325766 0.069965 -0.190604 -0.438183 -0.655901 -0.828921 -0.945451 +-0.996734 -0.941872 -0.822823 -0.647700 -0.428437 -0.179977 0.080749 0.335971 0.568298 0.761896 0.903572 0.983671 0.996734 0.941872 0.822823 0.647700 0.428437 0.179977 -0.080749 -0.335971 -0.568298 -0.761896 -0.903572 -0.983671 +0.160970 0.410929 0.632884 0.811709 0.935217 0.994992 0.986959 0.911667 0.774247 0.584063 0.354076 0.099959 -0.160970 -0.410929 -0.632884 -0.811709 -0.935217 -0.994992 -0.986959 -0.911667 -0.774247 -0.584063 -0.354076 -0.099959 +0.978017 0.998662 0.951250 0.839012 0.669596 0.454549 0.208525 -0.051710 -0.308421 -0.544113 -0.742725 -0.890722 -0.978017 -0.998662 -0.951250 -0.839012 -0.669596 -0.454549 -0.208525 0.051710 0.308421 0.544113 0.742725 0.890722 +0.978017 0.998662 0.951250 0.839012 0.669596 0.454549 0.208525 -0.051710 -0.308421 -0.544113 -0.742725 -0.890722 -0.978017 -0.998662 -0.951250 -0.839012 -0.669596 -0.454549 -0.208525 0.051710 0.308421 0.544113 0.742725 0.890722 +-0.996734 -0.941872 -0.822823 -0.647700 -0.428437 -0.179977 0.080749 0.335971 0.568298 0.761896 0.903572 0.983671 0.996734 0.941872 0.822823 0.647700 0.428437 0.179977 -0.080749 -0.335971 -0.568298 -0.761896 -0.903572 -0.983671 +-0.997549 -0.981667 -0.898886 -0.754847 -0.559366 -0.325766 -0.069965 0.190604 0.438183 0.655901 0.828921 0.945451 0.997549 0.981667 0.898886 0.754847 0.559366 0.325766 0.069965 -0.190604 -0.438183 -0.655901 -0.828921 -0.945451 +-0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 +0.997549 0.945451 0.828921 0.655901 0.438183 0.190604 -0.069965 -0.325766 -0.559366 -0.754847 -0.898886 -0.981667 -0.997549 -0.945451 -0.828921 -0.655901 -0.438183 -0.190604 0.069965 0.325766 0.559366 0.754847 0.898886 0.981667 +0.996734 0.983671 0.903572 0.761896 0.568298 0.335971 0.080749 -0.179977 -0.428437 -0.647700 -0.822823 -0.941872 -0.996734 -0.983671 -0.903572 -0.761896 -0.568298 -0.335971 -0.080749 0.179977 0.428437 0.647700 0.822823 0.941872 +0.996734 0.983671 0.903572 0.761896 0.568298 0.335971 0.080749 -0.179977 -0.428437 -0.647700 -0.822823 -0.941872 -0.996734 -0.983671 -0.903572 -0.761896 -0.568298 -0.335971 -0.080749 0.179977 0.428437 0.647700 0.822823 0.941872 +0.997549 0.945451 0.828921 0.655901 0.438183 0.190604 -0.069965 -0.325766 -0.559366 -0.754847 -0.898886 -0.981667 -0.997549 -0.945451 -0.828921 -0.655901 -0.438183 -0.190604 0.069965 0.325766 0.559366 0.754847 0.898886 0.981667 +-0.160970 0.099959 0.354076 0.584063 0.774247 0.911667 0.986959 0.994992 0.935217 0.811709 0.632884 0.410929 0.160970 -0.099959 -0.354076 -0.584063 -0.774247 -0.911667 -0.986959 -0.994992 -0.935217 -0.811709 -0.632884 -0.410929 +-0.978017 -0.890722 -0.742725 -0.544113 -0.308421 -0.051710 0.208525 0.454549 0.669596 0.839012 0.951250 0.998662 0.978017 0.890722 0.742725 0.544113 0.308421 0.051710 -0.208525 -0.454549 -0.669596 -0.839012 -0.951250 -0.998662 +-0.978017 -0.890722 -0.742725 -0.544113 -0.308421 -0.051710 0.208525 0.454549 0.669596 0.839012 0.951250 0.998662 0.978017 0.890722 0.742725 0.544113 0.308421 0.051710 -0.208525 -0.454549 -0.669596 -0.839012 -0.951250 -0.998662 +-0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 +0.997549 0.945451 0.828921 0.655901 0.438183 0.190604 -0.069965 -0.325766 -0.559366 -0.754847 -0.898886 -0.981667 -0.997549 -0.945451 -0.828921 -0.655901 -0.438183 -0.190604 0.069965 0.325766 0.559366 0.754847 0.898886 0.981667 +0.996734 0.983671 0.903572 0.761896 0.568298 0.335971 0.080749 -0.179977 -0.428437 -0.647700 -0.822823 -0.941872 -0.996734 -0.983671 -0.903572 -0.761896 -0.568298 -0.335971 -0.080749 0.179977 0.428437 0.647700 0.822823 0.941872 +-0.160970 0.099959 0.354076 0.584063 0.774247 0.911667 0.986959 0.994992 0.935217 0.811709 0.632884 0.410929 0.160970 -0.099959 -0.354076 -0.584063 -0.774247 -0.911667 -0.986959 -0.994992 -0.935217 -0.811709 -0.632884 -0.410929 +-0.978017 -0.890722 -0.742725 -0.544113 -0.308421 -0.051710 0.208525 0.454549 0.669596 0.839012 0.951250 0.998662 0.978017 0.890722 0.742725 0.544113 0.308421 0.051710 -0.208525 -0.454549 -0.669596 -0.839012 -0.951250 -0.998662 +-0.978017 -0.890722 -0.742725 -0.544113 -0.308421 -0.051710 0.208525 0.454549 0.669596 0.839012 0.951250 0.998662 0.978017 0.890722 0.742725 0.544113 0.308421 0.051710 -0.208525 -0.454549 -0.669596 -0.839012 -0.951250 -0.998662 +0.996734 0.983671 0.903572 0.761896 0.568298 0.335971 0.080749 -0.179977 -0.428437 -0.647700 -0.822823 -0.941872 -0.996734 -0.983671 -0.903572 -0.761896 -0.568298 -0.335971 -0.080749 0.179977 0.428437 0.647700 0.822823 0.941872 +0.997549 0.945451 0.828921 0.655901 0.438183 0.190604 -0.069965 -0.325766 -0.559366 -0.754847 -0.898886 -0.981667 -0.997549 -0.945451 -0.828921 -0.655901 -0.438183 -0.190604 0.069965 0.325766 0.559366 0.754847 0.898886 0.981667 +-0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 +-0.997549 -0.981667 -0.898886 -0.754847 -0.559366 -0.325766 -0.069965 0.190604 0.438183 0.655901 0.828921 0.945451 0.997549 0.981667 0.898886 0.754847 0.559366 0.325766 0.069965 -0.190604 -0.438183 -0.655901 -0.828921 -0.945451 +-0.996734 -0.941872 -0.822823 -0.647700 -0.428437 -0.179977 0.080749 0.335971 0.568298 0.761896 0.903572 0.983671 0.996734 0.941872 0.822823 0.647700 0.428437 0.179977 -0.080749 -0.335971 -0.568298 -0.761896 -0.903572 -0.983671 +-0.996734 -0.941872 -0.822823 -0.647700 -0.428437 -0.179977 0.080749 0.335971 0.568298 0.761896 0.903572 0.983671 0.996734 0.941872 0.822823 0.647700 0.428437 0.179977 -0.080749 -0.335971 -0.568298 -0.761896 -0.903572 -0.983671 +-0.997549 -0.981667 -0.898886 -0.754847 -0.559366 -0.325766 -0.069965 0.190604 0.438183 0.655901 0.828921 0.945451 0.997549 0.981667 0.898886 0.754847 0.559366 0.325766 0.069965 -0.190604 -0.438183 -0.655901 -0.828921 -0.945451 +0.160970 0.410929 0.632884 0.811709 0.935217 0.994992 0.986959 0.911667 0.774247 0.584063 0.354076 0.099959 -0.160970 -0.410929 -0.632884 -0.811709 -0.935217 -0.994992 -0.986959 -0.911667 -0.774247 -0.584063 -0.354076 -0.099959 +0.978017 0.998662 0.951250 0.839012 0.669596 0.454549 0.208525 -0.051710 -0.308421 -0.544113 -0.742725 -0.890722 -0.978017 -0.998662 -0.951250 -0.839012 -0.669596 -0.454549 -0.208525 0.051710 0.308421 0.544113 0.742725 0.890722 +0.978017 0.998662 0.951250 0.839012 0.669596 0.454549 0.208525 -0.051710 -0.308421 -0.544113 -0.742725 -0.890722 -0.978017 -0.998662 -0.951250 -0.839012 -0.669596 -0.454549 -0.208525 0.051710 0.308421 0.544113 0.742725 0.890722 +0.800141 0.617634 0.393036 0.141653 -0.119383 -0.372283 -0.599813 -0.786466 -0.919523 -0.989916 -0.992848 -0.928119 -0.800141 -0.617634 -0.393036 -0.141653 0.119383 0.372283 0.599813 0.786466 0.919523 0.989916 0.992848 0.928119 +-0.800141 -0.928119 -0.992848 -0.989916 -0.919523 -0.786466 -0.599813 -0.372283 -0.119383 0.141653 0.393036 0.617634 0.800141 0.928119 0.992848 0.989916 0.919523 0.786466 0.599813 0.372283 0.119383 -0.141653 -0.393036 -0.617634 +-0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 +-0.852508 -0.958748 -0.999651 -0.972429 -0.878937 -0.725548 -0.522714 -0.284257 -0.026429 0.233200 0.476937 0.688172 0.852508 0.958748 0.999651 0.972429 0.878937 0.725548 0.522714 0.284257 0.026429 -0.233200 -0.476937 -0.688172 +-0.351342 -0.097052 0.163852 0.413590 0.635143 0.813411 0.936247 0.995279 0.986485 0.910463 0.772395 0.581689 0.351342 0.097052 -0.163852 -0.413590 -0.635143 -0.813411 -0.936247 -0.995279 -0.986485 -0.910463 -0.772395 -0.581689 +-0.959869 -0.854576 -0.691046 -0.480422 -0.237058 0.022461 0.280450 0.519326 0.722811 0.877038 0.971496 0.999748 0.959869 0.854576 0.691046 0.480422 0.237058 -0.022461 -0.280450 -0.519326 -0.722811 -0.877038 -0.971496 -0.999748 +0.852508 0.688172 0.476937 0.233200 -0.026429 -0.284257 -0.522714 -0.725548 -0.878937 -0.972429 -0.999651 -0.958748 -0.852508 -0.688172 -0.476937 -0.233200 0.026429 0.284257 0.522714 0.725548 0.878937 0.972429 0.999651 0.958748 +0.959869 0.999748 0.971496 0.877038 0.722811 0.519326 0.280450 0.022461 -0.237058 -0.480422 -0.691046 -0.854576 -0.959869 -0.999748 -0.971496 -0.877038 -0.722811 -0.519326 -0.280450 -0.022461 0.237058 0.480422 0.691046 0.854576 +0.351342 0.581689 0.772395 0.910463 0.986485 0.995279 0.936247 0.813411 0.635143 0.413590 0.163852 -0.097052 -0.351342 -0.581689 -0.772395 -0.910463 -0.986485 -0.995279 -0.936247 -0.813411 -0.635143 -0.413590 -0.163852 0.097052 +-0.800141 -0.928119 -0.992848 -0.989916 -0.919523 -0.786466 -0.599813 -0.372283 -0.119383 0.141653 0.393036 0.617634 0.800141 0.928119 0.992848 0.989916 0.919523 0.786466 0.599813 0.372283 0.119383 -0.141653 -0.393036 -0.617634 +0.800141 0.617634 0.393036 0.141653 -0.119383 -0.372283 -0.599813 -0.786466 -0.919523 -0.989916 -0.992848 -0.928119 -0.800141 -0.617634 -0.393036 -0.141653 0.119383 0.372283 0.599813 0.786466 0.919523 0.989916 0.992848 0.928119 +-0.000000 -0.258819 -0.500000 -0.707107 -0.866025 -0.965926 -1.000000 -0.965926 -0.866025 -0.707107 -0.500000 -0.258819 0.000000 0.258819 0.500000 0.707107 0.866025 0.965926 1.000000 0.965926 0.866025 0.707107 0.500000 0.258819 +0.852508 0.688172 0.476937 0.233200 -0.026429 -0.284257 -0.522714 -0.725548 -0.878937 -0.972429 -0.999651 -0.958748 -0.852508 -0.688172 -0.476937 -0.233200 0.026429 0.284257 0.522714 0.725548 0.878937 0.972429 0.999651 0.958748 +0.351342 0.581689 0.772395 0.910463 0.986485 0.995279 0.936247 0.813411 0.635143 0.413590 0.163852 -0.097052 -0.351342 -0.581689 -0.772395 -0.910463 -0.986485 -0.995279 -0.936247 -0.813411 -0.635143 -0.413590 -0.163852 0.097052 +-0.852508 -0.958748 -0.999651 -0.972429 -0.878937 -0.725548 -0.522714 -0.284257 -0.026429 0.233200 0.476937 0.688172 0.852508 0.958748 0.999651 0.972429 0.878937 0.725548 0.522714 0.284257 0.026429 -0.233200 -0.476937 -0.688172 +-0.351342 -0.097052 0.163852 0.413590 0.635143 0.813411 0.936247 0.995279 0.986485 0.910463 0.772395 0.581689 0.351342 0.097052 -0.163852 -0.413590 -0.635143 -0.813411 -0.936247 -0.995279 -0.986485 -0.910463 -0.772395 -0.581689 +0.909371 0.986050 0.995531 0.937169 0.814940 0.637174 0.415986 0.166449 -0.094431 -0.348876 -0.579546 -0.770720 -0.909371 -0.986050 -0.995531 -0.937169 -0.814940 -0.637174 -0.415986 -0.166449 0.094431 0.348876 0.579546 0.770720 +0.909371 0.986050 0.995531 0.937169 0.814940 0.637174 0.415986 0.166449 -0.094431 -0.348876 -0.579546 -0.770720 -0.909371 -0.986050 -0.995531 -0.937169 -0.814940 -0.637174 -0.415986 -0.166449 0.094431 0.348876 0.579546 0.770720 +0.806607 0.626137 0.402997 0.152394 -0.108595 -0.362183 -0.591089 -0.779713 -0.915201 -0.988320 -0.994086 -0.932107 -0.806607 -0.626137 -0.402997 -0.152394 0.108595 0.362183 0.591089 0.779713 0.915201 0.988320 0.994086 0.932107 +0.302696 0.045705 -0.214401 -0.459896 -0.674049 -0.842268 -0.953087 -0.998955 -0.976746 -0.887973 -0.738686 -0.539059 -0.302696 -0.045705 0.214401 0.459896 0.674049 0.842268 0.953087 0.998955 0.976746 0.887973 0.738686 0.539059 +0.753476 0.557635 0.323792 0.067883 -0.192652 -0.440059 -0.657475 -0.830086 -0.946128 -0.997693 -0.981267 -0.897969 -0.753476 -0.557635 -0.323792 -0.067883 0.192652 0.440059 0.657475 0.830086 0.946128 0.997693 0.981267 0.897969 +0.276440 0.018288 -0.241111 -0.484079 -0.694057 -0.856737 -0.961031 -0.999833 -0.970498 -0.875024 -0.719920 -0.515754 -0.276440 -0.018288 0.241111 0.484079 0.694057 0.856737 0.961031 0.999833 0.970498 0.875024 0.719920 0.515754 +0.302696 0.045705 -0.214401 -0.459896 -0.674049 -0.842268 -0.953087 -0.998955 -0.976746 -0.887973 -0.738686 -0.539059 -0.302696 -0.045705 0.214401 0.459896 0.674049 0.842268 0.953087 0.998955 0.976746 0.887973 0.738686 0.539059 +0.276440 0.018288 -0.241111 -0.484079 -0.694057 -0.856737 -0.961031 -0.999833 -0.970498 -0.875024 -0.719920 -0.515754 -0.276440 -0.018288 0.241111 0.484079 0.694057 0.856737 0.961031 0.999833 0.970498 0.875024 0.719920 0.515754 +0.753476 0.557635 0.323792 0.067883 -0.192652 -0.440059 -0.657475 -0.830086 -0.946128 -0.997693 -0.981267 -0.897969 -0.753476 -0.557635 -0.323792 -0.067883 0.192652 0.440059 0.657475 0.830086 0.946128 0.997693 0.981267 0.897969 +0.909371 0.986050 0.995531 0.937169 0.814940 0.637174 0.415986 0.166449 -0.094431 -0.348876 -0.579546 -0.770720 -0.909371 -0.986050 -0.995531 -0.937169 -0.814940 -0.637174 -0.415986 -0.166449 0.094431 0.348876 0.579546 0.770720 +0.909371 0.986050 0.995531 0.937169 0.814940 0.637174 0.415986 0.166449 -0.094431 -0.348876 -0.579546 -0.770720 -0.909371 -0.986050 -0.995531 -0.937169 -0.814940 -0.637174 -0.415986 -0.166449 0.094431 0.348876 0.579546 0.770720 +0.806607 0.626137 0.402997 0.152394 -0.108595 -0.362183 -0.591089 -0.779713 -0.915201 -0.988320 -0.994086 -0.932107 -0.806607 -0.626137 -0.402997 -0.152394 0.108595 0.362183 0.591089 0.779713 0.915201 0.988320 0.994086 0.932107 +0.302696 0.045705 -0.214401 -0.459896 -0.674049 -0.842268 -0.953087 -0.998955 -0.976746 -0.887973 -0.738686 -0.539059 -0.302696 -0.045705 0.214401 0.459896 0.674049 0.842268 0.953087 0.998955 0.976746 0.887973 0.738686 0.539059 +0.753476 0.557635 0.323792 0.067883 -0.192652 -0.440059 -0.657475 -0.830086 -0.946128 -0.997693 -0.981267 -0.897969 -0.753476 -0.557635 -0.323792 -0.067883 0.192652 0.440059 0.657475 0.830086 0.946128 0.997693 0.981267 0.897969 +0.302696 0.045705 -0.214401 -0.459896 -0.674049 -0.842268 -0.953087 -0.998955 -0.976746 -0.887973 -0.738686 -0.539059 -0.302696 -0.045705 0.214401 0.459896 0.674049 0.842268 0.953087 0.998955 0.976746 0.887973 0.738686 0.539059 +0.753476 0.557635 0.323792 0.067883 -0.192652 -0.440059 -0.657475 -0.830086 -0.946128 -0.997693 -0.981267 -0.897969 -0.753476 -0.557635 -0.323792 -0.067883 0.192652 0.440059 0.657475 0.830086 0.946128 0.997693 0.981267 0.897969 +-0.909371 -0.770720 -0.579546 -0.348876 -0.094431 0.166449 0.415986 0.637174 0.814940 0.937169 0.995531 0.986050 0.909371 0.770720 0.579546 0.348876 0.094431 -0.166449 -0.415986 -0.637174 -0.814940 -0.937169 -0.995531 -0.986050 +-0.909371 -0.770720 -0.579546 -0.348876 -0.094431 0.166449 0.415986 0.637174 0.814940 0.937169 0.995531 0.986050 0.909371 0.770720 0.579546 0.348876 0.094431 -0.166449 -0.415986 -0.637174 -0.814940 -0.937169 -0.995531 -0.986050 +-0.806607 -0.932107 -0.994086 -0.988320 -0.915201 -0.779713 -0.591089 -0.362183 -0.108595 0.152394 0.402997 0.626137 0.806607 0.932107 0.994086 0.988320 0.915201 0.779713 0.591089 0.362183 0.108595 -0.152394 -0.402997 -0.626137 +-0.302696 -0.539059 -0.738686 -0.887973 -0.976746 -0.998955 -0.953087 -0.842268 -0.674049 -0.459896 -0.214401 0.045705 0.302696 0.539059 0.738686 0.887973 0.976746 0.998955 0.953087 0.842268 0.674049 0.459896 0.214401 -0.045705 +-0.753476 -0.897969 -0.981267 -0.997693 -0.946128 -0.830086 -0.657475 -0.440059 -0.192652 0.067883 0.323792 0.557635 0.753476 0.897969 0.981267 0.997693 0.946128 0.830086 0.657475 0.440059 0.192652 -0.067883 -0.323792 -0.557635 +-0.276440 -0.515754 -0.719920 -0.875024 -0.970498 -0.999833 -0.961031 -0.856737 -0.694057 -0.484079 -0.241111 0.018288 0.276440 0.515754 0.719920 0.875024 0.970498 0.999833 0.961031 0.856737 0.694057 0.484079 0.241111 -0.018288 +-0.302696 -0.539059 -0.738686 -0.887973 -0.976746 -0.998955 -0.953087 -0.842268 -0.674049 -0.459896 -0.214401 0.045705 0.302696 0.539059 0.738686 0.887973 0.976746 0.998955 0.953087 0.842268 0.674049 0.459896 0.214401 -0.045705 +-0.276440 -0.515754 -0.719920 -0.875024 -0.970498 -0.999833 -0.961031 -0.856737 -0.694057 -0.484079 -0.241111 0.018288 0.276440 0.515754 0.719920 0.875024 0.970498 0.999833 0.961031 0.856737 0.694057 0.484079 0.241111 -0.018288 +-0.753476 -0.897969 -0.981267 -0.997693 -0.946128 -0.830086 -0.657475 -0.440059 -0.192652 0.067883 0.323792 0.557635 0.753476 0.897969 0.981267 0.997693 0.946128 0.830086 0.657475 0.440059 0.192652 -0.067883 -0.323792 -0.557635 +-0.909371 -0.770720 -0.579546 -0.348876 -0.094431 0.166449 0.415986 0.637174 0.814940 0.937169 0.995531 0.986050 0.909371 0.770720 0.579546 0.348876 0.094431 -0.166449 -0.415986 -0.637174 -0.814940 -0.937169 -0.995531 -0.986050 +-0.909371 -0.770720 -0.579546 -0.348876 -0.094431 0.166449 0.415986 0.637174 0.814940 0.937169 0.995531 0.986050 0.909371 0.770720 0.579546 0.348876 0.094431 -0.166449 -0.415986 -0.637174 -0.814940 -0.937169 -0.995531 -0.986050 +-0.806607 -0.932107 -0.994086 -0.988320 -0.915201 -0.779713 -0.591089 -0.362183 -0.108595 0.152394 0.402997 0.626137 0.806607 0.932107 0.994086 0.988320 0.915201 0.779713 0.591089 0.362183 0.108595 -0.152394 -0.402997 -0.626137 +-0.302696 -0.539059 -0.738686 -0.887973 -0.976746 -0.998955 -0.953087 -0.842268 -0.674049 -0.459896 -0.214401 0.045705 0.302696 0.539059 0.738686 0.887973 0.976746 0.998955 0.953087 0.842268 0.674049 0.459896 0.214401 -0.045705 +-0.753476 -0.897969 -0.981267 -0.997693 -0.946128 -0.830086 -0.657475 -0.440059 -0.192652 0.067883 0.323792 0.557635 0.753476 0.897969 0.981267 0.997693 0.946128 0.830086 0.657475 0.440059 0.192652 -0.067883 -0.323792 -0.557635 +-0.302696 -0.539059 -0.738686 -0.887973 -0.976746 -0.998955 -0.953087 -0.842268 -0.674049 -0.459896 -0.214401 0.045705 0.302696 0.539059 0.738686 0.887973 0.976746 0.998955 0.953087 0.842268 0.674049 0.459896 0.214401 -0.045705 +-0.753476 -0.897969 -0.981267 -0.997693 -0.946128 -0.830086 -0.657475 -0.440059 -0.192652 0.067883 0.323792 0.557635 0.753476 0.897969 0.981267 0.997693 0.946128 0.830086 0.657475 0.440059 0.192652 -0.067883 -0.323792 -0.557635 +-0.452168 -0.205911 0.054378 0.310961 0.546353 0.744511 0.891933 0.978571 0.998520 0.950423 0.837555 0.667610 0.452168 0.205911 -0.054378 -0.310961 -0.546353 -0.744511 -0.891933 -0.978571 -0.998520 -0.950423 -0.837555 -0.667610 +0.524026 0.726607 0.879671 0.972787 0.999609 0.958309 0.851702 0.687053 0.475583 0.231702 -0.027969 -0.285734 -0.524026 -0.726607 -0.879671 -0.972787 -0.999609 -0.958309 -0.851702 -0.687053 -0.475583 -0.231702 0.027969 0.285734 +0.925532 0.992002 0.990869 0.922209 0.790703 0.605311 0.378669 0.126221 -0.134829 -0.386691 -0.612200 -0.795989 -0.925532 -0.992002 -0.990869 -0.922209 -0.790703 -0.605311 -0.378669 -0.126221 0.134829 0.386691 0.612200 0.795989 +0.452168 0.667610 0.837555 0.950423 0.998520 0.978571 0.891933 0.744511 0.546353 0.310961 0.054378 -0.205911 -0.452168 -0.667610 -0.837555 -0.950423 -0.998520 -0.978571 -0.891933 -0.744511 -0.546353 -0.310961 -0.054378 0.205911 +-0.925532 -0.795989 -0.612200 -0.386691 -0.134829 0.126221 0.378669 0.605311 0.790703 0.922209 0.990869 0.992002 0.925532 0.795989 0.612200 0.386691 0.134829 -0.126221 -0.378669 -0.605311 -0.790703 -0.922209 -0.990869 -0.992002 +-0.524026 -0.285734 -0.027969 0.231702 0.475583 0.687053 0.851702 0.958309 0.999609 0.972787 0.879671 0.726607 0.524026 0.285734 0.027969 -0.231702 -0.475583 -0.687053 -0.851702 -0.958309 -0.999609 -0.972787 -0.879671 -0.726607 +-0.452168 -0.205911 0.054378 0.310961 0.546353 0.744511 0.891933 0.978571 0.998520 0.950423 0.837555 0.667610 0.452168 0.205911 -0.054378 -0.310961 -0.546353 -0.744511 -0.891933 -0.978571 -0.998520 -0.950423 -0.837555 -0.667610 +0.925532 0.992002 0.990869 0.922209 0.790703 0.605311 0.378669 0.126221 -0.134829 -0.386691 -0.612200 -0.795989 -0.925532 -0.992002 -0.990869 -0.922209 -0.790703 -0.605311 -0.378669 -0.126221 0.134829 0.386691 0.612200 0.795989 +0.524026 0.726607 0.879671 0.972787 0.999609 0.958309 0.851702 0.687053 0.475583 0.231702 -0.027969 -0.285734 -0.524026 -0.726607 -0.879671 -0.972787 -0.999609 -0.958309 -0.851702 -0.687053 -0.475583 -0.231702 0.027969 0.285734 +0.452168 0.667610 0.837555 0.950423 0.998520 0.978571 0.891933 0.744511 0.546353 0.310961 0.054378 -0.205911 -0.452168 -0.667610 -0.837555 -0.950423 -0.998520 -0.978571 -0.891933 -0.744511 -0.546353 -0.310961 -0.054378 0.205911 +-0.524026 -0.285734 -0.027969 0.231702 0.475583 0.687053 0.851702 0.958309 0.999609 0.972787 0.879671 0.726607 0.524026 0.285734 0.027969 -0.231702 -0.475583 -0.687053 -0.851702 -0.958309 -0.999609 -0.972787 -0.879671 -0.726607 +-0.925532 -0.795989 -0.612200 -0.386691 -0.134829 0.126221 0.378669 0.605311 0.790703 0.922209 0.990869 0.992002 0.925532 0.795989 0.612200 0.386691 0.134829 -0.126221 -0.378669 -0.605311 -0.790703 -0.922209 -0.990869 -0.992002 +-0.452168 -0.205911 0.054378 0.310961 0.546353 0.744511 0.891933 0.978571 0.998520 0.950423 0.837555 0.667610 0.452168 0.205911 -0.054378 -0.310961 -0.546353 -0.744511 -0.891933 -0.978571 -0.998520 -0.950423 -0.837555 -0.667610 +0.524026 0.726607 0.879671 0.972787 0.999609 0.958309 0.851702 0.687053 0.475583 0.231702 -0.027969 -0.285734 -0.524026 -0.726607 -0.879671 -0.972787 -0.999609 -0.958309 -0.851702 -0.687053 -0.475583 -0.231702 0.027969 0.285734 +0.925532 0.992002 0.990869 0.922209 0.790703 0.605311 0.378669 0.126221 -0.134829 -0.386691 -0.612200 -0.795989 -0.925532 -0.992002 -0.990869 -0.922209 -0.790703 -0.605311 -0.378669 -0.126221 0.134829 0.386691 0.612200 0.795989 +0.452168 0.667610 0.837555 0.950423 0.998520 0.978571 0.891933 0.744511 0.546353 0.310961 0.054378 -0.205911 -0.452168 -0.667610 -0.837555 -0.950423 -0.998520 -0.978571 -0.891933 -0.744511 -0.546353 -0.310961 -0.054378 0.205911 +-0.925532 -0.795989 -0.612200 -0.386691 -0.134829 0.126221 0.378669 0.605311 0.790703 0.922209 0.990869 0.992002 0.925532 0.795989 0.612200 0.386691 0.134829 -0.126221 -0.378669 -0.605311 -0.790703 -0.922209 -0.990869 -0.992002 +-0.524026 -0.285734 -0.027969 0.231702 0.475583 0.687053 0.851702 0.958309 0.999609 0.972787 0.879671 0.726607 0.524026 0.285734 0.027969 -0.231702 -0.475583 -0.687053 -0.851702 -0.958309 -0.999609 -0.972787 -0.879671 -0.726607 +-0.452168 -0.205911 0.054378 0.310961 0.546353 0.744511 0.891933 0.978571 0.998520 0.950423 0.837555 0.667610 0.452168 0.205911 -0.054378 -0.310961 -0.546353 -0.744511 -0.891933 -0.978571 -0.998520 -0.950423 -0.837555 -0.667610 +0.925532 0.992002 0.990869 0.922209 0.790703 0.605311 0.378669 0.126221 -0.134829 -0.386691 -0.612200 -0.795989 -0.925532 -0.992002 -0.990869 -0.922209 -0.790703 -0.605311 -0.378669 -0.126221 0.134829 0.386691 0.612200 0.795989 +0.524026 0.726607 0.879671 0.972787 0.999609 0.958309 0.851702 0.687053 0.475583 0.231702 -0.027969 -0.285734 -0.524026 -0.726607 -0.879671 -0.972787 -0.999609 -0.958309 -0.851702 -0.687053 -0.475583 -0.231702 0.027969 0.285734 +0.452168 0.667610 0.837555 0.950423 0.998520 0.978571 0.891933 0.744511 0.546353 0.310961 0.054378 -0.205911 -0.452168 -0.667610 -0.837555 -0.950423 -0.998520 -0.978571 -0.891933 -0.744511 -0.546353 -0.310961 -0.054378 0.205911 +-0.524026 -0.285734 -0.027969 0.231702 0.475583 0.687053 0.851702 0.958309 0.999609 0.972787 0.879671 0.726607 0.524026 0.285734 0.027969 -0.231702 -0.475583 -0.687053 -0.851702 -0.958309 -0.999609 -0.972787 -0.879671 -0.726607 +-0.925532 -0.795989 -0.612200 -0.386691 -0.134829 0.126221 0.378669 0.605311 0.790703 0.922209 0.990869 0.992002 0.925532 0.795989 0.612200 0.386691 0.134829 -0.126221 -0.378669 -0.605311 -0.790703 -0.922209 -0.990869 -0.992002 diff --git a/examples/with_fields/timeseries_demo/timeseries.txt b/examples/with_fields/timeseries_demo/timeseries.txt new file mode 100644 index 0000000..fe140a5 --- /dev/null +++ b/examples/with_fields/timeseries_demo/timeseries.txt @@ -0,0 +1,25 @@ +# a field.txt@ +a 0.0000 20 0.02 field.txt@0 +a 15.0000 20 0.02 field.txt@1 +a 30.0000 20 0.02 field.txt@2 +a 45.0000 20 0.02 field.txt@3 +a 60.0000 20 0.02 field.txt@4 +a 75.0000 20 0.02 field.txt@5 +a 90.0000 20 0.02 field.txt@6 +a 105.0000 20 0.02 field.txt@7 +a 120.0000 20 0.02 field.txt@8 +a 135.0000 20 0.02 field.txt@9 +a 150.0000 20 0.02 field.txt@10 +a 165.0000 20 0.02 field.txt@11 +a 180.0000 20 0.02 field.txt@12 +a 195.0000 20 0.02 field.txt@13 +a 210.0000 20 0.02 field.txt@14 +a 225.0000 20 0.02 field.txt@15 +a 240.0000 20 0.02 field.txt@16 +a 255.0000 20 0.02 field.txt@17 +a 270.0000 20 0.02 field.txt@18 +a 285.0000 20 0.02 field.txt@19 +a 300.0000 20 0.02 field.txt@20 +a 315.0000 20 0.02 field.txt@21 +a 330.0000 20 0.02 field.txt@22 +a 345.0000 20 0.02 field.txt@23 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 887ba53..c640215 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,22 +1,22 @@ -cmake_minimum_required(VERSION 3.14) # A reasonably modern version; works everywhere +cmake_minimum_required(VERSION 3.14) project(FlatLand - VERSION 0.1 - DESCRIPTION "Projected Areas of arbitrary meshesl" + VERSION 2.0 + DESCRIPTION "Projected-area and field analysis of arbitrary meshes" LANGUAGES CXX) -# Set the C++ standard you need (adjust if you're using features from newer standards) -set(CMAKE_CXX_STANDARD 17) # Or 11, 14, 20, 23 depending on your code +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) # Use strict ISO C++ (good for portability) +set(CMAKE_CXX_EXTENSIONS OFF) # strict ISO C++ for portability -# Create the executable -add_executable(flatland main.cpp) # "mytool" is the output binary name; change if you want - -# Optional: Enable optimizations for release builds (default is fine otherwise) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() -# Optional: Install target (copies binary to a standard location when you run `cmake --install`) +add_executable(flatland main.cpp) + +# std::thread needs the platform threading library (e.g. -pthread on glibc). +find_package(Threads REQUIRED) +target_link_libraries(flatland PRIVATE Threads::Threads) + install(TARGETS flatland DESTINATION bin) diff --git a/src/main.cpp b/src/main.cpp index 90d070b..07eb471 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,11 +2,20 @@ // main.cpp // FlatLand // -// Features: -// - Runtime precision switching (Float vs Double) -// - Flexible Batch Mode (Per-view resolution & data files) -// - Edge Function Rasterization -// - JSON Metadata +// Orthographic projection + rasterization for geometric analysis of 3D meshes. +// +// Core capabilities: +// - Projected (silhouette / visible) surface area from arbitrary view directions +// - Generic per-view field statistics over the visible projection: +// average, min, max, and the AREA INTEGRAL ∫ f dA = Σ value · pixel_area. +// The integral is the building block for quantities such as radiant +// intensity (supply a radiance field) — FlatLand stays domain-agnostic. +// - Runtime precision switching (float / double) +// - Batch mode with per-view resolution and data files +// - Parallel batch processing (standard library threads only) +// - PPM heatmap export and structured JSON output +// +// No third-party dependencies. C++17. // #include @@ -19,8 +28,17 @@ #include #include #include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* ---------------------- Math & Structs (Templated) @@ -37,26 +55,34 @@ struct TriProjected { }; struct Triangle3D { - int v0_idx, v1_idx, v2_idx; // Indices into vertex array - // We store indices to allow re-fetching vertices if precision changes (though here we load once) + int v0_idx, v1_idx, v2_idx; // Indices into the vertex array }; enum ValueMode { MODE_NONE, MODE_NODE, MODE_FACE }; +// Read-only geometry, loaded once and shared across all views/threads. template struct Mesh { std::vector> vertices; std::vector faces; +}; + +// A scalar field defined on the mesh. Kept separate from Mesh so different +// views can use different fields without mutating shared state (thread-safe). +template +struct Field { std::vector values; - ValueMode val_mode = MODE_NONE; + ValueMode mode = MODE_NONE; }; template struct ViewResult { + bool has_field = false; T area = 0; T average_value = 0; - T min_val = std::numeric_limits::max(); - T max_val = -std::numeric_limits::max(); + T integral = 0; // Σ value · pixel_area (the area integral of the field) + T min_val = 0; + T max_val = 0; double time_seconds = 0.0; long covered_pixels = 0; int image_width = 0; @@ -78,8 +104,16 @@ template inline Vec3 cross(const Vec3& a, const Vec3& b) { template inline Vec3 operator-(const Vec3& a, const Vec3& b) { return {a.x - b.x, a.y - b.y, a.z - b.z}; } template inline Vec3 normalize(const Vec3& v) { T n = std::sqrt(dot(v,v)); return n>0 ? Vec3{v.x/n, v.y/n, v.z/n} : Vec3{0,0,0}; } +// Convert an azimuth/elevation pair (degrees) into a unit view direction. +// Azimuth sweeps around +Z measured from +X; elevation rises above the XY plane. +inline Vec3 angle_to_dir(double az_deg, double el_deg) { + const double PI = 3.14159265358979323846; + double az = az_deg * PI / 180.0, el = el_deg * PI / 180.0; + return { std::cos(el)*std::cos(az), std::cos(el)*std::sin(az), std::sin(el) }; +} + /* ---------------------- - Renderer + Renderer (one per worker thread) ---------------------- */ template class Renderer { @@ -91,12 +125,12 @@ class Renderer { void resize(int w, int h, bool use_vals) { size_t needed = (size_t)w * h; - if (needed == 0) return; + if (needed == 0) { Nx = Ny = 0; return; } Nx = w; Ny = h; if (zbuffer.size() < needed) zbuffer.resize(needed); if (mask.size() < needed) mask.resize(needed); if (use_vals && val_buffer.size() < needed) val_buffer.resize(needed); - + std::fill(zbuffer.begin(), zbuffer.begin() + needed, std::numeric_limits::max()); std::fill(mask.begin(), mask.begin() + needed, 0); if (use_vals) std::fill(val_buffer.begin(), val_buffer.begin() + needed, 0); @@ -112,7 +146,7 @@ inline T edge_eval(const Vec2& a, const Vec2& b, const Vec2& p) { } template -void rasterize(const TriProjected& tri, Renderer& r, T xmin, T ymin, T pix_sz) { +void rasterize(const TriProjected& tri, Renderer& r, T xmin, T ymin, T pix_sz, bool use_vals) { T min_x = std::min({tri.v0.x, tri.v1.x, tri.v2.x}); T max_x = std::max({tri.v0.x, tri.v1.x, tri.v2.x}); T min_y = std::min({tri.v0.y, tri.v1.y, tri.v2.y}); @@ -123,14 +157,14 @@ void rasterize(const TriProjected& tri, Renderer& r, T xmin, T ymin, T pix int iy_min = std::max(0, static_cast((min_y - ymin)/pix_sz)); int iy_max = std::min(r.Ny - 1, static_cast((max_y - ymin)/pix_sz)); - Vec2 p_start = { xmin + (ix_min + 0.5f)*pix_sz, ymin + (iy_min + 0.5f)*pix_sz }; - - // Edge Functions Setup + Vec2 p_start = { xmin + (ix_min + (T)0.5)*pix_sz, ymin + (iy_min + (T)0.5)*pix_sz }; + + // Edge function values at the first sampled pixel center T w0_row = edge_eval(tri.v1, tri.v2, p_start); T w1_row = edge_eval(tri.v2, tri.v0, p_start); T w2_row = edge_eval(tri.v0, tri.v1, p_start); - - // Increments + + // Per-pixel increments T A0 = (tri.v2.y - tri.v1.y)*pix_sz, B0 = (tri.v1.x - tri.v2.x)*pix_sz; T A1 = (tri.v0.y - tri.v2.y)*pix_sz, B1 = (tri.v2.x - tri.v0.x)*pix_sz; T A2 = (tri.v1.y - tri.v0.y)*pix_sz, B2 = (tri.v0.x - tri.v1.x)*pix_sz; @@ -144,7 +178,7 @@ void rasterize(const TriProjected& tri, Renderer& r, T xmin, T ymin, T pix if (z < r.zbuffer[idx]) { r.zbuffer[idx] = z; r.mask[idx] = 1; - if (!r.val_buffer.empty()) + if (use_vals) r.val_buffer[idx] = (w0*tri.val0 + w1*tri.val1 + w2*tri.val2)*tri.inv_area; } } @@ -157,13 +191,13 @@ void rasterize(const TriProjected& tri, Renderer& r, T xmin, T ymin, T pix /* ---------------------- IO & Loaders ---------------------- */ -// Templated OBJ loader to support Float/Double +// Templated OBJ loader (vertices + triangulated faces) to support float/double. template Mesh load_obj(const std::string& filename) { Mesh mesh; std::ifstream file(filename); - if (!file.is_open()) throw std::runtime_error("Cannot open " + filename); - + if (!file.is_open()) throw std::runtime_error("cannot open mesh file '" + filename + "'"); + std::string line; while (std::getline(file, line)) { if (line.empty() || line[0] == '#') continue; @@ -188,50 +222,194 @@ Mesh load_obj(const std::string& filename) { return mesh; } +// STL loader, auto-detecting binary vs ASCII. STL stores independent per-triangle +// vertices (no shared indexing), so each triangle contributes three fresh vertices. template -void load_values(const std::string& filename, Mesh& mesh) { - if (filename.empty()) return; - mesh.values.clear(); - std::ifstream file(filename); - if (!file.is_open()) throw std::runtime_error("Cannot open data file " + filename); - double v; - while (file >> v) mesh.values.push_back((T)v); - - if (mesh.values.size() == mesh.vertices.size()) mesh.val_mode = MODE_NODE; - else if (mesh.values.size() == mesh.faces.size()) mesh.val_mode = MODE_FACE; - else throw std::runtime_error("Data size mismatch: " + std::to_string(mesh.values.size())); +Mesh load_stl(const std::string& filename) { + std::ifstream file(filename, std::ios::binary); + if (!file.is_open()) throw std::runtime_error("cannot open mesh file '" + filename + "'"); + std::string buf((std::istreambuf_iterator(file)), std::istreambuf_iterator()); + Mesh mesh; + + // A binary STL is exactly 84 + 50*ntri bytes; this is the robust discriminator + // (the leading "solid" keyword is NOT reliable — some binary files contain it). + bool binary = false; + uint32_t ntri = 0; + if (buf.size() >= 84) { + std::memcpy(&ntri, buf.data() + 80, 4); + if (buf.size() == 84ull + 50ull * ntri) binary = true; + } + + if (binary) { + mesh.vertices.reserve((size_t)ntri * 3); + mesh.faces.reserve(ntri); + for (uint32_t t = 0; t < ntri; ++t) { + const char* tri = buf.data() + 84 + (size_t)t * 50; + float v[9]; + std::memcpy(v, tri + 12, 36); // skip the 12-byte facet normal, read 3 vertices + int base = (int)mesh.vertices.size(); + mesh.vertices.push_back({(T)v[0],(T)v[1],(T)v[2]}); + mesh.vertices.push_back({(T)v[3],(T)v[4],(T)v[5]}); + mesh.vertices.push_back({(T)v[6],(T)v[7],(T)v[8]}); + mesh.faces.push_back({base, base+1, base+2}); + } + } else { + std::istringstream is(buf); + std::string line, tok; + int vc = 0; + while (std::getline(is, line)) { + std::istringstream ls(line); + if (!(ls >> tok) || tok != "vertex") continue; + double x,y,z; + if (ls >> x >> y >> z) { + mesh.vertices.push_back({(T)x,(T)y,(T)z}); + if (++vc == 3) { int b=(int)mesh.vertices.size()-3; mesh.faces.push_back({b,b+1,b+2}); vc=0; } + } + } + } + return mesh; +} + +// Dispatch by file extension (.stl -> STL, otherwise OBJ), then validate. +template +Mesh load_mesh(const std::string& filename) { + auto ends_with_ci = [&](const char* ext) { + size_t n = std::strlen(ext); + if (filename.size() < n) return false; + for (size_t i=0;i mesh = ends_with_ci(".stl") ? load_stl(filename) : load_obj(filename); + + if (mesh.vertices.empty()) throw std::runtime_error("mesh '" + filename + "' contains no vertices"); + if (mesh.faces.empty()) throw std::runtime_error("mesh '" + filename + "' contains no faces"); + + // Guard against malformed files: every face index must reference a real vertex, + // otherwise process_view would read out of bounds. + const int nv = (int)mesh.vertices.size(); + for (const auto& f : mesh.faces) { + if (f.v0_idx < 0 || f.v0_idx >= nv || + f.v1_idx < 0 || f.v1_idx >= nv || + f.v2_idx < 0 || f.v2_idx >= nv) + throw std::runtime_error("mesh '" + filename + "' references an out-of-range vertex index"); + } + return mesh; +} + +/* ---------------------- + Scalar Fields + ---------------------- + A field file is a matrix: one row per mesh entity (vertex or face), one or more + whitespace-separated columns. A column is a timestep, so a whole time series can + live in ONE file. The classic "one value per line" file is just the single-column + case. A data token may select a column with a trailing '@' (default 0). */ + +struct FieldToken { std::string path; size_t col; }; + +// Split "path@3" into {"path", 3}; a bare path means column 0. +inline FieldToken parse_field_token(const std::string& token) { + size_t at = token.find_last_of('@'); + if (at != std::string::npos && at + 1 < token.size()) { + const std::string num = token.substr(at + 1); + if (num.find_first_not_of("0123456789") == std::string::npos) + return { token.substr(0, at), (size_t)std::stoul(num) }; + } + return { token, 0 }; +} + +template +struct FieldMatrix { + std::vector data; // row-major: data[row*ncols + col] + size_t nrows = 0, ncols = 0; + ValueMode mode = MODE_NONE; +}; + +// Load a field matrix and decide node-vs-face from the row count (or `forced`). +template +void load_matrix_into(const std::string& filename, const Mesh& mesh, + FieldMatrix& m, ValueMode forced) { + std::ifstream file(filename, std::ios::binary); + if (!file.is_open()) throw std::runtime_error("cannot open data file '" + filename + "'"); + m.data.clear(); m.nrows = 0; m.ncols = 0; + + std::string line; + while (std::getline(file, line)) { + size_t c = line.find('#'); + if (c != std::string::npos) line = line.substr(0, c); + const char* p = line.c_str(); char* end; + size_t before = m.data.size(); + double d = std::strtod(p, &end); + while (end != p) { m.data.push_back((T)d); p = end; d = std::strtod(p, &end); } + size_t got = m.data.size() - before; + if (got == 0) continue; // blank / comment-only line + if (m.ncols == 0) m.ncols = got; + else if (got != m.ncols) + throw std::runtime_error("data file '" + filename + "' row " + std::to_string(m.nrows+1) + + " has " + std::to_string(got) + " columns, expected " + std::to_string(m.ncols)); + ++m.nrows; + } + if (m.nrows == 0) throw std::runtime_error("data file '" + filename + "' has no values"); + + if (forced != MODE_NONE) { + size_t need = (forced == MODE_NODE) ? mesh.vertices.size() : mesh.faces.size(); + if (m.nrows != need) + throw std::runtime_error("data file '" + filename + "' has " + std::to_string(m.nrows) + + " rows but mesh has " + std::to_string(need) + + (forced == MODE_NODE ? " vertices (--field-mode node)" : " faces (--field-mode face)")); + m.mode = forced; + } else if (m.nrows == mesh.vertices.size()) { + m.mode = MODE_NODE; + } else if (m.nrows == mesh.faces.size()) { + m.mode = MODE_FACE; + } else { + throw std::runtime_error("data file '" + filename + "' has " + std::to_string(m.nrows) + + " rows, but mesh has " + std::to_string(mesh.vertices.size()) + " vertices / " + + std::to_string(mesh.faces.size()) + " faces; use --field-mode to disambiguate"); + } +} + +template +void extract_column(const FieldMatrix& m, size_t col, Field& out) { + if (col >= m.ncols) + throw std::runtime_error("field column " + std::to_string(col) + + " out of range (file has " + std::to_string(m.ncols) + " column(s))"); + out.values.resize(m.nrows); + for (size_t r = 0; r < m.nrows; ++r) out.values[r] = m.data[r * m.ncols + col]; + out.mode = m.mode; } /* ---------------------- Image Output ---------------------- */ template -void save_ppm(const Renderer& r, const std::string& fname, T min_v, T max_v) { +void save_ppm(const Renderer& r, const std::string& fname, T min_v, T max_v, bool use_vals) { std::ofstream f(fname, std::ios::binary); - if (!f.is_open()) return; + if (!f.is_open()) throw std::runtime_error("cannot write image '" + fname + "'"); f << "P6\n" << r.Nx << " " << r.Ny << "\n255\n"; double range = (double)(max_v - min_v); if (std::abs(range) < 1e-9) range = 1.0; const uint8_t bg[3] = {30,30,35}; - - // Simple heatmap colors + + // Simple 5-stop heatmap (blue -> cyan -> yellow -> orange -> red) const double stops[5][3] = {{0,0,1}, {0,1,1}, {1,1,0}, {1,.5,0}, {1,0,0}}; - + for (int iy=r.Ny-1; iy>=0; --iy) { for (int ix=0; ix= 4) idx = 3; double fr = t - idx; - uint8_t rgb[3]; for(int c=0;c<3;++c) rgb[c] = (uint8_t)(((1.0-fr)*stops[idx][c] + fr*stops[idx+1][c])*255); - if (r.val_buffer.empty()) { rgb[0]=rgb[1]=rgb[2]=255; } - f.write((char*)rgb, 3); } + f.write((const char*)rgb, 3); } } } @@ -240,17 +418,20 @@ void save_ppm(const Renderer& r, const std::string& fname, T min_v, T max_v) Processing Pipeline ---------------------- */ template -ViewResult process_view(const Vec3& view_dir, const Mesh& mesh, T pix_sz, bool cull, Renderer& renderer) { +ViewResult process_view(const Vec3& view_dir, const Mesh& mesh, const Field* field, + T pix_sz, bool cull, Renderer& renderer) { auto t0 = std::chrono::high_resolution_clock::now(); ViewResult res; - - // Basis + const bool use_vals = (field && field->mode != MODE_NONE); + res.has_field = use_vals; + + // Orthonormal view basis (n = view normal, u/v = screen axes) Vec3 n = normalize(view_dir); Vec3 h = (std::abs(n.x) < 0.9) ? Vec3{1,0,0} : Vec3{0,1,0}; Vec3 u = normalize(cross(h, n)); Vec3 v = cross(n, u); - // Project + // Project triangles to the view plane std::vector> tris; tris.reserve(mesh.faces.size()); T b_min_x=1e20, b_max_x=-1e20, b_min_y=1e20, b_max_y=-1e20; @@ -262,47 +443,40 @@ ViewResult process_view(const Vec3& view_dir, const Mesh& mesh, T pix_s const Vec3& v2 = mesh.vertices[f.v2_idx]; Vec3 tri_n = cross(v1-v0, v2-v0); - // if (cull && dot(tri_n, n) >= 0) continue; - if (cull && dot(tri_n, n) <= 0) continue; - + if (cull && dot(tri_n, n) <= 0) continue; // keep faces pointing toward the viewer + Vec2 p0 = {dot(v0,u), dot(v0,v)}; Vec2 p1 = {dot(v1,u), dot(v1,v)}; Vec2 p2 = {dot(v2,u), dot(v2,v)}; - // 1. COMPUTE VALUES FIRST to avoid "undeclared identifier" T val0=0, val1=0, val2=0; - if (mesh.val_mode == MODE_NODE) { - val0=mesh.values[f.v0_idx]; val1=mesh.values[f.v1_idx]; val2=mesh.values[f.v2_idx]; - } else if (mesh.val_mode == MODE_FACE) { - val0=val1=val2=mesh.values[i]; + if (use_vals) { + if (field->mode == MODE_NODE) { + val0=field->values[f.v0_idx]; val1=field->values[f.v1_idx]; val2=field->values[f.v2_idx]; + } else { // MODE_FACE + val0=val1=val2=field->values[i]; + } } - T area2 = edge_eval(p0, p1, p2); + T area2 = edge_eval(p0, p1, p2); // twice signed screen-space area; >0 = CCW if (std::abs(area2) < 1e-12) continue; - - // area2 is twice the signed area in screen space; positive = CCW + b_min_x = std::min({b_min_x, p0.x, p1.x, p2.x}); b_max_x = std::max({b_max_x, p0.x, p1.x, p2.x}); b_min_y = std::min({b_min_y, p0.y, p1.y, p2.y}); b_max_y = std::max({b_max_y, p0.y, p1.y, p2.y}); - // 2. WINDING FIX: Check for Negative Area (Clockwise) - // If CW, we swap vertices 1 and 2 to make it CCW. + // Normalize winding to CCW so edge functions are positive inside. if (area2 < 0) { - tris.push_back({ - p0, p2, p1, // Swap 2D Vertices - - dot(v0,n), dot(v2,n), dot(v1,n), // Swap Depths (CRITICAL for Z-buffer) - val0, val2, val1, // Swap Values (CRITICAL for Shading) - (T)(1.0/(-area2)) // Use Positive Area - }); + tris.push_back({ p0, p2, p1, + dot(v0,n), dot(v2,n), dot(v1,n), + val0, val2, val1, + (T)(1.0/(-area2)) }); } else { - tris.push_back({ - p0, p1, p2, - dot(v0,n), dot(v1,n), dot(v2,n), - val0, val1, val2, - (T)(1.0/area2) - }); + tris.push_back({ p0, p1, p2, + dot(v0,n), dot(v1,n), dot(v2,n), + val0, val1, val2, + (T)(1.0/area2) }); } } @@ -311,95 +485,183 @@ ViewResult process_view(const Vec3& view_dir, const Mesh& mesh, T pix_s b_min_y -= pix_sz; b_max_y += pix_sz; int w = (int)std::ceil((b_max_x - b_min_x)/pix_sz); int h = (int)std::ceil((b_max_y - b_min_y)/pix_sz); - - renderer.resize(w, h, mesh.val_mode != MODE_NONE); + + renderer.resize(w, h, use_vals); res.image_width=w; res.image_height=h; - for (const auto& t : tris) rasterize(t, renderer, b_min_x, b_min_y, pix_sz); + for (const auto& t : tris) rasterize(t, renderer, b_min_x, b_min_y, pix_sz, use_vals); - // Stats + // Aggregate statistics over visible pixels size_t npix = (size_t)w * h; double sum = 0; + T mn = std::numeric_limits::max(); + T mx = -std::numeric_limits::max(); for (size_t k=0; k res.max_val) res.max_val = val; - } + if (!renderer.mask[k]) continue; + res.covered_pixels++; + if (use_vals) { + T val = renderer.val_buffer[k]; + sum += val; + if (val < mn) mn = val; + if (val > mx) mx = val; } } - res.area = res.covered_pixels * pix_sz * pix_sz; - if (res.covered_pixels) res.average_value = (T)(sum / res.covered_pixels); - else { res.min_val = res.max_val = 0; } + T pix_area = pix_sz * pix_sz; + res.area = res.covered_pixels * pix_area; + if (use_vals && res.covered_pixels) { + res.average_value = (T)(sum / res.covered_pixels); + res.integral = (T)(sum * pix_area); // ∫ f dA over the visible projection + res.min_val = mn; + res.max_val = mx; + } } - + res.time_seconds = std::chrono::duration(std::chrono::high_resolution_clock::now() - t0).count(); return res; } /* ---------------------- - Application Runners + Output Helpers ---------------------- */ -// Escaping for JSON std::string esc(const std::string& s) { std::string out; for(char c:s) (c=='\\'||c=='"') ? out+="\\" + std::string(1,c) : out+=c; return out; } +// Emit a JSON-safe number: non-finite values become null so pipelines don't choke. +template +std::string jnum(T v) { + if (!std::isfinite((double)v)) return "null"; + std::ostringstream o; o << std::setprecision(10) << (double)v; return o.str(); +} + +/* ---------------------- + Application Runner + ---------------------- */ template void run_app(const std::string& obj, const std::string& default_data, const std::string& out_pre, - const std::vector& batch, double default_res, bool cull, bool json) { - - Mesh mesh = load_obj(obj); - if (!default_data.empty()) load_values(default_data, mesh); // Preload default data + const std::vector& batch, double default_res, bool cull, bool json, + unsigned threads, ValueMode forced_mode) { + + Mesh mesh = load_mesh(obj); + + // Each distinct field file is loaded ONCE into a shared, read-only cache; workers + // then extract their timestep's column from it concurrently. This keeps the + // common time-series case (one matrix file shared by every view) from being + // re-parsed per thread, while distinct per-view files are still each loaded once. + std::map>> mat_cache; + std::mutex cache_mtx; + auto get_matrix = [&](const std::string& path) -> std::shared_ptr> { + std::lock_guard lk(cache_mtx); + auto it = mat_cache.find(path); + if (it == mat_cache.end()) { + auto m = std::make_shared>(); + load_matrix_into(path, mesh, *m, forced_mode); + it = mat_cache.emplace(path, m).first; + } + return it->second; + }; + // Pre-warm + validate the default field up front so a bad -d fails fast. + if (!default_data.empty()) get_matrix(parse_field_token(default_data).path); + + std::vector view_res(batch.size()); + for (size_t k=0; k 0) ? (T)batch[k].resolution : (T)default_res; + + std::vector> results(batch.size()); + std::atomic next{0}; + std::mutex err_mtx; + std::string err_msg; + + // Worker: pull timestep indices off a shared counter. Each owns a renderer and a + // reusable field buffer, so per-timestep field files load on demand -> peak memory + // is O(threads), not O(timesteps). The shared fixed field is never reloaded. + auto worker = [&]() { + Renderer renderer; + Field local; // column extracted for the current view + size_t k; + while ((k = next.fetch_add(1)) < batch.size()) { + try { + const auto& b = batch[k]; + const std::string& token = b.data_file.empty() ? default_data : b.data_file; + + const Field* fp = nullptr; + if (!token.empty()) { + FieldToken ft = parse_field_token(token); + auto mat = get_matrix(ft.path); // shared, loaded once + extract_column(*mat, ft.col, local); + fp = &local; + } - Renderer renderer; + ViewResult r = process_view({(T)b.nx, (T)b.ny, (T)b.nz}, mesh, fp, + view_res[k], cull, renderer); + if (!out_pre.empty()) { + std::ostringstream oss; oss << out_pre << "_" << std::setw(4) << std::setfill('0') << k << ".ppm"; + r.output_image = oss.str(); + save_ppm(renderer, r.output_image, r.min_val, r.max_val, r.has_field); + } + results[k] = std::move(r); + } catch (const std::exception& e) { + std::lock_guard lk(err_mtx); + if (err_msg.empty()) err_msg = "timestep " + std::to_string(k) + ": " + e.what(); + next.store(batch.size()); // signal other workers to stop + return; + } + } + }; + + unsigned n_workers = std::max(1u, std::min(threads, (unsigned)batch.size())); + if (n_workers <= 1) { + worker(); + } else { + std::vector pool; + for (unsigned t=0; t 0) ? (T)b.resolution : (T)default_res; - ViewResult r = process_view({(T)b.nx, (T)b.ny, (T)b.nz}, mesh, res, cull, renderer); - - // Output Image? - if (!out_pre.empty()) { - std::ostringstream oss; oss << out_pre << "_" << std::setw(4) << std::setfill('0') << k << ".ppm"; - save_ppm(renderer, oss.str(), r.min_val, r.max_val); - } - + const auto& r = results[k]; if (json) { std::cout << " {\n" << " \"idx\": " << k << ",\n" - << " \"normal\": [" << b.nx << "," << b.ny << "," << b.nz << "],\n" - << " \"area\": " << r.area << ",\n" - << " \"avg\": " << r.average_value << ",\n" + << " \"normal\": [" << jnum(b.nx) << "," << jnum(b.ny) << "," << jnum(b.nz) << "],\n" + << " \"resolution\": " << jnum(view_res[k]) << ",\n" + << " \"area\": " << jnum(r.area) << ",\n" << " \"pixels\": " << r.covered_pixels << ",\n" - << " \"time\": " << r.time_seconds << "\n" + << " \"width\": " << r.image_width << ",\n" + << " \"height\": " << r.image_height << ",\n"; + if (r.has_field) { + std::cout << " \"average\": " << jnum(r.average_value) << ",\n" + << " \"integral\": " << jnum(r.integral) << ",\n" + << " \"min\": " << jnum(r.min_val) << ",\n" + << " \"max\": " << jnum(r.max_val) << ",\n"; + } else { + std::cout << " \"average\": null,\n" + << " \"integral\": null,\n" + << " \"min\": null,\n" + << " \"max\": null,\n"; + } + std::cout << " \"image\": " << (r.output_image.empty() ? "null" : "\"" + esc(r.output_image) + "\"") << ",\n" + << " \"time\": " << jnum(r.time_seconds) << "\n" << " }" << (k==batch.size()-1?"":",") << "\n"; } else { - std::cout << "View " << k << " | Area: " << r.area << " | Avg: " << r.average_value + std::cout << "View " << k << " | Area: " << r.area; + if (r.has_field) + std::cout << " | Avg: " << r.average_value << " | Integral: " << r.integral; + std::cout << " | Pixels: " << r.covered_pixels << " | Time: " << r.time_seconds << "s\n"; } - - // Restore default data if we switched it temporarily? - // For efficiency, we assume subsequent views use what is loaded unless changed. - // If batch mixed global/local indiscriminately, we'd need to track state carefully. } if (json) std::cout << " ]\n}\n"; } @@ -409,102 +671,198 @@ void run_app(const std::string& obj, const std::string& default_data, const std: ---------------------- */ void print_help(const char* prog) { std::cout << "FlatLand: Mesh Projection & Rasterization Tool\n" - << "Usage: " << prog << " [mesh.obj] [options]\n\n" + << "Usage: " << prog << " [options]\n\n" + << "Meshes:\n" + << " OBJ and STL (binary or ASCII) are accepted, auto-detected by extension.\n\n" << "Core Options:\n" - << " -v Add a single view direction. Can be repeated multiple times.\n" - << " -b, --batch Load views from a file. See 'Batch Format' below.\n" - << " (Note: Views from -v and -b are additive)\n\n" - << "Simulation Parameters:\n" - << " -r, --res Set default pixel resolution (default: 0.001).\n" - << " Used if a batch entry does not specify its own resolution.\n" - << " -d, --data Path to default scalar data file (node or face values).\n" - << " Used if a batch entry does not specify its own data file.\n" - << " --no-cull Disable backface culling (renders all matching faces).\n" - << " -p, --precision Set math precision: 'float' (default, faster) or 'double' (more accurate).\n\n" + << " -v, --view Add a view direction (vector). Repeatable.\n" + << " -a, --angle Add a view by azimuth/elevation in degrees.\n" + << " az sweeps around +Z from +X; el rises from XY.\n" + << " -b, --batch Load views from a file (see 'Batch Format').\n" + << " Views from -v/-a and -b are additive.\n\n" + << "Analysis Parameters:\n" + << " -r, --res Default pixel resolution (default: 0.001).\n" + << " Used when a batch entry omits its own resolution.\n" + << " -d, --data Default scalar field file (see 'Field Files').\n" + << " --field-mode Field is 'node', 'face', or 'auto' (default auto,\n" + << " inferred from row count).\n" + << " -p, --precision Math precision: 'float' (default) or 'double'.\n" + << " --no-cull Disable backface culling (render all faces).\n" + << " -t, --threads Worker threads for batch views (default: auto).\n\n" << "Output Control:\n" - << " -o, --out Save heatmap images with this filename prefix.\n" - << " Files named: _.ppm\n" - << " -j, --json Output results in structured JSON format to stdout.\n" - << " -h, --help Show this help message.\n\n" + << " -o, --out Save PPM heatmaps as _.ppm.\n" + << " -j, --json Emit structured JSON to stdout.\n" + << " -h, --help Show this help message.\n\n" + << "Per-View Outputs:\n" + << " area visible projected area (covered_pixels * resolution^2)\n" + << " average mean field value over visible pixels (with -d / batch data)\n" + << " integral area integral of the field: sum(value * pixel_area).\n" + << " Supply a radiance field to get radiant intensity, etc.\n" + << " min/max field extremes over visible pixels\n\n" + << "Field Files:\n" + << " One row per mesh entity (vertex or face); one or more columns. Each\n" + << " column is a timestep, so a whole time series fits in ONE file. Select a\n" + << " column with a trailing '@' (default 0), e.g. 'fields.txt@7'.\n" + << " A plain one-value-per-line file is just the single-column case.\n\n" << "Batch File Format:\n" - << " Each line represents a view. Lines starting with # are comments.\n" - << " Columns: [resolution] [data_file_path]\n" - << " Examples:\n" - << " 1.0 0.0 0.0 (Uses default resolution & default data)\n" - << " 0.0 1.0 0.0 0.005 (Overrides resolution, uses default data)\n" - << " 0.0 0.0 1.0 0.002 data.txt (Overrides both)\n\n" - << "Precedence Rules:\n" - << " 1. Batch file specific settings (resolution/data) take highest precedence.\n" - << " 2. Command line flags (-r, -d) set the defaults for any view missing those details.\n" - << " 3. Single views (-v) always use the command-line default resolution and data.\n"; + << " One view per line; '#' starts a comment. Two line forms:\n" + << " [resolution] [data[@col]] (direction vector)\n" + << " a [resolution] [data[@col]] (azimuth/elevation)\n" + << " resolution and data are optional and order-independent, e.g.:\n" + << " 1 0 0 (default resolution & data)\n" + << " a 45 30 0.005 (angle view, custom resolution)\n" + << " 0 1 0 fields.txt@12 (default resolution, column 12 of a series)\n"; +} + +// Parse the value following a flag; errors if it is missing. +static std::string need_value(int& i, int argc, char* argv[], const std::string& flag) { + if (i+1 >= argc) throw std::runtime_error("option '" + flag + "' requires an argument"); + return argv[++i]; +} + +static double parse_double(const std::string& s, const std::string& ctx) { + try { + size_t pos; double d = std::stod(s, &pos); + if (pos != s.size()) throw std::invalid_argument(""); + return d; + } catch (...) { throw std::runtime_error("invalid number '" + s + "' for " + ctx); } } int main(int argc, char* argv[]) { + // Force the C locale so numeric parsing (strtod/sscanf) always uses '.' as the + // decimal separator, regardless of the user's environment locale. + std::setlocale(LC_ALL, "C"); + if (argc < 2) { print_help(argv[0]); return 1; } std::string obj_file, data_file, batch_file, out_pre, prec="float"; double res = 0.001; bool json=false, cull=true; + unsigned threads = 0; // 0 => auto + ValueMode forced_mode = MODE_NONE; // --field-mode auto by default std::vector batch; - int i = 1; - if (argv[1][0] != '-') { obj_file = argv[1]; i++; } - - for (; i= argc) throw std::runtime_error("option '" + a + "' requires three numbers: x y z"); + double x = parse_double(argv[i+1], "-v x"); + double y = parse_double(argv[i+2], "-v y"); + double z = parse_double(argv[i+3], "-v z"); + if (x==0 && y==0 && z==0) throw std::runtime_error("view direction cannot be the zero vector"); + batch.push_back({x, y, z, -1.0, ""}); + i += 3; + } + else if (a == "-a" || a == "--angle") { + if (i+2 >= argc) throw std::runtime_error("option '" + a + "' requires two numbers: azimuth elevation (degrees)"); + double az = parse_double(argv[i+1], "-a azimuth"); + double el = parse_double(argv[i+2], "-a elevation"); + Vec3 d = angle_to_dir(az, el); + batch.push_back({d.x, d.y, d.z, -1.0, ""}); + i += 2; + } + else if (!a.empty() && a[0] == '-') { + throw std::runtime_error("unknown option '" + a + "' (try --help)"); } + else if (obj_file.empty()) { obj_file = a; } + else throw std::runtime_error("unexpected argument '" + a + "' (mesh already set to '" + obj_file + "')"); } - else if (obj_file.empty() && arg[0]!='-') { obj_file = arg; } - } - if (obj_file.empty()) { std::cerr << "Error: No OBJ file.\n"; return 1; } - - // Parse Batch File if present - if (!batch_file.empty()) { - std::ifstream f(batch_file); - if (!f.is_open()) { std::cerr << "Error: Cannot open batch file.\n"; return 1; } - std::string line; - while (std::getline(f, line)) { - size_t c = line.find('#'); - if (c != std::string::npos) line = line.substr(0, c); - std::stringstream ss(line); - double nx, ny, nz; - if (ss >> nx >> ny >> nz) { + if (obj_file.empty()) throw std::runtime_error("no mesh file specified (.obj or .stl)"); + if (prec != "float" && prec != "double") throw std::runtime_error("precision must be 'float' or 'double', got '" + prec + "'"); + if (res <= 0) throw std::runtime_error("resolution must be positive"); + + // Parse batch file (additive with any -v views) + if (!batch_file.empty()) { + std::ifstream f(batch_file); + if (!f.is_open()) throw std::runtime_error("cannot open batch file '" + batch_file + "'"); + // Relative data-file paths in a batch are resolved against the batch file's + // directory, so a committed time-series case works from any CWD. + std::string batch_dir; + size_t slash = batch_file.find_last_of('/'); + if (slash != std::string::npos) batch_dir = batch_file.substr(0, slash + 1); + std::string line; + int lineno = 0; + while (std::getline(f, line)) { + ++lineno; + size_t c = line.find('#'); + if (c != std::string::npos) line = line.substr(0, c); + std::stringstream ss(line); + std::string first; + if (!(ss >> first)) continue; // blank / comment-only line + + // A line is either a direction vector " ..." or an + // angle "a ..." (degrees). Detect by the first token. + double nx, ny, nz; + if (first == "a" || first == "A" || first == "angle") { + double az, el; + if (!(ss >> az >> el)) + throw std::runtime_error("batch line " + std::to_string(lineno) + ": angle view expects 'a ...'"); + Vec3 d = angle_to_dir(az, el); + nx = d.x; ny = d.y; nz = d.z; + } else { + char* endp; nx = std::strtod(first.c_str(), &endp); + if (*endp != '\0' || !(ss >> ny >> nz)) + throw std::runtime_error("batch line " + std::to_string(lineno) + ": expected ' ...' or 'a ...'"); + if (nx==0 && ny==0 && nz==0) + throw std::runtime_error("batch line " + std::to_string(lineno) + ": zero view vector"); + } + BatchEntry be = {nx, ny, nz, -1.0, ""}; - // Optional columns - double r_temp; - if (ss >> r_temp) { - be.resolution = r_temp; - std::string d_temp; - if (ss >> d_temp) be.data_file = d_temp; + auto resolve = [&](const std::string& p) { + return (!p.empty() && p[0] == '/') ? p : batch_dir + p; + }; + // The optional trailing tokens are [resolution] and/or [data_file], + // in that order. We sniff each token: a pure number is a resolution, + // anything else is a data-file path. This lets a view attach data + // without having to restate the default resolution. + std::string tok; + if (ss >> tok) { + char* endp; double rv = std::strtod(tok.c_str(), &endp); + if (*endp == '\0') { // pure number -> resolution + if (rv <= 0) throw std::runtime_error("batch line " + std::to_string(lineno) + ": resolution must be positive"); + be.resolution = rv; + std::string d_temp; + if (ss >> d_temp) be.data_file = resolve(d_temp); + } else { // non-numeric -> data file, default resolution + be.data_file = resolve(tok); + } } batch.push_back(be); } } - } - - if (batch.empty()) { std::cerr << "Error: No views specified.\n"; return 1; } - - // Dispatch - if (!json) std::cerr << "Running with " << prec << " precision...\n"; - - if (prec == "float") { - run_app(obj_file, data_file, out_pre, batch, res, cull, json); - } else { - run_app(obj_file, data_file, out_pre, batch, res, cull, json); - } + if (batch.empty()) throw std::runtime_error("no views specified (use -v or -b)"); + + unsigned hw = std::thread::hardware_concurrency(); + if (threads == 0) threads = hw ? hw : 1; + + if (!json) std::cerr << "Running " << batch.size() << " view(s) with " << prec + << " precision on " << threads << " thread(s)...\n"; + + if (prec == "float") run_app(obj_file, data_file, out_pre, batch, res, cull, json, threads, forced_mode); + else run_app(obj_file, data_file, out_pre, batch, res, cull, json, threads, forced_mode); + + } catch (const std::exception& e) { + std::cerr << "Error: " << e.what() << "\n"; + return 1; + } return 0; } diff --git a/tests/run_tests.sh b/tests/run_tests.sh new file mode 100755 index 0000000..9d9397d --- /dev/null +++ b/tests/run_tests.sh @@ -0,0 +1,156 @@ +#!/usr/bin/env bash +# +# FlatLand test suite — dependency-free (bash + awk only). +# +# Usage: tests/run_tests.sh [path-to-flatland-binary] +# If no binary is given, builds one from src/main.cpp with the system compiler. +# +set -u + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +BIN="${1:-}" +TMP="$(mktemp -d)" +trap 'rm -rf "$TMP"' EXIT + +pass=0; fail=0 + +ok() { printf " \033[32mPASS\033[0m %s\n" "$1"; pass=$((pass+1)); } +bad() { printf " \033[31mFAIL\033[0m %s\n" "$1"; fail=$((fail+1)); } + +# near